Line | Branch | Exec | 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 | 16962 | static int FUNC(obu_header)(CodedBitstreamContext *ctx, RWContext *rw, | |
20 | AV1RawOBUHeader *current) | ||
21 | { | ||
22 | 16962 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
23 | int err; | ||
24 | |||
25 | 16962 | HEADER("OBU header"); | |
26 | |||
27 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8481 times.
|
16962 | fc(1, obu_forbidden_bit, 0, 0); |
28 | |||
29 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8481 times.
|
16962 | fc(4, obu_type, 0, AV1_OBU_PADDING); |
30 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8481 times.
|
16962 | flag(obu_extension_flag); |
31 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8481 times.
|
16962 | flag(obu_has_size_field); |
32 | |||
33 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8481 times.
|
16962 | fc(1, obu_reserved_1bit, 0, 0); |
34 | |||
35 |
2/2✓ Branch 0 taken 560 times.
✓ Branch 1 taken 7921 times.
|
16962 | if (current->obu_extension_flag) { |
36 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 560 times.
|
1120 | fb(3, temporal_id); |
37 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 560 times.
|
1120 | fb(2, spatial_id); |
38 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 560 times.
|
1120 | fc(3, extension_header_reserved_3bits, 0, 0); |
39 | } else { | ||
40 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 937 times.
|
15842 | infer(temporal_id, 0); |
41 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 937 times.
|
15842 | infer(spatial_id, 0); |
42 | } | ||
43 | |||
44 | 16962 | priv->temporal_id = current->temporal_id; | |
45 | 16962 | priv->spatial_id = current->spatial_id; | |
46 | |||
47 | 16962 | return 0; | |
48 | } | ||
49 | |||
50 | 2332 | static int FUNC(trailing_bits)(CodedBitstreamContext *ctx, RWContext *rw, int nb_bits) | |
51 | { | ||
52 | int err; | ||
53 | |||
54 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1166 times.
|
2332 | av_assert0(nb_bits > 0); |
55 | |||
56 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1166 times.
|
2332 | fixed(1, trailing_one_bit, 1); |
57 | 2332 | --nb_bits; | |
58 | |||
59 |
2/2✓ Branch 0 taken 5413 times.
✓ Branch 1 taken 1166 times.
|
13158 | while (nb_bits > 0) { |
60 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 5413 times.
|
10826 | fixed(1, trailing_zero_bit, 0); |
61 | 10826 | --nb_bits; | |
62 | } | ||
63 | |||
64 | 2332 | return 0; | |
65 | } | ||
66 | |||
67 | 7244 | static int FUNC(byte_alignment)(CodedBitstreamContext *ctx, RWContext *rw) | |
68 | { | ||
69 | int err; | ||
70 | |||
71 |
2/2✓ Branch 1 taken 8503 times.
✓ Branch 2 taken 3622 times.
|
24250 | while (byte_alignment(rw) != 0) |
72 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 8503 times.
|
17006 | fixed(1, zero_bit, 0); |
73 | |||
74 | 7244 | return 0; | |
75 | } | ||
76 | |||
77 | 1532 | static int FUNC(color_config)(CodedBitstreamContext *ctx, RWContext *rw, | |
78 | AV1RawColorConfig *current, int seq_profile) | ||
79 | { | ||
80 | 1532 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
81 | int err; | ||
82 | |||
83 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(high_bitdepth); |
84 | |||
85 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (seq_profile == AV_PROFILE_AV1_PROFESSIONAL && |
86 | ✗ | current->high_bitdepth) { | |
87 | ✗ | flag(twelve_bit); | |
88 | ✗ | priv->bit_depth = current->twelve_bit ? 12 : 10; | |
89 | } else { | ||
90 |
2/2✓ Branch 0 taken 7 times.
✓ Branch 1 taken 759 times.
|
1532 | priv->bit_depth = current->high_bitdepth ? 10 : 8; |
91 | } | ||
92 | |||
93 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (seq_profile == AV_PROFILE_AV1_HIGH) |
94 | ✗ | infer(mono_chrome, 0); | |
95 | else | ||
96 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(mono_chrome); |
97 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | priv->num_planes = current->mono_chrome ? 1 : 3; |
98 | |||
99 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(color_description_present_flag); |
100 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (current->color_description_present_flag) { |
101 | ✗ | fb(8, color_primaries); | |
102 | ✗ | fb(8, transfer_characteristics); | |
103 | ✗ | fb(8, matrix_coefficients); | |
104 | } else { | ||
105 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(color_primaries, AVCOL_PRI_UNSPECIFIED); |
106 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(transfer_characteristics, AVCOL_TRC_UNSPECIFIED); |
107 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(matrix_coefficients, AVCOL_SPC_UNSPECIFIED); |
108 | } | ||
109 | |||
110 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (current->mono_chrome) { |
111 | ✗ | flag(color_range); | |
112 | |||
113 | ✗ | infer(subsampling_x, 1); | |
114 | ✗ | infer(subsampling_y, 1); | |
115 | ✗ | infer(chroma_sample_position, AV1_CSP_UNKNOWN); | |
116 | ✗ | infer(separate_uv_delta_q, 0); | |
117 | |||
118 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | } else if (current->color_primaries == AVCOL_PRI_BT709 && |
119 | ✗ | current->transfer_characteristics == AVCOL_TRC_IEC61966_2_1 && | |
120 | ✗ | current->matrix_coefficients == AVCOL_SPC_RGB) { | |
121 | ✗ | infer(color_range, 1); | |
122 | ✗ | infer(subsampling_x, 0); | |
123 | ✗ | infer(subsampling_y, 0); | |
124 | ✗ | flag(separate_uv_delta_q); | |
125 | |||
126 | } else { | ||
127 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(color_range); |
128 | |||
129 |
1/2✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
|
1532 | if (seq_profile == AV_PROFILE_AV1_MAIN) { |
130 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(subsampling_x, 1); |
131 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(subsampling_y, 1); |
132 | ✗ | } else if (seq_profile == AV_PROFILE_AV1_HIGH) { | |
133 | ✗ | infer(subsampling_x, 0); | |
134 | ✗ | infer(subsampling_y, 0); | |
135 | } else { | ||
136 | ✗ | if (priv->bit_depth == 12) { | |
137 | ✗ | fb(1, subsampling_x); | |
138 | ✗ | if (current->subsampling_x) | |
139 | ✗ | fb(1, subsampling_y); | |
140 | else | ||
141 | ✗ | infer(subsampling_y, 0); | |
142 | } else { | ||
143 | ✗ | infer(subsampling_x, 1); | |
144 | ✗ | infer(subsampling_y, 0); | |
145 | } | ||
146 | } | ||
147 |
2/4✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
✗ Branch 3 not taken.
|
1532 | if (current->subsampling_x && current->subsampling_y) { |
148 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fc(2, chroma_sample_position, AV1_CSP_UNKNOWN, |
149 | AV1_CSP_COLOCATED); | ||
150 | } | ||
151 | |||
152 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(separate_uv_delta_q); |
153 | } | ||
154 | |||
155 | 1532 | return 0; | |
156 | } | ||
157 | |||
158 | 1026 | static int FUNC(timing_info)(CodedBitstreamContext *ctx, RWContext *rw, | |
159 | AV1RawTimingInfo *current) | ||
160 | { | ||
161 | int err; | ||
162 | |||
163 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fc(32, num_units_in_display_tick, 1, MAX_UINT_BITS(32)); |
164 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fc(32, time_scale, 1, MAX_UINT_BITS(32)); |
165 | |||
166 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | flag(equal_picture_interval); |
167 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 513 times.
|
1026 | if (current->equal_picture_interval) |
168 | ✗ | uvlc(num_ticks_per_picture_minus_1, 0, MAX_UINT_BITS(32) - 1); | |
169 | |||
170 | 1026 | return 0; | |
171 | } | ||
172 | |||
173 | 1026 | static int FUNC(decoder_model_info)(CodedBitstreamContext *ctx, RWContext *rw, | |
174 | AV1RawDecoderModelInfo *current) | ||
175 | { | ||
176 | int err; | ||
177 | |||
178 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fb(5, buffer_delay_length_minus_1); |
179 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fc(32, num_units_in_decoding_tick, 1, MAX_UINT_BITS(32)); |
180 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fb(5, buffer_removal_time_length_minus_1); |
181 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fb(5, frame_presentation_time_length_minus_1); |
182 | |||
183 | 1026 | return 0; | |
184 | } | ||
185 | |||
186 | 1532 | static int FUNC(sequence_header_obu)(CodedBitstreamContext *ctx, RWContext *rw, | |
187 | AV1RawSequenceHeader *current) | ||
188 | { | ||
189 | int i, err; | ||
190 | |||
191 | 1532 | HEADER("Sequence Header"); | |
192 | |||
193 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fc(3, seq_profile, AV_PROFILE_AV1_MAIN, |
194 | AV_PROFILE_AV1_PROFESSIONAL); | ||
195 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(still_picture); |
196 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(reduced_still_picture_header); |
197 | |||
198 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (current->reduced_still_picture_header) { |
199 | ✗ | infer(timing_info_present_flag, 0); | |
200 | ✗ | infer(decoder_model_info_present_flag, 0); | |
201 | ✗ | infer(initial_display_delay_present_flag, 0); | |
202 | ✗ | infer(operating_points_cnt_minus_1, 0); | |
203 | ✗ | infer(operating_point_idc[0], 0); | |
204 | |||
205 | ✗ | fb(5, seq_level_idx[0]); | |
206 | |||
207 | ✗ | infer(seq_tier[0], 0); | |
208 | ✗ | infer(decoder_model_present_for_this_op[0], 0); | |
209 | ✗ | infer(initial_display_delay_present_for_this_op[0], 0); | |
210 | |||
211 | } else { | ||
212 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(timing_info_present_flag); |
213 |
2/2✓ Branch 0 taken 513 times.
✓ Branch 1 taken 253 times.
|
1532 | if (current->timing_info_present_flag) { |
214 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | CHECK(FUNC(timing_info)(ctx, rw, ¤t->timing_info)); |
215 | |||
216 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | flag(decoder_model_info_present_flag); |
217 |
1/2✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
|
1026 | if (current->decoder_model_info_present_flag) { |
218 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | CHECK(FUNC(decoder_model_info) |
219 | (ctx, rw, ¤t->decoder_model_info)); | ||
220 | } | ||
221 | } else { | ||
222 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 69 times.
|
506 | infer(decoder_model_info_present_flag, 0); |
223 | } | ||
224 | |||
225 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(initial_display_delay_present_flag); |
226 | |||
227 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fb(5, operating_points_cnt_minus_1); |
228 |
2/2✓ Branch 0 taken 801 times.
✓ Branch 1 taken 766 times.
|
3134 | for (i = 0; i <= current->operating_points_cnt_minus_1; i++) { |
229 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 801 times.
|
1602 | fbs(12, operating_point_idc[i], 1, i); |
230 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 801 times.
|
1602 | fbs(5, seq_level_idx[i], 1, i); |
231 | |||
232 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
|
1602 | if (current->seq_level_idx[i] > 7) |
233 | ✗ | flags(seq_tier[i], 1, i); | |
234 | else | ||
235 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 153 times.
|
1602 | infer(seq_tier[i], 0); |
236 | |||
237 |
2/2✓ Branch 0 taken 513 times.
✓ Branch 1 taken 288 times.
|
1602 | if (current->decoder_model_info_present_flag) { |
238 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | flags(decoder_model_present_for_this_op[i], 1, i); |
239 |
1/2✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
|
1026 | if (current->decoder_model_present_for_this_op[i]) { |
240 | 1026 | int n = current->decoder_model_info.buffer_delay_length_minus_1 + 1; | |
241 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fbs(n, decoder_buffer_delay[i], 1, i); |
242 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fbs(n, encoder_buffer_delay[i], 1, i); |
243 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | flags(low_delay_mode_flag[i], 1, i); |
244 | } | ||
245 | } else { | ||
246 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 79 times.
|
576 | infer(decoder_model_present_for_this_op[i], 0); |
247 | } | ||
248 | |||
249 |
2/2✓ Branch 0 taken 513 times.
✓ Branch 1 taken 288 times.
|
1602 | if (current->initial_display_delay_present_flag) { |
250 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | flags(initial_display_delay_present_for_this_op[i], 1, i); |
251 |
1/2✓ Branch 0 taken 513 times.
✗ Branch 1 not taken.
|
1026 | if (current->initial_display_delay_present_for_this_op[i]) |
252 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 513 times.
|
1026 | fbs(4, initial_display_delay_minus_1[i], 1, i); |
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fb(4, frame_width_bits_minus_1); |
258 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fb(4, frame_height_bits_minus_1); |
259 | |||
260 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fb(current->frame_width_bits_minus_1 + 1, max_frame_width_minus_1); |
261 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fb(current->frame_height_bits_minus_1 + 1, max_frame_height_minus_1); |
262 | |||
263 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (current->reduced_still_picture_header) |
264 | ✗ | infer(frame_id_numbers_present_flag, 0); | |
265 | else | ||
266 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(frame_id_numbers_present_flag); |
267 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (current->frame_id_numbers_present_flag) { |
268 | ✗ | fb(4, delta_frame_id_length_minus_2); | |
269 | ✗ | fb(3, additional_frame_id_length_minus_1); | |
270 | } | ||
271 | |||
272 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(use_128x128_superblock); |
273 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_filter_intra); |
274 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_intra_edge_filter); |
275 | |||
276 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 766 times.
|
1532 | if (current->reduced_still_picture_header) { |
277 | ✗ | infer(enable_interintra_compound, 0); | |
278 | ✗ | infer(enable_masked_compound, 0); | |
279 | ✗ | infer(enable_warped_motion, 0); | |
280 | ✗ | infer(enable_dual_filter, 0); | |
281 | ✗ | infer(enable_order_hint, 0); | |
282 | ✗ | infer(enable_jnt_comp, 0); | |
283 | ✗ | infer(enable_ref_frame_mvs, 0); | |
284 | |||
285 | ✗ | infer(seq_force_screen_content_tools, | |
286 | AV1_SELECT_SCREEN_CONTENT_TOOLS); | ||
287 | ✗ | infer(seq_force_integer_mv, | |
288 | AV1_SELECT_INTEGER_MV); | ||
289 | } else { | ||
290 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_interintra_compound); |
291 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_masked_compound); |
292 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_warped_motion); |
293 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_dual_filter); |
294 | |||
295 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_order_hint); |
296 |
1/2✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
|
1532 | if (current->enable_order_hint) { |
297 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_jnt_comp); |
298 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_ref_frame_mvs); |
299 | } else { | ||
300 | ✗ | infer(enable_jnt_comp, 0); | |
301 | ✗ | infer(enable_ref_frame_mvs, 0); | |
302 | } | ||
303 | |||
304 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(seq_choose_screen_content_tools); |
305 |
1/2✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
|
1532 | if (current->seq_choose_screen_content_tools) |
306 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(seq_force_screen_content_tools, |
307 | AV1_SELECT_SCREEN_CONTENT_TOOLS); | ||
308 | else | ||
309 | ✗ | fb(1, seq_force_screen_content_tools); | |
310 |
1/2✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
|
1532 | if (current->seq_force_screen_content_tools > 0) { |
311 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(seq_choose_integer_mv); |
312 |
1/2✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
|
1532 | if (current->seq_choose_integer_mv) |
313 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
|
1532 | infer(seq_force_integer_mv, |
314 | AV1_SELECT_INTEGER_MV); | ||
315 | else | ||
316 | ✗ | fb(1, seq_force_integer_mv); | |
317 | } else { | ||
318 | ✗ | infer(seq_force_integer_mv, AV1_SELECT_INTEGER_MV); | |
319 | } | ||
320 | |||
321 |
1/2✓ Branch 0 taken 766 times.
✗ Branch 1 not taken.
|
1532 | if (current->enable_order_hint) |
322 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | fb(3, order_hint_bits_minus_1); |
323 | } | ||
324 | |||
325 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_superres); |
326 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_cdef); |
327 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(enable_restoration); |
328 | |||
329 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | CHECK(FUNC(color_config)(ctx, rw, ¤t->color_config, |
330 | current->seq_profile)); | ||
331 | |||
332 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 766 times.
|
1532 | flag(film_grain_params_present); |
333 | |||
334 | 1532 | return 0; | |
335 | } | ||
336 | |||
337 | 3116 | static int FUNC(temporal_delimiter_obu)(CodedBitstreamContext *ctx, RWContext *rw) | |
338 | { | ||
339 | 3116 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
340 | |||
341 | 3116 | HEADER("Temporal Delimiter"); | |
342 | |||
343 | 3116 | priv->seen_frame_header = 0; | |
344 | |||
345 | 3116 | return 0; | |
346 | } | ||
347 | |||
348 | 112 | static int FUNC(set_frame_refs)(CodedBitstreamContext *ctx, RWContext *rw, | |
349 | AV1RawFrameHeader *current) | ||
350 | { | ||
351 | 112 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
352 | 112 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
353 | static const uint8_t ref_frame_list[AV1_NUM_REF_FRAMES - 2] = { | ||
354 | AV1_REF_FRAME_LAST2, AV1_REF_FRAME_LAST3, AV1_REF_FRAME_BWDREF, | ||
355 | AV1_REF_FRAME_ALTREF2, AV1_REF_FRAME_ALTREF | ||
356 | }; | ||
357 | int8_t ref_frame_idx[AV1_REFS_PER_FRAME], used_frame[AV1_NUM_REF_FRAMES]; | ||
358 | int16_t shifted_order_hints[AV1_NUM_REF_FRAMES]; | ||
359 | int cur_frame_hint, latest_order_hint, earliest_order_hint, ref; | ||
360 | int i, j; | ||
361 | |||
362 |
2/2✓ Branch 0 taken 392 times.
✓ Branch 1 taken 56 times.
|
896 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) |
363 | 784 | ref_frame_idx[i] = -1; | |
364 | 112 | ref_frame_idx[AV1_REF_FRAME_LAST - AV1_REF_FRAME_LAST] = current->last_frame_idx; | |
365 | 112 | ref_frame_idx[AV1_REF_FRAME_GOLDEN - AV1_REF_FRAME_LAST] = current->golden_frame_idx; | |
366 | |||
367 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
|
1008 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) |
368 | 896 | used_frame[i] = 0; | |
369 | 112 | used_frame[current->last_frame_idx] = 1; | |
370 | 112 | used_frame[current->golden_frame_idx] = 1; | |
371 | |||
372 | 112 | cur_frame_hint = 1 << (seq->order_hint_bits_minus_1); | |
373 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
|
1008 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) |
374 | 896 | shifted_order_hints[i] = cur_frame_hint + | |
375 | 896 | cbs_av1_get_relative_dist(seq, priv->ref[i].order_hint, | |
376 | 896 | priv->order_hint); | |
377 | |||
378 | 112 | latest_order_hint = shifted_order_hints[current->last_frame_idx]; | |
379 | 112 | earliest_order_hint = shifted_order_hints[current->golden_frame_idx]; | |
380 | |||
381 | 112 | ref = -1; | |
382 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
|
1008 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
383 | 896 | int hint = shifted_order_hints[i]; | |
384 |
6/6✓ Branch 0 taken 336 times.
✓ Branch 1 taken 112 times.
✓ Branch 2 taken 168 times.
✓ Branch 3 taken 168 times.
✓ Branch 4 taken 112 times.
✓ Branch 5 taken 56 times.
|
896 | if (!used_frame[i] && hint >= cur_frame_hint && |
385 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 52 times.
|
224 | (ref < 0 || hint >= latest_order_hint)) { |
386 | 232 | ref = i; | |
387 | 232 | latest_order_hint = hint; | |
388 | } | ||
389 | } | ||
390 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
112 | if (ref >= 0) { |
391 | 112 | ref_frame_idx[AV1_REF_FRAME_ALTREF - AV1_REF_FRAME_LAST] = ref; | |
392 | 112 | used_frame[ref] = 1; | |
393 | } | ||
394 | |||
395 | 112 | ref = -1; | |
396 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
|
1008 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
397 | 896 | int hint = shifted_order_hints[i]; | |
398 |
6/6✓ Branch 0 taken 280 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 168 times.
✓ Branch 4 taken 56 times.
✓ Branch 5 taken 56 times.
|
896 | if (!used_frame[i] && hint >= cur_frame_hint && |
399 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 52 times.
|
112 | (ref < 0 || hint < earliest_order_hint)) { |
400 | 120 | ref = i; | |
401 | 120 | earliest_order_hint = hint; | |
402 | } | ||
403 | } | ||
404 |
1/2✓ Branch 0 taken 56 times.
✗ Branch 1 not taken.
|
112 | if (ref >= 0) { |
405 | 112 | ref_frame_idx[AV1_REF_FRAME_BWDREF - AV1_REF_FRAME_LAST] = ref; | |
406 | 112 | used_frame[ref] = 1; | |
407 | } | ||
408 | |||
409 | 112 | ref = -1; | |
410 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
|
1008 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
411 | 896 | int hint = shifted_order_hints[i]; | |
412 |
6/6✓ Branch 0 taken 224 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 56 times.
✓ Branch 3 taken 168 times.
✓ Branch 4 taken 8 times.
✓ Branch 5 taken 48 times.
|
896 | if (!used_frame[i] && hint >= cur_frame_hint && |
413 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
|
16 | (ref < 0 || hint < earliest_order_hint)) { |
414 | 96 | ref = i; | |
415 | 96 | earliest_order_hint = hint; | |
416 | } | ||
417 | } | ||
418 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 8 times.
|
112 | if (ref >= 0) { |
419 | 96 | ref_frame_idx[AV1_REF_FRAME_ALTREF2 - AV1_REF_FRAME_LAST] = ref; | |
420 | 96 | used_frame[ref] = 1; | |
421 | } | ||
422 | |||
423 |
2/2✓ Branch 0 taken 280 times.
✓ Branch 1 taken 56 times.
|
672 | for (i = 0; i < AV1_REFS_PER_FRAME - 2; i++) { |
424 | 560 | int ref_frame = ref_frame_list[i]; | |
425 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 160 times.
|
560 | if (ref_frame_idx[ref_frame - AV1_REF_FRAME_LAST] < 0 ) { |
426 | 240 | ref = -1; | |
427 |
2/2✓ Branch 0 taken 960 times.
✓ Branch 1 taken 120 times.
|
2160 | for (j = 0; j < AV1_NUM_REF_FRAMES; j++) { |
428 | 1920 | int hint = shifted_order_hints[j]; | |
429 |
6/6✓ Branch 0 taken 312 times.
✓ Branch 1 taken 648 times.
✓ Branch 2 taken 296 times.
✓ Branch 3 taken 16 times.
✓ Branch 4 taken 176 times.
✓ Branch 5 taken 120 times.
|
1920 | if (!used_frame[j] && hint < cur_frame_hint && |
430 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 72 times.
|
352 | (ref < 0 || hint >= latest_order_hint)) { |
431 | 448 | ref = j; | |
432 | 448 | latest_order_hint = hint; | |
433 | } | ||
434 | } | ||
435 |
1/2✓ Branch 0 taken 120 times.
✗ Branch 1 not taken.
|
240 | if (ref >= 0) { |
436 | 240 | ref_frame_idx[ref_frame - AV1_REF_FRAME_LAST] = ref; | |
437 | 240 | used_frame[ref] = 1; | |
438 | } | ||
439 | } | ||
440 | } | ||
441 | |||
442 | 112 | ref = -1; | |
443 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 56 times.
|
1008 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
444 | 896 | int hint = shifted_order_hints[i]; | |
445 |
4/4✓ Branch 0 taken 392 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 44 times.
✓ Branch 3 taken 348 times.
|
896 | if (ref < 0 || hint < earliest_order_hint) { |
446 | 200 | ref = i; | |
447 | 200 | earliest_order_hint = hint; | |
448 | } | ||
449 | } | ||
450 |
2/2✓ Branch 0 taken 392 times.
✓ Branch 1 taken 56 times.
|
896 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) { |
451 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 392 times.
|
784 | if (ref_frame_idx[i] < 0) |
452 | ✗ | ref_frame_idx[i] = ref; | |
453 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 98 times.
|
784 | infer(ref_frame_idx[i], ref_frame_idx[i]); |
454 | } | ||
455 | |||
456 | 112 | return 0; | |
457 | } | ||
458 | |||
459 | 3526 | static int FUNC(superres_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
460 | AV1RawFrameHeader *current) | ||
461 | { | ||
462 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
463 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
464 | int denom, err; | ||
465 | |||
466 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (seq->enable_superres) |
467 | ✗ | flag(use_superres); | |
468 | else | ||
469 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
3526 | infer(use_superres, 0); |
470 | |||
471 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (current->use_superres) { |
472 | ✗ | fb(3, coded_denom); | |
473 | ✗ | denom = current->coded_denom + AV1_SUPERRES_DENOM_MIN; | |
474 | } else { | ||
475 | 3526 | denom = AV1_SUPERRES_NUM; | |
476 | } | ||
477 | |||
478 | 3526 | priv->upscaled_width = priv->frame_width; | |
479 | 3526 | priv->frame_width = (priv->upscaled_width * AV1_SUPERRES_NUM + | |
480 | 3526 | denom / 2) / denom; | |
481 | |||
482 | 3526 | return 0; | |
483 | } | ||
484 | |||
485 | 3406 | static int FUNC(frame_size)(CodedBitstreamContext *ctx, RWContext *rw, | |
486 | AV1RawFrameHeader *current) | ||
487 | { | ||
488 | 3406 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
489 | 3406 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
490 | int err; | ||
491 | |||
492 |
2/2✓ Branch 0 taken 12 times.
✓ Branch 1 taken 1691 times.
|
3406 | if (current->frame_size_override_flag) { |
493 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
24 | fb(seq->frame_width_bits_minus_1 + 1, frame_width_minus_1); |
494 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 12 times.
|
24 | fb(seq->frame_height_bits_minus_1 + 1, frame_height_minus_1); |
495 | } else { | ||
496 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
|
3382 | infer(frame_width_minus_1, seq->max_frame_width_minus_1); |
497 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 356 times.
|
3382 | infer(frame_height_minus_1, seq->max_frame_height_minus_1); |
498 | } | ||
499 | |||
500 | 3406 | priv->frame_width = current->frame_width_minus_1 + 1; | |
501 | 3406 | priv->frame_height = current->frame_height_minus_1 + 1; | |
502 | |||
503 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1703 times.
|
3406 | CHECK(FUNC(superres_params)(ctx, rw, current)); |
504 | |||
505 | 3406 | return 0; | |
506 | } | ||
507 | |||
508 | 3406 | static int FUNC(render_size)(CodedBitstreamContext *ctx, RWContext *rw, | |
509 | AV1RawFrameHeader *current) | ||
510 | { | ||
511 | 3406 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
512 | int err; | ||
513 | |||
514 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1703 times.
|
3406 | flag(render_and_frame_size_different); |
515 | |||
516 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1703 times.
|
3406 | if (current->render_and_frame_size_different) { |
517 | ✗ | fb(16, render_width_minus_1); | |
518 | ✗ | fb(16, render_height_minus_1); | |
519 | } else { | ||
520 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
|
3406 | infer(render_width_minus_1, current->frame_width_minus_1); |
521 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 359 times.
|
3406 | infer(render_height_minus_1, current->frame_height_minus_1); |
522 | } | ||
523 | |||
524 | 3406 | priv->render_width = current->render_width_minus_1 + 1; | |
525 | 3406 | priv->render_height = current->render_height_minus_1 + 1; | |
526 | |||
527 | 3406 | return 0; | |
528 | } | ||
529 | |||
530 | 120 | static int FUNC(frame_size_with_refs)(CodedBitstreamContext *ctx, RWContext *rw, | |
531 | AV1RawFrameHeader *current) | ||
532 | { | ||
533 | 120 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
534 | int i, err; | ||
535 | |||
536 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
120 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) { |
537 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
120 | flags(found_ref[i], 1, i); |
538 |
1/2✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
|
120 | if (current->found_ref[i]) { |
539 | 120 | AV1ReferenceFrameState *ref = | |
540 | 120 | &priv->ref[current->ref_frame_idx[i]]; | |
541 | |||
542 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
120 | if (!ref->valid) { |
543 | ✗ | av_log(ctx->log_ctx, AV_LOG_ERROR, | |
544 | "Missing reference frame needed for frame size " | ||
545 | "(ref = %d, ref_frame_idx = %d).\n", | ||
546 | ✗ | i, current->ref_frame_idx[i]); | |
547 | ✗ | return AVERROR_INVALIDDATA; | |
548 | } | ||
549 | |||
550 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
120 | infer(frame_width_minus_1, ref->upscaled_width - 1); |
551 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
120 | infer(frame_height_minus_1, ref->frame_height - 1); |
552 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
120 | infer(render_width_minus_1, ref->render_width - 1); |
553 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 15 times.
|
120 | infer(render_height_minus_1, ref->render_height - 1); |
554 | |||
555 | 120 | priv->upscaled_width = ref->upscaled_width; | |
556 | 120 | priv->frame_width = priv->upscaled_width; | |
557 | 120 | priv->frame_height = ref->frame_height; | |
558 | 120 | priv->render_width = ref->render_width; | |
559 | 120 | priv->render_height = ref->render_height; | |
560 | 120 | break; | |
561 | } | ||
562 | } | ||
563 | |||
564 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 60 times.
|
120 | if (i >= AV1_REFS_PER_FRAME) { |
565 | ✗ | CHECK(FUNC(frame_size)(ctx, rw, current)); | |
566 | ✗ | CHECK(FUNC(render_size)(ctx, rw, current)); | |
567 | } else { | ||
568 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
120 | CHECK(FUNC(superres_params)(ctx, rw, current)); |
569 | } | ||
570 | |||
571 | 120 | return 0; | |
572 | } | ||
573 | |||
574 | 3078 | static int FUNC(interpolation_filter)(CodedBitstreamContext *ctx, RWContext *rw, | |
575 | AV1RawFrameHeader *current) | ||
576 | { | ||
577 | int err; | ||
578 | |||
579 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1539 times.
|
3078 | flag(is_filter_switchable); |
580 |
2/2✓ Branch 0 taken 1231 times.
✓ Branch 1 taken 308 times.
|
3078 | if (current->is_filter_switchable) |
581 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 251 times.
|
2462 | infer(interpolation_filter, |
582 | AV1_INTERPOLATION_FILTER_SWITCHABLE); | ||
583 | else | ||
584 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 308 times.
|
616 | fb(2, interpolation_filter); |
585 | |||
586 | 3078 | return 0; | |
587 | } | ||
588 | |||
589 | 3526 | static int FUNC(tile_info)(CodedBitstreamContext *ctx, RWContext *rw, | |
590 | AV1RawFrameHeader *current) | ||
591 | { | ||
592 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
593 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
594 | int mi_cols, mi_rows, sb_cols, sb_rows, sb_shift, sb_size; | ||
595 | int max_tile_width_sb, max_tile_height_sb, max_tile_area_sb; | ||
596 | int min_log2_tile_cols, max_log2_tile_cols, max_log2_tile_rows; | ||
597 | int min_log2_tiles, min_log2_tile_rows; | ||
598 | int i, err; | ||
599 | |||
600 | 3526 | mi_cols = 2 * ((priv->frame_width + 7) >> 3); | |
601 | 3526 | mi_rows = 2 * ((priv->frame_height + 7) >> 3); | |
602 | |||
603 | 8624 | sb_cols = seq->use_128x128_superblock ? ((mi_cols + 31) >> 5) | |
604 |
2/2✓ Branch 0 taken 786 times.
✓ Branch 1 taken 977 times.
|
3526 | : ((mi_cols + 15) >> 4); |
605 | 8624 | sb_rows = seq->use_128x128_superblock ? ((mi_rows + 31) >> 5) | |
606 |
2/2✓ Branch 0 taken 786 times.
✓ Branch 1 taken 977 times.
|
3526 | : ((mi_rows + 15) >> 4); |
607 | |||
608 |
2/2✓ Branch 0 taken 786 times.
✓ Branch 1 taken 977 times.
|
3526 | sb_shift = seq->use_128x128_superblock ? 5 : 4; |
609 | 3526 | sb_size = sb_shift + 2; | |
610 | |||
611 | 3526 | max_tile_width_sb = AV1_MAX_TILE_WIDTH >> sb_size; | |
612 | 3526 | max_tile_area_sb = AV1_MAX_TILE_AREA >> (2 * sb_size); | |
613 | |||
614 | 3526 | min_log2_tile_cols = cbs_av1_tile_log2(max_tile_width_sb, sb_cols); | |
615 | 3526 | max_log2_tile_cols = cbs_av1_tile_log2(1, FFMIN(sb_cols, AV1_MAX_TILE_COLS)); | |
616 | 3526 | max_log2_tile_rows = cbs_av1_tile_log2(1, FFMIN(sb_rows, AV1_MAX_TILE_ROWS)); | |
617 |
1/2✓ Branch 1 taken 1763 times.
✗ Branch 2 not taken.
|
3526 | min_log2_tiles = FFMAX(min_log2_tile_cols, |
618 | cbs_av1_tile_log2(max_tile_area_sb, sb_rows * sb_cols)); | ||
619 | |||
620 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(uniform_tile_spacing_flag); |
621 | |||
622 |
2/2✓ Branch 0 taken 1659 times.
✓ Branch 1 taken 104 times.
|
3526 | if (current->uniform_tile_spacing_flag) { |
623 | int tile_width_sb, tile_height_sb; | ||
624 | |||
625 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1659 times.
|
3318 | increment(tile_cols_log2, min_log2_tile_cols, max_log2_tile_cols); |
626 | |||
627 | 3318 | tile_width_sb = (sb_cols + (1 << current->tile_cols_log2) - 1) >> | |
628 | 3318 | current->tile_cols_log2; | |
629 | |||
630 |
2/2✓ Branch 0 taken 2131 times.
✓ Branch 1 taken 1659 times.
|
7580 | for (int off = 0, i = 0; off < sb_cols; off += tile_width_sb) |
631 | 4262 | current->tile_start_col_sb[i++] = off; | |
632 | |||
633 | 3318 | current->tile_cols = (sb_cols + tile_width_sb - 1) / tile_width_sb; | |
634 | |||
635 | 3318 | min_log2_tile_rows = FFMAX(min_log2_tiles - current->tile_cols_log2, 0); | |
636 | |||
637 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1659 times.
|
3318 | increment(tile_rows_log2, min_log2_tile_rows, max_log2_tile_rows); |
638 | |||
639 | 3318 | tile_height_sb = (sb_rows + (1 << current->tile_rows_log2) - 1) >> | |
640 | 3318 | current->tile_rows_log2; | |
641 | |||
642 |
2/2✓ Branch 0 taken 1747 times.
✓ Branch 1 taken 1659 times.
|
6812 | for (int off = 0, i = 0; off < sb_rows; off += tile_height_sb) |
643 | 3494 | current->tile_start_row_sb[i++] = off; | |
644 | |||
645 | 3318 | current->tile_rows = (sb_rows + tile_height_sb - 1) / tile_height_sb; | |
646 | |||
647 |
2/2✓ Branch 0 taken 472 times.
✓ Branch 1 taken 1659 times.
|
4262 | for (i = 0; i < current->tile_cols - 1; i++) |
648 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 118 times.
|
944 | infer(width_in_sbs_minus_1[i], tile_width_sb - 1); |
649 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
3318 | infer(width_in_sbs_minus_1[i], |
650 | sb_cols - (current->tile_cols - 1) * tile_width_sb - 1); | ||
651 |
2/2✓ Branch 0 taken 88 times.
✓ Branch 1 taken 1659 times.
|
3494 | for (i = 0; i < current->tile_rows - 1; i++) |
652 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
|
176 | infer(height_in_sbs_minus_1[i], tile_height_sb - 1); |
653 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 348 times.
|
3318 | infer(height_in_sbs_minus_1[i], |
654 | sb_rows - (current->tile_rows - 1) * tile_height_sb - 1); | ||
655 | |||
656 | } else { | ||
657 | int widest_tile_sb, start_sb, size_sb, max_width, max_height; | ||
658 | |||
659 | 208 | widest_tile_sb = 0; | |
660 | |||
661 | 208 | start_sb = 0; | |
662 |
3/4✓ Branch 0 taken 104 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 104 times.
✗ Branch 3 not taken.
|
416 | for (i = 0; start_sb < sb_cols && i < AV1_MAX_TILE_COLS; i++) { |
663 | 208 | current->tile_start_col_sb[i] = start_sb; | |
664 | 208 | max_width = FFMIN(sb_cols - start_sb, max_tile_width_sb); | |
665 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 104 times.
|
208 | ns(max_width, width_in_sbs_minus_1[i], 1, i); |
666 | 208 | size_sb = current->width_in_sbs_minus_1[i] + 1; | |
667 | 208 | widest_tile_sb = FFMAX(size_sb, widest_tile_sb); | |
668 | 208 | start_sb += size_sb; | |
669 | } | ||
670 | 208 | current->tile_cols_log2 = cbs_av1_tile_log2(1, i); | |
671 | 208 | current->tile_cols = i; | |
672 | |||
673 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 104 times.
|
208 | if (min_log2_tiles > 0) |
674 | ✗ | max_tile_area_sb = (sb_rows * sb_cols) >> (min_log2_tiles + 1); | |
675 | else | ||
676 | 208 | max_tile_area_sb = sb_rows * sb_cols; | |
677 | 208 | max_tile_height_sb = FFMAX(max_tile_area_sb / widest_tile_sb, 1); | |
678 | |||
679 | 208 | start_sb = 0; | |
680 |
3/4✓ Branch 0 taken 416 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 416 times.
✗ Branch 3 not taken.
|
1040 | for (i = 0; start_sb < sb_rows && i < AV1_MAX_TILE_ROWS; i++) { |
681 | 832 | current->tile_start_row_sb[i] = start_sb; | |
682 | 832 | max_height = FFMIN(sb_rows - start_sb, max_tile_height_sb); | |
683 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
|
832 | ns(max_height, height_in_sbs_minus_1[i], 1, i); |
684 | 832 | size_sb = current->height_in_sbs_minus_1[i] + 1; | |
685 | 832 | start_sb += size_sb; | |
686 | } | ||
687 | 208 | current->tile_rows_log2 = cbs_av1_tile_log2(1, i); | |
688 | 208 | current->tile_rows = i; | |
689 | } | ||
690 | |||
691 |
2/2✓ Branch 0 taken 1559 times.
✓ Branch 1 taken 204 times.
|
3526 | if (current->tile_cols_log2 > 0 || |
692 |
2/2✓ Branch 0 taken 104 times.
✓ Branch 1 taken 1455 times.
|
3118 | current->tile_rows_log2 > 0) { |
693 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 308 times.
|
616 | fb(current->tile_cols_log2 + current->tile_rows_log2, |
694 | context_update_tile_id); | ||
695 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 308 times.
|
616 | fb(2, tile_size_bytes_minus1); |
696 | } else { | ||
697 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
|
2910 | infer(context_update_tile_id, 0); |
698 | } | ||
699 | |||
700 | 3526 | priv->tile_cols = current->tile_cols; | |
701 | 3526 | priv->tile_rows = current->tile_rows; | |
702 | |||
703 | 3526 | return 0; | |
704 | } | ||
705 | |||
706 | 3526 | static int FUNC(quantization_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
707 | AV1RawFrameHeader *current) | ||
708 | { | ||
709 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
710 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
711 | int err; | ||
712 | |||
713 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | fb(8, base_q_idx); |
714 | |||
715 |
2/6✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1763 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3526 | delta_q(delta_q_y_dc); |
716 | |||
717 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (priv->num_planes > 1) { |
718 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (seq->color_config.separate_uv_delta_q) |
719 | ✗ | flag(diff_uv_delta); | |
720 | else | ||
721 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
3526 | infer(diff_uv_delta, 0); |
722 | |||
723 |
2/6✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1763 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3526 | delta_q(delta_q_u_dc); |
724 |
2/6✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1763 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
|
3526 | delta_q(delta_q_u_ac); |
725 | |||
726 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (current->diff_uv_delta) { |
727 | ✗ | delta_q(delta_q_v_dc); | |
728 | ✗ | delta_q(delta_q_v_ac); | |
729 | } else { | ||
730 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
3526 | infer(delta_q_v_dc, current->delta_q_u_dc); |
731 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
3526 | infer(delta_q_v_ac, current->delta_q_u_ac); |
732 | } | ||
733 | } else { | ||
734 | ✗ | infer(delta_q_u_dc, 0); | |
735 | ✗ | infer(delta_q_u_ac, 0); | |
736 | ✗ | infer(delta_q_v_dc, 0); | |
737 | ✗ | infer(delta_q_v_ac, 0); | |
738 | } | ||
739 | |||
740 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(using_qmatrix); |
741 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (current->using_qmatrix) { |
742 | ✗ | fb(4, qm_y); | |
743 | ✗ | fb(4, qm_u); | |
744 | ✗ | if (seq->color_config.separate_uv_delta_q) | |
745 | ✗ | fb(4, qm_v); | |
746 | else | ||
747 | ✗ | infer(qm_v, current->qm_u); | |
748 | } | ||
749 | |||
750 | 3526 | return 0; | |
751 | } | ||
752 | |||
753 | 3526 | static int FUNC(segmentation_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
754 | AV1RawFrameHeader *current) | ||
755 | { | ||
756 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
757 | static const uint8_t bits[AV1_SEG_LVL_MAX] = { 8, 6, 6, 6, 6, 3, 0, 0 }; | ||
758 | static const uint8_t sign[AV1_SEG_LVL_MAX] = { 1, 1, 1, 1, 1, 0, 0, 0 }; | ||
759 | static const uint8_t default_feature_enabled[AV1_SEG_LVL_MAX] = { 0 }; | ||
760 | static const int16_t default_feature_value[AV1_SEG_LVL_MAX] = { 0 }; | ||
761 | int i, j, err; | ||
762 | |||
763 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(segmentation_enabled); |
764 | |||
765 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (current->segmentation_enabled) { |
766 | ✗ | if (current->primary_ref_frame == AV1_PRIMARY_REF_NONE) { | |
767 | ✗ | infer(segmentation_update_map, 1); | |
768 | ✗ | infer(segmentation_temporal_update, 0); | |
769 | ✗ | infer(segmentation_update_data, 1); | |
770 | } else { | ||
771 | ✗ | flag(segmentation_update_map); | |
772 | ✗ | if (current->segmentation_update_map) | |
773 | ✗ | flag(segmentation_temporal_update); | |
774 | else | ||
775 | ✗ | infer(segmentation_temporal_update, 0); | |
776 | ✗ | flag(segmentation_update_data); | |
777 | } | ||
778 | |||
779 | ✗ | for (i = 0; i < AV1_MAX_SEGMENTS; i++) { | |
780 | const uint8_t *ref_feature_enabled; | ||
781 | const int16_t *ref_feature_value; | ||
782 | |||
783 | ✗ | if (current->primary_ref_frame == AV1_PRIMARY_REF_NONE) { | |
784 | ✗ | ref_feature_enabled = default_feature_enabled; | |
785 | ✗ | ref_feature_value = default_feature_value; | |
786 | } else { | ||
787 | ✗ | ref_feature_enabled = | |
788 | ✗ | priv->ref[current->ref_frame_idx[current->primary_ref_frame]].feature_enabled[i]; | |
789 | ✗ | ref_feature_value = | |
790 | ✗ | priv->ref[current->ref_frame_idx[current->primary_ref_frame]].feature_value[i]; | |
791 | } | ||
792 | |||
793 | ✗ | for (j = 0; j < AV1_SEG_LVL_MAX; j++) { | |
794 | ✗ | if (current->segmentation_update_data) { | |
795 | ✗ | flags(feature_enabled[i][j], 2, i, j); | |
796 | |||
797 | ✗ | if (current->feature_enabled[i][j] && bits[j] > 0) { | |
798 | ✗ | if (sign[j]) | |
799 | ✗ | sus(1 + bits[j], feature_value[i][j], 2, i, j); | |
800 | else | ||
801 | ✗ | fbs(bits[j], feature_value[i][j], 2, i, j); | |
802 | } else { | ||
803 | ✗ | infer(feature_value[i][j], 0); | |
804 | } | ||
805 | } else { | ||
806 | ✗ | infer(feature_enabled[i][j], ref_feature_enabled[j]); | |
807 | ✗ | infer(feature_value[i][j], ref_feature_value[j]); | |
808 | } | ||
809 | } | ||
810 | } | ||
811 | } else { | ||
812 |
2/2✓ Branch 0 taken 14104 times.
✓ Branch 1 taken 1763 times.
|
31734 | for (i = 0; i < AV1_MAX_SEGMENTS; i++) { |
813 |
2/2✓ Branch 0 taken 112832 times.
✓ Branch 1 taken 14104 times.
|
253872 | for (j = 0; j < AV1_SEG_LVL_MAX; j++) { |
814 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23936 times.
|
225664 | infer(feature_enabled[i][j], 0); |
815 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 23936 times.
|
225664 | infer(feature_value[i][j], 0); |
816 | } | ||
817 | } | ||
818 | } | ||
819 | |||
820 | 3526 | return 0; | |
821 | } | ||
822 | |||
823 | 3526 | static int FUNC(delta_q_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
824 | AV1RawFrameHeader *current) | ||
825 | { | ||
826 | int err; | ||
827 | |||
828 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (current->base_q_idx > 0) |
829 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(delta_q_present); |
830 | else | ||
831 | ✗ | infer(delta_q_present, 0); | |
832 | |||
833 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1747 times.
|
3526 | if (current->delta_q_present) |
834 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(2, delta_q_res); |
835 | |||
836 | 3526 | return 0; | |
837 | } | ||
838 | |||
839 | 3526 | static int FUNC(delta_lf_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
840 | AV1RawFrameHeader *current) | ||
841 | { | ||
842 | int err; | ||
843 | |||
844 |
2/2✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1747 times.
|
3526 | if (current->delta_q_present) { |
845 |
1/2✓ Branch 0 taken 16 times.
✗ Branch 1 not taken.
|
32 | if (!current->allow_intrabc) |
846 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | flag(delta_lf_present); |
847 | else | ||
848 | ✗ | infer(delta_lf_present, 0); | |
849 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
|
32 | if (current->delta_lf_present) { |
850 | ✗ | fb(2, delta_lf_res); | |
851 | ✗ | flag(delta_lf_multi); | |
852 | } else { | ||
853 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
32 | infer(delta_lf_res, 0); |
854 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
|
32 | infer(delta_lf_multi, 0); |
855 | } | ||
856 | } else { | ||
857 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 370 times.
|
3494 | infer(delta_lf_present, 0); |
858 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 370 times.
|
3494 | infer(delta_lf_res, 0); |
859 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 370 times.
|
3494 | infer(delta_lf_multi, 0); |
860 | } | ||
861 | |||
862 | 3526 | return 0; | |
863 | } | ||
864 | |||
865 | 3526 | static int FUNC(loop_filter_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
866 | AV1RawFrameHeader *current) | ||
867 | { | ||
868 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
869 | static const int8_t default_loop_filter_ref_deltas[AV1_TOTAL_REFS_PER_FRAME] = | ||
870 | { 1, 0, 0, 0, -1, 0, -1, -1 }; | ||
871 | static const int8_t default_loop_filter_mode_deltas[2] = { 0, 0 }; | ||
872 | int i, err; | ||
873 | |||
874 |
2/4✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1763 times.
|
3526 | if (priv->coded_lossless || current->allow_intrabc) { |
875 | ✗ | infer(loop_filter_level[0], 0); | |
876 | ✗ | infer(loop_filter_level[1], 0); | |
877 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_INTRA], 1); | |
878 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_LAST], 0); | |
879 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_LAST2], 0); | |
880 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_LAST3], 0); | |
881 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_BWDREF], 0); | |
882 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_GOLDEN], -1); | |
883 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF], -1); | |
884 | ✗ | infer(loop_filter_ref_deltas[AV1_REF_FRAME_ALTREF2], -1); | |
885 | ✗ | for (i = 0; i < 2; i++) | |
886 | ✗ | infer(loop_filter_mode_deltas[i], 0); | |
887 | ✗ | return 0; | |
888 | } | ||
889 | |||
890 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | fb(6, loop_filter_level[0]); |
891 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | fb(6, loop_filter_level[1]); |
892 | |||
893 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (priv->num_planes > 1) { |
894 |
2/2✓ Branch 0 taken 798 times.
✓ Branch 1 taken 965 times.
|
3526 | if (current->loop_filter_level[0] || |
895 |
2/2✓ Branch 0 taken 20 times.
✓ Branch 1 taken 778 times.
|
1596 | current->loop_filter_level[1]) { |
896 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 985 times.
|
1970 | fb(6, loop_filter_level[2]); |
897 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 985 times.
|
1970 | fb(6, loop_filter_level[3]); |
898 | } | ||
899 | } | ||
900 | |||
901 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | fb(3, loop_filter_sharpness); |
902 | |||
903 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(loop_filter_delta_enabled); |
904 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (current->loop_filter_delta_enabled) { |
905 | const int8_t *ref_loop_filter_ref_deltas, *ref_loop_filter_mode_deltas; | ||
906 | |||
907 |
2/2✓ Branch 0 taken 426 times.
✓ Branch 1 taken 1337 times.
|
3526 | if (current->primary_ref_frame == AV1_PRIMARY_REF_NONE) { |
908 | 852 | ref_loop_filter_ref_deltas = default_loop_filter_ref_deltas; | |
909 | 852 | ref_loop_filter_mode_deltas = default_loop_filter_mode_deltas; | |
910 | } else { | ||
911 | 2674 | ref_loop_filter_ref_deltas = | |
912 | 2674 | priv->ref[current->ref_frame_idx[current->primary_ref_frame]].loop_filter_ref_deltas; | |
913 | 2674 | ref_loop_filter_mode_deltas = | |
914 | 2674 | priv->ref[current->ref_frame_idx[current->primary_ref_frame]].loop_filter_mode_deltas; | |
915 | } | ||
916 | |||
917 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(loop_filter_delta_update); |
918 |
2/2✓ Branch 0 taken 14104 times.
✓ Branch 1 taken 1763 times.
|
31734 | for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) { |
919 |
2/2✓ Branch 0 taken 3408 times.
✓ Branch 1 taken 10696 times.
|
28208 | if (current->loop_filter_delta_update) |
920 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 3408 times.
|
6816 | flags(update_ref_delta[i], 1, i); |
921 | else | ||
922 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2176 times.
|
21392 | infer(update_ref_delta[i], 0); |
923 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14104 times.
|
28208 | if (current->update_ref_delta[i]) |
924 | ✗ | sus(1 + 6, loop_filter_ref_deltas[i], 1, i); | |
925 | else | ||
926 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2992 times.
|
28208 | infer(loop_filter_ref_deltas[i], ref_loop_filter_ref_deltas[i]); |
927 | } | ||
928 |
2/2✓ Branch 0 taken 3526 times.
✓ Branch 1 taken 1763 times.
|
10578 | for (i = 0; i < 2; i++) { |
929 |
2/2✓ Branch 0 taken 852 times.
✓ Branch 1 taken 2674 times.
|
7052 | if (current->loop_filter_delta_update) |
930 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 852 times.
|
1704 | flags(update_mode_delta[i], 1, i); |
931 | else | ||
932 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 544 times.
|
5348 | infer(update_mode_delta[i], 0); |
933 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 3526 times.
|
7052 | if (current->update_mode_delta[i]) |
934 | ✗ | sus(1 + 6, loop_filter_mode_deltas[i], 1, i); | |
935 | else | ||
936 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 748 times.
|
7052 | infer(loop_filter_mode_deltas[i], ref_loop_filter_mode_deltas[i]); |
937 | } | ||
938 | } else { | ||
939 | ✗ | for (i = 0; i < AV1_TOTAL_REFS_PER_FRAME; i++) | |
940 | ✗ | infer(loop_filter_ref_deltas[i], default_loop_filter_ref_deltas[i]); | |
941 | ✗ | for (i = 0; i < 2; i++) | |
942 | ✗ | infer(loop_filter_mode_deltas[i], default_loop_filter_mode_deltas[i]); | |
943 | } | ||
944 | |||
945 | 3526 | return 0; | |
946 | } | ||
947 | |||
948 | 3526 | static int FUNC(cdef_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
949 | AV1RawFrameHeader *current) | ||
950 | { | ||
951 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
952 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
953 | int i, err; | ||
954 | |||
955 |
2/4✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
✗ Branch 3 not taken.
|
3526 | if (priv->coded_lossless || current->allow_intrabc || |
956 |
2/2✓ Branch 0 taken 172 times.
✓ Branch 1 taken 1591 times.
|
3526 | !seq->enable_cdef) { |
957 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
344 | infer(cdef_damping_minus_3, 0); |
958 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
344 | infer(cdef_bits, 0); |
959 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
344 | infer(cdef_y_pri_strength[0], 0); |
960 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
344 | infer(cdef_y_sec_strength[0], 0); |
961 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
344 | infer(cdef_uv_pri_strength[0], 0); |
962 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
|
344 | infer(cdef_uv_sec_strength[0], 0); |
963 | |||
964 | 344 | return 0; | |
965 | } | ||
966 | |||
967 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1591 times.
|
3182 | fb(2, cdef_damping_minus_3); |
968 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1591 times.
|
3182 | fb(2, cdef_bits); |
969 | |||
970 |
2/2✓ Branch 0 taken 6058 times.
✓ Branch 1 taken 1591 times.
|
15298 | for (i = 0; i < (1 << current->cdef_bits); i++) { |
971 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6058 times.
|
12116 | fbs(4, cdef_y_pri_strength[i], 1, i); |
972 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6058 times.
|
12116 | fbs(2, cdef_y_sec_strength[i], 1, i); |
973 | |||
974 |
1/2✓ Branch 0 taken 6058 times.
✗ Branch 1 not taken.
|
12116 | if (priv->num_planes > 1) { |
975 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6058 times.
|
12116 | fbs(4, cdef_uv_pri_strength[i], 1, i); |
976 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 6058 times.
|
12116 | fbs(2, cdef_uv_sec_strength[i], 1, i); |
977 | } | ||
978 | } | ||
979 | |||
980 | 3182 | return 0; | |
981 | } | ||
982 | |||
983 | 3526 | static int FUNC(lr_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
984 | AV1RawFrameHeader *current) | ||
985 | { | ||
986 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
987 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
988 | int uses_lr, uses_chroma_lr; | ||
989 | int i, err; | ||
990 | |||
991 |
2/4✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
✗ Branch 3 not taken.
|
3526 | if (priv->all_lossless || current->allow_intrabc || |
992 |
2/2✓ Branch 0 taken 128 times.
✓ Branch 1 taken 1635 times.
|
3526 | !seq->enable_restoration) { |
993 | 256 | return 0; | |
994 | } | ||
995 | |||
996 | 3270 | uses_lr = uses_chroma_lr = 0; | |
997 |
2/2✓ Branch 0 taken 4905 times.
✓ Branch 1 taken 1635 times.
|
13080 | for (i = 0; i < priv->num_planes; i++) { |
998 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4905 times.
|
9810 | fbs(2, lr_type[i], 1, i); |
999 | |||
1000 |
2/2✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 3705 times.
|
9810 | if (current->lr_type[i] != AV1_RESTORE_NONE) { |
1001 | 2400 | uses_lr = 1; | |
1002 |
2/2✓ Branch 0 taken 422 times.
✓ Branch 1 taken 778 times.
|
2400 | if (i > 0) |
1003 | 844 | uses_chroma_lr = 1; | |
1004 | } | ||
1005 | } | ||
1006 | |||
1007 |
2/2✓ Branch 0 taken 855 times.
✓ Branch 1 taken 780 times.
|
3270 | if (uses_lr) { |
1008 |
2/2✓ Branch 0 taken 481 times.
✓ Branch 1 taken 374 times.
|
1710 | if (seq->use_128x128_superblock) |
1009 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 481 times.
|
962 | increment(lr_unit_shift, 1, 2); |
1010 | else | ||
1011 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 374 times.
|
748 | increment(lr_unit_shift, 0, 2); |
1012 | |||
1013 |
1/2✓ Branch 0 taken 855 times.
✗ Branch 1 not taken.
|
1710 | if(seq->color_config.subsampling_x && |
1014 |
3/4✓ Branch 0 taken 855 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 277 times.
✓ Branch 3 taken 578 times.
|
1710 | seq->color_config.subsampling_y && uses_chroma_lr) { |
1015 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 277 times.
|
554 | fb(1, lr_uv_shift); |
1016 | } else { | ||
1017 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 122 times.
|
1156 | infer(lr_uv_shift, 0); |
1018 | } | ||
1019 | } | ||
1020 | |||
1021 | 3270 | return 0; | |
1022 | } | ||
1023 | |||
1024 | 3526 | static int FUNC(read_tx_mode)(CodedBitstreamContext *ctx, RWContext *rw, | |
1025 | AV1RawFrameHeader *current) | ||
1026 | { | ||
1027 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1028 | int err; | ||
1029 | |||
1030 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (priv->coded_lossless) |
1031 | ✗ | infer(tx_mode, AV1_ONLY_4X4); | |
1032 | else | ||
1033 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | increment(tx_mode, AV1_TX_MODE_LARGEST, AV1_TX_MODE_SELECT); |
1034 | |||
1035 | 3526 | return 0; | |
1036 | } | ||
1037 | |||
1038 | 3526 | static int FUNC(frame_reference_mode)(CodedBitstreamContext *ctx, RWContext *rw, | |
1039 | AV1RawFrameHeader *current) | ||
1040 | { | ||
1041 | int err; | ||
1042 | |||
1043 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (current->frame_type == AV1_FRAME_INTRA_ONLY || |
1044 |
2/2✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1539 times.
|
3526 | current->frame_type == AV1_FRAME_KEY) |
1045 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 58 times.
|
448 | infer(reference_select, 0); |
1046 | else | ||
1047 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1539 times.
|
3078 | flag(reference_select); |
1048 | |||
1049 | 3526 | return 0; | |
1050 | } | ||
1051 | |||
1052 | 3526 | static int FUNC(skip_mode_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
1053 | AV1RawFrameHeader *current) | ||
1054 | { | ||
1055 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1056 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
1057 | int skip_mode_allowed; | ||
1058 | int err; | ||
1059 | |||
1060 |
2/2✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 224 times.
|
3526 | if (current->frame_type == AV1_FRAME_KEY || |
1061 |
1/2✓ Branch 0 taken 1539 times.
✗ Branch 1 not taken.
|
3078 | current->frame_type == AV1_FRAME_INTRA_ONLY || |
1062 |
3/4✓ Branch 0 taken 922 times.
✓ Branch 1 taken 617 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 922 times.
|
3078 | !current->reference_select || !seq->enable_order_hint) { |
1063 | 1682 | skip_mode_allowed = 0; | |
1064 | } else { | ||
1065 | int forward_idx, backward_idx; | ||
1066 | int forward_hint, backward_hint; | ||
1067 | int ref_hint, dist, i; | ||
1068 | |||
1069 | 1844 | forward_idx = -1; | |
1070 | 1844 | backward_idx = -1; | |
1071 |
2/2✓ Branch 0 taken 6454 times.
✓ Branch 1 taken 922 times.
|
14752 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) { |
1072 | 12908 | ref_hint = priv->ref[current->ref_frame_idx[i]].order_hint; | |
1073 | 12908 | dist = cbs_av1_get_relative_dist(seq, ref_hint, | |
1074 | 12908 | priv->order_hint); | |
1075 |
2/2✓ Branch 0 taken 5592 times.
✓ Branch 1 taken 862 times.
|
12908 | if (dist < 0) { |
1076 |
4/4✓ Branch 0 taken 4670 times.
✓ Branch 1 taken 922 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 4541 times.
|
20524 | if (forward_idx < 0 || |
1077 | 9340 | cbs_av1_get_relative_dist(seq, ref_hint, | |
1078 | forward_hint) > 0) { | ||
1079 | 2102 | forward_idx = i; | |
1080 | 2102 | forward_hint = ref_hint; | |
1081 | } | ||
1082 |
2/2✓ Branch 0 taken 816 times.
✓ Branch 1 taken 46 times.
|
1724 | } else if (dist > 0) { |
1083 |
3/4✓ Branch 0 taken 368 times.
✓ Branch 1 taken 448 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 368 times.
|
2368 | if (backward_idx < 0 || |
1084 | 736 | cbs_av1_get_relative_dist(seq, ref_hint, | |
1085 | backward_hint) < 0) { | ||
1086 | 896 | backward_idx = i; | |
1087 | 896 | backward_hint = ref_hint; | |
1088 | } | ||
1089 | } | ||
1090 | } | ||
1091 | |||
1092 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 922 times.
|
1844 | if (forward_idx < 0) { |
1093 | ✗ | skip_mode_allowed = 0; | |
1094 |
2/2✓ Branch 0 taken 448 times.
✓ Branch 1 taken 474 times.
|
1844 | } else if (backward_idx >= 0) { |
1095 | 896 | skip_mode_allowed = 1; | |
1096 | // Frames for skip mode are forward_idx and backward_idx. | ||
1097 | } else { | ||
1098 | int second_forward_idx; | ||
1099 | int second_forward_hint; | ||
1100 | |||
1101 | 948 | second_forward_idx = -1; | |
1102 |
2/2✓ Branch 0 taken 3318 times.
✓ Branch 1 taken 474 times.
|
7584 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) { |
1103 | 6636 | ref_hint = priv->ref[current->ref_frame_idx[i]].order_hint; | |
1104 |
2/2✓ Branch 1 taken 2669 times.
✓ Branch 2 taken 649 times.
|
6636 | if (cbs_av1_get_relative_dist(seq, ref_hint, |
1105 | forward_hint) < 0) { | ||
1106 |
4/4✓ Branch 0 taken 2213 times.
✓ Branch 1 taken 456 times.
✓ Branch 2 taken 28 times.
✓ Branch 3 taken 2185 times.
|
9764 | if (second_forward_idx < 0 || |
1107 | 4426 | cbs_av1_get_relative_dist(seq, ref_hint, | |
1108 | second_forward_hint) > 0) { | ||
1109 | 968 | second_forward_idx = i; | |
1110 | 968 | second_forward_hint = ref_hint; | |
1111 | } | ||
1112 | } | ||
1113 | } | ||
1114 | |||
1115 |
2/2✓ Branch 0 taken 18 times.
✓ Branch 1 taken 456 times.
|
948 | if (second_forward_idx < 0) { |
1116 | 36 | skip_mode_allowed = 0; | |
1117 | } else { | ||
1118 | 912 | skip_mode_allowed = 1; | |
1119 | // Frames for skip mode are forward_idx and second_forward_idx. | ||
1120 | } | ||
1121 | } | ||
1122 | } | ||
1123 | |||
1124 |
2/2✓ Branch 0 taken 904 times.
✓ Branch 1 taken 859 times.
|
3526 | if (skip_mode_allowed) |
1125 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 904 times.
|
1808 | flag(skip_mode_present); |
1126 | else | ||
1127 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 204 times.
|
1718 | infer(skip_mode_present, 0); |
1128 | |||
1129 | 3526 | return 0; | |
1130 | } | ||
1131 | |||
1132 | 672 | static int FUNC(global_motion_param)(CodedBitstreamContext *ctx, RWContext *rw, | |
1133 | AV1RawFrameHeader *current, | ||
1134 | int type, int ref, int idx) | ||
1135 | { | ||
1136 | uint32_t abs_bits, prec_bits, num_syms; | ||
1137 | int err; | ||
1138 | |||
1139 |
2/2✓ Branch 0 taken 168 times.
✓ Branch 1 taken 168 times.
|
672 | if (idx < 2) { |
1140 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 168 times.
|
336 | if (type == AV1_WARP_MODEL_TRANSLATION) { |
1141 | ✗ | abs_bits = AV1_GM_ABS_TRANS_ONLY_BITS - !current->allow_high_precision_mv; | |
1142 | ✗ | prec_bits = AV1_GM_TRANS_ONLY_PREC_BITS - !current->allow_high_precision_mv; | |
1143 | } else { | ||
1144 | 336 | abs_bits = AV1_GM_ABS_TRANS_BITS; | |
1145 | 336 | prec_bits = AV1_GM_TRANS_PREC_BITS; | |
1146 | } | ||
1147 | } else { | ||
1148 | 336 | abs_bits = AV1_GM_ABS_ALPHA_BITS; | |
1149 | 336 | prec_bits = AV1_GM_ALPHA_PREC_BITS; | |
1150 | } | ||
1151 | |||
1152 | 672 | num_syms = 2 * (1 << abs_bits) + 1; | |
1153 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 336 times.
|
672 | subexp(gm_params[ref][idx], num_syms, 2, ref, idx); |
1154 | |||
1155 | // Actual gm_params value is not reconstructed here. | ||
1156 | (void)prec_bits; | ||
1157 | |||
1158 | 672 | return 0; | |
1159 | } | ||
1160 | |||
1161 | 3526 | static int FUNC(global_motion_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
1162 | AV1RawFrameHeader *current) | ||
1163 | { | ||
1164 | int ref, type; | ||
1165 | int err; | ||
1166 | |||
1167 |
2/2✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 224 times.
|
3526 | if (current->frame_type == AV1_FRAME_KEY || |
1168 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
|
3078 | current->frame_type == AV1_FRAME_INTRA_ONLY) |
1169 | 448 | return 0; | |
1170 | |||
1171 |
2/2✓ Branch 0 taken 10773 times.
✓ Branch 1 taken 1539 times.
|
24624 | for (ref = AV1_REF_FRAME_LAST; ref <= AV1_REF_FRAME_ALTREF; ref++) { |
1172 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10773 times.
|
21546 | flags(is_global[ref], 1, ref); |
1173 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 10689 times.
|
21546 | if (current->is_global[ref]) { |
1174 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
|
168 | flags(is_rot_zoom[ref], 1, ref); |
1175 |
1/2✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
|
168 | if (current->is_rot_zoom[ref]) { |
1176 | 168 | type = AV1_WARP_MODEL_ROTZOOM; | |
1177 | } else { | ||
1178 | ✗ | flags(is_translation[ref], 1, ref); | |
1179 | ✗ | type = current->is_translation[ref] ? AV1_WARP_MODEL_TRANSLATION | |
1180 | ✗ | : AV1_WARP_MODEL_AFFINE; | |
1181 | } | ||
1182 | } else { | ||
1183 | 21378 | type = AV1_WARP_MODEL_IDENTITY; | |
1184 | } | ||
1185 | |||
1186 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 10689 times.
|
21546 | if (type >= AV1_WARP_MODEL_ROTZOOM) { |
1187 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
|
168 | CHECK(FUNC(global_motion_param)(ctx, rw, current, type, ref, 2)); |
1188 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
|
168 | CHECK(FUNC(global_motion_param)(ctx, rw, current, type, ref, 3)); |
1189 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 84 times.
|
168 | if (type == AV1_WARP_MODEL_AFFINE) { |
1190 | ✗ | CHECK(FUNC(global_motion_param)(ctx, rw, current, type, ref, 4)); | |
1191 | ✗ | CHECK(FUNC(global_motion_param)(ctx, rw, current, type, ref, 5)); | |
1192 | } else { | ||
1193 | // gm_params[ref][4] = -gm_params[ref][3] | ||
1194 | // gm_params[ref][5] = gm_params[ref][2] | ||
1195 | } | ||
1196 | } | ||
1197 |
2/2✓ Branch 0 taken 84 times.
✓ Branch 1 taken 10689 times.
|
21546 | if (type >= AV1_WARP_MODEL_TRANSLATION) { |
1198 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
|
168 | CHECK(FUNC(global_motion_param)(ctx, rw, current, type, ref, 0)); |
1199 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 84 times.
|
168 | CHECK(FUNC(global_motion_param)(ctx, rw, current, type, ref, 1)); |
1200 | } | ||
1201 | } | ||
1202 | |||
1203 | 3078 | return 0; | |
1204 | } | ||
1205 | |||
1206 | 3526 | static int FUNC(film_grain_params)(CodedBitstreamContext *ctx, RWContext *rw, | |
1207 | AV1RawFilmGrainParams *current, | ||
1208 | AV1RawFrameHeader *frame_header) | ||
1209 | { | ||
1210 | 3526 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1211 | 3526 | const AV1RawSequenceHeader *seq = priv->sequence_header; | |
1212 | int num_pos_luma, num_pos_chroma; | ||
1213 | int i, err; | ||
1214 | |||
1215 |
2/2✓ Branch 0 taken 88 times.
✓ Branch 1 taken 1675 times.
|
3526 | if (!seq->film_grain_params_present || |
1216 |
4/4✓ Branch 0 taken 32 times.
✓ Branch 1 taken 56 times.
✓ Branch 2 taken 8 times.
✓ Branch 3 taken 24 times.
|
176 | (!frame_header->show_frame && !frame_header->showable_frame)) |
1217 | 3366 | return 0; | |
1218 | |||
1219 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | flag(apply_grain); |
1220 | |||
1221 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
160 | if (!current->apply_grain) |
1222 | ✗ | return 0; | |
1223 | |||
1224 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(16, grain_seed); |
1225 | |||
1226 |
2/2✓ Branch 0 taken 72 times.
✓ Branch 1 taken 8 times.
|
160 | if (frame_header->frame_type == AV1_FRAME_INTER) |
1227 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 72 times.
|
144 | flag(update_grain); |
1228 | else | ||
1229 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
|
16 | infer(update_grain, 1); |
1230 | |||
1231 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
160 | if (!current->update_grain) { |
1232 | ✗ | fb(3, film_grain_params_ref_idx); | |
1233 | ✗ | return 0; | |
1234 | } | ||
1235 | |||
1236 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fc(4, num_y_points, 0, 14); |
1237 |
2/2✓ Branch 0 taken 552 times.
✓ Branch 1 taken 80 times.
|
1264 | for (i = 0; i < current->num_y_points; i++) { |
1238 |
3/4✓ Branch 0 taken 472 times.
✓ Branch 1 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 552 times.
|
1104 | fcs(8, point_y_value[i], |
1239 | i ? current->point_y_value[i - 1] + 1 : 0, | ||
1240 | MAX_UINT_BITS(8) - (current->num_y_points - i - 1), | ||
1241 | 1, i); | ||
1242 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 552 times.
|
1104 | fbs(8, point_y_scaling[i], 1, i); |
1243 | } | ||
1244 | |||
1245 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
160 | if (seq->color_config.mono_chrome) |
1246 | ✗ | infer(chroma_scaling_from_luma, 0); | |
1247 | else | ||
1248 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | flag(chroma_scaling_from_luma); |
1249 | |||
1250 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | if (seq->color_config.mono_chrome || |
1251 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | current->chroma_scaling_from_luma || |
1252 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | (seq->color_config.subsampling_x == 1 && |
1253 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | seq->color_config.subsampling_y == 1 && |
1254 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 80 times.
|
160 | current->num_y_points == 0)) { |
1255 | ✗ | infer(num_cb_points, 0); | |
1256 | ✗ | infer(num_cr_points, 0); | |
1257 | } else { | ||
1258 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fc(4, num_cb_points, 0, 10); |
1259 |
2/2✓ Branch 0 taken 312 times.
✓ Branch 1 taken 80 times.
|
784 | for (i = 0; i < current->num_cb_points; i++) { |
1260 |
3/4✓ Branch 0 taken 232 times.
✓ Branch 1 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 312 times.
|
624 | fcs(8, point_cb_value[i], |
1261 | i ? current->point_cb_value[i - 1] + 1 : 0, | ||
1262 | MAX_UINT_BITS(8) - (current->num_cb_points - i - 1), | ||
1263 | 1, i); | ||
1264 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 312 times.
|
624 | fbs(8, point_cb_scaling[i], 1, i); |
1265 | } | ||
1266 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fc(4, num_cr_points, 0, 10); |
1267 |
2/2✓ Branch 0 taken 320 times.
✓ Branch 1 taken 80 times.
|
800 | for (i = 0; i < current->num_cr_points; i++) { |
1268 |
3/4✓ Branch 0 taken 240 times.
✓ Branch 1 taken 80 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 320 times.
|
640 | fcs(8, point_cr_value[i], |
1269 | i ? current->point_cr_value[i - 1] + 1 : 0, | ||
1270 | MAX_UINT_BITS(8) - (current->num_cr_points - i - 1), | ||
1271 | 1, i); | ||
1272 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 320 times.
|
640 | fbs(8, point_cr_scaling[i], 1, i); |
1273 | } | ||
1274 | } | ||
1275 | |||
1276 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(2, grain_scaling_minus_8); |
1277 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(2, ar_coeff_lag); |
1278 | 160 | num_pos_luma = 2 * current->ar_coeff_lag * (current->ar_coeff_lag + 1); | |
1279 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | if (current->num_y_points) { |
1280 | 160 | num_pos_chroma = num_pos_luma + 1; | |
1281 |
2/2✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 80 times.
|
4000 | for (i = 0; i < num_pos_luma; i++) |
1282 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1920 times.
|
3840 | fbs(8, ar_coeffs_y_plus_128[i], 1, i); |
1283 | } else { | ||
1284 | ✗ | num_pos_chroma = num_pos_luma; | |
1285 | } | ||
1286 |
2/4✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
|
160 | if (current->chroma_scaling_from_luma || current->num_cb_points) { |
1287 |
2/2✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 80 times.
|
4160 | for (i = 0; i < num_pos_chroma; i++) |
1288 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2000 times.
|
4000 | fbs(8, ar_coeffs_cb_plus_128[i], 1, i); |
1289 | } | ||
1290 |
2/4✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
✗ Branch 3 not taken.
|
160 | if (current->chroma_scaling_from_luma || current->num_cr_points) { |
1291 |
2/2✓ Branch 0 taken 2000 times.
✓ Branch 1 taken 80 times.
|
4160 | for (i = 0; i < num_pos_chroma; i++) |
1292 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2000 times.
|
4000 | fbs(8, ar_coeffs_cr_plus_128[i], 1, i); |
1293 | } | ||
1294 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(2, ar_coeff_shift_minus_6); |
1295 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(2, grain_scale_shift); |
1296 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | if (current->num_cb_points) { |
1297 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(8, cb_mult); |
1298 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(8, cb_luma_mult); |
1299 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(9, cb_offset); |
1300 | } | ||
1301 |
1/2✓ Branch 0 taken 80 times.
✗ Branch 1 not taken.
|
160 | if (current->num_cr_points) { |
1302 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(8, cr_mult); |
1303 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(8, cr_luma_mult); |
1304 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | fb(9, cr_offset); |
1305 | } | ||
1306 | |||
1307 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | flag(overlap_flag); |
1308 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 80 times.
|
160 | flag(clip_to_restricted_range); |
1309 | |||
1310 | 160 | return 0; | |
1311 | } | ||
1312 | |||
1313 | 3942 | static int FUNC(uncompressed_header)(CodedBitstreamContext *ctx, RWContext *rw, | |
1314 | AV1RawFrameHeader *current) | ||
1315 | { | ||
1316 | 3942 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1317 | const AV1RawSequenceHeader *seq; | ||
1318 | int id_len, diff_len, all_frames, frame_is_intra, order_hint_bits; | ||
1319 | int i, err; | ||
1320 | |||
1321 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1971 times.
|
3942 | if (!priv->sequence_header) { |
1322 | ✗ | av_log(ctx->log_ctx, AV_LOG_ERROR, "No sequence header available: " | |
1323 | "unable to decode frame header.\n"); | ||
1324 | ✗ | return AVERROR_INVALIDDATA; | |
1325 | } | ||
1326 | 3942 | seq = priv->sequence_header; | |
1327 | |||
1328 | 3942 | id_len = seq->additional_frame_id_length_minus_1 + | |
1329 | 3942 | seq->delta_frame_id_length_minus_2 + 3; | |
1330 | 3942 | all_frames = (1 << AV1_NUM_REF_FRAMES) - 1; | |
1331 | |||
1332 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1971 times.
|
3942 | if (seq->reduced_still_picture_header) { |
1333 | ✗ | infer(show_existing_frame, 0); | |
1334 | ✗ | infer(frame_type, AV1_FRAME_KEY); | |
1335 | ✗ | infer(show_frame, 1); | |
1336 | ✗ | infer(showable_frame, 0); | |
1337 | ✗ | frame_is_intra = 1; | |
1338 | |||
1339 | } else { | ||
1340 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1971 times.
|
3942 | flag(show_existing_frame); |
1341 | |||
1342 |
2/2✓ Branch 0 taken 208 times.
✓ Branch 1 taken 1763 times.
|
3942 | if (current->show_existing_frame) { |
1343 | AV1ReferenceFrameState *ref; | ||
1344 | |||
1345 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 208 times.
|
416 | fb(3, frame_to_show_map_idx); |
1346 | 416 | ref = &priv->ref[current->frame_to_show_map_idx]; | |
1347 | |||
1348 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
|
416 | if (!ref->valid) { |
1349 | ✗ | av_log(ctx->log_ctx, AV_LOG_ERROR, "Missing reference frame needed for " | |
1350 | "show_existing_frame (frame_to_show_map_idx = %d).\n", | ||
1351 | ✗ | current->frame_to_show_map_idx); | |
1352 | ✗ | return AVERROR_INVALIDDATA; | |
1353 | } | ||
1354 | |||
1355 |
2/2✓ Branch 0 taken 42 times.
✓ Branch 1 taken 166 times.
|
416 | if (seq->decoder_model_info_present_flag && |
1356 |
1/2✓ Branch 0 taken 42 times.
✗ Branch 1 not taken.
|
84 | !seq->timing_info.equal_picture_interval) { |
1357 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 42 times.
|
84 | fb(seq->decoder_model_info.frame_presentation_time_length_minus_1 + 1, |
1358 | frame_presentation_time); | ||
1359 | } | ||
1360 | |||
1361 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
|
416 | if (seq->frame_id_numbers_present_flag) |
1362 | ✗ | fb(id_len, display_frame_id); | |
1363 | |||
1364 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
416 | infer(frame_type, ref->frame_type); |
1365 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 208 times.
|
416 | if (current->frame_type == AV1_FRAME_KEY) { |
1366 | ✗ | infer(refresh_frame_flags, all_frames); | |
1367 | |||
1368 | // Section 7.21 | ||
1369 | ✗ | infer(current_frame_id, ref->frame_id); | |
1370 | ✗ | priv->upscaled_width = ref->upscaled_width; | |
1371 | ✗ | priv->frame_width = ref->frame_width; | |
1372 | ✗ | priv->frame_height = ref->frame_height; | |
1373 | ✗ | priv->render_width = ref->render_width; | |
1374 | ✗ | priv->render_height = ref->render_height; | |
1375 | ✗ | priv->bit_depth = ref->bit_depth; | |
1376 | ✗ | priv->order_hint = ref->order_hint; | |
1377 | } else | ||
1378 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
416 | infer(refresh_frame_flags, 0); |
1379 | |||
1380 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
416 | infer(frame_width_minus_1, ref->upscaled_width - 1); |
1381 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
416 | infer(frame_height_minus_1, ref->frame_height - 1); |
1382 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
416 | infer(render_width_minus_1, ref->render_width - 1); |
1383 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
|
416 | infer(render_height_minus_1, ref->render_height - 1); |
1384 | |||
1385 | // Section 7.20 | ||
1386 | 416 | goto update_refs; | |
1387 | } | ||
1388 | |||
1389 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | fb(2, frame_type); |
1390 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
7052 | frame_is_intra = (current->frame_type == AV1_FRAME_INTRA_ONLY || |
1391 |
2/2✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1539 times.
|
3526 | current->frame_type == AV1_FRAME_KEY); |
1392 | |||
1393 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(show_frame); |
1394 |
2/2✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 317 times.
|
3526 | if (current->show_frame && |
1395 |
2/2✓ Branch 0 taken 550 times.
✓ Branch 1 taken 896 times.
|
2892 | seq->decoder_model_info_present_flag && |
1396 |
1/2✓ Branch 0 taken 550 times.
✗ Branch 1 not taken.
|
1100 | !seq->timing_info.equal_picture_interval) { |
1397 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 550 times.
|
1100 | fb(seq->decoder_model_info.frame_presentation_time_length_minus_1 + 1, |
1398 | frame_presentation_time); | ||
1399 | } | ||
1400 |
2/2✓ Branch 0 taken 1446 times.
✓ Branch 1 taken 317 times.
|
3526 | if (current->show_frame) |
1401 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 306 times.
|
2892 | infer(showable_frame, current->frame_type != AV1_FRAME_KEY); |
1402 | else | ||
1403 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 317 times.
|
634 | flag(showable_frame); |
1404 | |||
1405 |
2/2✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 4 times.
|
3526 | if (current->frame_type == AV1_FRAME_SWITCH || |
1406 |
3/4✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1535 times.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
|
3518 | (current->frame_type == AV1_FRAME_KEY && current->show_frame)) |
1407 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
|
456 | infer(error_resilient_mode, 1); |
1408 | else | ||
1409 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1535 times.
|
3070 | flag(error_resilient_mode); |
1410 | } | ||
1411 | |||
1412 |
3/4✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1539 times.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
|
3526 | if (current->frame_type == AV1_FRAME_KEY && current->show_frame) { |
1413 |
2/2✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 224 times.
|
4032 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
1414 | 3584 | priv->ref[i].valid = 0; | |
1415 | 3584 | priv->ref[i].order_hint = 0; | |
1416 | } | ||
1417 | } | ||
1418 | |||
1419 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(disable_cdf_update); |
1420 | |||
1421 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (seq->seq_force_screen_content_tools == |
1422 | AV1_SELECT_SCREEN_CONTENT_TOOLS) { | ||
1423 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(allow_screen_content_tools); |
1424 | } else { | ||
1425 | ✗ | infer(allow_screen_content_tools, | |
1426 | seq->seq_force_screen_content_tools); | ||
1427 | } | ||
1428 |
2/2✓ Branch 0 taken 44 times.
✓ Branch 1 taken 1719 times.
|
3526 | if (current->allow_screen_content_tools) { |
1429 |
1/2✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
|
88 | if (seq->seq_force_integer_mv == AV1_SELECT_INTEGER_MV) |
1430 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
|
88 | flag(force_integer_mv); |
1431 | else | ||
1432 | ✗ | infer(force_integer_mv, seq->seq_force_integer_mv); | |
1433 | } else { | ||
1434 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 363 times.
|
3438 | infer(force_integer_mv, 0); |
1435 | } | ||
1436 | |||
1437 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | if (seq->frame_id_numbers_present_flag) { |
1438 | ✗ | fb(id_len, current_frame_id); | |
1439 | |||
1440 | ✗ | diff_len = seq->delta_frame_id_length_minus_2 + 2; | |
1441 | ✗ | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { | |
1442 | ✗ | if (current->current_frame_id > (1 << diff_len)) { | |
1443 | ✗ | if (priv->ref[i].frame_id > current->current_frame_id || | |
1444 | ✗ | priv->ref[i].frame_id < (current->current_frame_id - | |
1445 | ✗ | (1 << diff_len))) | |
1446 | ✗ | priv->ref[i].valid = 0; | |
1447 | } else { | ||
1448 | ✗ | if (priv->ref[i].frame_id > current->current_frame_id && | |
1449 | ✗ | priv->ref[i].frame_id < ((1 << id_len) + | |
1450 | ✗ | current->current_frame_id - | |
1451 | ✗ | (1 << diff_len))) | |
1452 | ✗ | priv->ref[i].valid = 0; | |
1453 | } | ||
1454 | } | ||
1455 | } else { | ||
1456 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
3526 | infer(current_frame_id, 0); |
1457 | } | ||
1458 | |||
1459 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1759 times.
|
3526 | if (current->frame_type == AV1_FRAME_SWITCH) |
1460 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
8 | infer(frame_size_override_flag, 1); |
1461 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1759 times.
|
3518 | else if(seq->reduced_still_picture_header) |
1462 | ✗ | infer(frame_size_override_flag, 0); | |
1463 | else | ||
1464 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1759 times.
|
3518 | flag(frame_size_override_flag); |
1465 | |||
1466 | 3526 | order_hint_bits = | |
1467 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | seq->enable_order_hint ? seq->order_hint_bits_minus_1 + 1 : 0; |
1468 |
1/2✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
|
3526 | if (order_hint_bits > 0) |
1469 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | fb(order_hint_bits, order_hint); |
1470 | else | ||
1471 | ✗ | infer(order_hint, 0); | |
1472 | 3526 | priv->order_hint = current->order_hint; | |
1473 | |||
1474 |
4/4✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1535 times.
|
3526 | if (frame_is_intra || current->error_resilient_mode) |
1475 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
|
456 | infer(primary_ref_frame, AV1_PRIMARY_REF_NONE); |
1476 | else | ||
1477 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1535 times.
|
3070 | fb(3, primary_ref_frame); |
1478 | |||
1479 |
2/2✓ Branch 0 taken 653 times.
✓ Branch 1 taken 1110 times.
|
3526 | if (seq->decoder_model_info_present_flag) { |
1480 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 653 times.
|
1306 | flag(buffer_removal_time_present_flag); |
1481 |
1/2✓ Branch 0 taken 653 times.
✗ Branch 1 not taken.
|
1306 | if (current->buffer_removal_time_present_flag) { |
1482 |
2/2✓ Branch 0 taken 653 times.
✓ Branch 1 taken 653 times.
|
2612 | for (i = 0; i <= seq->operating_points_cnt_minus_1; i++) { |
1483 |
1/2✓ Branch 0 taken 653 times.
✗ Branch 1 not taken.
|
1306 | if (seq->decoder_model_present_for_this_op[i]) { |
1484 | 1306 | int op_pt_idc = seq->operating_point_idc[i]; | |
1485 | 1306 | int in_temporal_layer = (op_pt_idc >> priv->temporal_id ) & 1; | |
1486 | 1306 | int in_spatial_layer = (op_pt_idc >> (priv->spatial_id + 8)) & 1; | |
1487 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 653 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
1306 | if (seq->operating_point_idc[i] == 0 || |
1488 | ✗ | (in_temporal_layer && in_spatial_layer)) { | |
1489 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 653 times.
|
1306 | fbs(seq->decoder_model_info.buffer_removal_time_length_minus_1 + 1, |
1490 | buffer_removal_time[i], 1, i); | ||
1491 | } | ||
1492 | } | ||
1493 | } | ||
1494 | } | ||
1495 | } | ||
1496 | |||
1497 |
2/2✓ Branch 0 taken 1759 times.
✓ Branch 1 taken 4 times.
|
3526 | if (current->frame_type == AV1_FRAME_SWITCH || |
1498 |
3/4✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1535 times.
✓ Branch 2 taken 224 times.
✗ Branch 3 not taken.
|
3518 | (current->frame_type == AV1_FRAME_KEY && current->show_frame)) |
1499 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
|
456 | infer(refresh_frame_flags, all_frames); |
1500 | else | ||
1501 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1535 times.
|
3070 | fb(8, refresh_frame_flags); |
1502 | |||
1503 |
3/4✓ Branch 0 taken 224 times.
✓ Branch 1 taken 1539 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 224 times.
|
3526 | if (!frame_is_intra || current->refresh_frame_flags != all_frames) { |
1504 |
1/2✓ Branch 0 taken 1539 times.
✗ Branch 1 not taken.
|
3078 | if (seq->enable_order_hint) { |
1505 |
2/2✓ Branch 0 taken 12312 times.
✓ Branch 1 taken 1539 times.
|
27702 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
1506 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 12280 times.
|
24624 | if (current->error_resilient_mode) |
1507 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
|
64 | fbs(order_hint_bits, ref_order_hint[i], 1, i); |
1508 | else | ||
1509 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 2520 times.
|
24560 | infer(ref_order_hint[i], priv->ref[i].order_hint); |
1510 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 12312 times.
|
24624 | if (current->ref_order_hint[i] != priv->ref[i].order_hint) |
1511 | ✗ | priv->ref[i].valid = 0; | |
1512 | } | ||
1513 | } | ||
1514 | } | ||
1515 | |||
1516 |
2/2✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 224 times.
|
3526 | if (current->frame_type == AV1_FRAME_KEY || |
1517 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
|
3078 | current->frame_type == AV1_FRAME_INTRA_ONLY) { |
1518 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
|
448 | CHECK(FUNC(frame_size)(ctx, rw, current)); |
1519 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 224 times.
|
448 | CHECK(FUNC(render_size)(ctx, rw, current)); |
1520 | |||
1521 |
2/2✓ Branch 0 taken 4 times.
✓ Branch 1 taken 220 times.
|
448 | if (current->allow_screen_content_tools && |
1522 |
1/2✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
|
8 | priv->upscaled_width == priv->frame_width) |
1523 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
|
8 | flag(allow_intrabc); |
1524 | else | ||
1525 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 57 times.
|
440 | infer(allow_intrabc, 0); |
1526 | |||
1527 | } else { | ||
1528 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
|
3078 | if (!seq->enable_order_hint) { |
1529 | ✗ | infer(frame_refs_short_signaling, 0); | |
1530 | } else { | ||
1531 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1539 times.
|
3078 | flag(frame_refs_short_signaling); |
1532 |
2/2✓ Branch 0 taken 56 times.
✓ Branch 1 taken 1483 times.
|
3078 | if (current->frame_refs_short_signaling) { |
1533 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
|
112 | fb(3, last_frame_idx); |
1534 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
|
112 | fb(3, golden_frame_idx); |
1535 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 56 times.
|
112 | CHECK(FUNC(set_frame_refs)(ctx, rw, current)); |
1536 | } | ||
1537 | } | ||
1538 | |||
1539 |
2/2✓ Branch 0 taken 10773 times.
✓ Branch 1 taken 1539 times.
|
24624 | for (i = 0; i < AV1_REFS_PER_FRAME; i++) { |
1540 |
2/2✓ Branch 0 taken 10381 times.
✓ Branch 1 taken 392 times.
|
21546 | if (!current->frame_refs_short_signaling) |
1541 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 10381 times.
|
20762 | fbs(3, ref_frame_idx[i], 1, i); |
1542 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 10773 times.
|
21546 | if (seq->frame_id_numbers_present_flag) { |
1543 | ✗ | fbs(seq->delta_frame_id_length_minus_2 + 2, | |
1544 | delta_frame_id_minus1[i], 1, i); | ||
1545 | } | ||
1546 | } | ||
1547 | |||
1548 |
2/2✓ Branch 0 taken 64 times.
✓ Branch 1 taken 1475 times.
|
3078 | if (current->frame_size_override_flag && |
1549 |
2/2✓ Branch 0 taken 60 times.
✓ Branch 1 taken 4 times.
|
128 | !current->error_resilient_mode) { |
1550 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 60 times.
|
120 | CHECK(FUNC(frame_size_with_refs)(ctx, rw, current)); |
1551 | } else { | ||
1552 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1479 times.
|
2958 | CHECK(FUNC(frame_size)(ctx, rw, current)); |
1553 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1479 times.
|
2958 | CHECK(FUNC(render_size)(ctx, rw, current)); |
1554 | } | ||
1555 | |||
1556 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1539 times.
|
3078 | if (current->force_integer_mv) |
1557 | ✗ | infer(allow_high_precision_mv, 0); | |
1558 | else | ||
1559 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1539 times.
|
3078 | flag(allow_high_precision_mv); |
1560 | |||
1561 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1539 times.
|
3078 | CHECK(FUNC(interpolation_filter)(ctx, rw, current)); |
1562 | |||
1563 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1539 times.
|
3078 | flag(is_motion_mode_switchable); |
1564 | |||
1565 |
2/2✓ Branch 0 taken 1535 times.
✓ Branch 1 taken 4 times.
|
3078 | if (current->error_resilient_mode || |
1566 |
2/2✓ Branch 0 taken 120 times.
✓ Branch 1 taken 1415 times.
|
3070 | !seq->enable_ref_frame_mvs) |
1567 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
|
248 | infer(use_ref_frame_mvs, 0); |
1568 | else | ||
1569 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1415 times.
|
2830 | flag(use_ref_frame_mvs); |
1570 | |||
1571 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 316 times.
|
3078 | infer(allow_intrabc, 0); |
1572 | } | ||
1573 | |||
1574 | if (!frame_is_intra) { | ||
1575 | // Derive reference frame sign biases. | ||
1576 | } | ||
1577 | |||
1578 |
2/4✓ Branch 0 taken 1763 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1763 times.
|
3526 | if (seq->reduced_still_picture_header || current->disable_cdf_update) |
1579 | ✗ | infer(disable_frame_end_update_cdf, 1); | |
1580 | else | ||
1581 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(disable_frame_end_update_cdf); |
1582 | |||
1583 | 3526 | if (current->primary_ref_frame == AV1_PRIMARY_REF_NONE) { | |
1584 | // Init non-coeff CDFs. | ||
1585 | // Setup past independence. | ||
1586 | } else { | ||
1587 | // Load CDF tables from previous frame. | ||
1588 | // Load params from previous frame. | ||
1589 | } | ||
1590 | |||
1591 | 3526 | if (current->use_ref_frame_mvs) { | |
1592 | // Perform motion field estimation process. | ||
1593 | } | ||
1594 | |||
1595 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(tile_info)(ctx, rw, current)); |
1596 | |||
1597 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(quantization_params)(ctx, rw, current)); |
1598 | |||
1599 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(segmentation_params)(ctx, rw, current)); |
1600 | |||
1601 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(delta_q_params)(ctx, rw, current)); |
1602 | |||
1603 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(delta_lf_params)(ctx, rw, current)); |
1604 | |||
1605 | // Init coeff CDFs / load previous segments. | ||
1606 | |||
1607 | 3526 | priv->coded_lossless = 1; | |
1608 |
2/2✓ Branch 0 taken 14104 times.
✓ Branch 1 taken 1763 times.
|
31734 | for (i = 0; i < AV1_MAX_SEGMENTS; i++) { |
1609 | int qindex; | ||
1610 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 14104 times.
|
28208 | if (current->feature_enabled[i][AV1_SEG_LVL_ALT_Q]) { |
1611 | ✗ | qindex = (current->base_q_idx + | |
1612 | ✗ | current->feature_value[i][AV1_SEG_LVL_ALT_Q]); | |
1613 | } else { | ||
1614 | 28208 | qindex = current->base_q_idx; | |
1615 | } | ||
1616 | 28208 | qindex = av_clip_uintp2(qindex, 8); | |
1617 | |||
1618 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 14104 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
|
28208 | if (qindex || current->delta_q_y_dc || |
1619 | ✗ | current->delta_q_u_ac || current->delta_q_u_dc || | |
1620 | ✗ | current->delta_q_v_ac || current->delta_q_v_dc) { | |
1621 | 28208 | priv->coded_lossless = 0; | |
1622 | } | ||
1623 | } | ||
1624 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1763 times.
|
3526 | priv->all_lossless = priv->coded_lossless && |
1625 | ✗ | priv->frame_width == priv->upscaled_width; | |
1626 | |||
1627 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(loop_filter_params)(ctx, rw, current)); |
1628 | |||
1629 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(cdef_params)(ctx, rw, current)); |
1630 | |||
1631 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(lr_params)(ctx, rw, current)); |
1632 | |||
1633 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(read_tx_mode)(ctx, rw, current)); |
1634 | |||
1635 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(frame_reference_mode)(ctx, rw, current)); |
1636 | |||
1637 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(skip_mode_params)(ctx, rw, current)); |
1638 | |||
1639 |
4/4✓ Branch 0 taken 1539 times.
✓ Branch 1 taken 224 times.
✓ Branch 2 taken 1535 times.
✓ Branch 3 taken 4 times.
|
3526 | if (frame_is_intra || current->error_resilient_mode || |
1640 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1535 times.
|
3070 | !seq->enable_warped_motion) |
1641 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 59 times.
|
456 | infer(allow_warped_motion, 0); |
1642 | else | ||
1643 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1535 times.
|
3070 | flag(allow_warped_motion); |
1644 | |||
1645 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | flag(reduced_tx_set); |
1646 | |||
1647 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(global_motion_params)(ctx, rw, current)); |
1648 | |||
1649 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1763 times.
|
3526 | CHECK(FUNC(film_grain_params)(ctx, rw, ¤t->film_grain, current)); |
1650 | |||
1651 | 3526 | av_log(ctx->log_ctx, AV_LOG_DEBUG, "Frame %d: size %dx%d " | |
1652 | "upscaled %d render %dx%d subsample %dx%d " | ||
1653 | "bitdepth %d tiles %dx%d.\n", priv->order_hint, | ||
1654 | priv->frame_width, priv->frame_height, priv->upscaled_width, | ||
1655 | priv->render_width, priv->render_height, | ||
1656 | 3526 | seq->color_config.subsampling_x + 1, | |
1657 | 3526 | seq->color_config.subsampling_y + 1, priv->bit_depth, | |
1658 | priv->tile_rows, priv->tile_cols); | ||
1659 | |||
1660 | 3942 | update_refs: | |
1661 |
2/2✓ Branch 0 taken 15768 times.
✓ Branch 1 taken 1971 times.
|
35478 | for (i = 0; i < AV1_NUM_REF_FRAMES; i++) { |
1662 |
2/2✓ Branch 0 taken 3305 times.
✓ Branch 1 taken 12463 times.
|
31536 | if (current->refresh_frame_flags & (1 << i)) { |
1663 | 6610 | priv->ref[i] = (AV1ReferenceFrameState) { | |
1664 | .valid = 1, | ||
1665 | 6610 | .frame_id = current->current_frame_id, | |
1666 | 6610 | .upscaled_width = priv->upscaled_width, | |
1667 | 6610 | .frame_width = priv->frame_width, | |
1668 | 6610 | .frame_height = priv->frame_height, | |
1669 | 6610 | .render_width = priv->render_width, | |
1670 | 6610 | .render_height = priv->render_height, | |
1671 | 6610 | .frame_type = current->frame_type, | |
1672 | 6610 | .subsampling_x = seq->color_config.subsampling_x, | |
1673 | 6610 | .subsampling_y = seq->color_config.subsampling_y, | |
1674 | 6610 | .bit_depth = priv->bit_depth, | |
1675 | 6610 | .order_hint = priv->order_hint, | |
1676 | }; | ||
1677 | 6610 | memcpy(priv->ref[i].loop_filter_ref_deltas, current->loop_filter_ref_deltas, | |
1678 | sizeof(current->loop_filter_ref_deltas)); | ||
1679 | 6610 | memcpy(priv->ref[i].loop_filter_mode_deltas, current->loop_filter_mode_deltas, | |
1680 | sizeof(current->loop_filter_mode_deltas)); | ||
1681 | 6610 | memcpy(priv->ref[i].feature_enabled, current->feature_enabled, | |
1682 | sizeof(current->feature_enabled)); | ||
1683 | 6610 | memcpy(priv->ref[i].feature_value, current->feature_value, | |
1684 | sizeof(current->feature_value)); | ||
1685 | } | ||
1686 | } | ||
1687 | |||
1688 | 3942 | return 0; | |
1689 | } | ||
1690 | |||
1691 | 3942 | static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw, | |
1692 | AV1RawFrameHeader *current, int redundant, | ||
1693 | AVBufferRef *rw_buffer_ref) | ||
1694 | { | ||
1695 | 3942 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1696 | int start_pos, fh_bits, fh_bytes, err; | ||
1697 | uint8_t *fh_start; | ||
1698 | |||
1699 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1971 times.
|
3942 | if (priv->seen_frame_header) { |
1700 | ✗ | if (!redundant) { | |
1701 | ✗ | av_log(ctx->log_ctx, AV_LOG_ERROR, "Invalid repeated " | |
1702 | "frame header OBU.\n"); | ||
1703 | ✗ | return AVERROR_INVALIDDATA; | |
1704 | } else { | ||
1705 | GetBitContext fh; | ||
1706 | size_t i, b; | ||
1707 | uint32_t val; | ||
1708 | |||
1709 | ✗ | HEADER("Redundant Frame Header"); | |
1710 | |||
1711 | ✗ | av_assert0(priv->frame_header_ref && priv->frame_header); | |
1712 | |||
1713 | ✗ | init_get_bits(&fh, priv->frame_header, | |
1714 | ✗ | priv->frame_header_size); | |
1715 | ✗ | for (i = 0; i < priv->frame_header_size; i += 8) { | |
1716 | ✗ | b = FFMIN(priv->frame_header_size - i, 8); | |
1717 | ✗ | val = get_bits(&fh, b); | |
1718 | ✗ | xf(b, frame_header_copy[i], | |
1719 | val, val, val, 1, i / 8); | ||
1720 | } | ||
1721 | } | ||
1722 | } else { | ||
1723 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1971 times.
|
3942 | if (redundant) |
1724 | ✗ | HEADER("Redundant Frame Header (used as Frame Header)"); | |
1725 | else | ||
1726 | 3942 | HEADER("Frame Header"); | |
1727 | |||
1728 | #ifdef READ | ||
1729 | 3100 | start_pos = get_bits_count(rw); | |
1730 | #else | ||
1731 | 842 | start_pos = put_bits_count(rw); | |
1732 | #endif | ||
1733 | |||
1734 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1971 times.
|
3942 | CHECK(FUNC(uncompressed_header)(ctx, rw, current)); |
1735 | |||
1736 | 3942 | priv->tile_num = 0; | |
1737 | |||
1738 |
2/2✓ Branch 0 taken 208 times.
✓ Branch 1 taken 1763 times.
|
3942 | if (current->show_existing_frame) { |
1739 | 416 | priv->seen_frame_header = 0; | |
1740 | } else { | ||
1741 | 3526 | priv->seen_frame_header = 1; | |
1742 | |||
1743 | 3526 | av_buffer_unref(&priv->frame_header_ref); | |
1744 | |||
1745 | #ifdef READ | ||
1746 | 2778 | fh_bits = get_bits_count(rw) - start_pos; | |
1747 | 2778 | fh_start = (uint8_t*)rw->buffer + start_pos / 8; | |
1748 | #else | ||
1749 | // Need to flush the bitwriter so that we can copy its output, | ||
1750 | // but use a copy so we don't affect the caller's structure. | ||
1751 | { | ||
1752 | 748 | PutBitContext tmp = *rw; | |
1753 | 748 | flush_put_bits(&tmp); | |
1754 | } | ||
1755 | |||
1756 | 748 | fh_bits = put_bits_count(rw) - start_pos; | |
1757 | 748 | fh_start = rw->buf + start_pos / 8; | |
1758 | #endif | ||
1759 | 3526 | fh_bytes = (fh_bits + 7) / 8; | |
1760 | |||
1761 | 3526 | priv->frame_header_size = fh_bits; | |
1762 | |||
1763 |
2/2✓ Branch 0 taken 1389 times.
✓ Branch 1 taken 374 times.
|
3526 | if (rw_buffer_ref) { |
1764 | 2778 | priv->frame_header_ref = av_buffer_ref(rw_buffer_ref); | |
1765 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1389 times.
|
2778 | if (!priv->frame_header_ref) |
1766 | ✗ | return AVERROR(ENOMEM); | |
1767 | 2778 | priv->frame_header = fh_start; | |
1768 | } else { | ||
1769 | 748 | priv->frame_header_ref = | |
1770 | 748 | av_buffer_alloc(fh_bytes + AV_INPUT_BUFFER_PADDING_SIZE); | |
1771 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 374 times.
|
748 | if (!priv->frame_header_ref) |
1772 | ✗ | return AVERROR(ENOMEM); | |
1773 | 748 | priv->frame_header = priv->frame_header_ref->data; | |
1774 | 748 | memcpy(priv->frame_header, fh_start, fh_bytes); | |
1775 | } | ||
1776 | } | ||
1777 | } | ||
1778 | |||
1779 | 3942 | return 0; | |
1780 | } | ||
1781 | |||
1782 | 4038 | static int FUNC(tile_group_obu)(CodedBitstreamContext *ctx, RWContext *rw, | |
1783 | AV1RawTileGroup *current) | ||
1784 | { | ||
1785 | 4038 | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1786 | int num_tiles, tile_bits; | ||
1787 | int err; | ||
1788 | |||
1789 | 4038 | HEADER("Tile Group"); | |
1790 | |||
1791 | 4038 | num_tiles = priv->tile_cols * priv->tile_rows; | |
1792 |
2/2✓ Branch 0 taken 564 times.
✓ Branch 1 taken 1455 times.
|
4038 | if (num_tiles > 1) |
1793 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 564 times.
|
1128 | flag(tile_start_and_end_present_flag); |
1794 | else | ||
1795 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 297 times.
|
2910 | infer(tile_start_and_end_present_flag, 0); |
1796 | |||
1797 |
4/4✓ Branch 0 taken 564 times.
✓ Branch 1 taken 1455 times.
✓ Branch 2 taken 148 times.
✓ Branch 3 taken 416 times.
|
4038 | if (num_tiles == 1 || !current->tile_start_and_end_present_flag) { |
1798 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
|
3206 | infer(tg_start, 0); |
1799 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 334 times.
|
3206 | infer(tg_end, num_tiles - 1); |
1800 | } else { | ||
1801 | 832 | tile_bits = cbs_av1_tile_log2(1, priv->tile_cols) + | |
1802 | 832 | cbs_av1_tile_log2(1, priv->tile_rows); | |
1803 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
|
832 | fc(tile_bits, tg_start, priv->tile_num, num_tiles - 1); |
1804 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 416 times.
|
832 | fc(tile_bits, tg_end, current->tg_start, num_tiles - 1); |
1805 | } | ||
1806 | |||
1807 | 4038 | priv->tile_num = current->tg_end + 1; | |
1808 | |||
1809 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 2019 times.
|
4038 | CHECK(FUNC(byte_alignment)(ctx, rw)); |
1810 | |||
1811 | // Reset header for next frame. | ||
1812 |
2/2✓ Branch 0 taken 1763 times.
✓ Branch 1 taken 256 times.
|
4038 | if (current->tg_end == num_tiles - 1) |
1813 | 3526 | priv->seen_frame_header = 0; | |
1814 | |||
1815 | // Tile data follows. | ||
1816 | |||
1817 | 4038 | return 0; | |
1818 | } | ||
1819 | |||
1820 | 3206 | static int FUNC(frame_obu)(CodedBitstreamContext *ctx, RWContext *rw, | |
1821 | AV1RawFrame *current, | ||
1822 | AVBufferRef *rw_buffer_ref) | ||
1823 | { | ||
1824 | int err; | ||
1825 | |||
1826 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1603 times.
|
3206 | CHECK(FUNC(frame_header_obu)(ctx, rw, ¤t->header, |
1827 | 0, rw_buffer_ref)); | ||
1828 | |||
1829 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1603 times.
|
3206 | CHECK(FUNC(byte_alignment)(ctx, rw)); |
1830 | |||
1831 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 1603 times.
|
3206 | CHECK(FUNC(tile_group_obu)(ctx, rw, ¤t->tile_group)); |
1832 | |||
1833 | 3206 | return 0; | |
1834 | } | ||
1835 | |||
1836 | ✗ | static int FUNC(tile_list_obu)(CodedBitstreamContext *ctx, RWContext *rw, | |
1837 | AV1RawTileList *current) | ||
1838 | { | ||
1839 | int err; | ||
1840 | |||
1841 | ✗ | fb(8, output_frame_width_in_tiles_minus_1); | |
1842 | ✗ | fb(8, output_frame_height_in_tiles_minus_1); | |
1843 | |||
1844 | ✗ | fb(16, tile_count_minus_1); | |
1845 | |||
1846 | // Tile data follows. | ||
1847 | |||
1848 | ✗ | return 0; | |
1849 | } | ||
1850 | |||
1851 | 32 | static int FUNC(metadata_hdr_cll)(CodedBitstreamContext *ctx, RWContext *rw, | |
1852 | AV1RawMetadataHDRCLL *current) | ||
1853 | { | ||
1854 | int err; | ||
1855 | |||
1856 | 32 | HEADER("HDR CLL Metadata"); | |
1857 | |||
1858 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(16, max_cll); |
1859 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(16, max_fall); |
1860 | |||
1861 | 32 | return 0; | |
1862 | } | ||
1863 | |||
1864 | 32 | static int FUNC(metadata_hdr_mdcv)(CodedBitstreamContext *ctx, RWContext *rw, | |
1865 | AV1RawMetadataHDRMDCV *current) | ||
1866 | { | ||
1867 | int err, i; | ||
1868 | |||
1869 | 32 | HEADER("HDR MDCV Metadata"); | |
1870 | |||
1871 |
2/2✓ Branch 0 taken 48 times.
✓ Branch 1 taken 16 times.
|
128 | for (i = 0; i < 3; i++) { |
1872 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
|
96 | fbs(16, primary_chromaticity_x[i], 1, i); |
1873 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
|
96 | fbs(16, primary_chromaticity_y[i], 1, i); |
1874 | } | ||
1875 | |||
1876 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(16, white_point_chromaticity_x); |
1877 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(16, white_point_chromaticity_y); |
1878 | |||
1879 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(32, luminance_max); |
1880 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 16 times.
|
32 | fb(32, luminance_min); |
1881 | |||
1882 | 32 | return 0; | |
1883 | } | ||
1884 | |||
1885 | ✗ | static int FUNC(scalability_structure)(CodedBitstreamContext *ctx, RWContext *rw, | |
1886 | AV1RawMetadataScalability *current) | ||
1887 | { | ||
1888 | ✗ | CodedBitstreamAV1Context *priv = ctx->priv_data; | |
1889 | const AV1RawSequenceHeader *seq; | ||
1890 | int err, i, j; | ||
1891 | |||
1892 | ✗ | if (!priv->sequence_header) { | |
1893 | ✗ | av_log(ctx->log_ctx, AV_LOG_ERROR, "No sequence header available: " | |
1894 | "unable to parse scalability metadata.\n"); | ||
1895 | ✗ | return AVERROR_INVALIDDATA; | |
1896 | } | ||
1897 | ✗ | seq = priv->sequence_header; | |
1898 | |||
1899 | ✗ | fb(2, spatial_layers_cnt_minus_1); | |
1900 | ✗ | flag(spatial_layer_dimensions_present_flag); | |
1901 | ✗ | flag(spatial_layer_description_present_flag); | |
1902 | ✗ | flag(temporal_group_description_present_flag); | |
1903 | ✗ | fc(3, scalability_structure_reserved_3bits, 0, 0); | |
1904 | ✗ | if (current->spatial_layer_dimensions_present_flag) { | |
1905 | ✗ | for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++) { | |
1906 | ✗ | fcs(16, spatial_layer_max_width[i], | |
1907 | 0, seq->max_frame_width_minus_1 + 1, 1, i); | ||
1908 | ✗ | fcs(16, spatial_layer_max_height[i], | |
1909 | 0, seq->max_frame_height_minus_1 + 1, 1, i); | ||
1910 | } | ||
1911 | } | ||
1912 | ✗ | if (current->spatial_layer_description_present_flag) { | |
1913 | ✗ | for (i = 0; i <= current->spatial_layers_cnt_minus_1; i++) | |
1914 | ✗ | fbs(8, spatial_layer_ref_id[i], 1, i); | |
1915 | } | ||
1916 | ✗ | if (current->temporal_group_description_present_flag) { | |
1917 | ✗ | fb(8, temporal_group_size); | |
1918 | ✗ | for (i = 0; i < current->temporal_group_size; i++) { | |
1919 | ✗ | fbs(3, temporal_group_temporal_id[i], 1, i); | |
1920 | ✗ | flags(temporal_group_temporal_switching_up_point_flag[i], 1, i); | |
1921 | ✗ | flags(temporal_group_spatial_switching_up_point_flag[i], 1, i); | |
1922 | ✗ | fbs(3, temporal_group_ref_cnt[i], 1, i); | |
1923 | ✗ | for (j = 0; j < current->temporal_group_ref_cnt[i]; j++) { | |
1924 | ✗ | fbs(8, temporal_group_ref_pic_diff[i][j], 2, i, j); | |
1925 | } | ||
1926 | } | ||
1927 | } | ||
1928 | |||
1929 | ✗ | return 0; | |
1930 | } | ||
1931 | |||
1932 | ✗ | static int FUNC(metadata_scalability)(CodedBitstreamContext *ctx, RWContext *rw, | |
1933 | AV1RawMetadataScalability *current) | ||
1934 | { | ||
1935 | int err; | ||
1936 | |||
1937 | ✗ | HEADER("Scalability Metadata"); | |
1938 | |||
1939 | ✗ | fb(8, scalability_mode_idc); | |
1940 | |||
1941 | ✗ | if (current->scalability_mode_idc == AV1_SCALABILITY_SS) | |
1942 | ✗ | CHECK(FUNC(scalability_structure)(ctx, rw, current)); | |
1943 | |||
1944 | ✗ | return 0; | |
1945 | } | ||
1946 | |||
1947 | ✗ | static int FUNC(metadata_itut_t35)(CodedBitstreamContext *ctx, RWContext *rw, | |
1948 | AV1RawMetadataITUTT35 *current) | ||
1949 | { | ||
1950 | int err; | ||
1951 | size_t i; | ||
1952 | |||
1953 | ✗ | HEADER("ITU-T T.35 Metadata"); | |
1954 | |||
1955 | ✗ | fb(8, itu_t_t35_country_code); | |
1956 | ✗ | if (current->itu_t_t35_country_code == 0xff) | |
1957 | ✗ | fb(8, itu_t_t35_country_code_extension_byte); | |
1958 | |||
1959 | #ifdef READ | ||
1960 | // The payload runs up to the start of the trailing bits, but there might | ||
1961 | // be arbitrarily many trailing zeroes so we need to read through twice. | ||
1962 | ✗ | current->payload_size = cbs_av1_get_payload_bytes_left(rw); | |
1963 | |||
1964 | ✗ | current->payload_ref = av_buffer_alloc(current->payload_size); | |
1965 | ✗ | if (!current->payload_ref) | |
1966 | ✗ | return AVERROR(ENOMEM); | |
1967 | ✗ | current->payload = current->payload_ref->data; | |
1968 | #endif | ||
1969 | |||
1970 | ✗ | for (i = 0; i < current->payload_size; i++) | |
1971 | ✗ | xf(8, < |