Path: blob/a-new-beginning/libavutil.xcframework/macos-arm64/libavutil.framework/Versions/A/Headers/bswap.h
2 views
/*1* copyright (c) 2006 Michael Niedermayer <[email protected]>2*3* This file is part of FFmpeg.4*5* FFmpeg is free software; you can redistribute it and/or6* modify it under the terms of the GNU Lesser General Public7* License as published by the Free Software Foundation; either8* version 2.1 of the License, or (at your option) any later version.9*10* FFmpeg is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU13* Lesser General Public License for more details.14*15* You should have received a copy of the GNU Lesser General Public16* License along with FFmpeg; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/1920/**21* @file22* byte swapping routines23*/2425#ifndef AVUTIL_BSWAP_H26#define AVUTIL_BSWAP_H2728#include <stdint.h>29#include "libavutil/avconfig.h"30#include "attributes.h"3132#ifdef HAVE_AV_CONFIG_H3334#include "config.h"3536#if ARCH_AARCH6437# include "aarch64/bswap.h"38#elif ARCH_ARM39# include "arm/bswap.h"40#elif ARCH_AVR3241# include "avr32/bswap.h"42#elif ARCH_RISCV43# include "riscv/bswap.h"44#elif ARCH_SH445# include "sh4/bswap.h"46#elif ARCH_X8647# include "x86/bswap.h"48#endif4950#endif /* HAVE_AV_CONFIG_H */5152#define AV_BSWAP16C(x) (((x) << 8 & 0xff00) | ((x) >> 8 & 0x00ff))53#define AV_BSWAP32C(x) (AV_BSWAP16C(x) << 16 | AV_BSWAP16C((x) >> 16))54#define AV_BSWAP64C(x) (AV_BSWAP32C(x) << 32 | AV_BSWAP32C((x) >> 32))5556#define AV_BSWAPC(s, x) AV_BSWAP##s##C(x)5758#ifndef av_bswap1659static av_always_inline av_const uint16_t av_bswap16(uint16_t x)60{61x= (x>>8) | (x<<8);62return x;63}64#endif6566#ifndef av_bswap3267static av_always_inline av_const uint32_t av_bswap32(uint32_t x)68{69return AV_BSWAP32C(x);70}71#endif7273#ifndef av_bswap6474static inline uint64_t av_const av_bswap64(uint64_t x)75{76return (uint64_t)av_bswap32(x) << 32 | av_bswap32(x >> 32);77}78#endif7980// be2ne ... big-endian to native-endian81// le2ne ... little-endian to native-endian8283#if AV_HAVE_BIGENDIAN84#define av_be2ne16(x) (x)85#define av_be2ne32(x) (x)86#define av_be2ne64(x) (x)87#define av_le2ne16(x) av_bswap16(x)88#define av_le2ne32(x) av_bswap32(x)89#define av_le2ne64(x) av_bswap64(x)90#define AV_BE2NEC(s, x) (x)91#define AV_LE2NEC(s, x) AV_BSWAPC(s, x)92#else93#define av_be2ne16(x) av_bswap16(x)94#define av_be2ne32(x) av_bswap32(x)95#define av_be2ne64(x) av_bswap64(x)96#define av_le2ne16(x) (x)97#define av_le2ne32(x) (x)98#define av_le2ne64(x) (x)99#define AV_BE2NEC(s, x) AV_BSWAPC(s, x)100#define AV_LE2NEC(s, x) (x)101#endif102103#define AV_BE2NE16C(x) AV_BE2NEC(16, x)104#define AV_BE2NE32C(x) AV_BE2NEC(32, x)105#define AV_BE2NE64C(x) AV_BE2NEC(64, x)106#define AV_LE2NE16C(x) AV_LE2NEC(16, x)107#define AV_LE2NE32C(x) AV_LE2NEC(32, x)108#define AV_LE2NE64C(x) AV_LE2NEC(64, x)109110#endif /* AVUTIL_BSWAP_H */111112113