comparison bytestream.h @ 5245:3d64f44fd2a3 libavcodec

add 64-bit bytestream read/write functions
author mru
date Sat, 07 Jul 2007 20:50:27 +0000
parents 4394344397d8
children 9975783f1cb2
comparison
equal deleted inserted replaced
5244:eeba62cd2181 5245:3d64f44fd2a3
22 #ifndef FFMPEG_BYTESTREAM_H 22 #ifndef FFMPEG_BYTESTREAM_H
23 #define FFMPEG_BYTESTREAM_H 23 #define FFMPEG_BYTESTREAM_H
24 24
25 #include "common.h" 25 #include "common.h"
26 26
27 #define DEF(name, bytes, read, write)\ 27 #define DEF_T(type, name, bytes, read, write) \
28 static av_always_inline unsigned int bytestream_get_ ## name(uint8_t **b){\ 28 static av_always_inline type bytestream_get_ ## name(uint8_t **b){\
29 (*b) += bytes;\ 29 (*b) += bytes;\
30 return read(*b - bytes);\ 30 return read(*b - bytes);\
31 }\ 31 }\
32 static av_always_inline void bytestream_put_ ##name(uint8_t **b, const unsigned int value){\ 32 static av_always_inline void bytestream_put_ ##name(uint8_t **b, const type value){\
33 write(*b, value);\ 33 write(*b, value);\
34 (*b) += bytes;\ 34 (*b) += bytes;\
35 } 35 }
36 36
37 #define DEF(name, bytes, read, write) \
38 DEF_T(unsigned int, name, bytes, read, write)
39 #define DEF64(name, bytes, read, write) \
40 DEF_T(uint64_t, name, bytes, read, write)
41
42 DEF64(le64, 8, AV_RL64, AV_WL64)
37 DEF(le32, 4, AV_RL32, AV_WL32) 43 DEF(le32, 4, AV_RL32, AV_WL32)
38 DEF(le24, 3, AV_RL24, AV_WL24) 44 DEF(le24, 3, AV_RL24, AV_WL24)
39 DEF(le16, 2, AV_RL16, AV_WL16) 45 DEF(le16, 2, AV_RL16, AV_WL16)
46 DEF64(be64, 8, AV_RB64, AV_WB64)
40 DEF(be32, 4, AV_RB32, AV_WB32) 47 DEF(be32, 4, AV_RB32, AV_WB32)
41 DEF(be24, 3, AV_RB24, AV_WB24) 48 DEF(be24, 3, AV_RB24, AV_WB24)
42 DEF(be16, 2, AV_RB16, AV_WB16) 49 DEF(be16, 2, AV_RB16, AV_WB16)
43 DEF(byte, 1, AV_RB8 , AV_WB8 ) 50 DEF(byte, 1, AV_RB8 , AV_WB8 )
44 51
45 #undef DEF 52 #undef DEF
53 #undef DEF64
54 #undef DEF_T
46 55
47 static av_always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size) 56 static av_always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size)
48 { 57 {
49 memcpy(dst, *b, size); 58 memcpy(dst, *b, size);
50 (*b) += size; 59 (*b) += size;