Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > VSs > VSs__H264__App
comparison libavutil/bswap.h @ 4:96e628866d41
naming some tasks to help debugging
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Wed, 19 Dec 2012 15:40:26 +0100 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:04daceed9b16 |
|---|---|
| 1 /* | |
| 2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at> | |
| 3 * | |
| 4 * This file is part of FFmpeg. | |
| 5 * | |
| 6 * FFmpeg is free software; you can redistribute it and/or | |
| 7 * modify it under the terms of the GNU Lesser General Public | |
| 8 * License as published by the Free Software Foundation; either | |
| 9 * version 2.1 of the License, or (at your option) any later version. | |
| 10 * | |
| 11 * FFmpeg is distributed in the hope that it will be useful, | |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 * Lesser General Public License for more details. | |
| 15 * | |
| 16 * You should have received a copy of the GNU Lesser General Public | |
| 17 * License along with FFmpeg; if not, write to the Free Software | |
| 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
| 19 */ | |
| 20 | |
| 21 /** | |
| 22 * @file | |
| 23 * byte swapping routines | |
| 24 */ | |
| 25 | |
| 26 #ifndef AVUTIL_BSWAP_H | |
| 27 #define AVUTIL_BSWAP_H | |
| 28 | |
| 29 #include <stdint.h> | |
| 30 #include "config.h" | |
| 31 #include "attributes.h" | |
| 32 | |
| 33 #if ARCH_ARM | |
| 34 # include "arm/bswap.h" | |
| 35 #elif ARCH_X86 | |
| 36 # include "x86/bswap.h" | |
| 37 #endif | |
| 38 | |
| 39 #ifndef bswap_16 | |
| 40 static av_always_inline av_const uint16_t bswap_16(uint16_t x) | |
| 41 { | |
| 42 x= (x>>8) | (x<<8); | |
| 43 return x; | |
| 44 } | |
| 45 #endif | |
| 46 | |
| 47 #ifndef bswap_32 | |
| 48 static av_always_inline av_const uint32_t bswap_32(uint32_t x) | |
| 49 { | |
| 50 x= ((x<<8)&0xFF00FF00) | ((x>>8)&0x00FF00FF); | |
| 51 x= (x>>16) | (x<<16); | |
| 52 return x; | |
| 53 } | |
| 54 #endif | |
| 55 | |
| 56 #ifndef bswap_64 | |
| 57 static inline uint64_t av_const bswap_64(uint64_t x) | |
| 58 { | |
| 59 #if 0 | |
| 60 x= ((x<< 8)&0xFF00FF00FF00FF00ULL) | ((x>> 8)&0x00FF00FF00FF00FFULL); | |
| 61 x= ((x<<16)&0xFFFF0000FFFF0000ULL) | ((x>>16)&0x0000FFFF0000FFFFULL); | |
| 62 return (x>>32) | (x<<32); | |
| 63 #else | |
| 64 union { | |
| 65 uint64_t ll; | |
| 66 uint32_t l[2]; | |
| 67 } w, r; | |
| 68 w.ll = x; | |
| 69 r.l[0] = bswap_32 (w.l[1]); | |
| 70 r.l[1] = bswap_32 (w.l[0]); | |
| 71 return r.ll; | |
| 72 #endif | |
| 73 } | |
| 74 #endif | |
| 75 | |
| 76 // be2me ... big-endian to machine-endian | |
| 77 // le2me ... little-endian to machine-endian | |
| 78 | |
| 79 #if HAVE_BIGENDIAN | |
| 80 #define be2me_16(x) (x) | |
| 81 #define be2me_32(x) (x) | |
| 82 #define be2me_64(x) (x) | |
| 83 #define le2me_16(x) bswap_16(x) | |
| 84 #define le2me_32(x) bswap_32(x) | |
| 85 #define le2me_64(x) bswap_64(x) | |
| 86 #else | |
| 87 #define be2me_16(x) bswap_16(x) | |
| 88 #define be2me_32(x) bswap_32(x) | |
| 89 #define be2me_64(x) bswap_64(x) | |
| 90 #define le2me_16(x) (x) | |
| 91 #define le2me_32(x) (x) | |
| 92 #define le2me_64(x) (x) | |
| 93 #endif | |
| 94 | |
| 95 #endif /* AVUTIL_BSWAP_H */ |
