00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FFMPEG_BYTESTREAM_H
00023 #define FFMPEG_BYTESTREAM_H
00024
00025 #include "common.h"
00026
00027 #define DEF_T(type, name, bytes, read, write) \
00028 static av_always_inline type bytestream_get_ ## name(const uint8_t **b){\
00029 (*b) += bytes;\
00030 return read(*b - bytes);\
00031 }\
00032 static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type value){\
00033 write(*b, value);\
00034 (*b) += bytes;\
00035 }
00036
00037 #define DEF(name, bytes, read, write) \
00038 DEF_T(unsigned int, name, bytes, read, write)
00039 #define DEF64(name, bytes, read, write) \
00040 DEF_T(uint64_t, name, bytes, read, write)
00041
00042 DEF64(le64, 8, AV_RL64, AV_WL64)
00043 DEF (le32, 4, AV_RL32, AV_WL32)
00044 DEF (le24, 3, AV_RL24, AV_WL24)
00045 DEF (le16, 2, AV_RL16, AV_WL16)
00046 DEF64(be64, 8, AV_RB64, AV_WB64)
00047 DEF (be32, 4, AV_RB32, AV_WB32)
00048 DEF (be24, 3, AV_RB24, AV_WB24)
00049 DEF (be16, 2, AV_RB16, AV_WB16)
00050 DEF (byte, 1, AV_RB8 , AV_WB8 )
00051
00052 #undef DEF
00053 #undef DEF64
00054 #undef DEF_T
00055
00056 static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, uint8_t *dst, unsigned int size)
00057 {
00058 memcpy(dst, *b, size);
00059 (*b) += size;
00060 return size;
00061 }
00062
00063 static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
00064 {
00065 memcpy(*b, src, size);
00066 (*b) += size;
00067 }
00068
00069 #endif