CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/ext/at3_standalone/intreadwrite.h
Views: 1401
/*1* This file is part of FFmpeg.2*3* FFmpeg is free software; you can redistribute it and/or4* modify it under the terms of the GNU Lesser General Public5* License as published by the Free Software Foundation; either6* version 2.1 of the License, or (at your option) any later version.7*8* FFmpeg is distributed in the hope that it will be useful,9* but WITHOUT ANY WARRANTY; without even the implied warranty of10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU11* Lesser General Public License for more details.12*13* You should have received a copy of the GNU Lesser General Public14* License along with FFmpeg; if not, write to the Free Software15* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA16*/1718#pragma once19#include <stdint.h>2021#include "compat.h"2223typedef union {24uint64_t u64;25uint32_t u32[2];26uint16_t u16[4];27uint8_t u8 [8];28double f64;29float f32[2];30} av_alias av_alias64;3132typedef union {33uint32_t u32;34uint16_t u16[2];35uint8_t u8 [4];36float f32;37} av_alias av_alias32;3839typedef union {40uint16_t u16;41uint8_t u8 [2];42} av_alias av_alias16;4344#include "compat.h"4546# if defined(AV_RN16) && !defined(AV_RL16)47# define AV_RL16(p) AV_RN16(p)48# elif !defined(AV_RN16) && defined(AV_RL16)49# define AV_RN16(p) AV_RL16(p)50# endif5152# if defined(AV_WN16) && !defined(AV_WL16)53# define AV_WL16(p, v) AV_WN16(p, v)54# elif !defined(AV_WN16) && defined(AV_WL16)55# define AV_WN16(p, v) AV_WL16(p, v)56# endif5758# if defined(AV_RN24) && !defined(AV_RL24)59# define AV_RL24(p) AV_RN24(p)60# elif !defined(AV_RN24) && defined(AV_RL24)61# define AV_RN24(p) AV_RL24(p)62# endif6364# if defined(AV_WN24) && !defined(AV_WL24)65# define AV_WL24(p, v) AV_WN24(p, v)66# elif !defined(AV_WN24) && defined(AV_WL24)67# define AV_WN24(p, v) AV_WL24(p, v)68# endif6970# if defined(AV_RN32) && !defined(AV_RL32)71# define AV_RL32(p) AV_RN32(p)72# elif !defined(AV_RN32) && defined(AV_RL32)73# define AV_RN32(p) AV_RL32(p)74# endif7576# if defined(AV_WN32) && !defined(AV_WL32)77# define AV_WL32(p, v) AV_WN32(p, v)78# elif !defined(AV_WN32) && defined(AV_WL32)79# define AV_WN32(p, v) AV_WL32(p, v)80# endif8182# if defined(AV_RN48) && !defined(AV_RL48)83# define AV_RL48(p) AV_RN48(p)84# elif !defined(AV_RN48) && defined(AV_RL48)85# define AV_RN48(p) AV_RL48(p)86# endif8788# if defined(AV_WN48) && !defined(AV_WL48)89# define AV_WL48(p, v) AV_WN48(p, v)90# elif !defined(AV_WN48) && defined(AV_WL48)91# define AV_WN48(p, v) AV_WL48(p, v)92# endif9394# if defined(AV_RN64) && !defined(AV_RL64)95# define AV_RL64(p) AV_RN64(p)96# elif !defined(AV_RN64) && defined(AV_RL64)97# define AV_RN64(p) AV_RL64(p)98# endif99100# if defined(AV_WN64) && !defined(AV_WL64)101# define AV_WL64(p, v) AV_WN64(p, v)102# elif !defined(AV_WN64) && defined(AV_WL64)103# define AV_WN64(p, v) AV_WL64(p, v)104# endif105106/*107* Define AV_[RW]N helper macros to simplify definitions not provided108* by per-arch headers.109*/110#if AV_HAVE_FAST_UNALIGNED111112# define AV_RN(s, p) (((const av_alias##s*)(p))->u##s)113# define AV_WN(s, p, v) (((av_alias##s*)(p))->u##s = (v))114115#else116117#ifndef AV_RB16118# define AV_RB16(x) \119((((const uint8_t*)(x))[0] << 8) | \120((const uint8_t*)(x))[1])121#endif122#ifndef AV_WB16123# define AV_WB16(p, darg) do { \124unsigned d = (darg); \125((uint8_t*)(p))[1] = (d); \126((uint8_t*)(p))[0] = (d)>>8; \127} while(0)128#endif129130#ifndef AV_RL16131# define AV_RL16(x) \132((((const uint8_t*)(x))[1] << 8) | \133((const uint8_t*)(x))[0])134#endif135#ifndef AV_WL16136# define AV_WL16(p, darg) do { \137unsigned d = (darg); \138((uint8_t*)(p))[0] = (d); \139((uint8_t*)(p))[1] = (d)>>8; \140} while(0)141#endif142143#ifndef AV_RB32144# define AV_RB32(x) \145(((uint32_t)((const uint8_t*)(x))[0] << 24) | \146(((const uint8_t*)(x))[1] << 16) | \147(((const uint8_t*)(x))[2] << 8) | \148((const uint8_t*)(x))[3])149#endif150#ifndef AV_WB32151# define AV_WB32(p, darg) do { \152unsigned d = (darg); \153((uint8_t*)(p))[3] = (d); \154((uint8_t*)(p))[2] = (d)>>8; \155((uint8_t*)(p))[1] = (d)>>16; \156((uint8_t*)(p))[0] = (d)>>24; \157} while(0)158#endif159160#ifndef AV_RL32161# define AV_RL32(x) \162(((uint32_t)((const uint8_t*)(x))[3] << 24) | \163(((const uint8_t*)(x))[2] << 16) | \164(((const uint8_t*)(x))[1] << 8) | \165((const uint8_t*)(x))[0])166#endif167#ifndef AV_WL32168# define AV_WL32(p, darg) do { \169unsigned d = (darg); \170((uint8_t*)(p))[0] = (d); \171((uint8_t*)(p))[1] = (d)>>8; \172((uint8_t*)(p))[2] = (d)>>16; \173((uint8_t*)(p))[3] = (d)>>24; \174} while(0)175#endif176177#ifndef AV_RB64178# define AV_RB64(x) \179(((uint64_t)((const uint8_t*)(x))[0] << 56) | \180((uint64_t)((const uint8_t*)(x))[1] << 48) | \181((uint64_t)((const uint8_t*)(x))[2] << 40) | \182((uint64_t)((const uint8_t*)(x))[3] << 32) | \183((uint64_t)((const uint8_t*)(x))[4] << 24) | \184((uint64_t)((const uint8_t*)(x))[5] << 16) | \185((uint64_t)((const uint8_t*)(x))[6] << 8) | \186(uint64_t)((const uint8_t*)(x))[7])187#endif188#ifndef AV_WB64189# define AV_WB64(p, darg) do { \190uint64_t d = (darg); \191((uint8_t*)(p))[7] = (d); \192((uint8_t*)(p))[6] = (d)>>8; \193((uint8_t*)(p))[5] = (d)>>16; \194((uint8_t*)(p))[4] = (d)>>24; \195((uint8_t*)(p))[3] = (d)>>32; \196((uint8_t*)(p))[2] = (d)>>40; \197((uint8_t*)(p))[1] = (d)>>48; \198((uint8_t*)(p))[0] = (d)>>56; \199} while(0)200#endif201202#ifndef AV_RL64203# define AV_RL64(x) \204(((uint64_t)((const uint8_t*)(x))[7] << 56) | \205((uint64_t)((const uint8_t*)(x))[6] << 48) | \206((uint64_t)((const uint8_t*)(x))[5] << 40) | \207((uint64_t)((const uint8_t*)(x))[4] << 32) | \208((uint64_t)((const uint8_t*)(x))[3] << 24) | \209((uint64_t)((const uint8_t*)(x))[2] << 16) | \210((uint64_t)((const uint8_t*)(x))[1] << 8) | \211(uint64_t)((const uint8_t*)(x))[0])212#endif213#ifndef AV_WL64214# define AV_WL64(p, darg) do { \215uint64_t d = (darg); \216((uint8_t*)(p))[0] = (d); \217((uint8_t*)(p))[1] = (d)>>8; \218((uint8_t*)(p))[2] = (d)>>16; \219((uint8_t*)(p))[3] = (d)>>24; \220((uint8_t*)(p))[4] = (d)>>32; \221((uint8_t*)(p))[5] = (d)>>40; \222((uint8_t*)(p))[6] = (d)>>48; \223((uint8_t*)(p))[7] = (d)>>56; \224} while(0)225#endif226227# define AV_RN(s, p) AV_RL##s(p)228# define AV_WN(s, p, v) AV_WL##s(p, v)229230#endif /* HAVE_FAST_UNALIGNED */231232#ifndef AV_RN16233# define AV_RN16(p) AV_RN(16, p)234#endif235236#ifndef AV_RN32237# define AV_RN32(p) AV_RN(32, p)238#endif239240#ifndef AV_RN64241# define AV_RN64(p) AV_RN(64, p)242#endif243244#ifndef AV_WN16245# define AV_WN16(p, v) AV_WN(16, p, v)246#endif247248#ifndef AV_WN32249# define AV_WN32(p, v) AV_WN(32, p, v)250#endif251252#ifndef AV_WN64253# define AV_WN64(p, v) AV_WN(64, p, v)254#endif255256# define AV_RB(s, p) av_bswap##s(AV_RN##s(p))257# define AV_WB(s, p, v) AV_WN##s(p, av_bswap##s(v))258# define AV_RL(s, p) AV_RN##s(p)259# define AV_WL(s, p, v) AV_WN##s(p, v)260261#define AV_RB8(x) (((const uint8_t*)(x))[0])262#define AV_WB8(p, d) do { ((uint8_t*)(p))[0] = (d); } while(0)263264#define AV_RL8(x) AV_RB8(x)265#define AV_WL8(p, d) AV_WB8(p, d)266267#ifndef AV_RB16268# define AV_RB16(p) AV_RB(16, p)269#endif270#ifndef AV_WB16271# define AV_WB16(p, v) AV_WB(16, p, v)272#endif273274#ifndef AV_RL16275# define AV_RL16(p) AV_RL(16, p)276#endif277#ifndef AV_WL16278# define AV_WL16(p, v) AV_WL(16, p, v)279#endif280281#ifndef AV_RB32282# define AV_RB32(p) AV_RB(32, p)283#endif284#ifndef AV_WB32285# define AV_WB32(p, v) AV_WB(32, p, v)286#endif287288#ifndef AV_RL32289# define AV_RL32(p) AV_RL(32, p)290#endif291#ifndef AV_WL32292# define AV_WL32(p, v) AV_WL(32, p, v)293#endif294295#ifndef AV_RB64296# define AV_RB64(p) AV_RB(64, p)297#endif298#ifndef AV_WB64299# define AV_WB64(p, v) AV_WB(64, p, v)300#endif301302#ifndef AV_RL64303# define AV_RL64(p) AV_RL(64, p)304#endif305#ifndef AV_WL64306# define AV_WL64(p, v) AV_WL(64, p, v)307#endif308309#ifndef AV_RB24310# define AV_RB24(x) \311((((const uint8_t*)(x))[0] << 16) | \312(((const uint8_t*)(x))[1] << 8) | \313((const uint8_t*)(x))[2])314#endif315#ifndef AV_WB24316# define AV_WB24(p, d) do { \317((uint8_t*)(p))[2] = (d); \318((uint8_t*)(p))[1] = (d)>>8; \319((uint8_t*)(p))[0] = (d)>>16; \320} while(0)321#endif322323#ifndef AV_RL24324# define AV_RL24(x) \325((((const uint8_t*)(x))[2] << 16) | \326(((const uint8_t*)(x))[1] << 8) | \327((const uint8_t*)(x))[0])328#endif329#ifndef AV_WL24330# define AV_WL24(p, d) do { \331((uint8_t*)(p))[0] = (d); \332((uint8_t*)(p))[1] = (d)>>8; \333((uint8_t*)(p))[2] = (d)>>16; \334} while(0)335#endif336337338