ffmpeg / libavcodec / bytestream.h @ 849f1035
History | View | Annotate | Download (2.34 KB)
1 |
/*
|
---|---|
2 |
* Bytestream functions
|
3 |
* copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
|
4 |
*
|
5 |
* This file is part of FFmpeg.
|
6 |
*
|
7 |
* FFmpeg is free software; you can redistribute it and/or
|
8 |
* modify it under the terms of the GNU Lesser General Public
|
9 |
* License as published by the Free Software Foundation; either
|
10 |
* version 2.1 of the License, or (at your option) any later version.
|
11 |
*
|
12 |
* FFmpeg is distributed in the hope that it will be useful,
|
13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15 |
* Lesser General Public License for more details.
|
16 |
*
|
17 |
* You should have received a copy of the GNU Lesser General Public
|
18 |
* License along with FFmpeg; if not, write to the Free Software
|
19 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
20 |
*/
|
21 |
|
22 |
#ifndef FFMPEG_BYTESTREAM_H
|
23 |
#define FFMPEG_BYTESTREAM_H
|
24 |
|
25 |
static av_always_inline unsigned int bytestream_get_le32(uint8_t **b) |
26 |
{ |
27 |
(*b) += 4;
|
28 |
return LE_32(*b - 4); |
29 |
} |
30 |
|
31 |
static av_always_inline unsigned int bytestream_get_le16(uint8_t **b) |
32 |
{ |
33 |
(*b) += 2;
|
34 |
return LE_16(*b - 2); |
35 |
} |
36 |
|
37 |
static av_always_inline unsigned int bytestream_get_byte(uint8_t **b) |
38 |
{ |
39 |
(*b)++; |
40 |
return (*b)[-1]; |
41 |
} |
42 |
|
43 |
static av_always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size) |
44 |
{ |
45 |
memcpy(dst, *b, size); |
46 |
(*b) += size; |
47 |
return size;
|
48 |
} |
49 |
|
50 |
static av_always_inline void bytestream_put_be32(uint8_t **b, const unsigned int value) |
51 |
{ |
52 |
*(*b)++ = value >> 24;
|
53 |
*(*b)++ = value >> 16;
|
54 |
*(*b)++ = value >> 8;
|
55 |
*(*b)++ = value; |
56 |
}; |
57 |
|
58 |
static av_always_inline void bytestream_put_be16(uint8_t **b, const unsigned int value) |
59 |
{ |
60 |
*(*b)++ = value >> 8;
|
61 |
*(*b)++ = value; |
62 |
} |
63 |
|
64 |
static av_always_inline void bytestream_put_le32(uint8_t **b, const unsigned int value) |
65 |
{ |
66 |
*(*b)++ = value; |
67 |
*(*b)++ = value >> 8;
|
68 |
*(*b)++ = value >> 16;
|
69 |
*(*b)++ = value >> 24;
|
70 |
} |
71 |
|
72 |
static av_always_inline void bytestream_put_le16(uint8_t **b, const unsigned int value) |
73 |
{ |
74 |
*(*b)++ = value; |
75 |
*(*b)++ = value >> 8;
|
76 |
} |
77 |
|
78 |
static av_always_inline void bytestream_put_byte(uint8_t **b, const unsigned int value) |
79 |
{ |
80 |
*(*b)++ = value; |
81 |
} |
82 |
|
83 |
static av_always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size) |
84 |
{ |
85 |
memcpy(*b, src, size); |
86 |
(*b) += size; |
87 |
} |
88 |
|
89 |
#endif /* FFMPEG_BYTESTREAM_H */ |