/src/mozilla-central/third_party/aom/aom_dsp/daalaboolreader.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2016, Alliance for Open Media. All rights reserved |
3 | | * |
4 | | * This source code is subject to the terms of the BSD 2 Clause License and |
5 | | * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License |
6 | | * was not distributed with this source code in the LICENSE file, you can |
7 | | * obtain it at www.aomedia.org/license/software. If the Alliance for Open |
8 | | * Media Patent License 1.0 was not distributed with this source code in the |
9 | | * PATENTS file, you can obtain it at www.aomedia.org/license/patent. |
10 | | */ |
11 | | |
12 | | #ifndef AOM_AOM_DSP_DAALABOOLREADER_H_ |
13 | | #define AOM_AOM_DSP_DAALABOOLREADER_H_ |
14 | | |
15 | | #include "aom/aom_integer.h" |
16 | | #include "aom_dsp/entdec.h" |
17 | | #include "aom_dsp/prob.h" |
18 | | #if CONFIG_ACCOUNTING |
19 | | #include "av1/decoder/accounting.h" |
20 | | #endif |
21 | | #if CONFIG_BITSTREAM_DEBUG |
22 | | #include <stdio.h> |
23 | | #include "aom_util/debug_util.h" |
24 | | #endif // CONFIG_BITSTREAM_DEBUG |
25 | | |
26 | | #ifdef __cplusplus |
27 | | extern "C" { |
28 | | #endif |
29 | | |
30 | | struct daala_reader { |
31 | | const uint8_t *buffer; |
32 | | const uint8_t *buffer_end; |
33 | | od_ec_dec ec; |
34 | | #if CONFIG_ACCOUNTING |
35 | | Accounting *accounting; |
36 | | #endif |
37 | | uint8_t allow_update_cdf; |
38 | | }; |
39 | | |
40 | | typedef struct daala_reader daala_reader; |
41 | | |
42 | | int aom_daala_reader_init(daala_reader *r, const uint8_t *buffer, int size); |
43 | | const uint8_t *aom_daala_reader_find_begin(daala_reader *r); |
44 | | const uint8_t *aom_daala_reader_find_end(daala_reader *r); |
45 | | uint32_t aom_daala_reader_tell(const daala_reader *r); |
46 | | uint32_t aom_daala_reader_tell_frac(const daala_reader *r); |
47 | | // Returns true if the reader has tried to decode more data from the buffer |
48 | | // than was actually provided. |
49 | | int aom_daala_reader_has_overflowed(const daala_reader *r); |
50 | | |
51 | 0 | static INLINE int aom_daala_read(daala_reader *r, int prob) { |
52 | 0 | int bit; |
53 | 0 | int p = (0x7FFFFF - (prob << 15) + prob) >> 8; |
54 | | #if CONFIG_BITSTREAM_DEBUG |
55 | | /*{ |
56 | | const int queue_r = bitstream_queue_get_read(); |
57 | | const int frame_idx = bitstream_queue_get_frame_read(); |
58 | | if (frame_idx == 0 && queue_r == 0) { |
59 | | fprintf(stderr, "\n *** bitstream queue at frame_idx_r %d queue_r %d\n", |
60 | | frame_idx, queue_r); |
61 | | } |
62 | | }*/ |
63 | | #endif |
64 | |
|
65 | 0 | bit = od_ec_decode_bool_q15(&r->ec, p); |
66 | 0 |
|
67 | | #if CONFIG_BITSTREAM_DEBUG |
68 | | { |
69 | | int i; |
70 | | int ref_bit, ref_nsymbs; |
71 | | aom_cdf_prob ref_cdf[16]; |
72 | | const int queue_r = bitstream_queue_get_read(); |
73 | | const int frame_idx = bitstream_queue_get_frame_read(); |
74 | | bitstream_queue_pop(&ref_bit, ref_cdf, &ref_nsymbs); |
75 | | if (ref_nsymbs != 2) { |
76 | | fprintf(stderr, |
77 | | "\n *** [bit] nsymbs error, frame_idx_r %d nsymbs %d ref_nsymbs " |
78 | | "%d queue_r %d\n", |
79 | | frame_idx, 2, ref_nsymbs, queue_r); |
80 | | assert(0); |
81 | | } |
82 | | if ((ref_nsymbs != 2) || (ref_cdf[0] != (aom_cdf_prob)p) || |
83 | | (ref_cdf[1] != 32767)) { |
84 | | fprintf(stderr, |
85 | | "\n *** [bit] cdf error, frame_idx_r %d cdf {%d, %d} ref_cdf {%d", |
86 | | frame_idx, p, 32767, ref_cdf[0]); |
87 | | for (i = 1; i < ref_nsymbs; ++i) fprintf(stderr, ", %d", ref_cdf[i]); |
88 | | fprintf(stderr, "} queue_r %d\n", queue_r); |
89 | | assert(0); |
90 | | } |
91 | | if (bit != ref_bit) { |
92 | | fprintf(stderr, |
93 | | "\n *** [bit] symb error, frame_idx_r %d symb %d ref_symb %d " |
94 | | "queue_r %d\n", |
95 | | frame_idx, bit, ref_bit, queue_r); |
96 | | assert(0); |
97 | | } |
98 | | } |
99 | | #endif |
100 | |
|
101 | 0 | return bit; |
102 | 0 | } Unexecuted instantiation: binary_codes_reader.c:aom_daala_read Unexecuted instantiation: daalaboolreader.c:aom_daala_read Unexecuted instantiation: av1_dx_iface.c:aom_daala_read Unexecuted instantiation: decodeframe.c:aom_daala_read Unexecuted instantiation: decodemv.c:aom_daala_read Unexecuted instantiation: decoder.c:aom_daala_read Unexecuted instantiation: decodetxb.c:aom_daala_read Unexecuted instantiation: detokenize.c:aom_daala_read Unexecuted instantiation: dthread.c:aom_daala_read Unexecuted instantiation: obu.c:aom_daala_read |
103 | | |
104 | 0 | static INLINE int aom_daala_reader_has_error(daala_reader *r) { |
105 | 0 | return r->ec.error; |
106 | 0 | } Unexecuted instantiation: binary_codes_reader.c:aom_daala_reader_has_error Unexecuted instantiation: daalaboolreader.c:aom_daala_reader_has_error Unexecuted instantiation: av1_dx_iface.c:aom_daala_reader_has_error Unexecuted instantiation: decodeframe.c:aom_daala_reader_has_error Unexecuted instantiation: decodemv.c:aom_daala_reader_has_error Unexecuted instantiation: decoder.c:aom_daala_reader_has_error Unexecuted instantiation: decodetxb.c:aom_daala_reader_has_error Unexecuted instantiation: detokenize.c:aom_daala_reader_has_error Unexecuted instantiation: dthread.c:aom_daala_reader_has_error Unexecuted instantiation: obu.c:aom_daala_reader_has_error |
107 | | |
108 | | static INLINE int daala_read_symbol(daala_reader *r, const aom_cdf_prob *cdf, |
109 | 0 | int nsymbs) { |
110 | 0 | int symb; |
111 | 0 | assert(cdf != NULL); |
112 | 0 | symb = od_ec_decode_cdf_q15(&r->ec, cdf, nsymbs); |
113 | 0 |
|
114 | | #if CONFIG_BITSTREAM_DEBUG |
115 | | { |
116 | | int i; |
117 | | int cdf_error = 0; |
118 | | int ref_symb, ref_nsymbs; |
119 | | aom_cdf_prob ref_cdf[16]; |
120 | | const int queue_r = bitstream_queue_get_read(); |
121 | | const int frame_idx = bitstream_queue_get_frame_read(); |
122 | | bitstream_queue_pop(&ref_symb, ref_cdf, &ref_nsymbs); |
123 | | if (nsymbs != ref_nsymbs) { |
124 | | fprintf(stderr, |
125 | | "\n *** nsymbs error, frame_idx_r %d nsymbs %d ref_nsymbs %d " |
126 | | "queue_r %d\n", |
127 | | frame_idx, nsymbs, ref_nsymbs, queue_r); |
128 | | cdf_error = 0; |
129 | | assert(0); |
130 | | } else { |
131 | | for (i = 0; i < nsymbs; ++i) |
132 | | if (cdf[i] != ref_cdf[i]) cdf_error = 1; |
133 | | } |
134 | | if (cdf_error) { |
135 | | fprintf(stderr, "\n *** cdf error, frame_idx_r %d cdf {%d", frame_idx, |
136 | | cdf[0]); |
137 | | for (i = 1; i < nsymbs; ++i) fprintf(stderr, ", %d", cdf[i]); |
138 | | fprintf(stderr, "} ref_cdf {%d", ref_cdf[0]); |
139 | | for (i = 1; i < ref_nsymbs; ++i) fprintf(stderr, ", %d", ref_cdf[i]); |
140 | | fprintf(stderr, "} queue_r %d\n", queue_r); |
141 | | assert(0); |
142 | | } |
143 | | if (symb != ref_symb) { |
144 | | fprintf( |
145 | | stderr, |
146 | | "\n *** symb error, frame_idx_r %d symb %d ref_symb %d queue_r %d\n", |
147 | | frame_idx, symb, ref_symb, queue_r); |
148 | | assert(0); |
149 | | } |
150 | | } |
151 | | #endif |
152 | |
|
153 | 0 | return symb; |
154 | 0 | } Unexecuted instantiation: binary_codes_reader.c:daala_read_symbol Unexecuted instantiation: daalaboolreader.c:daala_read_symbol Unexecuted instantiation: av1_dx_iface.c:daala_read_symbol Unexecuted instantiation: decodeframe.c:daala_read_symbol Unexecuted instantiation: decodemv.c:daala_read_symbol Unexecuted instantiation: decoder.c:daala_read_symbol Unexecuted instantiation: decodetxb.c:daala_read_symbol Unexecuted instantiation: detokenize.c:daala_read_symbol Unexecuted instantiation: dthread.c:daala_read_symbol Unexecuted instantiation: obu.c:daala_read_symbol |
155 | | |
156 | | #ifdef __cplusplus |
157 | | } // extern "C" |
158 | | #endif |
159 | | |
160 | | #endif // AOM_AOM_DSP_DAALABOOLREADER_H_ |