• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavutil/mips/intreadwrite.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009 Mans Rullgard <mans@mansr.com>
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 
00021 #ifndef AVUTIL_MIPS_INTREADWRITE_H
00022 #define AVUTIL_MIPS_INTREADWRITE_H
00023 
00024 #include <stdint.h>
00025 #include "config.h"
00026 
00027 #define AV_RN32 AV_RN32
00028 static av_always_inline uint32_t AV_RN32(const void *p)
00029 {
00030     uint32_t v;
00031     __asm__ ("lwl %0, %1  \n\t"
00032              "lwr %0, %2  \n\t"
00033              : "=&r"(v)
00034              : "m"(*(const uint32_t *)((const uint8_t *)p+3*!HAVE_BIGENDIAN)),
00035                "m"(*(const uint32_t *)((const uint8_t *)p+3*HAVE_BIGENDIAN)));
00036     return v;
00037 }
00038 
00039 #define AV_WN32 AV_WN32
00040 static av_always_inline void AV_WN32(void *p, uint32_t v)
00041 {
00042     __asm__ ("swl %2, %0  \n\t"
00043              "swr %2, %1  \n\t"
00044              : "=m"(*(uint32_t *)((uint8_t *)p+3*!HAVE_BIGENDIAN)),
00045                "=m"(*(uint32_t *)((uint8_t *)p+3*HAVE_BIGENDIAN))
00046              : "r"(v));
00047 }
00048 
00049 #if ARCH_MIPS64
00050 
00051 #define AV_RN64 AV_RN64
00052 static av_always_inline uint64_t AV_RN64(const void *p)
00053 {
00054     uint64_t v;
00055     __asm__ ("ldl %0, %1  \n\t"
00056              "ldr %0, %2  \n\t"
00057              : "=&r"(v)
00058              : "m"(*(const uint64_t *)((const uint8_t *)p+7*!HAVE_BIGENDIAN)),
00059                "m"(*(const uint64_t *)((const uint8_t *)p+7*HAVE_BIGENDIAN)));
00060     return v;
00061 }
00062 
00063 #define AV_WN64 AV_WN64
00064 static av_always_inline void AV_WN64(void *p, uint64_t v)
00065 {
00066     __asm__ ("sdl %2, %0  \n\t"
00067              "sdr %2, %1  \n\t"
00068              : "=m"(*(uint64_t *)((uint8_t *)p+7*!HAVE_BIGENDIAN)),
00069                "=m"(*(uint64_t *)((uint8_t *)p+7*HAVE_BIGENDIAN))
00070              : "r"(v));
00071 }
00072 
00073 #else
00074 
00075 #define AV_RN64 AV_RN64
00076 static av_always_inline uint64_t AV_RN64(const void *p)
00077 {
00078     union { uint64_t v; uint32_t hl[2]; } v;
00079     v.hl[0] = AV_RN32(p);
00080     v.hl[1] = AV_RN32((const uint8_t *)p + 4);
00081     return v.v;
00082 }
00083 
00084 #define AV_WN64 AV_WN64
00085 static av_always_inline void AV_WN64(void *p, uint64_t v)
00086 {
00087     union { uint64_t v; uint32_t hl[2]; } vv = { v };
00088     AV_WN32(p, vv.hl[0]);
00089     AV_WN32((uint8_t *)p + 4, vv.hl[1]);
00090 }
00091 
00092 #endif /* ARCH_MIPS64 */
00093 
00094 #endif /* AVUTIL_MIPS_INTREADWRITE_H */

Generated on Fri Sep 16 2011 17:17:51 for FFmpeg by  doxygen 1.7.1