/src/ffmpeg/libavcodec/bytestream.h
Line | Count | Source |
1 | | /* |
2 | | * Bytestream functions |
3 | | * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier@free.fr> |
4 | | * Copyright (c) 2012 Aneesh Dogra (lionaneesh) <lionaneesh@gmail.com> |
5 | | * |
6 | | * This file is part of FFmpeg. |
7 | | * |
8 | | * FFmpeg is free software; you can redistribute it and/or |
9 | | * modify it under the terms of the GNU Lesser General Public |
10 | | * License as published by the Free Software Foundation; either |
11 | | * version 2.1 of the License, or (at your option) any later version. |
12 | | * |
13 | | * FFmpeg is distributed in the hope that it will be useful, |
14 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 | | * Lesser General Public License for more details. |
17 | | * |
18 | | * You should have received a copy of the GNU Lesser General Public |
19 | | * License along with FFmpeg; if not, write to the Free Software |
20 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 | | */ |
22 | | |
23 | | #ifndef AVCODEC_BYTESTREAM_H |
24 | | #define AVCODEC_BYTESTREAM_H |
25 | | |
26 | | #include <stdint.h> |
27 | | #include <string.h> |
28 | | |
29 | | #include "libavutil/avassert.h" |
30 | | #include "libavutil/common.h" |
31 | | #include "libavutil/intreadwrite.h" |
32 | | |
33 | | typedef struct GetByteContext { |
34 | | const uint8_t *buffer, *buffer_end, *buffer_start; |
35 | | } GetByteContext; |
36 | | |
37 | | typedef struct PutByteContext { |
38 | | uint8_t *buffer, *buffer_end, *buffer_start; |
39 | | int eof; |
40 | | } PutByteContext; |
41 | | |
42 | | #define DEF(type, name, bytes, read, write) \ |
43 | 0 | static av_always_inline type bytestream_get_ ## name(const uint8_t **b) \ |
44 | 0 | { \ |
45 | 0 | (*b) += bytes; \ |
46 | 0 | return read(*b - bytes); \ |
47 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream_get_le64 Unexecuted instantiation: demux_utils.c:bytestream_get_le32 Unexecuted instantiation: demux_utils.c:bytestream_get_le24 Unexecuted instantiation: demux_utils.c:bytestream_get_le16 Unexecuted instantiation: demux_utils.c:bytestream_get_be64 Unexecuted instantiation: demux_utils.c:bytestream_get_be32 Unexecuted instantiation: demux_utils.c:bytestream_get_be24 Unexecuted instantiation: demux_utils.c:bytestream_get_be16 Unexecuted instantiation: demux_utils.c:bytestream_get_byte Unexecuted instantiation: decode.c:bytestream_get_le32 Unexecuted instantiation: decode.c:bytestream_get_le64 Unexecuted instantiation: decode.c:bytestream_get_le24 Unexecuted instantiation: decode.c:bytestream_get_le16 Unexecuted instantiation: decode.c:bytestream_get_be64 Unexecuted instantiation: decode.c:bytestream_get_be32 Unexecuted instantiation: decode.c:bytestream_get_be24 Unexecuted instantiation: decode.c:bytestream_get_be16 Unexecuted instantiation: decode.c:bytestream_get_byte Unexecuted instantiation: exif.c:bytestream_get_le64 Unexecuted instantiation: exif.c:bytestream_get_le32 Unexecuted instantiation: exif.c:bytestream_get_le24 Unexecuted instantiation: exif.c:bytestream_get_le16 Unexecuted instantiation: exif.c:bytestream_get_be64 Unexecuted instantiation: exif.c:bytestream_get_be32 Unexecuted instantiation: exif.c:bytestream_get_be24 Unexecuted instantiation: exif.c:bytestream_get_be16 Unexecuted instantiation: exif.c:bytestream_get_byte Unexecuted instantiation: tiff_common.c:bytestream_get_be16 Unexecuted instantiation: tiff_common.c:bytestream_get_le32 Unexecuted instantiation: tiff_common.c:bytestream_get_be32 Unexecuted instantiation: tiff_common.c:bytestream_get_le64 Unexecuted instantiation: tiff_common.c:bytestream_get_be64 Unexecuted instantiation: tiff_common.c:bytestream_get_byte Unexecuted instantiation: tiff_common.c:bytestream_get_le16 Unexecuted instantiation: tiff_common.c:bytestream_get_le24 Unexecuted instantiation: tiff_common.c:bytestream_get_be24 |
48 | | static av_always_inline void bytestream_put_ ## name(uint8_t **b, \ |
49 | 0 | const type value) \ |
50 | 0 | { \ |
51 | 0 | write(*b, value); \ |
52 | 0 | (*b) += bytes; \ |
53 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream_put_le32 Unexecuted instantiation: demux_utils.c:bytestream_put_le64 Unexecuted instantiation: demux_utils.c:bytestream_put_le24 Unexecuted instantiation: demux_utils.c:bytestream_put_le16 Unexecuted instantiation: demux_utils.c:bytestream_put_be64 Unexecuted instantiation: demux_utils.c:bytestream_put_be32 Unexecuted instantiation: demux_utils.c:bytestream_put_be24 Unexecuted instantiation: demux_utils.c:bytestream_put_be16 Unexecuted instantiation: demux_utils.c:bytestream_put_byte Unexecuted instantiation: decode.c:bytestream_put_le64 Unexecuted instantiation: decode.c:bytestream_put_le32 Unexecuted instantiation: decode.c:bytestream_put_le24 Unexecuted instantiation: decode.c:bytestream_put_le16 Unexecuted instantiation: decode.c:bytestream_put_be64 Unexecuted instantiation: decode.c:bytestream_put_be32 Unexecuted instantiation: decode.c:bytestream_put_be24 Unexecuted instantiation: decode.c:bytestream_put_be16 Unexecuted instantiation: decode.c:bytestream_put_byte Unexecuted instantiation: exif.c:bytestream_put_le64 Unexecuted instantiation: exif.c:bytestream_put_le32 Unexecuted instantiation: exif.c:bytestream_put_le24 Unexecuted instantiation: exif.c:bytestream_put_le16 Unexecuted instantiation: exif.c:bytestream_put_be64 Unexecuted instantiation: exif.c:bytestream_put_be32 Unexecuted instantiation: exif.c:bytestream_put_be24 Unexecuted instantiation: exif.c:bytestream_put_be16 Unexecuted instantiation: exif.c:bytestream_put_byte Unexecuted instantiation: tiff_common.c:bytestream_put_le64 Unexecuted instantiation: tiff_common.c:bytestream_put_le32 Unexecuted instantiation: tiff_common.c:bytestream_put_le24 Unexecuted instantiation: tiff_common.c:bytestream_put_le16 Unexecuted instantiation: tiff_common.c:bytestream_put_be64 Unexecuted instantiation: tiff_common.c:bytestream_put_be32 Unexecuted instantiation: tiff_common.c:bytestream_put_be24 Unexecuted instantiation: tiff_common.c:bytestream_put_be16 Unexecuted instantiation: tiff_common.c:bytestream_put_byte |
54 | | static av_always_inline void bytestream2_put_ ## name ## u(PutByteContext *p, \ |
55 | 0 | const type value) \ |
56 | 0 | { \ |
57 | 0 | bytestream_put_ ## name(&p->buffer, value); \ |
58 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream2_put_le64u Unexecuted instantiation: demux_utils.c:bytestream2_put_le32u Unexecuted instantiation: demux_utils.c:bytestream2_put_le24u Unexecuted instantiation: demux_utils.c:bytestream2_put_le16u Unexecuted instantiation: demux_utils.c:bytestream2_put_be64u Unexecuted instantiation: demux_utils.c:bytestream2_put_be32u Unexecuted instantiation: demux_utils.c:bytestream2_put_be24u Unexecuted instantiation: demux_utils.c:bytestream2_put_be16u Unexecuted instantiation: demux_utils.c:bytestream2_put_byteu Unexecuted instantiation: decode.c:bytestream2_put_le64u Unexecuted instantiation: decode.c:bytestream2_put_le32u Unexecuted instantiation: decode.c:bytestream2_put_le24u Unexecuted instantiation: decode.c:bytestream2_put_le16u Unexecuted instantiation: decode.c:bytestream2_put_be64u Unexecuted instantiation: decode.c:bytestream2_put_be32u Unexecuted instantiation: decode.c:bytestream2_put_be24u Unexecuted instantiation: decode.c:bytestream2_put_be16u Unexecuted instantiation: decode.c:bytestream2_put_byteu Unexecuted instantiation: exif.c:bytestream2_put_le64u Unexecuted instantiation: exif.c:bytestream2_put_le32u Unexecuted instantiation: exif.c:bytestream2_put_le24u Unexecuted instantiation: exif.c:bytestream2_put_le16u Unexecuted instantiation: exif.c:bytestream2_put_be64u Unexecuted instantiation: exif.c:bytestream2_put_be32u Unexecuted instantiation: exif.c:bytestream2_put_be24u Unexecuted instantiation: exif.c:bytestream2_put_be16u Unexecuted instantiation: exif.c:bytestream2_put_byteu Unexecuted instantiation: tiff_common.c:bytestream2_put_le64u Unexecuted instantiation: tiff_common.c:bytestream2_put_le32u Unexecuted instantiation: tiff_common.c:bytestream2_put_le24u Unexecuted instantiation: tiff_common.c:bytestream2_put_le16u Unexecuted instantiation: tiff_common.c:bytestream2_put_be64u Unexecuted instantiation: tiff_common.c:bytestream2_put_be32u Unexecuted instantiation: tiff_common.c:bytestream2_put_be24u Unexecuted instantiation: tiff_common.c:bytestream2_put_be16u Unexecuted instantiation: tiff_common.c:bytestream2_put_byteu |
59 | | static av_always_inline void bytestream2_put_ ## name(PutByteContext *p, \ |
60 | 0 | const type value) \ |
61 | 0 | { \ |
62 | 0 | if (!p->eof && (p->buffer_end - p->buffer >= bytes)) { \ |
63 | 0 | write(p->buffer, value); \ |
64 | 0 | p->buffer += bytes; \ |
65 | 0 | } else \ |
66 | 0 | p->eof = 1; \ |
67 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream2_put_le64 Unexecuted instantiation: demux_utils.c:bytestream2_put_le32 Unexecuted instantiation: demux_utils.c:bytestream2_put_le24 Unexecuted instantiation: demux_utils.c:bytestream2_put_le16 Unexecuted instantiation: demux_utils.c:bytestream2_put_be64 Unexecuted instantiation: demux_utils.c:bytestream2_put_be32 Unexecuted instantiation: demux_utils.c:bytestream2_put_be24 Unexecuted instantiation: demux_utils.c:bytestream2_put_be16 Unexecuted instantiation: demux_utils.c:bytestream2_put_byte Unexecuted instantiation: decode.c:bytestream2_put_le64 Unexecuted instantiation: decode.c:bytestream2_put_le32 Unexecuted instantiation: decode.c:bytestream2_put_le24 Unexecuted instantiation: decode.c:bytestream2_put_le16 Unexecuted instantiation: decode.c:bytestream2_put_be64 Unexecuted instantiation: decode.c:bytestream2_put_be32 Unexecuted instantiation: decode.c:bytestream2_put_be24 Unexecuted instantiation: decode.c:bytestream2_put_be16 Unexecuted instantiation: decode.c:bytestream2_put_byte Unexecuted instantiation: exif.c:bytestream2_put_be32 Unexecuted instantiation: exif.c:bytestream2_put_le32 Unexecuted instantiation: exif.c:bytestream2_put_le16 Unexecuted instantiation: exif.c:bytestream2_put_be16 Unexecuted instantiation: exif.c:bytestream2_put_le64 Unexecuted instantiation: exif.c:bytestream2_put_be64 Unexecuted instantiation: exif.c:bytestream2_put_le24 Unexecuted instantiation: exif.c:bytestream2_put_be24 Unexecuted instantiation: exif.c:bytestream2_put_byte Unexecuted instantiation: tiff_common.c:bytestream2_put_le64 Unexecuted instantiation: tiff_common.c:bytestream2_put_le32 Unexecuted instantiation: tiff_common.c:bytestream2_put_le24 Unexecuted instantiation: tiff_common.c:bytestream2_put_le16 Unexecuted instantiation: tiff_common.c:bytestream2_put_be64 Unexecuted instantiation: tiff_common.c:bytestream2_put_be32 Unexecuted instantiation: tiff_common.c:bytestream2_put_be24 Unexecuted instantiation: tiff_common.c:bytestream2_put_be16 Unexecuted instantiation: tiff_common.c:bytestream2_put_byte |
68 | 0 | static av_always_inline type bytestream2_get_ ## name ## u(GetByteContext *g) \ |
69 | 0 | { \ |
70 | 0 | return bytestream_get_ ## name(&g->buffer); \ |
71 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream2_get_le64u Unexecuted instantiation: demux_utils.c:bytestream2_get_le32u Unexecuted instantiation: demux_utils.c:bytestream2_get_le24u Unexecuted instantiation: demux_utils.c:bytestream2_get_le16u Unexecuted instantiation: demux_utils.c:bytestream2_get_be64u Unexecuted instantiation: demux_utils.c:bytestream2_get_be32u Unexecuted instantiation: demux_utils.c:bytestream2_get_be24u Unexecuted instantiation: demux_utils.c:bytestream2_get_be16u Unexecuted instantiation: demux_utils.c:bytestream2_get_byteu Unexecuted instantiation: decode.c:bytestream2_get_le64u Unexecuted instantiation: decode.c:bytestream2_get_le32u Unexecuted instantiation: decode.c:bytestream2_get_le24u Unexecuted instantiation: decode.c:bytestream2_get_le16u Unexecuted instantiation: decode.c:bytestream2_get_be64u Unexecuted instantiation: decode.c:bytestream2_get_be32u Unexecuted instantiation: decode.c:bytestream2_get_be24u Unexecuted instantiation: decode.c:bytestream2_get_be16u Unexecuted instantiation: decode.c:bytestream2_get_byteu Unexecuted instantiation: exif.c:bytestream2_get_le64u Unexecuted instantiation: exif.c:bytestream2_get_le32u Unexecuted instantiation: exif.c:bytestream2_get_le24u Unexecuted instantiation: exif.c:bytestream2_get_le16u Unexecuted instantiation: exif.c:bytestream2_get_be64u Unexecuted instantiation: exif.c:bytestream2_get_be32u Unexecuted instantiation: exif.c:bytestream2_get_be24u Unexecuted instantiation: exif.c:bytestream2_get_be16u Unexecuted instantiation: exif.c:bytestream2_get_byteu Unexecuted instantiation: tiff_common.c:bytestream2_get_be16u Unexecuted instantiation: tiff_common.c:bytestream2_get_le32u Unexecuted instantiation: tiff_common.c:bytestream2_get_be32u Unexecuted instantiation: tiff_common.c:bytestream2_get_le64u Unexecuted instantiation: tiff_common.c:bytestream2_get_be64u Unexecuted instantiation: tiff_common.c:bytestream2_get_byteu Unexecuted instantiation: tiff_common.c:bytestream2_get_le16u Unexecuted instantiation: tiff_common.c:bytestream2_get_le24u Unexecuted instantiation: tiff_common.c:bytestream2_get_be24u |
72 | 0 | static av_always_inline type bytestream2_get_ ## name(GetByteContext *g) \ |
73 | 0 | { \ |
74 | 0 | if (g->buffer_end - g->buffer < bytes) { \ |
75 | 0 | g->buffer = g->buffer_end; \ |
76 | 0 | return 0; \ |
77 | 0 | } \ |
78 | 0 | return bytestream2_get_ ## name ## u(g); \ |
79 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream2_get_le64 Unexecuted instantiation: demux_utils.c:bytestream2_get_le32 Unexecuted instantiation: demux_utils.c:bytestream2_get_le24 Unexecuted instantiation: demux_utils.c:bytestream2_get_le16 Unexecuted instantiation: demux_utils.c:bytestream2_get_be64 Unexecuted instantiation: demux_utils.c:bytestream2_get_be32 Unexecuted instantiation: demux_utils.c:bytestream2_get_be24 Unexecuted instantiation: demux_utils.c:bytestream2_get_be16 Unexecuted instantiation: demux_utils.c:bytestream2_get_byte Unexecuted instantiation: decode.c:bytestream2_get_le64 Unexecuted instantiation: decode.c:bytestream2_get_le32 Unexecuted instantiation: decode.c:bytestream2_get_le24 Unexecuted instantiation: decode.c:bytestream2_get_le16 Unexecuted instantiation: decode.c:bytestream2_get_be64 Unexecuted instantiation: decode.c:bytestream2_get_be32 Unexecuted instantiation: decode.c:bytestream2_get_be24 Unexecuted instantiation: decode.c:bytestream2_get_be16 Unexecuted instantiation: decode.c:bytestream2_get_byte Unexecuted instantiation: exif.c:bytestream2_get_le64 Unexecuted instantiation: exif.c:bytestream2_get_le32 Unexecuted instantiation: exif.c:bytestream2_get_le24 Unexecuted instantiation: exif.c:bytestream2_get_le16 Unexecuted instantiation: exif.c:bytestream2_get_be64 Unexecuted instantiation: exif.c:bytestream2_get_be32 Unexecuted instantiation: exif.c:bytestream2_get_be24 Unexecuted instantiation: exif.c:bytestream2_get_be16 Unexecuted instantiation: exif.c:bytestream2_get_byte Unexecuted instantiation: tiff_common.c:bytestream2_get_le16 Unexecuted instantiation: tiff_common.c:bytestream2_get_be16 Unexecuted instantiation: tiff_common.c:bytestream2_get_le32 Unexecuted instantiation: tiff_common.c:bytestream2_get_be32 Unexecuted instantiation: tiff_common.c:bytestream2_get_le64 Unexecuted instantiation: tiff_common.c:bytestream2_get_be64 Unexecuted instantiation: tiff_common.c:bytestream2_get_byte Unexecuted instantiation: tiff_common.c:bytestream2_get_le24 Unexecuted instantiation: tiff_common.c:bytestream2_get_be24 |
80 | 0 | static av_always_inline type bytestream2_peek_ ## name ## u(const GetByteContext *g) \ |
81 | 0 | { \ |
82 | 0 | return read(g->buffer); \ |
83 | 0 | } \ Unexecuted instantiation: demux_utils.c:bytestream2_peek_le64u Unexecuted instantiation: demux_utils.c:bytestream2_peek_le32u Unexecuted instantiation: demux_utils.c:bytestream2_peek_le24u Unexecuted instantiation: demux_utils.c:bytestream2_peek_le16u Unexecuted instantiation: demux_utils.c:bytestream2_peek_be64u Unexecuted instantiation: demux_utils.c:bytestream2_peek_be32u Unexecuted instantiation: demux_utils.c:bytestream2_peek_be24u Unexecuted instantiation: demux_utils.c:bytestream2_peek_be16u Unexecuted instantiation: demux_utils.c:bytestream2_peek_byteu Unexecuted instantiation: decode.c:bytestream2_peek_le64u Unexecuted instantiation: decode.c:bytestream2_peek_le32u Unexecuted instantiation: decode.c:bytestream2_peek_le24u Unexecuted instantiation: decode.c:bytestream2_peek_le16u Unexecuted instantiation: decode.c:bytestream2_peek_be64u Unexecuted instantiation: decode.c:bytestream2_peek_be32u Unexecuted instantiation: decode.c:bytestream2_peek_be24u Unexecuted instantiation: decode.c:bytestream2_peek_be16u Unexecuted instantiation: decode.c:bytestream2_peek_byteu Unexecuted instantiation: exif.c:bytestream2_peek_le64u Unexecuted instantiation: exif.c:bytestream2_peek_le32u Unexecuted instantiation: exif.c:bytestream2_peek_le24u Unexecuted instantiation: exif.c:bytestream2_peek_le16u Unexecuted instantiation: exif.c:bytestream2_peek_be64u Unexecuted instantiation: exif.c:bytestream2_peek_be32u Unexecuted instantiation: exif.c:bytestream2_peek_be24u Unexecuted instantiation: exif.c:bytestream2_peek_be16u Unexecuted instantiation: exif.c:bytestream2_peek_byteu Unexecuted instantiation: tiff_common.c:bytestream2_peek_le64u Unexecuted instantiation: tiff_common.c:bytestream2_peek_le32u Unexecuted instantiation: tiff_common.c:bytestream2_peek_le24u Unexecuted instantiation: tiff_common.c:bytestream2_peek_le16u Unexecuted instantiation: tiff_common.c:bytestream2_peek_be64u Unexecuted instantiation: tiff_common.c:bytestream2_peek_be32u Unexecuted instantiation: tiff_common.c:bytestream2_peek_be24u Unexecuted instantiation: tiff_common.c:bytestream2_peek_be16u Unexecuted instantiation: tiff_common.c:bytestream2_peek_byteu |
84 | 0 | static av_always_inline type bytestream2_peek_ ## name(const GetByteContext *g)\ |
85 | 0 | { \ |
86 | 0 | if (g->buffer_end - g->buffer < bytes) \ |
87 | 0 | return 0; \ |
88 | 0 | return bytestream2_peek_ ## name ## u(g); \ |
89 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_peek_le64 Unexecuted instantiation: demux_utils.c:bytestream2_peek_le32 Unexecuted instantiation: demux_utils.c:bytestream2_peek_le24 Unexecuted instantiation: demux_utils.c:bytestream2_peek_le16 Unexecuted instantiation: demux_utils.c:bytestream2_peek_be64 Unexecuted instantiation: demux_utils.c:bytestream2_peek_be32 Unexecuted instantiation: demux_utils.c:bytestream2_peek_be24 Unexecuted instantiation: demux_utils.c:bytestream2_peek_be16 Unexecuted instantiation: demux_utils.c:bytestream2_peek_byte Unexecuted instantiation: decode.c:bytestream2_peek_le64 Unexecuted instantiation: decode.c:bytestream2_peek_le32 Unexecuted instantiation: decode.c:bytestream2_peek_le24 Unexecuted instantiation: decode.c:bytestream2_peek_le16 Unexecuted instantiation: decode.c:bytestream2_peek_be64 Unexecuted instantiation: decode.c:bytestream2_peek_be32 Unexecuted instantiation: decode.c:bytestream2_peek_be24 Unexecuted instantiation: decode.c:bytestream2_peek_be16 Unexecuted instantiation: decode.c:bytestream2_peek_byte Unexecuted instantiation: exif.c:bytestream2_peek_le64 Unexecuted instantiation: exif.c:bytestream2_peek_le32 Unexecuted instantiation: exif.c:bytestream2_peek_le24 Unexecuted instantiation: exif.c:bytestream2_peek_le16 Unexecuted instantiation: exif.c:bytestream2_peek_be64 Unexecuted instantiation: exif.c:bytestream2_peek_be32 Unexecuted instantiation: exif.c:bytestream2_peek_be24 Unexecuted instantiation: exif.c:bytestream2_peek_be16 Unexecuted instantiation: exif.c:bytestream2_peek_byte Unexecuted instantiation: tiff_common.c:bytestream2_peek_le64 Unexecuted instantiation: tiff_common.c:bytestream2_peek_le32 Unexecuted instantiation: tiff_common.c:bytestream2_peek_le24 Unexecuted instantiation: tiff_common.c:bytestream2_peek_le16 Unexecuted instantiation: tiff_common.c:bytestream2_peek_be64 Unexecuted instantiation: tiff_common.c:bytestream2_peek_be32 Unexecuted instantiation: tiff_common.c:bytestream2_peek_be24 Unexecuted instantiation: tiff_common.c:bytestream2_peek_be16 Unexecuted instantiation: tiff_common.c:bytestream2_peek_byte |
90 | | |
91 | 0 | DEF(uint64_t, le64, 8, AV_RL64, AV_WL64) |
92 | 0 | DEF(unsigned int, le32, 4, AV_RL32, AV_WL32) |
93 | | DEF(unsigned int, le24, 3, AV_RL24, AV_WL24) |
94 | 0 | DEF(unsigned int, le16, 2, AV_RL16, AV_WL16) |
95 | 0 | DEF(uint64_t, be64, 8, AV_RB64, AV_WB64) |
96 | 0 | DEF(unsigned int, be32, 4, AV_RB32, AV_WB32) |
97 | | DEF(unsigned int, be24, 3, AV_RB24, AV_WB24) |
98 | 0 | DEF(unsigned int, be16, 2, AV_RB16, AV_WB16) |
99 | 0 | DEF(unsigned int, byte, 1, AV_RB8 , AV_WB8) |
100 | | |
101 | | #if AV_HAVE_BIGENDIAN |
102 | | # define bytestream2_get_ne16 bytestream2_get_be16 |
103 | | # define bytestream2_get_ne24 bytestream2_get_be24 |
104 | | # define bytestream2_get_ne32 bytestream2_get_be32 |
105 | | # define bytestream2_get_ne64 bytestream2_get_be64 |
106 | | # define bytestream2_get_ne16u bytestream2_get_be16u |
107 | | # define bytestream2_get_ne24u bytestream2_get_be24u |
108 | | # define bytestream2_get_ne32u bytestream2_get_be32u |
109 | | # define bytestream2_get_ne64u bytestream2_get_be64u |
110 | | # define bytestream2_put_ne16 bytestream2_put_be16 |
111 | | # define bytestream2_put_ne24 bytestream2_put_be24 |
112 | | # define bytestream2_put_ne32 bytestream2_put_be32 |
113 | | # define bytestream2_put_ne64 bytestream2_put_be64 |
114 | | # define bytestream2_peek_ne16 bytestream2_peek_be16 |
115 | | # define bytestream2_peek_ne24 bytestream2_peek_be24 |
116 | | # define bytestream2_peek_ne32 bytestream2_peek_be32 |
117 | | # define bytestream2_peek_ne64 bytestream2_peek_be64 |
118 | | #else |
119 | | # define bytestream2_get_ne16 bytestream2_get_le16 |
120 | | # define bytestream2_get_ne24 bytestream2_get_le24 |
121 | | # define bytestream2_get_ne32 bytestream2_get_le32 |
122 | | # define bytestream2_get_ne64 bytestream2_get_le64 |
123 | | # define bytestream2_get_ne16u bytestream2_get_le16u |
124 | | # define bytestream2_get_ne24u bytestream2_get_le24u |
125 | | # define bytestream2_get_ne32u bytestream2_get_le32u |
126 | | # define bytestream2_get_ne64u bytestream2_get_le64u |
127 | | # define bytestream2_put_ne16 bytestream2_put_le16 |
128 | | # define bytestream2_put_ne24 bytestream2_put_le24 |
129 | | # define bytestream2_put_ne32 bytestream2_put_le32 |
130 | | # define bytestream2_put_ne64 bytestream2_put_le64 |
131 | | # define bytestream2_peek_ne16 bytestream2_peek_le16 |
132 | | # define bytestream2_peek_ne24 bytestream2_peek_le24 |
133 | | # define bytestream2_peek_ne32 bytestream2_peek_le32 |
134 | | # define bytestream2_peek_ne64 bytestream2_peek_le64 |
135 | | #endif |
136 | | |
137 | | static av_always_inline void bytestream2_init(GetByteContext *g, |
138 | | const uint8_t *buf, |
139 | | int buf_size) |
140 | 0 | { |
141 | 0 | av_assert0(buf_size >= 0); |
142 | 0 | g->buffer = buf; |
143 | 0 | g->buffer_start = buf; |
144 | 0 | g->buffer_end = buf + buf_size; |
145 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_init Unexecuted instantiation: decode.c:bytestream2_init Unexecuted instantiation: exif.c:bytestream2_init Unexecuted instantiation: tiff_common.c:bytestream2_init |
146 | | |
147 | | static av_always_inline void bytestream2_init_writer(PutByteContext *p, |
148 | | uint8_t *buf, |
149 | | int buf_size) |
150 | 0 | { |
151 | 0 | av_assert0(buf_size >= 0); |
152 | 0 | p->buffer = buf; |
153 | 0 | p->buffer_start = buf; |
154 | 0 | p->buffer_end = buf + buf_size; |
155 | 0 | p->eof = 0; |
156 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_init_writer Unexecuted instantiation: decode.c:bytestream2_init_writer Unexecuted instantiation: exif.c:bytestream2_init_writer Unexecuted instantiation: tiff_common.c:bytestream2_init_writer |
157 | | |
158 | | static av_always_inline int bytestream2_get_bytes_left(const GetByteContext *g) |
159 | 0 | { |
160 | 0 | return g->buffer_end - g->buffer; |
161 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_get_bytes_left Unexecuted instantiation: decode.c:bytestream2_get_bytes_left Unexecuted instantiation: exif.c:bytestream2_get_bytes_left Unexecuted instantiation: tiff_common.c:bytestream2_get_bytes_left |
162 | | |
163 | | static av_always_inline int bytestream2_get_bytes_left_p(const PutByteContext *p) |
164 | 0 | { |
165 | 0 | return p->buffer_end - p->buffer; |
166 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_get_bytes_left_p Unexecuted instantiation: decode.c:bytestream2_get_bytes_left_p Unexecuted instantiation: exif.c:bytestream2_get_bytes_left_p Unexecuted instantiation: tiff_common.c:bytestream2_get_bytes_left_p |
167 | | |
168 | | static av_always_inline void bytestream2_skip(GetByteContext *g, |
169 | | unsigned int size) |
170 | 0 | { |
171 | 0 | g->buffer += FFMIN(g->buffer_end - g->buffer, size); |
172 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_skip Unexecuted instantiation: decode.c:bytestream2_skip Unexecuted instantiation: exif.c:bytestream2_skip Unexecuted instantiation: tiff_common.c:bytestream2_skip |
173 | | |
174 | | static av_always_inline void bytestream2_skipu(GetByteContext *g, |
175 | | unsigned int size) |
176 | 0 | { |
177 | 0 | g->buffer += size; |
178 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_skipu Unexecuted instantiation: decode.c:bytestream2_skipu Unexecuted instantiation: exif.c:bytestream2_skipu Unexecuted instantiation: tiff_common.c:bytestream2_skipu |
179 | | |
180 | | static av_always_inline void bytestream2_skip_p(PutByteContext *p, |
181 | | unsigned int size) |
182 | 0 | { |
183 | 0 | unsigned int size2; |
184 | 0 | if (p->eof) |
185 | 0 | return; |
186 | 0 | size2 = FFMIN(p->buffer_end - p->buffer, size); |
187 | 0 | if (size2 != size) |
188 | 0 | p->eof = 1; |
189 | 0 | p->buffer += size2; |
190 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_skip_p Unexecuted instantiation: decode.c:bytestream2_skip_p Unexecuted instantiation: exif.c:bytestream2_skip_p Unexecuted instantiation: tiff_common.c:bytestream2_skip_p |
191 | | |
192 | | static av_always_inline int bytestream2_tell(const GetByteContext *g) |
193 | 0 | { |
194 | 0 | return (int)(g->buffer - g->buffer_start); |
195 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_tell Unexecuted instantiation: decode.c:bytestream2_tell Unexecuted instantiation: exif.c:bytestream2_tell Unexecuted instantiation: tiff_common.c:bytestream2_tell |
196 | | |
197 | | static av_always_inline int bytestream2_tell_p(const PutByteContext *p) |
198 | 0 | { |
199 | 0 | return (int)(p->buffer - p->buffer_start); |
200 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_tell_p Unexecuted instantiation: decode.c:bytestream2_tell_p Unexecuted instantiation: exif.c:bytestream2_tell_p Unexecuted instantiation: tiff_common.c:bytestream2_tell_p |
201 | | |
202 | | static av_always_inline int bytestream2_size(const GetByteContext *g) |
203 | 0 | { |
204 | 0 | return (int)(g->buffer_end - g->buffer_start); |
205 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_size Unexecuted instantiation: decode.c:bytestream2_size Unexecuted instantiation: exif.c:bytestream2_size Unexecuted instantiation: tiff_common.c:bytestream2_size |
206 | | |
207 | | static av_always_inline int bytestream2_size_p(const PutByteContext *p) |
208 | 0 | { |
209 | 0 | return (int)(p->buffer_end - p->buffer_start); |
210 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_size_p Unexecuted instantiation: decode.c:bytestream2_size_p Unexecuted instantiation: exif.c:bytestream2_size_p Unexecuted instantiation: tiff_common.c:bytestream2_size_p |
211 | | |
212 | | static av_always_inline int bytestream2_seek(GetByteContext *g, |
213 | | int offset, |
214 | | int whence) |
215 | 0 | { |
216 | 0 | switch (whence) { |
217 | 0 | case SEEK_CUR: |
218 | 0 | offset = av_clip(offset, -(g->buffer - g->buffer_start), |
219 | 0 | g->buffer_end - g->buffer); |
220 | 0 | g->buffer += offset; |
221 | 0 | break; |
222 | 0 | case SEEK_END: |
223 | 0 | offset = av_clip(offset, -(g->buffer_end - g->buffer_start), 0); |
224 | 0 | g->buffer = g->buffer_end + offset; |
225 | 0 | break; |
226 | 0 | case SEEK_SET: |
227 | 0 | offset = av_clip(offset, 0, g->buffer_end - g->buffer_start); |
228 | 0 | g->buffer = g->buffer_start + offset; |
229 | 0 | break; |
230 | 0 | default: |
231 | 0 | return AVERROR(EINVAL); |
232 | 0 | } |
233 | 0 | return bytestream2_tell(g); |
234 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_seek Unexecuted instantiation: decode.c:bytestream2_seek Unexecuted instantiation: exif.c:bytestream2_seek Unexecuted instantiation: tiff_common.c:bytestream2_seek |
235 | | |
236 | | static av_always_inline int bytestream2_seek_p(PutByteContext *p, |
237 | | int offset, |
238 | | int whence) |
239 | 0 | { |
240 | 0 | p->eof = 0; |
241 | 0 | switch (whence) { |
242 | 0 | case SEEK_CUR: |
243 | 0 | if (p->buffer_end - p->buffer < offset) |
244 | 0 | p->eof = 1; |
245 | 0 | offset = av_clip(offset, -(p->buffer - p->buffer_start), |
246 | 0 | p->buffer_end - p->buffer); |
247 | 0 | p->buffer += offset; |
248 | 0 | break; |
249 | 0 | case SEEK_END: |
250 | 0 | if (offset > 0) |
251 | 0 | p->eof = 1; |
252 | 0 | offset = av_clip(offset, -(p->buffer_end - p->buffer_start), 0); |
253 | 0 | p->buffer = p->buffer_end + offset; |
254 | 0 | break; |
255 | 0 | case SEEK_SET: |
256 | 0 | if (p->buffer_end - p->buffer_start < offset) |
257 | 0 | p->eof = 1; |
258 | 0 | offset = av_clip(offset, 0, p->buffer_end - p->buffer_start); |
259 | 0 | p->buffer = p->buffer_start + offset; |
260 | 0 | break; |
261 | 0 | default: |
262 | 0 | return AVERROR(EINVAL); |
263 | 0 | } |
264 | 0 | return bytestream2_tell_p(p); |
265 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_seek_p Unexecuted instantiation: decode.c:bytestream2_seek_p Unexecuted instantiation: exif.c:bytestream2_seek_p Unexecuted instantiation: tiff_common.c:bytestream2_seek_p |
266 | | |
267 | | static av_always_inline unsigned int bytestream2_get_buffer(GetByteContext *g, |
268 | | uint8_t *dst, |
269 | | unsigned int size) |
270 | 0 | { |
271 | 0 | unsigned int size2 = FFMIN(g->buffer_end - g->buffer, size); |
272 | 0 | memcpy(dst, g->buffer, size2); |
273 | 0 | g->buffer += size2; |
274 | 0 | return size2; |
275 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_get_buffer Unexecuted instantiation: decode.c:bytestream2_get_buffer Unexecuted instantiation: exif.c:bytestream2_get_buffer Unexecuted instantiation: tiff_common.c:bytestream2_get_buffer |
276 | | |
277 | | static av_always_inline unsigned int bytestream2_get_bufferu(GetByteContext *g, |
278 | | uint8_t *dst, |
279 | | unsigned int size) |
280 | 0 | { |
281 | 0 | memcpy(dst, g->buffer, size); |
282 | 0 | g->buffer += size; |
283 | 0 | return size; |
284 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_get_bufferu Unexecuted instantiation: decode.c:bytestream2_get_bufferu Unexecuted instantiation: exif.c:bytestream2_get_bufferu Unexecuted instantiation: tiff_common.c:bytestream2_get_bufferu |
285 | | |
286 | | static av_always_inline unsigned int bytestream2_put_buffer(PutByteContext *p, |
287 | | const uint8_t *src, |
288 | | unsigned int size) |
289 | 0 | { |
290 | 0 | unsigned int size2; |
291 | 0 | if (p->eof) |
292 | 0 | return 0; |
293 | 0 | size2 = FFMIN(p->buffer_end - p->buffer, size); |
294 | 0 | if (size2 != size) |
295 | 0 | p->eof = 1; |
296 | 0 | memcpy(p->buffer, src, size2); |
297 | 0 | p->buffer += size2; |
298 | 0 | return size2; |
299 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_put_buffer Unexecuted instantiation: decode.c:bytestream2_put_buffer Unexecuted instantiation: exif.c:bytestream2_put_buffer Unexecuted instantiation: tiff_common.c:bytestream2_put_buffer |
300 | | |
301 | | static av_always_inline unsigned int bytestream2_put_bufferu(PutByteContext *p, |
302 | | const uint8_t *src, |
303 | | unsigned int size) |
304 | 0 | { |
305 | 0 | memcpy(p->buffer, src, size); |
306 | 0 | p->buffer += size; |
307 | 0 | return size; |
308 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_put_bufferu Unexecuted instantiation: decode.c:bytestream2_put_bufferu Unexecuted instantiation: exif.c:bytestream2_put_bufferu Unexecuted instantiation: tiff_common.c:bytestream2_put_bufferu |
309 | | |
310 | | static av_always_inline void bytestream2_set_buffer(PutByteContext *p, |
311 | | const uint8_t c, |
312 | | unsigned int size) |
313 | 0 | { |
314 | 0 | unsigned int size2; |
315 | 0 | if (p->eof) |
316 | 0 | return; |
317 | 0 | size2 = FFMIN(p->buffer_end - p->buffer, size); |
318 | 0 | if (size2 != size) |
319 | 0 | p->eof = 1; |
320 | 0 | memset(p->buffer, c, size2); |
321 | 0 | p->buffer += size2; |
322 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_set_buffer Unexecuted instantiation: decode.c:bytestream2_set_buffer Unexecuted instantiation: exif.c:bytestream2_set_buffer Unexecuted instantiation: tiff_common.c:bytestream2_set_buffer |
323 | | |
324 | | static av_always_inline void bytestream2_set_bufferu(PutByteContext *p, |
325 | | const uint8_t c, |
326 | | unsigned int size) |
327 | 0 | { |
328 | 0 | memset(p->buffer, c, size); |
329 | 0 | p->buffer += size; |
330 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_set_bufferu Unexecuted instantiation: decode.c:bytestream2_set_bufferu Unexecuted instantiation: exif.c:bytestream2_set_bufferu Unexecuted instantiation: tiff_common.c:bytestream2_set_bufferu |
331 | | |
332 | | static av_always_inline unsigned int bytestream2_get_eof(PutByteContext *p) |
333 | 0 | { |
334 | 0 | return p->eof; |
335 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_get_eof Unexecuted instantiation: decode.c:bytestream2_get_eof Unexecuted instantiation: exif.c:bytestream2_get_eof Unexecuted instantiation: tiff_common.c:bytestream2_get_eof |
336 | | |
337 | | static av_always_inline unsigned int bytestream2_copy_bufferu(PutByteContext *p, |
338 | | GetByteContext *g, |
339 | | unsigned int size) |
340 | 0 | { |
341 | 0 | memcpy(p->buffer, g->buffer, size); |
342 | 0 | p->buffer += size; |
343 | 0 | g->buffer += size; |
344 | 0 | return size; |
345 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_copy_bufferu Unexecuted instantiation: decode.c:bytestream2_copy_bufferu Unexecuted instantiation: exif.c:bytestream2_copy_bufferu Unexecuted instantiation: tiff_common.c:bytestream2_copy_bufferu |
346 | | |
347 | | static av_always_inline unsigned int bytestream2_copy_buffer(PutByteContext *p, |
348 | | GetByteContext *g, |
349 | | unsigned int size) |
350 | 0 | { |
351 | 0 | unsigned int size2; |
352 | 0 |
|
353 | 0 | if (p->eof) |
354 | 0 | return 0; |
355 | 0 | size = FFMIN(g->buffer_end - g->buffer, size); |
356 | 0 | size2 = FFMIN(p->buffer_end - p->buffer, size); |
357 | 0 | if (size2 != size) |
358 | 0 | p->eof = 1; |
359 | 0 |
|
360 | 0 | return bytestream2_copy_bufferu(p, g, size2); |
361 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream2_copy_buffer Unexecuted instantiation: decode.c:bytestream2_copy_buffer Unexecuted instantiation: exif.c:bytestream2_copy_buffer Unexecuted instantiation: tiff_common.c:bytestream2_copy_buffer |
362 | | |
363 | | static av_always_inline unsigned int bytestream_get_buffer(const uint8_t **b, |
364 | | uint8_t *dst, |
365 | | unsigned int size) |
366 | 0 | { |
367 | 0 | memcpy(dst, *b, size); |
368 | 0 | (*b) += size; |
369 | 0 | return size; |
370 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream_get_buffer Unexecuted instantiation: decode.c:bytestream_get_buffer Unexecuted instantiation: exif.c:bytestream_get_buffer Unexecuted instantiation: tiff_common.c:bytestream_get_buffer |
371 | | |
372 | | static av_always_inline void bytestream_put_buffer(uint8_t **b, |
373 | | const uint8_t *src, |
374 | | unsigned int size) |
375 | 0 | { |
376 | 0 | memcpy(*b, src, size); |
377 | 0 | (*b) += size; |
378 | 0 | } Unexecuted instantiation: demux_utils.c:bytestream_put_buffer Unexecuted instantiation: decode.c:bytestream_put_buffer Unexecuted instantiation: exif.c:bytestream_put_buffer Unexecuted instantiation: tiff_common.c:bytestream_put_buffer |
379 | | |
380 | | #endif /* AVCODEC_BYTESTREAM_H */ |