/src/ffmpeg/libavcodec/leb.h
Line | Count | Source |
1 | | /* |
2 | | * This file is part of FFmpeg. |
3 | | * |
4 | | * FFmpeg is free software; you can redistribute it and/or |
5 | | * modify it under the terms of the GNU Lesser General Public |
6 | | * License as published by the Free Software Foundation; either |
7 | | * version 2.1 of the License, or (at your option) any later version. |
8 | | * |
9 | | * FFmpeg is distributed in the hope that it will be useful, |
10 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | | * Lesser General Public License for more details. |
13 | | * |
14 | | * You should have received a copy of the GNU Lesser General Public |
15 | | * License along with FFmpeg; if not, write to the Free Software |
16 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
17 | | */ |
18 | | |
19 | | /** |
20 | | * @file |
21 | | * leb128 handling implementations |
22 | | */ |
23 | | |
24 | | #ifndef AVCODEC_LEB_H |
25 | | #define AVCODEC_LEB_H |
26 | | |
27 | | #include "get_bits.h" |
28 | | |
29 | | /** |
30 | | * Read a unsigned integer coded as a variable number of up to eight |
31 | | * little-endian bytes, where the MSB in a byte signals another byte |
32 | | * must be read. |
33 | | * All coded bits are read, but values > UINT_MAX are truncated. |
34 | | */ |
35 | 3.00M | static inline unsigned get_leb(GetBitContext *s) { |
36 | 3.00M | int more, i = 0; |
37 | 3.00M | unsigned leb = 0; |
38 | | |
39 | 5.41M | do { |
40 | 5.41M | int byte = get_bits(s, 8); |
41 | 5.41M | unsigned bits = byte & 0x7f; |
42 | 5.41M | more = byte & 0x80; |
43 | 5.41M | if (i <= 4) |
44 | 4.69M | leb |= bits << (i * 7); |
45 | 5.41M | if (++i == 8) |
46 | 227k | break; |
47 | 5.41M | } while (more); |
48 | | |
49 | 3.00M | return leb; |
50 | 3.00M | } extract_extradata.c:get_leb Line | Count | Source | 35 | 2.86k | static inline unsigned get_leb(GetBitContext *s) { | 36 | 2.86k | int more, i = 0; | 37 | 2.86k | unsigned leb = 0; | 38 | | | 39 | 7.37k | do { | 40 | 7.37k | int byte = get_bits(s, 8); | 41 | 7.37k | unsigned bits = byte & 0x7f; | 42 | 7.37k | more = byte & 0x80; | 43 | 7.37k | if (i <= 4) | 44 | 6.13k | leb |= bits << (i * 7); | 45 | 7.37k | if (++i == 8) | 46 | 382 | break; | 47 | 7.37k | } while (more); | 48 | | | 49 | 2.86k | return leb; | 50 | 2.86k | } |
Unexecuted instantiation: remove_extradata.c:get_leb Unexecuted instantiation: av1_parse.c:get_leb Unexecuted instantiation: av1_parser.c:get_leb Unexecuted instantiation: av1dec.c:get_leb Line | Count | Source | 35 | 3.00M | static inline unsigned get_leb(GetBitContext *s) { | 36 | 3.00M | int more, i = 0; | 37 | 3.00M | unsigned leb = 0; | 38 | | | 39 | 5.40M | do { | 40 | 5.40M | int byte = get_bits(s, 8); | 41 | 5.40M | unsigned bits = byte & 0x7f; | 42 | 5.40M | more = byte & 0x80; | 43 | 5.40M | if (i <= 4) | 44 | 4.68M | leb |= bits << (i * 7); | 45 | 5.40M | if (++i == 8) | 46 | 226k | break; | 47 | 5.40M | } while (more); | 48 | | | 49 | 3.00M | return leb; | 50 | 3.00M | } |
|
51 | | |
52 | | /** |
53 | | * Read a unsigned integer coded as a variable number of up to eight |
54 | | * little-endian bytes, where the MSB in a byte signals another byte |
55 | | * must be read. |
56 | | */ |
57 | 4.38M | static inline int64_t get_leb128(GetBitContext *gb) { |
58 | 4.38M | int64_t ret = 0; |
59 | | |
60 | 4.46M | for (int i = 0; i < 8; i++) { |
61 | 4.46M | int byte = get_bits(gb, 8); |
62 | 4.46M | ret |= (int64_t)(byte & 0x7f) << (i * 7); |
63 | 4.46M | if (!(byte & 0x80)) |
64 | 4.38M | break; |
65 | 4.46M | } |
66 | | |
67 | 4.38M | return ret; |
68 | 4.38M | } Unexecuted instantiation: extract_extradata.c:get_leb128 Unexecuted instantiation: remove_extradata.c:get_leb128 Line | Count | Source | 57 | 1.36M | static inline int64_t get_leb128(GetBitContext *gb) { | 58 | 1.36M | int64_t ret = 0; | 59 | | | 60 | 1.36M | for (int i = 0; i < 8; i++) { | 61 | 1.36M | int byte = get_bits(gb, 8); | 62 | 1.36M | ret |= (int64_t)(byte & 0x7f) << (i * 7); | 63 | 1.36M | if (!(byte & 0x80)) | 64 | 1.36M | break; | 65 | 1.36M | } | 66 | | | 67 | 1.36M | return ret; | 68 | 1.36M | } |
Unexecuted instantiation: av1_parser.c:get_leb128 Line | Count | Source | 57 | 3.02M | static inline int64_t get_leb128(GetBitContext *gb) { | 58 | 3.02M | int64_t ret = 0; | 59 | | | 60 | 3.10M | for (int i = 0; i < 8; i++) { | 61 | 3.10M | int byte = get_bits(gb, 8); | 62 | 3.10M | ret |= (int64_t)(byte & 0x7f) << (i * 7); | 63 | 3.10M | if (!(byte & 0x80)) | 64 | 3.02M | break; | 65 | 3.10M | } | 66 | | | 67 | 3.02M | return ret; | 68 | 3.02M | } |
Unexecuted instantiation: iamf_parse.c:get_leb128 |
69 | | |
70 | | #endif /* AVCODEC_LEB_H */ |