annotate bytestream.h @ 4214:6a546bbe5b31 libavcodec

Add useful Altivec types, taken from with permission from x264 authors
author gpoirier
date Sun, 19 Nov 2006 22:51:54 +0000
parents f6f67a8bdd09
children b0d38ef4b547
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4054
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
1 /*
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
2 * Bytestream functions
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
3 * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr>
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
4 *
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
5 * This file is part of FFmpeg.
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
6 *
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
11 *
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
15 * Lesser General Public License for more details.
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
16 *
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
20 */
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
21
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
22 #ifndef FFMPEG_BYTESTREAM_H
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
23 #define FFMPEG_BYTESTREAM_H
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
24
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
25 static always_inline unsigned int bytestream_get_le32(uint8_t **b)
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
26 {
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
27 (*b) += 4;
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
28 return LE_32(*b - 4);
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
29 }
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
30
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
31 static always_inline unsigned int bytestream_get_le16(uint8_t **b)
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
32 {
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
33 (*b) += 2;
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
34 return LE_16(*b - 2);
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
35 }
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
36
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
37 static always_inline unsigned int bytestream_get_byte(uint8_t **b)
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
38 {
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
39 (*b)++;
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
40 return (*b)[-1];
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
41 }
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
42
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
43 static always_inline unsigned int bytestream_get_buffer(uint8_t **b, uint8_t *dst, unsigned int size)
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
44 {
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
45 memcpy(dst, *b, size);
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
46 (*b) += size;
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
47 return size;
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
48 }
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
49
4125
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
50 static always_inline void bytestream_put_le32(uint8_t **b, const unsigned int value)
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
51 {
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
52 *(*b)++ = value;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
53 *(*b)++ = value >> 8;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
54 *(*b)++ = value >> 16;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
55 *(*b)++ = value >> 24;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
56 }
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
57
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
58 static always_inline void bytestream_put_le16(uint8_t **b, const unsigned int value)
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
59 {
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
60 *(*b)++ = value;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
61 *(*b)++ = value >> 8;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
62 }
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
63
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
64 static always_inline void bytestream_put_byte(uint8_t **b, const unsigned int value)
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
65 {
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
66 *(*b)++ = value;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
67 }
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
68
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
69 static always_inline void bytestream_put_buffer(uint8_t **b, const uint8_t *src, unsigned int size)
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
70 {
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
71 memcpy(*b, src, size);
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
72 (*b) += size;
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
73 }
f6f67a8bdd09 change gif muxer to simple gif encoder
bcoudurier
parents: 4054
diff changeset
74
4054
f20c7bb12103 change gif demuxer to gif decoder
bcoudurier
parents:
diff changeset
75 #endif /* FFMPEG_BYTESTREAM_H */