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

libavutil/arm/intreadwrite.h

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

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