4054
|
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 always_inline unsigned int bytestream_get_le32(uint8_t **b)
|
|
26 {
|
|
27 (*b) += 4;
|
|
28 return LE_32(*b - 4);
|
|
29 }
|
|
30
|
|
31 static always_inline unsigned int bytestream_get_le16(uint8_t **b)
|
|
32 {
|
|
33 (*b) += 2;
|
|
34 return LE_16(*b - 2);
|
|
35 }
|
|
36
|
|
37 static always_inline unsigned int bytestream_get_byte(uint8_t **b)
|
|
38 {
|
|
39 (*b)++;
|
|
40 return (*b)[-1];
|
|
41 }
|
|
42
|
|
43 static 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
|
4125
|
50 static always_inline void bytestream_put_le32(uint8_t **b, const unsigned int value)
|
|
51 {
|
|
52 *(*b)++ = value;
|
|
53 *(*b)++ = value >> 8;
|
|
54 *(*b)++ = value >> 16;
|
|
55 *(*b)++ = value >> 24;
|
|
56 }
|
|
57
|
|
58 static always_inline void bytestream_put_le16(uint8_t **b, const unsigned int value)
|
|
59 {
|
|
60 *(*b)++ = value;
|
|
61 *(*b)++ = value >> 8;
|
|
62 }
|
|
63
|
|
64 static always_inline void bytestream_put_byte(uint8_t **b, const unsigned int value)
|
|
65 {
|
|
66 *(*b)++ = value;
|
|
67 }
|
|
68
|
|
69 static always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
|
|
70 {
|
|
71 memcpy(*b, src, size);
|
|
72 (*b) += size;
|
|
73 }
|
|
74
|
4054
|
75 #endif /* FFMPEG_BYTESTREAM_H */
|