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

libavutil/x86/bswap.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 
00024 #ifndef AVUTIL_X86_BSWAP_H
00025 #define AVUTIL_X86_BSWAP_H
00026 
00027 #include <stdint.h>
00028 #include "config.h"
00029 #include "libavutil/attributes.h"
00030 
00031 #define bswap_16 bswap_16
00032 static av_always_inline av_const uint16_t bswap_16(uint16_t x)
00033 {
00034     __asm__("rorw $8, %0" : "+r"(x));
00035     return x;
00036 }
00037 
00038 #define bswap_32 bswap_32
00039 static av_always_inline av_const uint32_t bswap_32(uint32_t x)
00040 {
00041 #if HAVE_BSWAP
00042     __asm__("bswap   %0" : "+r" (x));
00043 #else
00044     __asm__("rorw    $8,  %w0 \n\t"
00045             "rorl    $16, %0  \n\t"
00046             "rorw    $8,  %w0"
00047             : "+r"(x));
00048 #endif
00049     return x;
00050 }
00051 
00052 #if ARCH_X86_64
00053 #define bswap_64 bswap_64
00054 static inline uint64_t av_const bswap_64(uint64_t x)
00055 {
00056     __asm__("bswap  %0": "=r" (x) : "0" (x));
00057     return x;
00058 }
00059 #endif
00060 
00061 #endif /* AVUTIL_X86_BSWAP_H */

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