FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vc1_block.c
Date: 2026-01-16 07:34:38
Exec Total Coverage
Lines: 1795 1905 94.2%
Functions: 25 25 100.0%
Branches: 1581 2160 73.2%

Line Branch Exec Source
1 /*
2 * VC-1 and WMV3 decoder
3 * Copyright (c) 2011 Mashiat Sarker Shakkhar
4 * Copyright (c) 2006-2007 Konstantin Shishkov
5 * Partly based on vc9.c (c) 2005 Anonymous, Alex Beregszaszi, Michael Niedermayer
6 *
7 * This file is part of FFmpeg.
8 *
9 * FFmpeg is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13 *
14 * FFmpeg is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with FFmpeg; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
24 /**
25 * @file
26 * VC-1 and WMV3 block decoding routines
27 */
28
29 #include "avcodec.h"
30 #include "mpegutils.h"
31 #include "mpegvideo.h"
32 #include "mpegvideodec.h"
33 #include "msmpeg4_vc1_data.h"
34 #include "unary.h"
35 #include "vc1.h"
36 #include "vc1_pred.h"
37 #include "vc1acdata.h"
38 #include "vc1data.h"
39
40 // offset tables for interlaced picture MVDATA decoding
41 static const uint8_t offset_table[2][9] = {
42 { 0, 1, 2, 4, 8, 16, 32, 64, 128 },
43 { 0, 1, 3, 7, 15, 31, 63, 127, 255 },
44 };
45
46 // mapping table for internal block representation
47 static const int block_map[6] = {0, 2, 1, 3, 4, 5};
48
49 /***********************************************************************/
50 /**
51 * @name VC-1 Bitplane decoding
52 * @see 8.7, p56
53 * @{
54 */
55
56
57 10080 static inline void init_block_index(VC1Context *v)
58 {
59 10080 MpegEncContext *s = &v->s;
60 10080 ff_init_block_index(s);
61
4/4
✓ Branch 0 taken 1338 times.
✓ Branch 1 taken 8742 times.
✓ Branch 2 taken 669 times.
✓ Branch 3 taken 669 times.
10080 if (v->field_mode && !(v->second_field ^ v->tff)) {
62 669 s->dest[0] += s->cur_pic.ptr->f->linesize[0];
63 669 s->dest[1] += s->cur_pic.ptr->f->linesize[1];
64 669 s->dest[2] += s->cur_pic.ptr->f->linesize[2];
65 }
66 10080 }
67
68 356993 static inline void update_block_index(MpegEncContext *s)
69 {
70 /* VC1 is always 420 except when using AV_CODEC_FLAG_GRAY
71 * (or a HWAccel). Shall we inline this value? */
72 356993 ff_update_block_index(s, 8, 0, s->chroma_x_shift);
73 356993 }
74
75 /** @} */ //Bitplane group
76
77 250256 static void vc1_put_blocks_clamped(VC1Context *v, int put_signed)
78 {
79 250256 MpegEncContext *s = &v->s;
80 uint8_t *dest;
81 250256 int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
82 250256 int fieldtx = 0;
83 int i;
84
85 /* The put pixels loop is one MB row and one MB column behind the decoding
86 * loop because we can only put pixels when overlap filtering is done. For
87 * interlaced frame pictures, however, the put pixels loop is only one
88 * column behind the decoding loop as interlaced frame pictures only need
89 * horizontal overlap filtering. */
90
4/4
✓ Branch 0 taken 212046 times.
✓ Branch 1 taken 38210 times.
✓ Branch 2 taken 179886 times.
✓ Branch 3 taken 32160 times.
250256 if (!s->first_slice_line && v->fcm != ILACE_FRAME) {
91
2/2
✓ Branch 0 taken 174427 times.
✓ Branch 1 taken 5459 times.
179886 if (s->mb_x) {
92
2/2
✓ Branch 0 taken 1046562 times.
✓ Branch 1 taken 174427 times.
1220989 for (i = 0; i < block_count; i++) {
93
4/4
✓ Branch 0 taken 348854 times.
✓ Branch 1 taken 697708 times.
✓ Branch 2 taken 294391 times.
✓ Branch 3 taken 752171 times.
1744270 if (i > 3 ? v->mb_type[s->block_index[i] - s->block_wrap[i] - 1] :
94 697708 v->mb_type[s->block_index[i] - 2 * s->block_wrap[i] - 2]) {
95 294391 dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + ((i & 1) - 2) * 8;
96
2/2
✓ Branch 0 taken 192997 times.
✓ Branch 1 taken 101394 times.
294391 if (put_signed)
97
4/4
✓ Branch 0 taken 63146 times.
✓ Branch 1 taken 129851 times.
✓ Branch 2 taken 63146 times.
✓ Branch 3 taken 129851 times.
256143 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]],
98 63146 i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
99 i > 3 ? s->uvlinesize : s->linesize);
100 else
101
4/4
✓ Branch 0 taken 33798 times.
✓ Branch 1 taken 67596 times.
✓ Branch 2 taken 33798 times.
✓ Branch 3 taken 67596 times.
135192 s->idsp.put_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]],
102 33798 i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize - 8 : dest,
103 i > 3 ? s->uvlinesize : s->linesize);
104 }
105 }
106 }
107
2/2
✓ Branch 0 taken 5458 times.
✓ Branch 1 taken 174428 times.
179886 if (s->mb_x == v->end_mb_x - 1) {
108
2/2
✓ Branch 0 taken 32748 times.
✓ Branch 1 taken 5458 times.
38206 for (i = 0; i < block_count; i++) {
109
4/4
✓ Branch 0 taken 10916 times.
✓ Branch 1 taken 21832 times.
✓ Branch 2 taken 11235 times.
✓ Branch 3 taken 21513 times.
54580 if (i > 3 ? v->mb_type[s->block_index[i] - s->block_wrap[i]] :
110 21832 v->mb_type[s->block_index[i] - 2 * s->block_wrap[i]]) {
111 11235 dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + (i & 1) * 8;
112
2/2
✓ Branch 0 taken 5649 times.
✓ Branch 1 taken 5586 times.
11235 if (put_signed)
113
4/4
✓ Branch 0 taken 1826 times.
✓ Branch 1 taken 3823 times.
✓ Branch 2 taken 1826 times.
✓ Branch 3 taken 3823 times.
7475 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][block_map[i]],
114 1826 i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
115 i > 3 ? s->uvlinesize : s->linesize);
116 else
117
4/4
✓ Branch 0 taken 1862 times.
✓ Branch 1 taken 3724 times.
✓ Branch 2 taken 1862 times.
✓ Branch 3 taken 3724 times.
7448 s->idsp.put_pixels_clamped(v->block[v->top_blk_idx][block_map[i]],
118 1862 i > 3 ? s->dest[i - 3] - 8 * s->uvlinesize : dest,
119 i > 3 ? s->uvlinesize : s->linesize);
120 }
121 }
122 }
123 }
124
4/4
✓ Branch 0 taken 212066 times.
✓ Branch 1 taken 38190 times.
✓ Branch 2 taken 32160 times.
✓ Branch 3 taken 179906 times.
250256 if (s->mb_y == s->end_mb_y - 1 || v->fcm == ILACE_FRAME) {
125
2/2
✓ Branch 0 taken 69047 times.
✓ Branch 1 taken 1303 times.
70350 if (s->mb_x) {
126
2/2
✓ Branch 0 taken 32368 times.
✓ Branch 1 taken 36679 times.
69047 if (v->fcm == ILACE_FRAME)
127 32368 fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x - 1];
128
2/2
✓ Branch 0 taken 414282 times.
✓ Branch 1 taken 69047 times.
483329 for (i = 0; i < block_count; i++) {
129
4/4
✓ Branch 0 taken 138094 times.
✓ Branch 1 taken 276188 times.
✓ Branch 2 taken 185773 times.
✓ Branch 3 taken 228509 times.
690470 if (i > 3 ? v->mb_type[s->block_index[i] - 1] :
130 276188 v->mb_type[s->block_index[i] - 2]) {
131
2/2
✓ Branch 0 taken 34086 times.
✓ Branch 1 taken 151687 times.
185773 if (fieldtx)
132 34086 dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + ((i & 1) - 2) * 8;
133 else
134 151687 dest = s->dest[0] + (i & 2) * 4 * s->linesize + ((i & 1) - 2) * 8;
135
2/2
✓ Branch 0 taken 178219 times.
✓ Branch 1 taken 7554 times.
185773 if (put_signed)
136
4/4
✓ Branch 0 taken 58766 times.
✓ Branch 1 taken 119453 times.
✓ Branch 2 taken 58766 times.
✓ Branch 3 taken 119453 times.
356438 s->idsp.put_signed_pixels_clamped(v->block[v->left_blk_idx][block_map[i]],
137 58766 i > 3 ? s->dest[i - 3] - 8 : dest,
138 119453 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
139 else
140
4/4
✓ Branch 0 taken 2518 times.
✓ Branch 1 taken 5036 times.
✓ Branch 2 taken 2518 times.
✓ Branch 3 taken 5036 times.
15108 s->idsp.put_pixels_clamped(v->block[v->left_blk_idx][block_map[i]],
141 2518 i > 3 ? s->dest[i - 3] - 8 : dest,
142 5036 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
143 }
144 }
145 }
146
2/2
✓ Branch 0 taken 1303 times.
✓ Branch 1 taken 69047 times.
70350 if (s->mb_x == v->end_mb_x - 1) {
147
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 1031 times.
1303 if (v->fcm == ILACE_FRAME)
148 272 fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x];
149
2/2
✓ Branch 0 taken 7818 times.
✓ Branch 1 taken 1303 times.
9121 for (i = 0; i < block_count; i++) {
150
2/2
✓ Branch 0 taken 3365 times.
✓ Branch 1 taken 4453 times.
7818 if (v->mb_type[s->block_index[i]]) {
151
2/2
✓ Branch 0 taken 252 times.
✓ Branch 1 taken 3113 times.
3365 if (fieldtx)
152 252 dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + (i & 1) * 8;
153 else
154 3113 dest = s->dest[0] + (i & 2) * 4 * s->linesize + (i & 1) * 8;
155
2/2
✓ Branch 0 taken 2819 times.
✓ Branch 1 taken 546 times.
3365 if (put_signed)
156
4/4
✓ Branch 0 taken 926 times.
✓ Branch 1 taken 1893 times.
✓ Branch 2 taken 926 times.
✓ Branch 3 taken 1893 times.
5638 s->idsp.put_signed_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]],
157 926 i > 3 ? s->dest[i - 3] : dest,
158 1893 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
159 else
160
4/4
✓ Branch 0 taken 182 times.
✓ Branch 1 taken 364 times.
✓ Branch 2 taken 182 times.
✓ Branch 3 taken 364 times.
1092 s->idsp.put_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]],
161 182 i > 3 ? s->dest[i - 3] : dest,
162 364 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
163 }
164 }
165 }
166 }
167 250256 }
168
169 #define inc_blk_idx(idx) do { \
170 idx++; \
171 if (idx >= v->n_allocated_blks) \
172 idx = 0; \
173 } while (0)
174
175 /***********************************************************************/
176 /**
177 * @name VC-1 Block-level functions
178 * @see 7.1.4, p91 and 8.1.1.7, p(1)04
179 * @{
180 */
181
182 /**
183 * @def GET_MQUANT
184 * @brief Get macroblock-level quantizer scale
185 */
186 #define GET_MQUANT() \
187 if (v->dquantfrm) { \
188 int edges = 0; \
189 if (v->dqprofile == DQPROFILE_ALL_MBS) { \
190 if (v->dqbilevel) { \
191 mquant = (get_bits1(gb)) ? -v->altpq : v->pq; \
192 } else { \
193 mqdiff = get_bits(gb, 3); \
194 if (mqdiff != 7) \
195 mquant = -v->pq - mqdiff; \
196 else \
197 mquant = -get_bits(gb, 5); \
198 } \
199 } \
200 if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \
201 edges = 1 << v->dqsbedge; \
202 else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
203 edges = (3 << v->dqsbedge) % 15; \
204 else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \
205 edges = 15; \
206 if ((edges&1) && !s->mb_x) \
207 mquant = -v->altpq; \
208 if ((edges&2) && !s->mb_y) \
209 mquant = -v->altpq; \
210 if ((edges&4) && s->mb_x == (s->mb_width - 1)) \
211 mquant = -v->altpq; \
212 if ((edges&8) && \
213 s->mb_y == ((s->mb_height >> v->field_mode) - 1)) \
214 mquant = -v->altpq; \
215 if (!mquant || mquant > 31 || mquant < -31) { \
216 av_log(v->s.avctx, AV_LOG_ERROR, \
217 "Overriding invalid mquant %d\n", mquant); \
218 mquant = 1; \
219 } \
220 }
221
222 /**
223 * @def GET_MVDATA(_dmv_x, _dmv_y)
224 * @brief Get MV differentials
225 * @see MVDATA decoding from 8.3.5.2, p(1)20
226 * @param _dmv_x Horizontal differential for decoded MV
227 * @param _dmv_y Vertical differential for decoded MV
228 */
229 #define GET_MVDATA(_dmv_x, _dmv_y) \
230 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[v->mv_table_index], \
231 VC1_MV_DIFF_VLC_BITS, 2); \
232 if (index > 36) { \
233 mb_has_coeffs = 1; \
234 index -= 37; \
235 } else \
236 mb_has_coeffs = 0; \
237 s->mb_intra = 0; \
238 if (!index) { \
239 _dmv_x = _dmv_y = 0; \
240 } else if (index == 35) { \
241 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \
242 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \
243 } else if (index == 36) { \
244 _dmv_x = 0; \
245 _dmv_y = 0; \
246 s->mb_intra = 1; \
247 } else { \
248 index1 = index % 6; \
249 _dmv_x = offset_table[1][index1]; \
250 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \
251 if (val > 0) { \
252 val = get_bits(gb, val); \
253 sign = 0 - (val & 1); \
254 _dmv_x = (sign ^ ((val >> 1) + _dmv_x)) - sign; \
255 } \
256 \
257 index1 = index / 6; \
258 _dmv_y = offset_table[1][index1]; \
259 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \
260 if (val > 0) { \
261 val = get_bits(gb, val); \
262 sign = 0 - (val & 1); \
263 _dmv_y = (sign ^ ((val >> 1) + _dmv_y)) - sign; \
264 } \
265 }
266
267 119188 static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x,
268 int *dmv_y, int *pred_flag)
269 {
270 int index, index1;
271 int extend_x, extend_y;
272 119188 GetBitContext *const gb = &v->gb;
273 int bits, esc;
274 int val, sign;
275
276
2/2
✓ Branch 0 taken 59405 times.
✓ Branch 1 taken 59783 times.
119188 if (v->numref) {
277 59405 bits = VC1_2REF_MVDATA_VLC_BITS;
278 59405 esc = 125;
279 } else {
280 59783 bits = VC1_1REF_MVDATA_VLC_BITS;
281 59783 esc = 71;
282 }
283 119188 extend_x = v->dmvrange & 1;
284 119188 extend_y = (v->dmvrange >> 1) & 1;
285 119188 index = get_vlc2(gb, v->imv_vlc, bits, 3);
286
2/2
✓ Branch 0 taken 8896 times.
✓ Branch 1 taken 110292 times.
119188 if (index == esc) {
287 8896 *dmv_x = get_bits(gb, v->k_x);
288 8896 *dmv_y = get_bits(gb, v->k_y);
289
2/2
✓ Branch 0 taken 414 times.
✓ Branch 1 taken 8482 times.
8896 if (v->numref) {
290
1/2
✓ Branch 0 taken 414 times.
✗ Branch 1 not taken.
414 if (pred_flag)
291 414 *pred_flag = *dmv_y & 1;
292 414 *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
293 }
294 }
295 else {
296
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 110292 times.
110292 av_assert0(index < esc);
297 110292 index1 = (index + 1) % 9;
298
2/2
✓ Branch 0 taken 84924 times.
✓ Branch 1 taken 25368 times.
110292 if (index1 != 0) {
299 84924 val = get_bits(gb, index1 + extend_x);
300 84924 sign = 0 - (val & 1);
301 84924 *dmv_x = (sign ^ ((val >> 1) + offset_table[extend_x][index1])) - sign;
302 } else
303 25368 *dmv_x = 0;
304 110292 index1 = (index + 1) / 9;
305
2/2
✓ Branch 0 taken 76909 times.
✓ Branch 1 taken 33383 times.
110292 if (index1 > v->numref) {
306 76909 val = get_bits(gb, (index1 >> v->numref) + extend_y);
307 76909 sign = 0 - (val & 1);
308 76909 *dmv_y = (sign ^ ((val >> 1) + offset_table[extend_y][index1 >> v->numref])) - sign;
309 } else
310 33383 *dmv_y = 0;
311
3/4
✓ Branch 0 taken 58991 times.
✓ Branch 1 taken 51301 times.
✓ Branch 2 taken 58991 times.
✗ Branch 3 not taken.
110292 if (v->numref && pred_flag)
312 58991 *pred_flag = index1 & 1;
313 }
314 119188 }
315
316 /** Reconstruct motion vector for B-frame and do motion compensation
317 */
318 62854 static inline void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2],
319 int direct, int mode)
320 {
321
2/2
✓ Branch 0 taken 9339 times.
✓ Branch 1 taken 53515 times.
62854 if (direct) {
322 9339 ff_vc1_mc_1mv(v, 0);
323 9339 ff_vc1_interp_mc(v);
324 9339 return;
325 }
326
2/2
✓ Branch 0 taken 12043 times.
✓ Branch 1 taken 41472 times.
53515 if (mode == BMV_TYPE_INTERPOLATED) {
327 12043 ff_vc1_mc_1mv(v, 0);
328 12043 ff_vc1_interp_mc(v);
329 12043 return;
330 }
331
332 41472 ff_vc1_mc_1mv(v, (mode == BMV_TYPE_BACKWARD));
333 }
334
335 /** Get predicted DC value for I-frames only
336 * prediction dir: left=0, top=1
337 * @param s MpegEncContext
338 * @param overlap flag indicating that overlap filtering is used
339 * @param pq integer part of picture quantizer
340 * @param[in] n block index in the current MB
341 * @param dc_val_ptr Pointer to DC predictor
342 * @param dir_ptr Prediction direction for use in AC prediction
343 */
344 115080 static inline int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
345 int16_t **dc_val_ptr, int *dir_ptr)
346 {
347 int a, b, c, wrap, pred, scale;
348 int16_t *dc_val;
349 static const uint16_t dcpred[32] = {
350 -1, 1024, 512, 341, 256, 205, 171, 146, 128,
351 114, 102, 93, 85, 79, 73, 68, 64,
352 60, 57, 54, 51, 49, 47, 45, 43,
353 41, 39, 38, 37, 35, 34, 33
354 };
355
356 /* find prediction - wmv3_dc_scale always used here in fact */
357 115080 scale = s->y_dc_scale;
358
359 115080 wrap = s->block_wrap[n];
360 115080 dc_val = s->dc_val + s->block_index[n];
361
362 /* B A
363 * C X
364 */
365 115080 c = dc_val[ - 1];
366 115080 b = dc_val[ - 1 - wrap];
367 115080 a = dc_val[ - wrap];
368
369
3/4
✓ Branch 0 taken 58800 times.
✓ Branch 1 taken 56280 times.
✓ Branch 2 taken 58800 times.
✗ Branch 3 not taken.
115080 if (pq < 9 || !overlap) {
370 /* Set outer values */
371
6/6
✓ Branch 0 taken 8100 times.
✓ Branch 1 taken 106980 times.
✓ Branch 2 taken 6750 times.
✓ Branch 3 taken 1350 times.
✓ Branch 4 taken 5400 times.
✓ Branch 5 taken 1350 times.
115080 if (s->first_slice_line && (n != 2 && n != 3))
372 5400 b = a = dcpred[scale];
373
6/6
✓ Branch 0 taken 6132 times.
✓ Branch 1 taken 108948 times.
✓ Branch 2 taken 5110 times.
✓ Branch 3 taken 1022 times.
✓ Branch 4 taken 4088 times.
✓ Branch 5 taken 1022 times.
115080 if (s->mb_x == 0 && (n != 1 && n != 3))
374 4088 b = c = dcpred[scale];
375 } else {
376 /* Set outer values */
377 if (s->first_slice_line && (n != 2 && n != 3))
378 b = a = 0;
379 if (s->mb_x == 0 && (n != 1 && n != 3))
380 b = c = 0;
381 }
382
383
2/2
✓ Branch 0 taken 77938 times.
✓ Branch 1 taken 37142 times.
115080 if (abs(a - b) <= abs(b - c)) {
384 77938 pred = c;
385 77938 *dir_ptr = 1; // left
386 } else {
387 37142 pred = a;
388 37142 *dir_ptr = 0; // top
389 }
390
391 /* update predictor */
392 115080 *dc_val_ptr = &dc_val[0];
393 115080 return pred;
394 }
395
396
397 /** Get predicted DC value
398 * prediction dir: left=0, top=1
399 * @param s MpegEncContext
400 * @param overlap flag indicating that overlap filtering is used
401 * @param pq integer part of picture quantizer
402 * @param[in] n block index in the current MB
403 * @param a_avail flag indicating top block availability
404 * @param c_avail flag indicating left block availability
405 * @param dc_val_ptr Pointer to DC predictor
406 * @param dir_ptr Prediction direction for use in AC prediction
407 */
408 381610 static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
409 int a_avail, int c_avail,
410 int16_t **dc_val_ptr, int *dir_ptr)
411 {
412 int a, b, c, wrap, pred;
413 int16_t *dc_val;
414 381610 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
415 381610 int q1, q2 = 0;
416 int dqscale_index;
417
418 /* scale predictors if needed */
419 381610 q1 = FFABS(s->cur_pic.qscale_table[mb_pos]);
420 381610 dqscale_index = ff_wmv3_dc_scale_table[q1] - 1;
421
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 381610 times.
381610 if (dqscale_index < 0)
422 return 0;
423
424 381610 wrap = s->block_wrap[n];
425 381610 dc_val = s->dc_val + s->block_index[n];
426
427 /* B A
428 * C X
429 */
430 381610 c = dc_val[ - 1];
431 381610 b = dc_val[ - 1 - wrap];
432 381610 a = dc_val[ - wrap];
433
434
6/6
✓ Branch 0 taken 286987 times.
✓ Branch 1 taken 94623 times.
✓ Branch 2 taken 224380 times.
✓ Branch 3 taken 62607 times.
✓ Branch 4 taken 161716 times.
✓ Branch 5 taken 62664 times.
381610 if (c_avail && (n != 1 && n != 3)) {
435 161716 q2 = FFABS(s->cur_pic.qscale_table[mb_pos - 1]);
436
3/4
✓ Branch 0 taken 161716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10876 times.
✓ Branch 3 taken 150840 times.
161716 if (q2 && q2 != q1)
437 10876 c = (int)((unsigned)c * ff_wmv3_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
438 }
439
6/6
✓ Branch 0 taken 267085 times.
✓ Branch 1 taken 114525 times.
✓ Branch 2 taken 204442 times.
✓ Branch 3 taken 62643 times.
✓ Branch 4 taken 141745 times.
✓ Branch 5 taken 62697 times.
381610 if (a_avail && (n != 2 && n != 3)) {
440 141745 q2 = FFABS(s->cur_pic.qscale_table[mb_pos - s->mb_stride]);
441
3/4
✓ Branch 0 taken 141745 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 10104 times.
✓ Branch 3 taken 131641 times.
141745 if (q2 && q2 != q1)
442 10104 a = (int)((unsigned)a * ff_wmv3_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
443 }
444
6/6
✓ Branch 0 taken 267085 times.
✓ Branch 1 taken 114525 times.
✓ Branch 2 taken 225911 times.
✓ Branch 3 taken 41174 times.
✓ Branch 4 taken 163754 times.
✓ Branch 5 taken 62157 times.
381610 if (a_avail && c_avail && (n != 3)) {
445 163754 int off = mb_pos;
446
2/2
✓ Branch 0 taken 128389 times.
✓ Branch 1 taken 35365 times.
163754 if (n != 1)
447 128389 off--;
448
2/2
✓ Branch 0 taken 123403 times.
✓ Branch 1 taken 40351 times.
163754 if (n != 2)
449 123403 off -= s->mb_stride;
450 163754 q2 = FFABS(s->cur_pic.qscale_table[off]);
451
4/4
✓ Branch 0 taken 163179 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 13767 times.
✓ Branch 3 taken 149412 times.
163754 if (q2 && q2 != q1)
452 13767 b = (int)((unsigned)b * ff_wmv3_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
453 }
454
455
6/6
✓ Branch 0 taken 286987 times.
✓ Branch 1 taken 94623 times.
✓ Branch 2 taken 225911 times.
✓ Branch 3 taken 61076 times.
✓ Branch 4 taken 148792 times.
✓ Branch 5 taken 77119 times.
381610 if (c_avail && (!a_avail || abs(a - b) <= abs(b - c))) {
456 209868 pred = c;
457 209868 *dir_ptr = 1; // left
458
2/2
✓ Branch 0 taken 118293 times.
✓ Branch 1 taken 53449 times.
171742 } else if (a_avail) {
459 118293 pred = a;
460 118293 *dir_ptr = 0; // top
461 } else {
462 53449 pred = 0;
463 53449 *dir_ptr = 1; // left
464 }
465
466 /* update predictor */
467 381610 *dc_val_ptr = &dc_val[0];
468 381610 return pred;
469 }
470
471 /** @} */ // Block group
472
473 /**
474 * @name VC1 Macroblock-level functions in Simple/Main Profiles
475 * @see 7.1.4, p91 and 8.1.1.7, p(1)04
476 * @{
477 */
478
479 173632 static inline int vc1_coded_block_pred(MPVContext *const s, int n, int diff)
480 {
481 int xy, wrap, pred, a, b, c;
482
483 173632 xy = s->block_index[n];
484 173632 wrap = s->b8_stride;
485
486 /* B C
487 * A X
488 */
489 173632 a = s->coded_block[xy - 1 ];
490 173632 b = s->coded_block[xy - 1 - wrap];
491 173632 c = s->coded_block[xy - wrap];
492
493
2/2
✓ Branch 0 taken 157475 times.
✓ Branch 1 taken 16157 times.
173632 if (b == c) {
494 157475 pred = a;
495 } else {
496 16157 pred = c;
497 }
498
499 /* store value */
500 173632 s->coded_block[xy] = pred ^ diff;
501
502 173632 return pred ^ diff;
503 }
504
505 /**
506 * Decode one AC coefficient
507 * @param v The VC1 context
508 * @param last Last coefficient
509 * @param skip How much zero coefficients to skip
510 * @param value Decoded AC coefficient value
511 * @param codingset set of VLC to decode data
512 * @see 8.1.3.4
513 */
514 8424122 static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip,
515 int *value, int codingset)
516 {
517 8424122 GetBitContext *const gb = &v->gb;
518 int index, run, level, lst, sign;
519
520 8424122 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset], AC_VLC_BITS, 3);
521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8424122 times.
8424122 if (index < 0)
522 return index;
523
2/2
✓ Branch 0 taken 8352121 times.
✓ Branch 1 taken 72001 times.
8424122 if (index != ff_vc1_ac_sizes[codingset] - 1) {
524 8352121 run = vc1_index_decode_table[codingset][index][0];
525 8352121 level = vc1_index_decode_table[codingset][index][1];
526
4/4
✓ Branch 0 taken 7029756 times.
✓ Branch 1 taken 1322365 times.
✓ Branch 3 taken 3 times.
✓ Branch 4 taken 7029753 times.
8352121 lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0;
527 8352121 sign = get_bits1(gb);
528 } else {
529 72001 int escape = decode210(gb);
530
2/2
✓ Branch 0 taken 62172 times.
✓ Branch 1 taken 9829 times.
72001 if (escape != 2) {
531 62172 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset], AC_VLC_BITS, 3);
532
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 62172 times.
62172 if (index >= ff_vc1_ac_sizes[codingset] - 1U)
533 return AVERROR_INVALIDDATA;
534 62172 run = vc1_index_decode_table[codingset][index][0];
535 62172 level = vc1_index_decode_table[codingset][index][1];
536 62172 lst = index >= vc1_last_decode_table[codingset];
537
2/2
✓ Branch 0 taken 31204 times.
✓ Branch 1 taken 30968 times.
62172 if (escape == 0) {
538
2/2
✓ Branch 0 taken 12124 times.
✓ Branch 1 taken 19080 times.
31204 if (lst)
539 12124 level += vc1_last_delta_level_table[codingset][run];
540 else
541 19080 level += vc1_delta_level_table[codingset][run];
542 } else {
543
2/2
✓ Branch 0 taken 11240 times.
✓ Branch 1 taken 19728 times.
30968 if (lst)
544 11240 run += vc1_last_delta_run_table[codingset][level] + 1;
545 else
546 19728 run += vc1_delta_run_table[codingset][level] + 1;
547 }
548 62172 sign = get_bits1(gb);
549 } else {
550 9829 lst = get_bits1(gb);
551
2/2
✓ Branch 0 taken 389 times.
✓ Branch 1 taken 9440 times.
9829 if (v->esc3_level_length == 0) {
552
4/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 324 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 58 times.
389 if (v->pq < 8 || v->dquantfrm) { // table 59
553 331 v->esc3_level_length = get_bits(gb, 3);
554
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 307 times.
331 if (!v->esc3_level_length)
555 24 v->esc3_level_length = get_bits(gb, 2) + 8;
556 } else { // table 60
557 58 v->esc3_level_length = get_unary(gb, 1, 6) + 2;
558 }
559 389 v->esc3_run_length = 3 + get_bits(gb, 2);
560 }
561 9829 run = get_bits(gb, v->esc3_run_length);
562 9829 sign = get_bits1(gb);
563 9829 level = get_bits(gb, v->esc3_level_length);
564 }
565 }
566
567 8424122 *last = lst;
568 8424122 *skip = run;
569 8424122 *value = (level ^ -sign) + sign;
570
571 8424122 return 0;
572 }
573
574 /** Decode intra block in intra frames - should be faster than decode_intra_block
575 * @param v VC1Context
576 * @param block block to decode
577 * @param[in] n subblock index
578 * @param coded are AC coeffs present or not
579 * @param codingset set of VLC to decode data
580 */
581 115080 static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n,
582 int coded, int codingset)
583 {
584 115080 GetBitContext *const gb = &v->gb;
585 115080 MpegEncContext *s = &v->s;
586 115080 int dc_pred_dir = 0; /* Direction of the DC prediction used */
587 int16_t *dc_val;
588 int16_t *ac_val, *ac_val2;
589 int dcdiff, scale;
590
591 /* Get DC differential */
592 115080 dcdiff = get_vlc2(gb, ff_msmp4_dc_vlc[v->dc_table_index][n >= 4],
593 MSMP4_DC_VLC_BITS, 3);
594
2/2
✓ Branch 0 taken 84692 times.
✓ Branch 1 taken 30388 times.
115080 if (dcdiff) {
595
4/4
✓ Branch 0 taken 70792 times.
✓ Branch 1 taken 13900 times.
✓ Branch 2 taken 17266 times.
✓ Branch 3 taken 53526 times.
84692 const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0;
596
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 84690 times.
84692 if (dcdiff == 119 /* ESC index value */) {
597 2 dcdiff = get_bits(gb, 8 + m);
598 } else {
599
2/2
✓ Branch 0 taken 31164 times.
✓ Branch 1 taken 53526 times.
84690 if (m)
600 31164 dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
601 }
602
2/2
✓ Branch 1 taken 44002 times.
✓ Branch 2 taken 40690 times.
84692 if (get_bits1(gb))
603 44002 dcdiff = -dcdiff;
604 }
605
606 /* Prediction */
607 115080 dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir);
608 115080 *dc_val = dcdiff;
609
610 /* Store the quantized DC coeff, used for prediction */
611 115080 block[0] = dcdiff * s->y_dc_scale;
612
613 115080 ac_val = s->ac_val[s->block_index[n]];
614 115080 ac_val2 = ac_val;
615
2/2
✓ Branch 0 taken 77938 times.
✓ Branch 1 taken 37142 times.
115080 if (dc_pred_dir) // left
616 77938 ac_val -= 16;
617 else // top
618 37142 ac_val -= 16 * s->block_wrap[n];
619
620 115080 scale = v->pq * 2 + v->halfpq;
621
622 //AC Decoding
623
624
2/2
✓ Branch 0 taken 60119 times.
✓ Branch 1 taken 54961 times.
115080 if (coded) {
625 60119 int last = 0, skip, value;
626 const uint8_t *zz_table;
627 int k;
628
629
2/2
✓ Branch 0 taken 14921 times.
✓ Branch 1 taken 45198 times.
60119 if (v->s.ac_pred) {
630
2/2
✓ Branch 0 taken 5077 times.
✓ Branch 1 taken 9844 times.
14921 if (!dc_pred_dir)
631 5077 zz_table = v->zz_8x8[2];
632 else
633 9844 zz_table = v->zz_8x8[3];
634 } else
635 45198 zz_table = v->zz_8x8[1];
636
637
2/2
✓ Branch 0 taken 940465 times.
✓ Branch 1 taken 60119 times.
1000584 for (int i = 1; !last; ++i) {
638 940465 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940465 times.
940465 if (ret < 0)
640 return ret;
641 940465 i += skip;
642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 940465 times.
940465 if (i > 63)
643 break;
644 940465 block[zz_table[i]] = value;
645 }
646
647 /* apply AC prediction if needed */
648
2/2
✓ Branch 0 taken 14921 times.
✓ Branch 1 taken 45198 times.
60119 if (s->ac_pred) {
649 int sh;
650
2/2
✓ Branch 0 taken 9844 times.
✓ Branch 1 taken 5077 times.
14921 if (dc_pred_dir) { // left
651 9844 sh = v->left_blk_sh;
652 } else { // top
653 5077 sh = v->top_blk_sh;
654 5077 ac_val += 8;
655 }
656
2/2
✓ Branch 0 taken 104447 times.
✓ Branch 1 taken 14921 times.
119368 for (k = 1; k < 8; k++)
657 104447 block[k << sh] += ac_val[k];
658 }
659 /* save AC coeffs for further prediction */
660
2/2
✓ Branch 0 taken 420833 times.
✓ Branch 1 taken 60119 times.
480952 for (k = 1; k < 8; k++) {
661 420833 ac_val2[k] = block[k << v->left_blk_sh];
662 420833 ac_val2[k + 8] = block[k << v->top_blk_sh];
663 }
664
665 /* scale AC coeffs */
666
2/2
✓ Branch 0 taken 3787497 times.
✓ Branch 1 taken 60119 times.
3847616 for (k = 1; k < 64; k++)
667
2/2
✓ Branch 0 taken 939836 times.
✓ Branch 1 taken 2847661 times.
3787497 if (block[k]) {
668 939836 block[k] *= scale;
669
2/2
✓ Branch 0 taken 66709 times.
✓ Branch 1 taken 873127 times.
939836 if (!v->pquantizer)
670
2/2
✓ Branch 0 taken 33176 times.
✓ Branch 1 taken 33533 times.
66709 block[k] += (block[k] < 0) ? -v->pq : v->pq;
671 }
672
673 } else {
674 int k;
675
676 54961 memset(ac_val2, 0, 16 * 2);
677
678 /* apply AC prediction if needed */
679
2/2
✓ Branch 0 taken 4231 times.
✓ Branch 1 taken 50730 times.
54961 if (s->ac_pred) {
680 int sh;
681
2/2
✓ Branch 0 taken 3202 times.
✓ Branch 1 taken 1029 times.
4231 if (dc_pred_dir) { //left
682 3202 sh = v->left_blk_sh;
683 } else { // top
684 1029 sh = v->top_blk_sh;
685 1029 ac_val += 8;
686 1029 ac_val2 += 8;
687 }
688 4231 memcpy(ac_val2, ac_val, 8 * 2);
689
2/2
✓ Branch 0 taken 29617 times.
✓ Branch 1 taken 4231 times.
33848 for (k = 1; k < 8; k++) {
690 29617 block[k << sh] = ac_val[k] * scale;
691
4/4
✓ Branch 0 taken 20475 times.
✓ Branch 1 taken 9142 times.
✓ Branch 2 taken 593 times.
✓ Branch 3 taken 19882 times.
29617 if (!v->pquantizer && block[k << sh])
692
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 324 times.
593 block[k << sh] += (block[k << sh] < 0) ? -v->pq : v->pq;
693 }
694 }
695 }
696
697 115080 return 0;
698 }
699
700 /** Decode intra block in intra frames - should be faster than decode_intra_block
701 * @param v VC1Context
702 * @param block block to decode
703 * @param[in] n subblock number
704 * @param coded are AC coeffs present or not
705 * @param codingset set of VLC to decode data
706 * @param mquant quantizer value for this macroblock
707 */
708 145368 static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
709 int coded, int codingset, int mquant)
710 {
711 145368 GetBitContext *const gb = &v->gb;
712 145368 MpegEncContext *s = &v->s;
713 145368 int dc_pred_dir = 0; /* Direction of the DC prediction used */
714 145368 int16_t *dc_val = NULL;
715 int16_t *ac_val, *ac_val2;
716 int dcdiff;
717 145368 int a_avail = v->a_avail, c_avail = v->c_avail;
718 145368 int use_pred = s->ac_pred;
719 int scale;
720 145368 int q1, q2 = 0;
721 145368 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
722 145368 int quant = FFABS(mquant);
723
724 /* Get DC differential */
725 145368 dcdiff = get_vlc2(gb, ff_msmp4_dc_vlc[v->dc_table_index][n >= 4],
726 MSMP4_DC_VLC_BITS, 3);
727
2/2
✓ Branch 0 taken 100398 times.
✓ Branch 1 taken 44970 times.
145368 if (dcdiff) {
728
4/4
✓ Branch 0 taken 92074 times.
✓ Branch 1 taken 8324 times.
✓ Branch 2 taken 4766 times.
✓ Branch 3 taken 87308 times.
100398 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
729
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 100396 times.
100398 if (dcdiff == 119 /* ESC index value */) {
730 2 dcdiff = get_bits(gb, 8 + m);
731 } else {
732
2/2
✓ Branch 0 taken 13090 times.
✓ Branch 1 taken 87306 times.
100396 if (m)
733 13090 dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
734 }
735
2/2
✓ Branch 1 taken 51735 times.
✓ Branch 2 taken 48663 times.
100398 if (get_bits1(gb))
736 51735 dcdiff = -dcdiff;
737 }
738
739 /* Prediction */
740 145368 dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, quant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
741 145368 *dc_val = dcdiff;
742
743 /* Store the quantized DC coeff, used for prediction */
744 145368 block[0] = dcdiff * s->y_dc_scale;
745
746 /* check if AC is needed at all */
747
4/4
✓ Branch 0 taken 4656 times.
✓ Branch 1 taken 140712 times.
✓ Branch 2 taken 84 times.
✓ Branch 3 taken 4572 times.
145368 if (!a_avail && !c_avail)
748 84 use_pred = 0;
749
750
2/2
✓ Branch 0 taken 47448 times.
✓ Branch 1 taken 97920 times.
145368 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
751
752 145368 ac_val = s->ac_val[s->block_index[n]];
753 145368 ac_val2 = ac_val;
754
2/2
✓ Branch 0 taken 96277 times.
✓ Branch 1 taken 49091 times.
145368 if (dc_pred_dir) // left
755 96277 ac_val -= 16;
756 else // top
757 49091 ac_val -= 16 * s->block_wrap[n];
758
759 145368 q1 = s->cur_pic.qscale_table[mb_pos];
760
2/2
✓ Branch 0 taken 24228 times.
✓ Branch 1 taken 121140 times.
145368 if (n == 3)
761 24228 q2 = q1;
762
2/2
✓ Branch 0 taken 81287 times.
✓ Branch 1 taken 39853 times.
121140 else if (dc_pred_dir) {
763
2/2
✓ Branch 0 taken 16438 times.
✓ Branch 1 taken 64849 times.
81287 if (n == 1)
764 16438 q2 = q1;
765
3/4
✓ Branch 0 taken 64765 times.
✓ Branch 1 taken 84 times.
✓ Branch 2 taken 64765 times.
✗ Branch 3 not taken.
64849 else if (c_avail && mb_pos)
766 64765 q2 = s->cur_pic.qscale_table[mb_pos - 1];
767 } else {
768
2/2
✓ Branch 0 taken 9816 times.
✓ Branch 1 taken 30037 times.
39853 if (n == 2)
769 9816 q2 = q1;
770
2/4
✓ Branch 0 taken 30037 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30037 times.
✗ Branch 3 not taken.
30037 else if (a_avail && mb_pos >= s->mb_stride)
771 30037 q2 = s->cur_pic.qscale_table[mb_pos - s->mb_stride];
772 }
773
774 //AC Decoding
775
776
2/2
✓ Branch 0 taken 131297 times.
✓ Branch 1 taken 14071 times.
145368 if (coded) {
777 131297 int last = 0, skip, value;
778 const uint8_t *zz_table;
779 int k;
780
781
2/2
✓ Branch 0 taken 32458 times.
✓ Branch 1 taken 98839 times.
131297 if (v->s.ac_pred) {
782
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 32434 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 18 times.
32458 if (!use_pred && v->fcm == ILACE_FRAME) {
783 6 zz_table = v->zzi_8x8;
784 } else {
785
2/2
✓ Branch 0 taken 11944 times.
✓ Branch 1 taken 20508 times.
32452 if (!dc_pred_dir) // top
786 11944 zz_table = v->zz_8x8[2];
787 else // left
788 20508 zz_table = v->zz_8x8[3];
789 }
790 } else {
791
2/2
✓ Branch 0 taken 25079 times.
✓ Branch 1 taken 73760 times.
98839 if (v->fcm != ILACE_FRAME)
792 25079 zz_table = v->zz_8x8[1];
793 else
794 73760 zz_table = v->zzi_8x8;
795 }
796
797
2/2
✓ Branch 0 taken 1562576 times.
✓ Branch 1 taken 131297 times.
1693873 for (int i = 1; !last; ++i) {
798 1562576 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562576 times.
1562576 if (ret < 0)
800 return ret;
801 1562576 i += skip;
802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1562576 times.
1562576 if (i > 63)
803 break;
804 1562576 block[zz_table[i]] = value;
805 }
806
807 /* apply AC prediction if needed */
808
2/2
✓ Branch 0 taken 32434 times.
✓ Branch 1 taken 98863 times.
131297 if (use_pred) {
809 int sh;
810
2/2
✓ Branch 0 taken 20490 times.
✓ Branch 1 taken 11944 times.
32434 if (dc_pred_dir) { // left
811 20490 sh = v->left_blk_sh;
812 } else { // top
813 11944 sh = v->top_blk_sh;
814 11944 ac_val += 8;
815 }
816 /* scale predictors if needed*/
817
2/2
✓ Branch 0 taken 12022 times.
✓ Branch 1 taken 20412 times.
32434 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32434 times.
32434 if (q1 < 1)
819 return AVERROR_INVALIDDATA;
820
1/2
✓ Branch 0 taken 32434 times.
✗ Branch 1 not taken.
32434 if (q2)
821
2/2
✓ Branch 0 taken 12022 times.
✓ Branch 1 taken 20412 times.
32434 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
822
3/4
✓ Branch 0 taken 32434 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2034 times.
✓ Branch 3 taken 30400 times.
32434 if (q2 && q1 != q2) {
823
2/2
✓ Branch 0 taken 14238 times.
✓ Branch 1 taken 2034 times.
16272 for (k = 1; k < 8; k++)
824 14238 block[k << sh] += (int)(ac_val[k] * (unsigned)q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
825 } else {
826
2/2
✓ Branch 0 taken 212800 times.
✓ Branch 1 taken 30400 times.
243200 for (k = 1; k < 8; k++)
827 212800 block[k << sh] += ac_val[k];
828 }
829 }
830 /* save AC coeffs for further prediction */
831
2/2
✓ Branch 0 taken 919079 times.
✓ Branch 1 taken 131297 times.
1050376 for (k = 1; k < 8; k++) {
832 919079 ac_val2[k ] = block[k << v->left_blk_sh];
833 919079 ac_val2[k + 8] = block[k << v->top_blk_sh];
834 }
835
836 /* scale AC coeffs */
837
2/2
✓ Branch 0 taken 8271711 times.
✓ Branch 1 taken 131297 times.
8403008 for (k = 1; k < 64; k++)
838
2/2
✓ Branch 0 taken 1560534 times.
✓ Branch 1 taken 6711177 times.
8271711 if (block[k]) {
839 1560534 block[k] *= scale;
840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1560534 times.
1560534 if (!v->pquantizer)
841 block[k] += (block[k] < 0) ? -quant : quant;
842 }
843
844 } else { // no AC coeffs
845 int k;
846
847 14071 memset(ac_val2, 0, 16 * 2);
848
849 /* apply AC prediction if needed */
850
2/2
✓ Branch 0 taken 3290 times.
✓ Branch 1 taken 10781 times.
14071 if (use_pred) {
851 int sh;
852
2/2
✓ Branch 0 taken 2833 times.
✓ Branch 1 taken 457 times.
3290 if (dc_pred_dir) { // left
853 2833 sh = v->left_blk_sh;
854 } else { // top
855 457 sh = v->top_blk_sh;
856 457 ac_val += 8;
857 457 ac_val2 += 8;
858 }
859 3290 memcpy(ac_val2, ac_val, 8 * 2);
860
2/2
✓ Branch 0 taken 2564 times.
✓ Branch 1 taken 726 times.
3290 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3290 times.
3290 if (q1 < 1)
862 return AVERROR_INVALIDDATA;
863
1/2
✓ Branch 0 taken 3290 times.
✗ Branch 1 not taken.
3290 if (q2)
864
2/2
✓ Branch 0 taken 2564 times.
✓ Branch 1 taken 726 times.
3290 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
865
3/4
✓ Branch 0 taken 3290 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
✓ Branch 3 taken 3080 times.
3290 if (q2 && q1 != q2) {
866
2/2
✓ Branch 0 taken 1470 times.
✓ Branch 1 taken 210 times.
1680 for (k = 1; k < 8; k++)
867 1470 ac_val2[k] = (int)(ac_val2[k] * q2 * (unsigned)ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
868 }
869
2/2
✓ Branch 0 taken 23030 times.
✓ Branch 1 taken 3290 times.
26320 for (k = 1; k < 8; k++) {
870 23030 block[k << sh] = ac_val2[k] * scale;
871
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 23030 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23030 if (!v->pquantizer && block[k << sh])
872 block[k << sh] += (block[k << sh] < 0) ? -quant : quant;
873 }
874 }
875 }
876
877 145368 return 0;
878 }
879
880 /** Decode intra block in inter frames - more generic version than vc1_decode_i_block
881 * @param v VC1Context
882 * @param block block to decode
883 * @param[in] n subblock index
884 * @param coded are AC coeffs present or not
885 * @param mquant block quantizer
886 * @param codingset set of VLC to decode data
887 */
888 236242 static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,
889 int coded, int mquant, int codingset)
890 {
891 236242 GetBitContext *const gb = &v->gb;
892 236242 MpegEncContext *s = &v->s;
893 236242 int dc_pred_dir = 0; /* Direction of the DC prediction used */
894 236242 int16_t *dc_val = NULL;
895 int16_t *ac_val, *ac_val2;
896 int dcdiff;
897 236242 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
898 236242 int a_avail = v->a_avail, c_avail = v->c_avail;
899 236242 int use_pred = s->ac_pred;
900 int scale;
901 236242 int q1, q2 = 0;
902 236242 int quant = FFABS(mquant);
903
904 236242 s->bdsp.clear_block(block);
905
906 /* XXX: Guard against dumb values of mquant */
907 236242 quant = av_clip_uintp2(quant, 5);
908
909 /* Set DC scale - y and c use the same so we only set y */
910 236242 s->y_dc_scale = ff_wmv3_dc_scale_table[quant];
911
912 /* Get DC differential */
913 236242 dcdiff = get_vlc2(gb, ff_msmp4_dc_vlc[v->dc_table_index][n >= 4],
914 MSMP4_DC_VLC_BITS, 3);
915
2/2
✓ Branch 0 taken 190507 times.
✓ Branch 1 taken 45735 times.
236242 if (dcdiff) {
916
3/4
✓ Branch 0 taken 190507 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18284 times.
✓ Branch 3 taken 172223 times.
190507 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
917
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 190504 times.
190507 if (dcdiff == 119 /* ESC index value */) {
918 3 dcdiff = get_bits(gb, 8 + m);
919 } else {
920
2/2
✓ Branch 0 taken 18284 times.
✓ Branch 1 taken 172220 times.
190504 if (m)
921 18284 dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
922 }
923
2/2
✓ Branch 1 taken 106640 times.
✓ Branch 2 taken 83867 times.
190507 if (get_bits1(gb))
924 106640 dcdiff = -dcdiff;
925 }
926
927 /* Prediction */
928 236242 dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, quant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
929 236242 *dc_val = dcdiff;
930
931 /* Store the quantized DC coeff, used for prediction */
932 236242 block[0] = dcdiff * s->y_dc_scale;
933
934 //AC Decoding
935
936 /* check if AC is needed at all and adjust direction if needed */
937
2/2
✓ Branch 0 taken 109869 times.
✓ Branch 1 taken 126373 times.
236242 if (!a_avail) dc_pred_dir = 1;
938
2/2
✓ Branch 0 taken 93175 times.
✓ Branch 1 taken 143067 times.
236242 if (!c_avail) dc_pred_dir = 0;
939
4/4
✓ Branch 0 taken 109869 times.
✓ Branch 1 taken 126373 times.
✓ Branch 2 taken 53365 times.
✓ Branch 3 taken 56504 times.
236242 if (!a_avail && !c_avail) use_pred = 0;
940 236242 ac_val = s->ac_val[s->block_index[n]];
941 236242 ac_val2 = ac_val;
942
943
2/2
✓ Branch 0 taken 232678 times.
✓ Branch 1 taken 3564 times.
236242 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
944
945
2/2
✓ Branch 0 taken 113675 times.
✓ Branch 1 taken 122567 times.
236242 if (dc_pred_dir) //left
946 113675 ac_val -= 16;
947 else //top
948 122567 ac_val -= 16 * s->block_wrap[n];
949
950 236242 q1 = s->cur_pic.qscale_table[mb_pos];
951
5/6
✓ Branch 0 taken 113675 times.
✓ Branch 1 taken 122567 times.
✓ Branch 2 taken 113675 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 113596 times.
✓ Branch 5 taken 79 times.
236242 if (dc_pred_dir && c_avail && mb_pos)
952 113596 q2 = s->cur_pic.qscale_table[mb_pos - 1];
953
6/6
✓ Branch 0 taken 122567 times.
✓ Branch 1 taken 113675 times.
✓ Branch 2 taken 69202 times.
✓ Branch 3 taken 53365 times.
✓ Branch 4 taken 67664 times.
✓ Branch 5 taken 1538 times.
236242 if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
954 67664 q2 = s->cur_pic.qscale_table[mb_pos - s->mb_stride];
955
4/4
✓ Branch 0 taken 113675 times.
✓ Branch 1 taken 122567 times.
✓ Branch 2 taken 34090 times.
✓ Branch 3 taken 79585 times.
236242 if (dc_pred_dir && n == 1)
956 34090 q2 = q1;
957
4/4
✓ Branch 0 taken 122567 times.
✓ Branch 1 taken 113675 times.
✓ Branch 2 taken 28445 times.
✓ Branch 3 taken 94122 times.
236242 if (!dc_pred_dir && n == 2)
958 28445 q2 = q1;
959
2/2
✓ Branch 0 taken 39896 times.
✓ Branch 1 taken 196346 times.
236242 if (n == 3) q2 = q1;
960
961
2/2
✓ Branch 0 taken 163776 times.
✓ Branch 1 taken 72466 times.
236242 if (coded) {
962 163776 int last = 0, skip, value;
963 int k;
964
965
2/2
✓ Branch 0 taken 1543069 times.
✓ Branch 1 taken 163774 times.
1706843 for (int i = 1; !last; ++i) {
966 1543069 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1543069 times.
1543069 if (ret < 0)
968 return ret;
969 1543069 i += skip;
970
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1543067 times.
1543069 if (i > 63)
971 2 break;
972
2/2
✓ Branch 0 taken 925417 times.
✓ Branch 1 taken 617650 times.
1543067 if (v->fcm == PROGRESSIVE)
973 925417 block[v->zz_8x8[0][i]] = value;
974 else {
975
4/4
✓ Branch 0 taken 191926 times.
✓ Branch 1 taken 425724 times.
✓ Branch 2 taken 19188 times.
✓ Branch 3 taken 172738 times.
617650 if (use_pred && (v->fcm == ILACE_FRAME)) {
976
2/2
✓ Branch 0 taken 8623 times.
✓ Branch 1 taken 10565 times.
19188 if (!dc_pred_dir) // top
977 8623 block[v->zz_8x8[2][i]] = value;
978 else // left
979 10565 block[v->zz_8x8[3][i]] = value;
980 } else {
981 598462 block[v->zzi_8x8[i]] = value;
982 }
983 }
984 }
985
986 /* apply AC prediction if needed */
987
2/2
✓ Branch 0 taken 43023 times.
✓ Branch 1 taken 120753 times.
163776 if (use_pred) {
988 /* scale predictors if needed*/
989
2/2
✓ Branch 0 taken 42128 times.
✓ Branch 1 taken 895 times.
43023 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
990
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43023 times.
43023 if (q1 < 1)
991 return AVERROR_INVALIDDATA;
992
1/2
✓ Branch 0 taken 43023 times.
✗ Branch 1 not taken.
43023 if (q2)
993
2/2
✓ Branch 0 taken 42018 times.
✓ Branch 1 taken 1005 times.
43023 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
994
3/4
✓ Branch 0 taken 43023 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✓ Branch 3 taken 42669 times.
43023 if (q2 && q1 != q2) {
995
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 119 times.
354 if (dc_pred_dir) { // left
996
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 235 times.
1880 for (k = 1; k < 8; k++)
997 1645 block[k << v->left_blk_sh] += (int)(ac_val[k] * q2 * (unsigned)ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
998 } else { //top
999
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 119 times.
952 for (k = 1; k < 8; k++)
1000 833 block[k << v->top_blk_sh] += (int)(ac_val[k + 8] * q2 * (unsigned)ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1001 }
1002 } else {
1003
2/2
✓ Branch 0 taken 25655 times.
✓ Branch 1 taken 17014 times.
42669 if (dc_pred_dir) { // left
1004
2/2
✓ Branch 0 taken 179585 times.
✓ Branch 1 taken 25655 times.
205240 for (k = 1; k < 8; k++)
1005 179585 block[k << v->left_blk_sh] += ac_val[k];
1006 } else { // top
1007
2/2
✓ Branch 0 taken 119098 times.
✓ Branch 1 taken 17014 times.
136112 for (k = 1; k < 8; k++)
1008 119098 block[k << v->top_blk_sh] += ac_val[k + 8];
1009 }
1010 }
1011 }
1012 /* save AC coeffs for further prediction */
1013
2/2
✓ Branch 0 taken 1146432 times.
✓ Branch 1 taken 163776 times.
1310208 for (k = 1; k < 8; k++) {
1014 1146432 ac_val2[k ] = block[k << v->left_blk_sh];
1015 1146432 ac_val2[k + 8] = block[k << v->top_blk_sh];
1016 }
1017
1018 /* scale AC coeffs */
1019
2/2
✓ Branch 0 taken 10317888 times.
✓ Branch 1 taken 163776 times.
10481664 for (k = 1; k < 64; k++)
1020
2/2
✓ Branch 0 taken 1546034 times.
✓ Branch 1 taken 8771854 times.
10317888 if (block[k]) {
1021 1546034 block[k] *= scale;
1022
2/2
✓ Branch 0 taken 28424 times.
✓ Branch 1 taken 1517610 times.
1546034 if (!v->pquantizer)
1023
2/2
✓ Branch 0 taken 14356 times.
✓ Branch 1 taken 14068 times.
28424 block[k] += (block[k] < 0) ? -quant : quant;
1024 }
1025 } else { // no AC coeffs
1026 int k;
1027
1028 72466 memset(ac_val2, 0, 16 * 2);
1029
2/2
✓ Branch 0 taken 34095 times.
✓ Branch 1 taken 38371 times.
72466 if (dc_pred_dir) { // left
1030
2/2
✓ Branch 0 taken 6724 times.
✓ Branch 1 taken 27371 times.
34095 if (use_pred) {
1031 6724 memcpy(ac_val2, ac_val, 8 * 2);
1032
2/2
✓ Branch 0 taken 5988 times.
✓ Branch 1 taken 736 times.
6724 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
1033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6724 times.
6724 if (q1 < 1)
1034 return AVERROR_INVALIDDATA;
1035
1/2
✓ Branch 0 taken 6724 times.
✗ Branch 1 not taken.
6724 if (q2)
1036
2/2
✓ Branch 0 taken 5988 times.
✓ Branch 1 taken 736 times.
6724 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
1037
3/4
✓ Branch 0 taken 6724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 6692 times.
6724 if (q2 && q1 != q2) {
1038
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 32 times.
256 for (k = 1; k < 8; k++)
1039 224 ac_val2[k] = (int)(ac_val2[k] * (unsigned)q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1040 }
1041 }
1042 } else { // top
1043
2/2
✓ Branch 0 taken 2674 times.
✓ Branch 1 taken 35697 times.
38371 if (use_pred) {
1044 2674 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
1045
2/2
✓ Branch 0 taken 2580 times.
✓ Branch 1 taken 94 times.
2674 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
1046
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2674 times.
2674 if (q1 < 1)
1047 return AVERROR_INVALIDDATA;
1048
1/2
✓ Branch 0 taken 2674 times.
✗ Branch 1 not taken.
2674 if (q2)
1049
2/2
✓ Branch 0 taken 2581 times.
✓ Branch 1 taken 93 times.
2674 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
1050
3/4
✓ Branch 0 taken 2674 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 2661 times.
2674 if (q2 && q1 != q2) {
1051
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 13 times.
104 for (k = 1; k < 8; k++)
1052 91 ac_val2[k + 8] = (int)(ac_val2[k + 8] * (unsigned)q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1053 }
1054 }
1055 }
1056
1057 /* apply AC prediction if needed */
1058
2/2
✓ Branch 0 taken 9398 times.
✓ Branch 1 taken 63068 times.
72466 if (use_pred) {
1059
2/2
✓ Branch 0 taken 6724 times.
✓ Branch 1 taken 2674 times.
9398 if (dc_pred_dir) { // left
1060
2/2
✓ Branch 0 taken 47068 times.
✓ Branch 1 taken 6724 times.
53792 for (k = 1; k < 8; k++) {
1061 47068 block[k << v->left_blk_sh] = ac_val2[k] * scale;
1062
4/4
✓ Branch 0 taken 5341 times.
✓ Branch 1 taken 41727 times.
✓ Branch 2 taken 127 times.
✓ Branch 3 taken 5214 times.
47068 if (!v->pquantizer && block[k << v->left_blk_sh])
1063
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 85 times.
127 block[k << v->left_blk_sh] += (block[k << v->left_blk_sh] < 0) ? -quant : quant;
1064 }
1065 } else { // top
1066
2/2
✓ Branch 0 taken 18718 times.
✓ Branch 1 taken 2674 times.
21392 for (k = 1; k < 8; k++) {
1067 18718 block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
1068
4/4
✓ Branch 0 taken 3493 times.
✓ Branch 1 taken 15225 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 3364 times.
18718 if (!v->pquantizer && block[k << v->top_blk_sh])
1069
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 81 times.
129 block[k << v->top_blk_sh] += (block[k << v->top_blk_sh] < 0) ? -quant : quant;
1070 }
1071 }
1072 }
1073 }
1074
1075 236242 return 0;
1076 }
1077
1078 /** Decode P block
1079 */
1080 705481 static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n,
1081 int mquant, int ttmb, int first_block,
1082 uint8_t *dst, int linesize, int skip_block,
1083 int *ttmb_out)
1084 {
1085 705481 MpegEncContext *s = &v->s;
1086 705481 GetBitContext *const gb = &v->gb;
1087 int i, j;
1088 705481 int subblkpat = 0;
1089 int scale, off, idx, last, skip, value;
1090 705481 int ttblk = ttmb & 7;
1091 705481 int pat = 0;
1092 705481 int quant = FFABS(mquant);
1093
1094 705481 s->bdsp.clear_block(block);
1095
1096
2/2
✓ Branch 0 taken 328239 times.
✓ Branch 1 taken 377242 times.
705481 if (ttmb == -1) {
1097 328239 ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index], VC1_TTBLK_VLC_BITS, 1)];
1098 }
1099
2/2
✓ Branch 0 taken 78333 times.
✓ Branch 1 taken 627148 times.
705481 if (ttblk == TT_4X4) {
1100 78333 subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index], VC1_SUBBLKPAT_VLC_BITS, 1) + 1);
1101 }
1102
4/4
✓ Branch 0 taken 352415 times.
✓ Branch 1 taken 353066 times.
✓ Branch 2 taken 274082 times.
✓ Branch 3 taken 78333 times.
705481 if ((ttblk != TT_8X8 && ttblk != TT_4X4)
1103
8/8
✓ Branch 0 taken 274062 times.
✓ Branch 1 taken 20 times.
✓ Branch 2 taken 108094 times.
✓ Branch 3 taken 165968 times.
✓ Branch 4 taken 43444 times.
✓ Branch 5 taken 64650 times.
✓ Branch 6 taken 12667 times.
✓ Branch 7 taken 30777 times.
274082 && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
1104
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 243285 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
243285 || (!v->res_rtm_flag && !first_block))) {
1105 30797 subblkpat = decode012(gb);
1106
2/2
✓ Branch 0 taken 11209 times.
✓ Branch 1 taken 19588 times.
30797 if (subblkpat)
1107 11209 subblkpat ^= 3; // swap decoded pattern bits
1108
4/4
✓ Branch 0 taken 27940 times.
✓ Branch 1 taken 2857 times.
✓ Branch 2 taken 2882 times.
✓ Branch 3 taken 25058 times.
30797 if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM)
1109 5739 ttblk = TT_8X4;
1110
4/4
✓ Branch 0 taken 28554 times.
✓ Branch 1 taken 2243 times.
✓ Branch 2 taken 1746 times.
✓ Branch 3 taken 26808 times.
30797 if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT)
1111 3989 ttblk = TT_4X8;
1112 }
1113
2/2
✓ Branch 0 taken 675330 times.
✓ Branch 1 taken 30151 times.
705481 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
1114
1115 // convert transforms like 8X4_TOP to generic TT and SUBBLKPAT
1116
4/4
✓ Branch 0 taken 686634 times.
✓ Branch 1 taken 18847 times.
✓ Branch 2 taken 20159 times.
✓ Branch 3 taken 666475 times.
705481 if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) {
1117
2/2
✓ Branch 0 taken 18847 times.
✓ Branch 1 taken 20159 times.
39006 subblkpat = 2 - (ttblk == TT_8X4_TOP);
1118 39006 ttblk = TT_8X4;
1119 }
1120
4/4
✓ Branch 0 taken 681363 times.
✓ Branch 1 taken 24118 times.
✓ Branch 2 taken 23560 times.
✓ Branch 3 taken 657803 times.
705481 if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) {
1121
2/2
✓ Branch 0 taken 23560 times.
✓ Branch 1 taken 24118 times.
47678 subblkpat = 2 - (ttblk == TT_4X8_LEFT);
1122 47678 ttblk = TT_4X8;
1123 }
1124
4/5
✓ Branch 0 taken 353066 times.
✓ Branch 1 taken 78333 times.
✓ Branch 2 taken 134484 times.
✓ Branch 3 taken 139598 times.
✗ Branch 4 not taken.
705481 switch (ttblk) {
1125 353066 case TT_8X8:
1126 353066 pat = 0xF;
1127 353066 i = 0;
1128 353066 last = 0;
1129
2/2
✓ Branch 0 taken 2080609 times.
✓ Branch 1 taken 353066 times.
2433675 while (!last) {
1130 2080609 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1131
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2080609 times.
2080609 if (ret < 0)
1132 return ret;
1133 2080609 i += skip;
1134
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2080609 times.
2080609 if (i > 63)
1135 break;
1136
2/2
✓ Branch 0 taken 934770 times.
✓ Branch 1 taken 1145839 times.
2080609 if (!v->fcm)
1137 934770 idx = v->zz_8x8[0][i++];
1138 else
1139 1145839 idx = v->zzi_8x8[i++];
1140 2080609 block[idx] = value * scale;
1141
2/2
✓ Branch 0 taken 201139 times.
✓ Branch 1 taken 1879470 times.
2080609 if (!v->pquantizer)
1142
2/2
✓ Branch 0 taken 100867 times.
✓ Branch 1 taken 100272 times.
201139 block[idx] += (block[idx] < 0) ? -quant : quant;
1143 }
1144
1/2
✓ Branch 0 taken 353066 times.
✗ Branch 1 not taken.
353066 if (!skip_block) {
1145
2/2
✓ Branch 0 taken 48601 times.
✓ Branch 1 taken 304465 times.
353066 if (i == 1)
1146 48601 v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
1147 else {
1148 304465 v->vc1dsp.vc1_inv_trans_8x8(block);
1149 304465 s->idsp.add_pixels_clamped(block, dst, linesize);
1150 }
1151 }
1152 353066 break;
1153 78333 case TT_4X4:
1154 78333 pat = ~subblkpat & 0xF;
1155
2/2
✓ Branch 0 taken 313332 times.
✓ Branch 1 taken 78333 times.
391665 for (j = 0; j < 4; j++) {
1156 313332 last = subblkpat & (1 << (3 - j));
1157 313332 i = 0;
1158 313332 off = (j & 1) * 4 + (j & 2) * 16;
1159
2/2
✓ Branch 0 taken 512755 times.
✓ Branch 1 taken 313332 times.
826087 while (!last) {
1160 512755 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1161
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512755 times.
512755 if (ret < 0)
1162 return ret;
1163 512755 i += skip;
1164
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 512755 times.
512755 if (i > 15)
1165 break;
1166
2/2
✓ Branch 0 taken 283472 times.
✓ Branch 1 taken 229283 times.
512755 if (!v->fcm)
1167 283472 idx = ff_vc1_simple_progressive_4x4_zz[i++];
1168 else
1169 229283 idx = ff_vc1_adv_interlaced_4x4_zz[i++];
1170 512755 block[idx + off] = value * scale;
1171
2/2
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 503037 times.
512755 if (!v->pquantizer)
1172
2/2
✓ Branch 0 taken 4862 times.
✓ Branch 1 taken 4856 times.
9718 block[idx + off] += (block[idx + off] < 0) ? -quant : quant;
1173 }
1174
3/4
✓ Branch 0 taken 191401 times.
✓ Branch 1 taken 121931 times.
✓ Branch 2 taken 191401 times.
✗ Branch 3 not taken.
313332 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
1175
2/2
✓ Branch 0 taken 21249 times.
✓ Branch 1 taken 170152 times.
191401 if (i == 1)
1176 21249 v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off);
1177 else
1178 170152 v->vc1dsp.vc1_inv_trans_4x4(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off);
1179 }
1180 }
1181 78333 break;
1182 134484 case TT_8X4:
1183 134484 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
1184
2/2
✓ Branch 0 taken 268968 times.
✓ Branch 1 taken 134484 times.
403452 for (j = 0; j < 2; j++) {
1185 268968 last = subblkpat & (1 << (1 - j));
1186 268968 i = 0;
1187 268968 off = j * 32;
1188
2/2
✓ Branch 0 taken 902639 times.
✓ Branch 1 taken 268968 times.
1171607 while (!last) {
1189 902639 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1190
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 902639 times.
902639 if (ret < 0)
1191 return ret;
1192 902639 i += skip;
1193
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 902639 times.
902639 if (i > 31)
1194 break;
1195
2/2
✓ Branch 0 taken 470573 times.
✓ Branch 1 taken 432066 times.
902639 if (!v->fcm)
1196 470573 idx = v->zz_8x4[i++] + off;
1197 else
1198 432066 idx = ff_vc1_adv_interlaced_8x4_zz[i++] + off;
1199 902639 block[idx] = value * scale;
1200
2/2
✓ Branch 0 taken 9538 times.
✓ Branch 1 taken 893101 times.
902639 if (!v->pquantizer)
1201
2/2
✓ Branch 0 taken 4864 times.
✓ Branch 1 taken 4674 times.
9538 block[idx] += (block[idx] < 0) ? -quant : quant;
1202 }
1203
3/4
✓ Branch 0 taken 223232 times.
✓ Branch 1 taken 45736 times.
✓ Branch 2 taken 223232 times.
✗ Branch 3 not taken.
268968 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1204
2/2
✓ Branch 0 taken 15847 times.
✓ Branch 1 taken 207385 times.
223232 if (i == 1)
1205 15847 v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j * 4 * linesize, linesize, block + off);
1206 else
1207 207385 v->vc1dsp.vc1_inv_trans_8x4(dst + j * 4 * linesize, linesize, block + off);
1208 }
1209 }
1210 134484 break;
1211 139598 case TT_4X8:
1212 139598 pat = ~(subblkpat * 5) & 0xF;
1213
2/2
✓ Branch 0 taken 279196 times.
✓ Branch 1 taken 139598 times.
418794 for (j = 0; j < 2; j++) {
1214 279196 last = subblkpat & (1 << (1 - j));
1215 279196 i = 0;
1216 279196 off = j * 4;
1217
2/2
✓ Branch 0 taken 882009 times.
✓ Branch 1 taken 279190 times.
1161199 while (!last) {
1218 882009 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1219
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 882009 times.
882009 if (ret < 0)
1220 return ret;
1221 882009 i += skip;
1222
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 882003 times.
882009 if (i > 31)
1223 6 break;
1224
2/2
✓ Branch 0 taken 432119 times.
✓ Branch 1 taken 449884 times.
882003 if (!v->fcm)
1225 432119 idx = v->zz_4x8[i++] + off;
1226 else
1227 449884 idx = ff_vc1_adv_interlaced_4x8_zz[i++] + off;
1228 882003 block[idx] = value * scale;
1229
2/2
✓ Branch 0 taken 10845 times.
✓ Branch 1 taken 871158 times.
882003 if (!v->pquantizer)
1230
2/2
✓ Branch 0 taken 5474 times.
✓ Branch 1 taken 5371 times.
10845 block[idx] += (block[idx] < 0) ? -quant : quant;
1231 }
1232
3/4
✓ Branch 0 taken 227039 times.
✓ Branch 1 taken 52157 times.
✓ Branch 2 taken 227039 times.
✗ Branch 3 not taken.
279196 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1233
2/2
✓ Branch 0 taken 17934 times.
✓ Branch 1 taken 209105 times.
227039 if (i == 1)
1234 17934 v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j * 4, linesize, block + off);
1235 else
1236 209105 v->vc1dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
1237 }
1238 }
1239 139598 break;
1240 }
1241
2/2
✓ Branch 0 taken 648016 times.
✓ Branch 1 taken 57465 times.
705481 if (ttmb_out)
1242 648016 *ttmb_out |= ttblk << (n * 4);
1243 705481 return pat;
1244 }
1245
1246 /** @} */ // Macroblock group
1247
1248 static const uint8_t size_table[6] = { 0, 2, 3, 4, 5, 8 };
1249
1250 /** Decode one P-frame MB
1251 */
1252 152608 static int vc1_decode_p_mb(VC1Context *v)
1253 {
1254 152608 MpegEncContext *s = &v->s;
1255 152608 GetBitContext *const gb = &v->gb;
1256 int i, j;
1257 152608 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1258 int cbp; /* cbp decoding stuff */
1259 int mqdiff, mquant; /* MB quantization */
1260 152608 int ttmb = v->ttfrm; /* MB Transform type */
1261
1262 152608 int mb_has_coeffs = 1; /* last_flag */
1263 int dmv_x, dmv_y; /* Differential MV components */
1264 int index, index1; /* LUT indexes */
1265 int val, sign; /* temp values */
1266 152608 int first_block = 1;
1267 int dst_idx, off;
1268 int skipped, fourmv;
1269 152608 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
1270 int ret;
1271
1272 152608 mquant = v->pq; /* lossy initialization */
1273
1274
2/2
✓ Branch 0 taken 58770 times.
✓ Branch 1 taken 93838 times.
152608 if (v->mv_type_is_raw)
1275 58770 fourmv = get_bits1(gb);
1276 else
1277 93838 fourmv = v->mv_type_mb_plane[mb_pos];
1278
2/2
✓ Branch 0 taken 58470 times.
✓ Branch 1 taken 94138 times.
152608 if (v->skip_is_raw)
1279 58470 skipped = get_bits1(gb);
1280 else
1281 94138 skipped = v->s.mbskip_table[mb_pos];
1282
1283
2/2
✓ Branch 0 taken 126032 times.
✓ Branch 1 taken 26576 times.
152608 if (!fourmv) { /* 1MV mode */
1284
2/2
✓ Branch 0 taken 113910 times.
✓ Branch 1 taken 12122 times.
126032 if (!skipped) {
1285
20/20
✓ Branch 1 taken 92378 times.
✓ Branch 2 taken 21532 times.
✓ Branch 3 taken 23737 times.
✓ Branch 4 taken 90173 times.
✓ Branch 5 taken 1950 times.
✓ Branch 6 taken 88223 times.
✓ Branch 9 taken 24987 times.
✓ Branch 10 taken 63236 times.
✓ Branch 11 taken 22380 times.
✓ Branch 12 taken 40856 times.
✓ Branch 13 taken 153 times.
✓ Branch 14 taken 22227 times.
✓ Branch 15 taken 47286 times.
✓ Branch 16 taken 15950 times.
✓ Branch 18 taken 22380 times.
✓ Branch 19 taken 40856 times.
✓ Branch 20 taken 130 times.
✓ Branch 21 taken 22250 times.
✓ Branch 22 taken 49139 times.
✓ Branch 23 taken 14097 times.
113910 GET_MVDATA(dmv_x, dmv_y);
1286
1287
2/2
✓ Branch 0 taken 24987 times.
✓ Branch 1 taken 88923 times.
113910 if (s->mb_intra) {
1288 24987 s->cur_pic.motion_val[1][s->block_index[0]][0] = 0;
1289 24987 s->cur_pic.motion_val[1][s->block_index[0]][1] = 0;
1290 }
1291
2/2
✓ Branch 0 taken 24987 times.
✓ Branch 1 taken 88923 times.
113910 s->cur_pic.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
1292 113910 ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type, 0, 0);
1293
1294 /* FIXME Set DC val for inter block ? */
1295
4/4
✓ Branch 0 taken 24987 times.
✓ Branch 1 taken 88923 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 22239 times.
113910 if (s->mb_intra && !mb_has_coeffs) {
1296
21/38
✓ Branch 0 taken 99 times.
✓ Branch 1 taken 2649 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 99 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 13 taken 98 times.
✓ Branch 14 taken 1 times.
✓ Branch 15 taken 1 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 49 times.
✓ Branch 20 taken 50 times.
✓ Branch 21 taken 3 times.
✓ Branch 22 taken 46 times.
✓ Branch 23 taken 48 times.
✓ Branch 24 taken 51 times.
✓ Branch 25 taken 7 times.
✓ Branch 26 taken 41 times.
✗ Branch 27 not taken.
✓ Branch 28 taken 99 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✓ Branch 31 taken 3 times.
✓ Branch 32 taken 96 times.
✗ Branch 33 not taken.
✓ Branch 34 taken 3 times.
✓ Branch 35 taken 99 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 99 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 99 times.
2748 GET_MQUANT();
1297 2748 s->ac_pred = get_bits1(gb);
1298 2748 cbp = 0;
1299
2/2
✓ Branch 0 taken 92378 times.
✓ Branch 1 taken 18784 times.
111162 } else if (mb_has_coeffs) {
1300
2/2
✓ Branch 0 taken 22239 times.
✓ Branch 1 taken 70139 times.
92378 if (s->mb_intra)
1301 22239 s->ac_pred = get_bits1(gb);
1302 92378 cbp = get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1303
27/38
✓ Branch 0 taken 8185 times.
✓ Branch 1 taken 84193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8185 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✓ Branch 13 taken 7970 times.
✓ Branch 14 taken 215 times.
✓ Branch 15 taken 203 times.
✓ Branch 16 taken 12 times.
✓ Branch 17 taken 12 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 2077 times.
✓ Branch 20 taken 6108 times.
✓ Branch 21 taken 38 times.
✓ Branch 22 taken 2039 times.
✓ Branch 23 taken 5912 times.
✓ Branch 24 taken 2273 times.
✓ Branch 25 taken 349 times.
✓ Branch 26 taken 5563 times.
✓ Branch 27 taken 120 times.
✓ Branch 28 taken 8065 times.
✓ Branch 29 taken 6 times.
✓ Branch 30 taken 114 times.
✓ Branch 31 taken 315 times.
✓ Branch 32 taken 7870 times.
✓ Branch 33 taken 1 times.
✓ Branch 34 taken 314 times.
✓ Branch 35 taken 8185 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 8185 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 8185 times.
92378 GET_MQUANT();
1304 } else {
1305 18784 mquant = v->pq;
1306 18784 cbp = 0;
1307 }
1308 113910 s->cur_pic.qscale_table[mb_pos] = mquant;
1309
1310
6/6
✓ Branch 0 taken 75248 times.
✓ Branch 1 taken 38662 times.
✓ Branch 2 taken 53768 times.
✓ Branch 3 taken 21480 times.
✓ Branch 4 taken 42234 times.
✓ Branch 5 taken 11534 times.
113910 if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
1311 42234 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index],
1312 VC1_TTMB_VLC_BITS, 2);
1313
2/2
✓ Branch 0 taken 88923 times.
✓ Branch 1 taken 24987 times.
113910 if (!s->mb_intra) ff_vc1_mc_1mv(v, 0);
1314 113910 dst_idx = 0;
1315
2/2
✓ Branch 0 taken 683460 times.
✓ Branch 1 taken 113910 times.
797370 for (i = 0; i < 6; i++) {
1316 683460 s->dc_val[s->block_index[i]] = 0;
1317 683460 dst_idx += i >> 2;
1318 683460 val = ((cbp >> (5 - i)) & 1);
1319
2/2
✓ Branch 0 taken 455640 times.
✓ Branch 1 taken 227820 times.
683460 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
1320 683460 v->mb_type[s->block_index[i]] = s->mb_intra;
1321
2/2
✓ Branch 0 taken 149922 times.
✓ Branch 1 taken 533538 times.
683460 if (s->mb_intra) {
1322 /* check if prediction blocks A and C are available */
1323 149922 v->a_avail = v->c_avail = 0;
1324
6/6
✓ Branch 0 taken 124935 times.
✓ Branch 1 taken 24987 times.
✓ Branch 2 taken 99948 times.
✓ Branch 3 taken 24987 times.
✓ Branch 4 taken 60556 times.
✓ Branch 5 taken 39392 times.
149922 if (i == 2 || i == 3 || !s->first_slice_line)
1325 110530 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
1326
6/6
✓ Branch 0 taken 124935 times.
✓ Branch 1 taken 24987 times.
✓ Branch 2 taken 99948 times.
✓ Branch 3 taken 24987 times.
✓ Branch 4 taken 97332 times.
✓ Branch 5 taken 2616 times.
149922 if (i == 1 || i == 3 || s->mb_x)
1327 147306 v->c_avail = v->mb_type[s->block_index[i] - 1];
1328
1329 149922 ret = vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, val, mquant,
1330
2/2
✓ Branch 0 taken 49974 times.
✓ Branch 1 taken 99948 times.
149922 (i & 4) ? v->codingset2 : v->codingset);
1331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149922 times.
149922 if (ret < 0)
1332 return ret;
1333 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1334 continue;
1335 149922 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149922 times.
149922 if (v->rangeredfrm)
1337 for (j = 0; j < 64; j++)
1338 v->block[v->cur_blk_idx][block_map[i]][j] *= 2;
1339 149922 block_cbp |= 0xF << (i << 2);
1340 149922 block_intra |= 1 << i;
1341
2/2
✓ Branch 0 taken 219478 times.
✓ Branch 1 taken 314060 times.
533538 } else if (val) {
1342 658434 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb, first_block,
1343
2/2
✓ Branch 0 taken 33600 times.
✓ Branch 1 taken 185878 times.
219478 s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize,
1344 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
1345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 219478 times.
219478 if (pat < 0)
1346 return pat;
1347 219478 block_cbp |= pat << (i << 2);
1348
4/4
✓ Branch 0 taken 131418 times.
✓ Branch 1 taken 88060 times.
✓ Branch 2 taken 87522 times.
✓ Branch 3 taken 43896 times.
219478 if (!v->ttmbf && ttmb < 8)
1349 87522 ttmb = -1;
1350 219478 first_block = 0;
1351 }
1352 }
1353 } else { // skipped
1354 12122 s->mb_intra = 0;
1355
2/2
✓ Branch 0 taken 72732 times.
✓ Branch 1 taken 12122 times.
84854 for (i = 0; i < 6; i++) {
1356 72732 v->mb_type[s->block_index[i]] = 0;
1357 72732 s->dc_val[s->block_index[i]] = 0;
1358 }
1359 12122 s->cur_pic.mb_type[mb_pos] = MB_TYPE_SKIP;
1360 12122 s->cur_pic.qscale_table[mb_pos] = 0;
1361 12122 ff_vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type, 0, 0);
1362 12122 ff_vc1_mc_1mv(v, 0);
1363 }
1364 } else { // 4MV mode
1365
2/2
✓ Branch 0 taken 22855 times.
✓ Branch 1 taken 3721 times.
26576 if (!skipped /* unskipped MB */) {
1366 22855 int intra_count = 0, coded_inter = 0;
1367 int is_intra[6], is_coded[6];
1368 /* Get CBPCY */
1369 22855 cbp = get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1370
2/2
✓ Branch 0 taken 137130 times.
✓ Branch 1 taken 22855 times.
159985 for (i = 0; i < 6; i++) {
1371 137130 val = ((cbp >> (5 - i)) & 1);
1372 137130 s->dc_val[s->block_index[i]] = 0;
1373 137130 s->mb_intra = 0;
1374
2/2
✓ Branch 0 taken 91420 times.
✓ Branch 1 taken 45710 times.
137130 if (i < 4) {
1375 91420 dmv_x = dmv_y = 0;
1376 91420 s->mb_intra = 0;
1377 91420 mb_has_coeffs = 0;
1378
2/2
✓ Branch 0 taken 71997 times.
✓ Branch 1 taken 19423 times.
91420 if (val) {
1379
14/20
✓ Branch 1 taken 59461 times.
✓ Branch 2 taken 12536 times.
✓ Branch 3 taken 21378 times.
✓ Branch 4 taken 50619 times.
✓ Branch 5 taken 3130 times.
✓ Branch 6 taken 47489 times.
✓ Branch 9 taken 10564 times.
✓ Branch 10 taken 36925 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 36925 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 27632 times.
✓ Branch 16 taken 9293 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 36925 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 26108 times.
✓ Branch 23 taken 10817 times.
71997 GET_MVDATA(dmv_x, dmv_y);
1380 }
1381 91420 ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type, 0, 0);
1382
2/2
✓ Branch 0 taken 80856 times.
✓ Branch 1 taken 10564 times.
91420 if (!s->mb_intra)
1383 80856 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1384 91420 intra_count += s->mb_intra;
1385 91420 is_intra[i] = s->mb_intra;
1386 91420 is_coded[i] = mb_has_coeffs;
1387 }
1388
2/2
✓ Branch 0 taken 45710 times.
✓ Branch 1 taken 91420 times.
137130 if (i & 4) {
1389 45710 is_intra[i] = (intra_count >= 3);
1390 45710 is_coded[i] = val;
1391 }
1392
2/2
✓ Branch 0 taken 22855 times.
✓ Branch 1 taken 114275 times.
137130 if (i == 4)
1393 22855 ff_vc1_mc_4mv_chroma(v, 0);
1394 137130 v->mb_type[s->block_index[i]] = is_intra[i];
1395
2/2
✓ Branch 0 taken 52317 times.
✓ Branch 1 taken 84813 times.
137130 if (!coded_inter)
1396 52317 coded_inter = !is_intra[i] & is_coded[i];
1397 }
1398 // if there are no coded blocks then don't do anything more
1399 22855 dst_idx = 0;
1400
4/4
✓ Branch 0 taken 16906 times.
✓ Branch 1 taken 5949 times.
✓ Branch 2 taken 2699 times.
✓ Branch 3 taken 14207 times.
22855 if (!intra_count && !coded_inter)
1401 2699 goto end;
1402
1/38
✗ Branch 0 not taken.
✓ Branch 1 taken 20156 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
20156 GET_MQUANT();
1403 20156 s->cur_pic.qscale_table[mb_pos] = mquant;
1404 /* test if block is intra and has pred */
1405 {
1406 20156 int intrapred = 0;
1407
2/2
✓ Branch 0 taken 106282 times.
✓ Branch 1 taken 16462 times.
122744 for (i = 0; i < 6; i++)
1408
2/2
✓ Branch 0 taken 7257 times.
✓ Branch 1 taken 99025 times.
106282 if (is_intra[i]) {
1409
8/8
✓ Branch 0 taken 2657 times.
✓ Branch 1 taken 4600 times.
✓ Branch 2 taken 2099 times.
✓ Branch 3 taken 558 times.
✓ Branch 4 taken 467 times.
✓ Branch 5 taken 1632 times.
✓ Branch 6 taken 3831 times.
✓ Branch 7 taken 1794 times.
7257 if (((!s->first_slice_line || (i == 2 || i == 3)) && v->mb_type[s->block_index[i] - s->block_wrap[i]])
1410
8/8
✓ Branch 0 taken 145 times.
✓ Branch 1 taken 5318 times.
✓ Branch 2 taken 116 times.
✓ Branch 3 taken 29 times.
✓ Branch 4 taken 23 times.
✓ Branch 5 taken 93 times.
✓ Branch 6 taken 1900 times.
✓ Branch 7 taken 3470 times.
5463 || ((s->mb_x || (i == 1 || i == 3)) && v->mb_type[s->block_index[i] - 1])) {
1411 3694 intrapred = 1;
1412 3694 break;
1413 }
1414 }
1415
2/2
✓ Branch 0 taken 3694 times.
✓ Branch 1 taken 16462 times.
20156 if (intrapred)
1416 3694 s->ac_pred = get_bits1(gb);
1417 else
1418 16462 s->ac_pred = 0;
1419 }
1420
4/4
✓ Branch 0 taken 19197 times.
✓ Branch 1 taken 959 times.
✓ Branch 2 taken 18220 times.
✓ Branch 3 taken 977 times.
20156 if (!v->ttmbf && coded_inter)
1421 18220 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
1422
2/2
✓ Branch 0 taken 120936 times.
✓ Branch 1 taken 20156 times.
141092 for (i = 0; i < 6; i++) {
1423 120936 dst_idx += i >> 2;
1424
2/2
✓ Branch 0 taken 80624 times.
✓ Branch 1 taken 40312 times.
120936 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
1425 120936 s->mb_intra = is_intra[i];
1426
2/2
✓ Branch 0 taken 13000 times.
✓ Branch 1 taken 107936 times.
120936 if (is_intra[i]) {
1427 /* check if prediction blocks A and C are available */
1428 13000 v->a_avail = v->c_avail = 0;
1429
6/6
✓ Branch 0 taken 10330 times.
✓ Branch 1 taken 2670 times.
✓ Branch 2 taken 7641 times.
✓ Branch 3 taken 2689 times.
✓ Branch 4 taken 4662 times.
✓ Branch 5 taken 2979 times.
13000 if (i == 2 || i == 3 || !s->first_slice_line)
1430 10021 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
1431
6/6
✓ Branch 0 taken 10345 times.
✓ Branch 1 taken 2655 times.
✓ Branch 2 taken 7656 times.
✓ Branch 3 taken 2689 times.
✓ Branch 4 taken 7460 times.
✓ Branch 5 taken 196 times.
13000 if (i == 1 || i == 3 || s->mb_x)
1432 12804 v->c_avail = v->mb_type[s->block_index[i] - 1];
1433
1434 13000 ret = vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, is_coded[i], mquant,
1435
2/2
✓ Branch 0 taken 2436 times.
✓ Branch 1 taken 10564 times.
13000 (i & 4) ? v->codingset2 : v->codingset);
1436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13000 times.
13000 if (ret < 0)
1437 return ret;
1438 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1439 continue;
1440 13000 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1441
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13000 times.
13000 if (v->rangeredfrm)
1442 for (j = 0; j < 64; j++)
1443 v->block[v->cur_blk_idx][block_map[i]][j] *= 2;
1444 13000 block_cbp |= 0xF << (i << 2);
1445 13000 block_intra |= 1 << i;
1446
2/2
✓ Branch 0 taken 66705 times.
✓ Branch 1 taken 41231 times.
107936 } else if (is_coded[i]) {
1447 200115 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb,
1448 66705 first_block, s->dest[dst_idx] + off,
1449
2/2
✓ Branch 0 taken 15468 times.
✓ Branch 1 taken 51237 times.
66705 (i & 4) ? s->uvlinesize : s->linesize,
1450 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY),
1451 &block_tt);
1452
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66705 times.
66705 if (pat < 0)
1453 return pat;
1454 66705 block_cbp |= pat << (i << 2);
1455
4/4
✓ Branch 0 taken 63583 times.
✓ Branch 1 taken 3122 times.
✓ Branch 2 taken 44004 times.
✓ Branch 3 taken 19579 times.
66705 if (!v->ttmbf && ttmb < 8)
1456 44004 ttmb = -1;
1457 66705 first_block = 0;
1458 }
1459 }
1460 } else { // skipped MB
1461 3721 s->mb_intra = 0;
1462 3721 s->cur_pic.qscale_table[mb_pos] = 0;
1463
2/2
✓ Branch 0 taken 22326 times.
✓ Branch 1 taken 3721 times.
26047 for (i = 0; i < 6; i++) {
1464 22326 v->mb_type[s->block_index[i]] = 0;
1465 22326 s->dc_val[s->block_index[i]] = 0;
1466 }
1467
2/2
✓ Branch 0 taken 14884 times.
✓ Branch 1 taken 3721 times.
18605 for (i = 0; i < 4; i++) {
1468 14884 ff_vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type, 0, 0);
1469 14884 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1470 }
1471 3721 ff_vc1_mc_4mv_chroma(v, 0);
1472 3721 s->cur_pic.qscale_table[mb_pos] = 0;
1473 }
1474 }
1475 152608 end:
1476
3/4
✓ Branch 0 taken 107428 times.
✓ Branch 1 taken 45180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107428 times.
152608 if (v->overlap && v->pq >= 9)
1477 ff_vc1_p_overlap_filter(v);
1478 152608 vc1_put_blocks_clamped(v, 1);
1479
1480 152608 v->cbp[s->mb_x] = block_cbp;
1481 152608 v->ttblk[s->mb_x] = block_tt;
1482 152608 v->is_intra[s->mb_x] = block_intra;
1483
1484 152608 return 0;
1485 }
1486
1487 /* Decode one macroblock in an interlaced frame p picture */
1488
1489 16320 static int vc1_decode_p_mb_intfr(VC1Context *v)
1490 {
1491 16320 MpegEncContext *s = &v->s;
1492 16320 GetBitContext *const gb = &v->gb;
1493 int i;
1494 16320 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1495 16320 int cbp = 0; /* cbp decoding stuff */
1496 int mqdiff, mquant; /* MB quantization */
1497 16320 int ttmb = v->ttfrm; /* MB Transform type */
1498
1499 16320 int mb_has_coeffs = 1; /* last_flag */
1500 int dmv_x, dmv_y; /* Differential MV components */
1501 int val; /* temp value */
1502 16320 int first_block = 1;
1503 int dst_idx, off;
1504 16320 int skipped, fourmv = 0, twomv = 0;
1505 16320 int block_cbp = 0, pat, block_tt = 0;
1506 16320 int idx_mbmode = 0, mvbp;
1507 int fieldtx;
1508 int ret;
1509
1510 16320 mquant = v->pq; /* Lossy initialization */
1511
1512
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if (v->skip_is_raw)
1513 skipped = get_bits1(gb);
1514 else
1515 16320 skipped = v->s.mbskip_table[mb_pos];
1516
2/2
✓ Branch 0 taken 16307 times.
✓ Branch 1 taken 13 times.
16320 if (!skipped) {
1517
1/2
✓ Branch 0 taken 16307 times.
✗ Branch 1 not taken.
16307 if (v->fourmvswitch)
1518 16307 idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done
1519 else
1520 idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line
1521
5/5
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 1084 times.
✓ Branch 2 taken 4797 times.
✓ Branch 3 taken 8046 times.
✓ Branch 4 taken 1676 times.
16307 switch (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0]) {
1522 /* store the motion vector type in a flag (useful later) */
1523 704 case MV_PMODE_INTFR_4MV:
1524 704 fourmv = 1;
1525 704 v->blk_mv_type[s->block_index[0]] = 0;
1526 704 v->blk_mv_type[s->block_index[1]] = 0;
1527 704 v->blk_mv_type[s->block_index[2]] = 0;
1528 704 v->blk_mv_type[s->block_index[3]] = 0;
1529 704 break;
1530 1084 case MV_PMODE_INTFR_4MV_FIELD:
1531 1084 fourmv = 1;
1532 1084 v->blk_mv_type[s->block_index[0]] = 1;
1533 1084 v->blk_mv_type[s->block_index[1]] = 1;
1534 1084 v->blk_mv_type[s->block_index[2]] = 1;
1535 1084 v->blk_mv_type[s->block_index[3]] = 1;
1536 1084 break;
1537 4797 case MV_PMODE_INTFR_2MV_FIELD:
1538 4797 twomv = 1;
1539 4797 v->blk_mv_type[s->block_index[0]] = 1;
1540 4797 v->blk_mv_type[s->block_index[1]] = 1;
1541 4797 v->blk_mv_type[s->block_index[2]] = 1;
1542 4797 v->blk_mv_type[s->block_index[3]] = 1;
1543 4797 break;
1544 8046 case MV_PMODE_INTFR_1MV:
1545 8046 v->blk_mv_type[s->block_index[0]] = 0;
1546 8046 v->blk_mv_type[s->block_index[1]] = 0;
1547 8046 v->blk_mv_type[s->block_index[2]] = 0;
1548 8046 v->blk_mv_type[s->block_index[3]] = 0;
1549 8046 break;
1550 }
1551
2/2
✓ Branch 0 taken 1676 times.
✓ Branch 1 taken 14631 times.
16307 if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { // intra MB
1552
2/2
✓ Branch 0 taken 6704 times.
✓ Branch 1 taken 1676 times.
8380 for (i = 0; i < 4; i++) {
1553 6704 s->cur_pic.motion_val[1][s->block_index[i]][0] = 0;
1554 6704 s->cur_pic.motion_val[1][s->block_index[i]][1] = 0;
1555 }
1556 1676 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
1557 1676 s->mb_intra = 1;
1558 1676 s->cur_pic.mb_type[mb_pos] = MB_TYPE_INTRA;
1559 1676 fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
1560 1676 mb_has_coeffs = get_bits1(gb);
1561
2/2
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 61 times.
1676 if (mb_has_coeffs)
1562 1615 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1563 1676 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
1564
15/38
✓ Branch 0 taken 1676 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1676 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1676 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 347 times.
✓ Branch 8 taken 1329 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 1676 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 1676 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 1676 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 1676 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 1676 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1676 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 1676 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 1676 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 1676 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 1676 times.
1676 GET_MQUANT();
1565 1676 s->cur_pic.qscale_table[mb_pos] = mquant;
1566 /* Set DC scale - y and c use the same so we only set y */
1567 1676 s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)];
1568 1676 dst_idx = 0;
1569
2/2
✓ Branch 0 taken 10056 times.
✓ Branch 1 taken 1676 times.
11732 for (i = 0; i < 6; i++) {
1570 10056 v->a_avail = v->c_avail = 0;
1571 10056 v->mb_type[s->block_index[i]] = 1;
1572 10056 s->dc_val[s->block_index[i]] = 0;
1573 10056 dst_idx += i >> 2;
1574 10056 val = ((cbp >> (5 - i)) & 1);
1575
6/6
✓ Branch 0 taken 8380 times.
✓ Branch 1 taken 1676 times.
✓ Branch 2 taken 6704 times.
✓ Branch 3 taken 1676 times.
✓ Branch 4 taken 6488 times.
✓ Branch 5 taken 216 times.
10056 if (i == 2 || i == 3 || !s->first_slice_line)
1576 9840 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
1577
6/6
✓ Branch 0 taken 8380 times.
✓ Branch 1 taken 1676 times.
✓ Branch 2 taken 6704 times.
✓ Branch 3 taken 1676 times.
✓ Branch 4 taken 6648 times.
✓ Branch 5 taken 56 times.
10056 if (i == 1 || i == 3 || s->mb_x)
1578 10000 v->c_avail = v->mb_type[s->block_index[i] - 1];
1579
1580 10056 ret = vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, val, mquant,
1581
2/2
✓ Branch 0 taken 3352 times.
✓ Branch 1 taken 6704 times.
10056 (i & 4) ? v->codingset2 : v->codingset);
1582
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10056 times.
10056 if (ret < 0)
1583 return ret;
1584 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1585 continue;
1586 10056 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1587 10056 block_cbp |= 0xf << (i << 2);
1588 }
1589
1590 } else { // inter MB
1591 14631 mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];
1592
2/2
✓ Branch 0 taken 13330 times.
✓ Branch 1 taken 1301 times.
14631 if (mb_has_coeffs)
1593 13330 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1594
2/2
✓ Branch 0 taken 4797 times.
✓ Branch 1 taken 9834 times.
14631 if (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
1595 4797 v->twomvbp = get_vlc2(gb, v->twomvbp_vlc, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
1596 } else {
1597
2/2
✓ Branch 0 taken 9130 times.
✓ Branch 1 taken 704 times.
9834 if ((ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV)
1598
2/2
✓ Branch 0 taken 1084 times.
✓ Branch 1 taken 8046 times.
9130 || (ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][0] == MV_PMODE_INTFR_4MV_FIELD)) {
1599 1788 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
1600 }
1601 }
1602 14631 s->mb_intra = v->is_intra[s->mb_x] = 0;
1603
2/2
✓ Branch 0 taken 87786 times.
✓ Branch 1 taken 14631 times.
102417 for (i = 0; i < 6; i++)
1604 87786 v->mb_type[s->block_index[i]] = 0;
1605 14631 fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];
1606 /* for all motion vector read MVDATA and motion compensate each block */
1607 14631 dst_idx = 0;
1608
2/2
✓ Branch 0 taken 1788 times.
✓ Branch 1 taken 12843 times.
14631 if (fourmv) {
1609 1788 mvbp = v->fourmvbp;
1610
2/2
✓ Branch 0 taken 7152 times.
✓ Branch 1 taken 1788 times.
8940 for (i = 0; i < 4; i++) {
1611 7152 dmv_x = dmv_y = 0;
1612
2/2
✓ Branch 0 taken 5798 times.
✓ Branch 1 taken 1354 times.
7152 if (mvbp & (8 >> i))
1613 5798 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1614 7152 ff_vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, 0);
1615 7152 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1616 }
1617 1788 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
1618
2/2
✓ Branch 0 taken 4797 times.
✓ Branch 1 taken 8046 times.
12843 } else if (twomv) {
1619 4797 mvbp = v->twomvbp;
1620 4797 dmv_x = dmv_y = 0;
1621
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 284 times.
4797 if (mvbp & 2) {
1622 4513 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1623 }
1624 4797 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, 0);
1625 4797 ff_vc1_mc_4mv_luma(v, 0, 0, 0);
1626 4797 ff_vc1_mc_4mv_luma(v, 1, 0, 0);
1627 4797 dmv_x = dmv_y = 0;
1628
2/2
✓ Branch 0 taken 4517 times.
✓ Branch 1 taken 280 times.
4797 if (mvbp & 1) {
1629 4517 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1630 }
1631 4797 ff_vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, 0);
1632 4797 ff_vc1_mc_4mv_luma(v, 2, 0, 0);
1633 4797 ff_vc1_mc_4mv_luma(v, 3, 0, 0);
1634 4797 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
1635 } else {
1636 8046 mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];
1637 8046 dmv_x = dmv_y = 0;
1638
2/2
✓ Branch 0 taken 7892 times.
✓ Branch 1 taken 154 times.
8046 if (mvbp) {
1639 7892 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1640 }
1641 8046 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, 0);
1642 8046 ff_vc1_mc_1mv(v, 0);
1643 }
1644
2/2
✓ Branch 0 taken 13330 times.
✓ Branch 1 taken 1301 times.
14631 if (cbp)
1645
15/38
✓ Branch 0 taken 13330 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13330 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 13330 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3698 times.
✓ Branch 8 taken 9632 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 13330 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 13330 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 13330 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 13330 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 13330 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 13330 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 13330 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 13330 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 13330 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 13330 times.
13330 GET_MQUANT(); // p. 227
1646 14631 s->cur_pic.qscale_table[mb_pos] = mquant;
1647
3/4
✓ Branch 0 taken 14631 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13330 times.
✓ Branch 3 taken 1301 times.
14631 if (!v->ttmbf && cbp)
1648 13330 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
1649
2/2
✓ Branch 0 taken 87786 times.
✓ Branch 1 taken 14631 times.
102417 for (i = 0; i < 6; i++) {
1650 87786 s->dc_val[s->block_index[i]] = 0;
1651 87786 dst_idx += i >> 2;
1652 87786 val = ((cbp >> (5 - i)) & 1);
1653
2/2
✓ Branch 0 taken 70050 times.
✓ Branch 1 taken 17736 times.
87786 if (!fieldtx)
1654
2/2
✓ Branch 0 taken 46700 times.
✓ Branch 1 taken 23350 times.
70050 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
1655 else
1656
2/2
✓ Branch 0 taken 11824 times.
✓ Branch 1 taken 5912 times.
17736 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
1657
2/2
✓ Branch 0 taken 63627 times.
✓ Branch 1 taken 24159 times.
87786 if (val) {
1658 190881 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb,
1659 63627 first_block, s->dest[dst_idx] + off,
1660
2/2
✓ Branch 0 taken 20177 times.
✓ Branch 1 taken 43450 times.
63627 (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
1661 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
1662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63627 times.
63627 if (pat < 0)
1663 return pat;
1664 63627 block_cbp |= pat << (i << 2);
1665
3/4
✓ Branch 0 taken 63627 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44047 times.
✓ Branch 3 taken 19580 times.
63627 if (!v->ttmbf && ttmb < 8)
1666 44047 ttmb = -1;
1667 63627 first_block = 0;
1668 }
1669 }
1670 }
1671 } else { // skipped
1672 13 s->mb_intra = v->is_intra[s->mb_x] = 0;
1673
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 13 times.
91 for (i = 0; i < 6; i++) {
1674 78 v->mb_type[s->block_index[i]] = 0;
1675 78 s->dc_val[s->block_index[i]] = 0;
1676 }
1677 13 s->cur_pic.mb_type[mb_pos] = MB_TYPE_SKIP;
1678 13 s->cur_pic.qscale_table[mb_pos] = 0;
1679 13 v->blk_mv_type[s->block_index[0]] = 0;
1680 13 v->blk_mv_type[s->block_index[1]] = 0;
1681 13 v->blk_mv_type[s->block_index[2]] = 0;
1682 13 v->blk_mv_type[s->block_index[3]] = 0;
1683 13 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, 0);
1684 13 ff_vc1_mc_1mv(v, 0);
1685 13 v->fieldtx_plane[mb_pos] = 0;
1686 }
1687
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
16320 if (v->overlap && v->pq >= 9)
1688 ff_vc1_p_overlap_filter(v);
1689 16320 vc1_put_blocks_clamped(v, 1);
1690
1691 16320 v->cbp[s->mb_x] = block_cbp;
1692 16320 v->ttblk[s->mb_x] = block_tt;
1693
1694 16320 return 0;
1695 }
1696
1697 37920 static int vc1_decode_p_mb_intfi(VC1Context *v)
1698 {
1699 37920 MpegEncContext *s = &v->s;
1700 37920 GetBitContext *const gb = &v->gb;
1701 int i;
1702 37920 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1703 37920 int cbp = 0; /* cbp decoding stuff */
1704 int mqdiff, mquant; /* MB quantization */
1705 37920 int ttmb = v->ttfrm; /* MB Transform type */
1706
1707 37920 int mb_has_coeffs = 1; /* last_flag */
1708 int dmv_x, dmv_y; /* Differential MV components */
1709 int val; /* temp values */
1710 37920 int first_block = 1;
1711 int dst_idx, off;
1712 37920 int pred_flag = 0;
1713 37920 int block_cbp = 0, pat, block_tt = 0;
1714 37920 int idx_mbmode = 0;
1715 int ret;
1716
1717 37920 mquant = v->pq; /* Lossy initialization */
1718
1719 37920 idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_IF_MBMODE_VLC_BITS, 2);
1720
2/2
✓ Branch 0 taken 10225 times.
✓ Branch 1 taken 27695 times.
37920 if (idx_mbmode <= 1) { // intra MB
1721 10225 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
1722 10225 s->mb_intra = 1;
1723 10225 s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
1724 10225 s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
1725 10225 s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
1726
16/38
✓ Branch 0 taken 2966 times.
✓ Branch 1 taken 7259 times.
✓ Branch 2 taken 2966 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2966 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 189 times.
✓ Branch 8 taken 2777 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 2966 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2966 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 2966 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 2966 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 2966 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 2966 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 2966 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 2966 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 2966 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 2966 times.
10225 GET_MQUANT();
1727 10225 s->cur_pic.qscale_table[mb_pos] = mquant;
1728 /* Set DC scale - y and c use the same so we only set y */
1729 10225 s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)];
1730 10225 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
1731 10225 mb_has_coeffs = idx_mbmode & 1;
1732
2/2
✓ Branch 0 taken 9472 times.
✓ Branch 1 taken 753 times.
10225 if (mb_has_coeffs)
1733 9472 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_ICBPCY_VLC_BITS, 2);
1734 10225 dst_idx = 0;
1735
2/2
✓ Branch 0 taken 61350 times.
✓ Branch 1 taken 10225 times.
71575 for (i = 0; i < 6; i++) {
1736 61350 v->a_avail = v->c_avail = 0;
1737 61350 v->mb_type[s->block_index[i]] = 1;
1738 61350 s->dc_val[s->block_index[i]] = 0;
1739 61350 dst_idx += i >> 2;
1740 61350 val = ((cbp >> (5 - i)) & 1);
1741
6/6
✓ Branch 0 taken 51125 times.
✓ Branch 1 taken 10225 times.
✓ Branch 2 taken 40900 times.
✓ Branch 3 taken 10225 times.
✓ Branch 4 taken 38332 times.
✓ Branch 5 taken 2568 times.
61350 if (i == 2 || i == 3 || !s->first_slice_line)
1742 58782 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
1743
6/6
✓ Branch 0 taken 51125 times.
✓ Branch 1 taken 10225 times.
✓ Branch 2 taken 40900 times.
✓ Branch 3 taken 10225 times.
✓ Branch 4 taken 40116 times.
✓ Branch 5 taken 784 times.
61350 if (i == 1 || i == 3 || s->mb_x)
1744 60566 v->c_avail = v->mb_type[s->block_index[i] - 1];
1745
1746 61350 ret = vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, val, mquant,
1747
2/2
✓ Branch 0 taken 20450 times.
✓ Branch 1 taken 40900 times.
61350 (i & 4) ? v->codingset2 : v->codingset);
1748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 61350 times.
61350 if (ret < 0)
1749 return ret;
1750 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1751 continue;
1752 61350 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1753 61350 block_cbp |= 0xf << (i << 2);
1754 }
1755 } else {
1756 27695 s->mb_intra = v->is_intra[s->mb_x] = 0;
1757 27695 s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
1758
2/2
✓ Branch 0 taken 166170 times.
✓ Branch 1 taken 27695 times.
193865 for (i = 0; i < 6; i++)
1759 166170 v->mb_type[s->block_index[i]] = 0;
1760
2/2
✓ Branch 0 taken 20627 times.
✓ Branch 1 taken 7068 times.
27695 if (idx_mbmode <= 5) { // 1-MV
1761 20627 dmv_x = dmv_y = pred_flag = 0;
1762
2/2
✓ Branch 0 taken 15875 times.
✓ Branch 1 taken 4752 times.
20627 if (idx_mbmode & 1) {
1763 15875 get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag);
1764 }
1765 20627 ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type, pred_flag, 0);
1766 20627 ff_vc1_mc_1mv(v, 0);
1767 20627 mb_has_coeffs = !(idx_mbmode & 2);
1768 } else { // 4-MV
1769 7068 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
1770
2/2
✓ Branch 0 taken 28272 times.
✓ Branch 1 taken 7068 times.
35340 for (i = 0; i < 4; i++) {
1771 28272 dmv_x = dmv_y = pred_flag = 0;
1772
2/2
✓ Branch 0 taken 8553 times.
✓ Branch 1 taken 19719 times.
28272 if (v->fourmvbp & (8 >> i))
1773 8553 get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag);
1774 28272 ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type, pred_flag, 0);
1775 28272 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1776 }
1777 7068 ff_vc1_mc_4mv_chroma(v, 0);
1778 7068 mb_has_coeffs = idx_mbmode & 1;
1779 }
1780
2/2
✓ Branch 0 taken 20790 times.
✓ Branch 1 taken 6905 times.
27695 if (mb_has_coeffs)
1781 20790 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1782
2/2
✓ Branch 0 taken 20790 times.
✓ Branch 1 taken 6905 times.
27695 if (cbp) {
1783
16/38
✓ Branch 0 taken 12145 times.
✓ Branch 1 taken 8645 times.
✓ Branch 2 taken 12145 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 12145 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 3055 times.
✓ Branch 8 taken 9090 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 12145 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 12145 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 12145 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 12145 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 12145 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 12145 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 12145 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 12145 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 12145 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 12145 times.
20790 GET_MQUANT();
1784 }
1785 27695 s->cur_pic.qscale_table[mb_pos] = mquant;
1786
3/4
✓ Branch 0 taken 27695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20790 times.
✓ Branch 3 taken 6905 times.
27695 if (!v->ttmbf && cbp) {
1787 20790 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
1788 }
1789 27695 dst_idx = 0;
1790
2/2
✓ Branch 0 taken 166170 times.
✓ Branch 1 taken 27695 times.
193865 for (i = 0; i < 6; i++) {
1791 166170 s->dc_val[s->block_index[i]] = 0;
1792 166170 dst_idx += i >> 2;
1793 166170 val = ((cbp >> (5 - i)) & 1);
1794
2/2
✓ Branch 0 taken 110780 times.
✓ Branch 1 taken 55390 times.
166170 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
1795
2/2
✓ Branch 0 taken 91115 times.
✓ Branch 1 taken 75055 times.
166170 if (val) {
1796 273345 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb,
1797 91115 first_block, s->dest[dst_idx] + off,
1798
2/2
✓ Branch 0 taken 24386 times.
✓ Branch 1 taken 66729 times.
91115 (i & 4) ? s->uvlinesize : s->linesize,
1799 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY),
1800 &block_tt);
1801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91115 times.
91115 if (pat < 0)
1802 return pat;
1803 91115 block_cbp |= pat << (i << 2);
1804
3/4
✓ Branch 0 taken 91115 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 59029 times.
✓ Branch 3 taken 32086 times.
91115 if (!v->ttmbf && ttmb < 8)
1805 59029 ttmb = -1;
1806 91115 first_block = 0;
1807 }
1808 }
1809 }
1810
3/4
✓ Branch 0 taken 21600 times.
✓ Branch 1 taken 16320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 21600 times.
37920 if (v->overlap && v->pq >= 9)
1811 ff_vc1_p_overlap_filter(v);
1812 37920 vc1_put_blocks_clamped(v, 1);
1813
1814 37920 v->cbp[s->mb_x] = block_cbp;
1815 37920 v->ttblk[s->mb_x] = block_tt;
1816
1817 37920 return 0;
1818 }
1819
1820 /** Decode one B-frame MB (in Main profile)
1821 */
1822 20940 static int vc1_decode_b_mb(VC1Context *v)
1823 {
1824 20940 MpegEncContext *s = &v->s;
1825 20940 GetBitContext *const gb = &v->gb;
1826 int i, j;
1827 20940 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1828 20940 int cbp = 0; /* cbp decoding stuff */
1829 int mqdiff, mquant; /* MB quantization */
1830 20940 int ttmb = v->ttfrm; /* MB Transform type */
1831 20940 int mb_has_coeffs = 0; /* last_flag */
1832 int index, index1; /* LUT indexes */
1833 int val, sign; /* temp values */
1834 20940 int first_block = 1;
1835 int dst_idx, off;
1836 int skipped, direct;
1837 int dmv_x[2], dmv_y[2];
1838 20940 int bmvtype = BMV_TYPE_BACKWARD;
1839 int ret;
1840
1841 20940 mquant = v->pq; /* lossy initialization */
1842 20940 s->mb_intra = 0;
1843
1844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20940 times.
20940 if (v->dmb_is_raw)
1845 direct = get_bits1(gb);
1846 else
1847 20940 direct = v->direct_mb_plane[mb_pos];
1848
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20940 times.
20940 if (v->skip_is_raw)
1849 skipped = get_bits1(gb);
1850 else
1851 20940 skipped = v->s.mbskip_table[mb_pos];
1852
1853 20940 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1854
2/2
✓ Branch 0 taken 125640 times.
✓ Branch 1 taken 20940 times.
146580 for (i = 0; i < 6; i++) {
1855 125640 v->mb_type[s->block_index[i]] = 0;
1856 125640 s->dc_val[s->block_index[i]] = 0;
1857 }
1858 20940 s->cur_pic.qscale_table[mb_pos] = 0;
1859
1860
2/2
✓ Branch 0 taken 18371 times.
✓ Branch 1 taken 2569 times.
20940 if (!direct) {
1861
2/2
✓ Branch 0 taken 15906 times.
✓ Branch 1 taken 2465 times.
18371 if (!skipped) {
1862
14/20
✓ Branch 1 taken 14871 times.
✓ Branch 2 taken 1035 times.
✓ Branch 3 taken 6626 times.
✓ Branch 4 taken 9280 times.
✓ Branch 5 taken 146 times.
✓ Branch 6 taken 9134 times.
✓ Branch 9 taken 170 times.
✓ Branch 10 taken 8964 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 8964 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 7005 times.
✓ Branch 16 taken 1959 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 8964 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 6314 times.
✓ Branch 23 taken 2650 times.
15906 GET_MVDATA(dmv_x[0], dmv_y[0]);
1863 15906 dmv_x[1] = dmv_x[0];
1864 15906 dmv_y[1] = dmv_y[0];
1865 }
1866
4/4
✓ Branch 0 taken 15906 times.
✓ Branch 1 taken 2465 times.
✓ Branch 2 taken 15736 times.
✓ Branch 3 taken 170 times.
18371 if (skipped || !s->mb_intra) {
1867 18201 bmvtype = decode012(gb);
1868
3/4
✓ Branch 0 taken 8021 times.
✓ Branch 1 taken 4023 times.
✓ Branch 2 taken 6157 times.
✗ Branch 3 not taken.
18201 switch (bmvtype) {
1869 8021 case 0:
1870 8021 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD;
1871 8021 break;
1872 4023 case 1:
1873 4023 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD;
1874 4023 break;
1875 6157 case 2:
1876 6157 bmvtype = BMV_TYPE_INTERPOLATED;
1877 6157 dmv_x[0] = dmv_y[0] = 0;
1878 }
1879 }
1880 }
1881
2/2
✓ Branch 0 taken 125640 times.
✓ Branch 1 taken 20940 times.
146580 for (i = 0; i < 6; i++)
1882 125640 v->mb_type[s->block_index[i]] = s->mb_intra;
1883
1884
2/2
✓ Branch 0 taken 3578 times.
✓ Branch 1 taken 17362 times.
20940 if (skipped) {
1885
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 2465 times.
3578 if (direct)
1886 1113 bmvtype = BMV_TYPE_INTERPOLATED;
1887 3578 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1888 3578 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1889 3578 return 0;
1890 }
1891
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 15906 times.
17362 if (direct) {
1892 1456 cbp = get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1893
1/38
✗ Branch 0 not taken.
✓ Branch 1 taken 1456 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
1456 GET_MQUANT();
1894 1456 s->mb_intra = 0;
1895 1456 s->cur_pic.qscale_table[mb_pos] = mquant;
1896
1/2
✓ Branch 0 taken 1456 times.
✗ Branch 1 not taken.
1456 if (!v->ttmbf)
1897 1456 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
1898 1456 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1899 1456 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1900 1456 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1901 } else {
1902
3/4
✓ Branch 0 taken 1035 times.
✓ Branch 1 taken 14871 times.
✓ Branch 2 taken 1035 times.
✗ Branch 3 not taken.
15906 if (!mb_has_coeffs && !s->mb_intra) {
1903 /* no coded blocks - effectively skipped */
1904 1035 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1905 1035 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1906 1035 return 0;
1907 }
1908
3/4
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 14701 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 170 times.
14871 if (s->mb_intra && !mb_has_coeffs) {
1909 GET_MQUANT();
1910 s->cur_pic.qscale_table[mb_pos] = mquant;
1911 s->ac_pred = get_bits1(gb);
1912 cbp = 0;
1913 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1914 } else {
1915
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 9582 times.
14871 if (bmvtype == BMV_TYPE_INTERPOLATED) {
1916
13/20
✓ Branch 1 taken 4814 times.
✓ Branch 2 taken 475 times.
✓ Branch 3 taken 1908 times.
✓ Branch 4 taken 3381 times.
✓ Branch 5 taken 72 times.
✓ Branch 6 taken 3309 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 3309 times.
✗ Branch 11 not taken.
✓ Branch 12 taken 3309 times.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✓ Branch 15 taken 2641 times.
✓ Branch 16 taken 668 times.
✗ Branch 18 not taken.
✓ Branch 19 taken 3309 times.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✓ Branch 22 taken 2422 times.
✓ Branch 23 taken 887 times.
5289 GET_MVDATA(dmv_x[0], dmv_y[0]);
1917
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 4814 times.
5289 if (!mb_has_coeffs) {
1918 /* interpolated skipped block */
1919 475 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1920 475 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1921 475 return 0;
1922 }
1923 }
1924 14396 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1925
2/2
✓ Branch 0 taken 14226 times.
✓ Branch 1 taken 170 times.
14396 if (!s->mb_intra) {
1926 14226 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1927 }
1928
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 14226 times.
14396 if (s->mb_intra)
1929 170 s->ac_pred = get_bits1(gb);
1930 14396 cbp = get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
1931
1/38
✗ Branch 0 not taken.
✓ Branch 1 taken 14396 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✗ Branch 24 not taken.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✗ Branch 28 not taken.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✗ Branch 32 not taken.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✗ Branch 35 not taken.
✗ Branch 36 not taken.
✗ Branch 37 not taken.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✗ Branch 40 not taken.
14396 GET_MQUANT();
1932 14396 s->cur_pic.qscale_table[mb_pos] = mquant;
1933
4/6
✓ Branch 0 taken 14396 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14226 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 14226 times.
✗ Branch 5 not taken.
14396 if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
1934 14226 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
1935 }
1936 }
1937 15852 dst_idx = 0;
1938
2/2
✓ Branch 0 taken 95112 times.
✓ Branch 1 taken 15852 times.
110964 for (i = 0; i < 6; i++) {
1939 95112 s->dc_val[s->block_index[i]] = 0;
1940 95112 dst_idx += i >> 2;
1941 95112 val = ((cbp >> (5 - i)) & 1);
1942
2/2
✓ Branch 0 taken 63408 times.
✓ Branch 1 taken 31704 times.
95112 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
1943 95112 v->mb_type[s->block_index[i]] = s->mb_intra;
1944
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 94092 times.
95112 if (s->mb_intra) {
1945 /* check if prediction blocks A and C are available */
1946 1020 v->a_avail = v->c_avail = 0;
1947
6/6
✓ Branch 0 taken 850 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 680 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 656 times.
✓ Branch 5 taken 24 times.
1020 if (i == 2 || i == 3 || !s->first_slice_line)
1948 996 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
1949
6/6
✓ Branch 0 taken 850 times.
✓ Branch 1 taken 170 times.
✓ Branch 2 taken 680 times.
✓ Branch 3 taken 170 times.
✓ Branch 4 taken 652 times.
✓ Branch 5 taken 28 times.
1020 if (i == 1 || i == 3 || s->mb_x)
1950 992 v->c_avail = v->mb_type[s->block_index[i] - 1];
1951
1952 1020 ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
1953
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 680 times.
1020 (i & 4) ? v->codingset2 : v->codingset);
1954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1020 times.
1020 if (ret < 0)
1955 return ret;
1956 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1957 continue;
1958 1020 v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
1959
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1020 times.
1020 if (v->rangeredfrm)
1960 for (j = 0; j < 64; j++)
1961 v->blocks[i][j] *= 2;
1962 1020 s->idsp.put_signed_pixels_clamped(v->blocks[i],
1963 1020 s->dest[dst_idx] + off,
1964
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 680 times.
1020 i & 4 ? s->uvlinesize
1965 : s->linesize);
1966
2/2
✓ Branch 0 taken 57465 times.
✓ Branch 1 taken 36627 times.
94092 } else if (val) {
1967 172395 int pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
1968 57465 first_block, s->dest[dst_idx] + off,
1969
2/2
✓ Branch 0 taken 10287 times.
✓ Branch 1 taken 47178 times.
57465 (i & 4) ? s->uvlinesize : s->linesize,
1970 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL);
1971
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57465 times.
57465 if (pat < 0)
1972 return pat;
1973
3/4
✓ Branch 0 taken 57465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 54531 times.
✓ Branch 3 taken 2934 times.
57465 if (!v->ttmbf && ttmb < 8)
1974 54531 ttmb = -1;
1975 57465 first_block = 0;
1976 }
1977 }
1978 15852 return 0;
1979 }
1980
1981 /** Decode one B-frame MB (in interlaced field B picture)
1982 */
1983 51540 static int vc1_decode_b_mb_intfi(VC1Context *v)
1984 {
1985 51540 MpegEncContext *s = &v->s;
1986 51540 GetBitContext *const gb = &v->gb;
1987 int i, j;
1988 51540 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1989 51540 int cbp = 0; /* cbp decoding stuff */
1990 int mqdiff, mquant; /* MB quantization */
1991 51540 int ttmb = v->ttfrm; /* MB Transform type */
1992 51540 int mb_has_coeffs = 0; /* last_flag */
1993 int val; /* temp value */
1994 51540 int first_block = 1;
1995 int dst_idx, off;
1996 int fwd;
1997 int dmv_x[2], dmv_y[2], pred_flag[2];
1998 51540 int bmvtype = BMV_TYPE_BACKWARD;
1999 51540 int block_cbp = 0, pat, block_tt = 0;
2000 int idx_mbmode;
2001 int ret;
2002
2003 51540 mquant = v->pq; /* Lossy initialization */
2004 51540 s->mb_intra = 0;
2005
2006 51540 idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_IF_MBMODE_VLC_BITS, 2);
2007
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 51492 times.
51540 if (idx_mbmode <= 1) { // intra MB
2008 48 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
2009 48 s->mb_intra = 1;
2010 48 s->cur_pic.motion_val[1][s->block_index[0]][0] = 0;
2011 48 s->cur_pic.motion_val[1][s->block_index[0]][1] = 0;
2012 48 s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
2013
15/38
✓ Branch 0 taken 48 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 48 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 32 times.
✓ Branch 8 taken 16 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 48 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 48 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 48 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 48 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 48 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 48 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 48 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 48 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 48 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 48 times.
48 GET_MQUANT();
2014 48 s->cur_pic.qscale_table[mb_pos] = mquant;
2015 /* Set DC scale - y and c use the same so we only set y */
2016 48 s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)];
2017 48 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
2018 48 mb_has_coeffs = idx_mbmode & 1;
2019
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 15 times.
48 if (mb_has_coeffs)
2020 33 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_ICBPCY_VLC_BITS, 2);
2021 48 dst_idx = 0;
2022
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 48 times.
336 for (i = 0; i < 6; i++) {
2023 288 v->a_avail = v->c_avail = 0;
2024 288 v->mb_type[s->block_index[i]] = 1;
2025 288 s->dc_val[s->block_index[i]] = 0;
2026 288 dst_idx += i >> 2;
2027 288 val = ((cbp >> (5 - i)) & 1);
2028
5/6
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 192 times.
✗ Branch 5 not taken.
288 if (i == 2 || i == 3 || !s->first_slice_line)
2029 288 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
2030
6/6
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 48 times.
✓ Branch 2 taken 192 times.
✓ Branch 3 taken 48 times.
✓ Branch 4 taken 188 times.
✓ Branch 5 taken 4 times.
288 if (i == 1 || i == 3 || s->mb_x)
2031 284 v->c_avail = v->mb_type[s->block_index[i] - 1];
2032
2033 288 ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
2034
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 192 times.
288 (i & 4) ? v->codingset2 : v->codingset);
2035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if (ret < 0)
2036 return ret;
2037 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2038 continue;
2039 288 v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
2040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if (v->rangeredfrm)
2041 for (j = 0; j < 64; j++)
2042 v->blocks[i][j] <<= 1;
2043
2/2
✓ Branch 0 taken 192 times.
✓ Branch 1 taken 96 times.
288 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
2044 288 s->idsp.put_signed_pixels_clamped(v->blocks[i],
2045 288 s->dest[dst_idx] + off,
2046
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 192 times.
288 (i & 4) ? s->uvlinesize
2047 : s->linesize);
2048 }
2049 } else {
2050 51492 s->mb_intra = v->is_intra[s->mb_x] = 0;
2051 51492 s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
2052
2/2
✓ Branch 0 taken 308952 times.
✓ Branch 1 taken 51492 times.
360444 for (i = 0; i < 6; i++)
2053 308952 v->mb_type[s->block_index[i]] = 0;
2054
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 50817 times.
51492 if (v->fmb_is_raw)
2055 675 fwd = v->forward_mb_plane[mb_pos] = get_bits1(gb);
2056 else
2057 50817 fwd = v->forward_mb_plane[mb_pos];
2058
2/2
✓ Branch 0 taken 42084 times.
✓ Branch 1 taken 9408 times.
51492 if (idx_mbmode <= 5) { // 1-MV
2059 42084 int interpmvp = 0;
2060 42084 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2061 42084 pred_flag[0] = pred_flag[1] = 0;
2062
2/2
✓ Branch 0 taken 15503 times.
✓ Branch 1 taken 26581 times.
42084 if (fwd)
2063 15503 bmvtype = BMV_TYPE_FORWARD;
2064 else {
2065 26581 bmvtype = decode012(gb);
2066
3/4
✓ Branch 0 taken 13925 times.
✓ Branch 1 taken 6770 times.
✓ Branch 2 taken 5886 times.
✗ Branch 3 not taken.
26581 switch (bmvtype) {
2067 13925 case 0:
2068 13925 bmvtype = BMV_TYPE_BACKWARD;
2069 13925 break;
2070 6770 case 1:
2071 6770 bmvtype = BMV_TYPE_DIRECT;
2072 6770 break;
2073 5886 case 2:
2074 5886 bmvtype = BMV_TYPE_INTERPOLATED;
2075 5886 interpmvp = get_bits1(gb);
2076 }
2077 }
2078 42084 v->bmvtype = bmvtype;
2079
4/4
✓ Branch 0 taken 35314 times.
✓ Branch 1 taken 6770 times.
✓ Branch 2 taken 20242 times.
✓ Branch 3 taken 15072 times.
42084 if (bmvtype != BMV_TYPE_DIRECT && idx_mbmode & 1) {
2080 20242 get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
2081 }
2082
2/2
✓ Branch 0 taken 4685 times.
✓ Branch 1 taken 37399 times.
42084 if (interpmvp) {
2083 4685 get_mvdata_interlaced(v, &dmv_x[1], &dmv_y[1], &pred_flag[1]);
2084 }
2085
2/2
✓ Branch 0 taken 6770 times.
✓ Branch 1 taken 35314 times.
42084 if (bmvtype == BMV_TYPE_DIRECT) {
2086 6770 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2087 6770 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6770 times.
6770 if (!s->next_pic.ptr->field_picture) {
2089 av_log(s->avctx, AV_LOG_ERROR, "Mixed field/frame direct mode not supported\n");
2090 return AVERROR_INVALIDDATA;
2091 }
2092 }
2093 42084 ff_vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag);
2094 42084 vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype);
2095 42084 mb_has_coeffs = !(idx_mbmode & 2);
2096 } else { // 4-MV
2097
2/2
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 4516 times.
9408 if (fwd)
2098 4892 bmvtype = BMV_TYPE_FORWARD;
2099 9408 v->bmvtype = bmvtype;
2100 9408 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
2101
2/2
✓ Branch 0 taken 37632 times.
✓ Branch 1 taken 9408 times.
47040 for (i = 0; i < 4; i++) {
2102 37632 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2103 37632 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2104
2/2
✓ Branch 0 taken 10050 times.
✓ Branch 1 taken 27582 times.
37632 if (v->fourmvbp & (8 >> i)) {
2105 10050 get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD],
2106 10050 &dmv_y[bmvtype == BMV_TYPE_BACKWARD],
2107 10050 &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
2108 }
2109 37632 ff_vc1_pred_b_mv_intfi(v, i, dmv_x, dmv_y, 0, pred_flag);
2110 37632 ff_vc1_mc_4mv_luma(v, i, bmvtype == BMV_TYPE_BACKWARD, 0);
2111 }
2112 9408 ff_vc1_mc_4mv_chroma(v, bmvtype == BMV_TYPE_BACKWARD);
2113 9408 mb_has_coeffs = idx_mbmode & 1;
2114 }
2115
2/2
✓ Branch 0 taken 30972 times.
✓ Branch 1 taken 20520 times.
51492 if (mb_has_coeffs)
2116 30972 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
2117
2/2
✓ Branch 0 taken 30972 times.
✓ Branch 1 taken 20520 times.
51492 if (cbp) {
2118
16/38
✓ Branch 0 taken 23186 times.
✓ Branch 1 taken 7786 times.
✓ Branch 2 taken 23186 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 23186 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 2960 times.
✓ Branch 8 taken 20226 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 23186 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 23186 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 23186 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 23186 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 23186 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 23186 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 23186 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 23186 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 23186 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 23186 times.
30972 GET_MQUANT();
2119 }
2120 51492 s->cur_pic.qscale_table[mb_pos] = mquant;
2121
3/4
✓ Branch 0 taken 51492 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30972 times.
✓ Branch 3 taken 20520 times.
51492 if (!v->ttmbf && cbp) {
2122 30972 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
2123 }
2124 51492 dst_idx = 0;
2125
2/2
✓ Branch 0 taken 308952 times.
✓ Branch 1 taken 51492 times.
360444 for (i = 0; i < 6; i++) {
2126 308952 s->dc_val[s->block_index[i]] = 0;
2127 308952 dst_idx += i >> 2;
2128 308952 val = ((cbp >> (5 - i)) & 1);
2129
2/2
✓ Branch 0 taken 205968 times.
✓ Branch 1 taken 102984 times.
308952 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
2130
2/2
✓ Branch 0 taken 91470 times.
✓ Branch 1 taken 217482 times.
308952 if (val) {
2131 274410 pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
2132 91470 first_block, s->dest[dst_idx] + off,
2133
2/2
✓ Branch 0 taken 20546 times.
✓ Branch 1 taken 70924 times.
91470 (i & 4) ? s->uvlinesize : s->linesize,
2134 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
2135
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91470 times.
91470 if (pat < 0)
2136 return pat;
2137 91470 block_cbp |= pat << (i << 2);
2138
3/4
✓ Branch 0 taken 91470 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69969 times.
✓ Branch 3 taken 21501 times.
91470 if (!v->ttmbf && ttmb < 8)
2139 69969 ttmb = -1;
2140 91470 first_block = 0;
2141 }
2142 }
2143 }
2144 51540 v->cbp[s->mb_x] = block_cbp;
2145 51540 v->ttblk[s->mb_x] = block_tt;
2146
2147 51540 return 0;
2148 }
2149
2150 /** Decode one B-frame MB (in interlaced frame B picture)
2151 */
2152 32640 static int vc1_decode_b_mb_intfr(VC1Context *v)
2153 {
2154 32640 MpegEncContext *s = &v->s;
2155 32640 GetBitContext *const gb = &v->gb;
2156 int i, j;
2157 32640 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
2158 32640 int cbp = 0; /* cbp decoding stuff */
2159 int mqdiff, mquant; /* MB quantization */
2160 32640 int ttmb = v->ttfrm; /* MB Transform type */
2161 32640 int mvsw = 0; /* motion vector switch */
2162 32640 int mb_has_coeffs = 1; /* last_flag */
2163 int dmv_x, dmv_y; /* Differential MV components */
2164 int val; /* temp value */
2165 32640 int first_block = 1;
2166 int dst_idx, off;
2167 32640 int skipped, direct, twomv = 0;
2168 32640 int block_cbp = 0, pat, block_tt = 0;
2169 32640 int idx_mbmode = 0, mvbp;
2170 int stride_y, fieldtx;
2171 32640 int bmvtype = BMV_TYPE_BACKWARD;
2172 int dir, dir2;
2173 int ret;
2174
2175 32640 mquant = v->pq; /* Lossy initialization */
2176 32640 s->mb_intra = 0;
2177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32640 times.
32640 if (v->skip_is_raw)
2178 skipped = get_bits1(gb);
2179 else
2180 32640 skipped = v->s.mbskip_table[mb_pos];
2181
2182
2/2
✓ Branch 0 taken 31098 times.
✓ Branch 1 taken 1542 times.
32640 if (!skipped) {
2183 31098 idx_mbmode = get_vlc2(gb, v->mbmode_vlc, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
2184
2/2
✓ Branch 0 taken 17446 times.
✓ Branch 1 taken 13652 times.
31098 if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_2MV_FIELD) {
2185 17446 twomv = 1;
2186 17446 v->blk_mv_type[s->block_index[0]] = 1;
2187 17446 v->blk_mv_type[s->block_index[1]] = 1;
2188 17446 v->blk_mv_type[s->block_index[2]] = 1;
2189 17446 v->blk_mv_type[s->block_index[3]] = 1;
2190 } else {
2191 13652 v->blk_mv_type[s->block_index[0]] = 0;
2192 13652 v->blk_mv_type[s->block_index[1]] = 0;
2193 13652 v->blk_mv_type[s->block_index[2]] = 0;
2194 13652 v->blk_mv_type[s->block_index[3]] = 0;
2195 }
2196 }
2197
2198
2/2
✓ Branch 0 taken 101 times.
✓ Branch 1 taken 32539 times.
32640 if (ff_vc1_mbmode_intfrp[0][idx_mbmode][0] == MV_PMODE_INTFR_INTRA) { // intra MB
2199
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 101 times.
505 for (i = 0; i < 4; i++) {
2200 404 s->mv[0][i][0] = s->cur_pic.motion_val[0][s->block_index[i]][0] = 0;
2201 404 s->mv[0][i][1] = s->cur_pic.motion_val[0][s->block_index[i]][1] = 0;
2202 404 s->mv[1][i][0] = s->cur_pic.motion_val[1][s->block_index[i]][0] = 0;
2203 404 s->mv[1][i][1] = s->cur_pic.motion_val[1][s->block_index[i]][1] = 0;
2204 }
2205 101 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
2206 101 s->mb_intra = 1;
2207 101 s->cur_pic.mb_type[mb_pos] = MB_TYPE_INTRA;
2208 101 fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
2209 101 mb_has_coeffs = get_bits1(gb);
2210
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if (mb_has_coeffs)
2211 101 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
2212 101 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
2213
15/38
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 101 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 101 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 89 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 101 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 101 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 101 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 101 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 101 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 101 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 101 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 101 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 101 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 101 times.
101 GET_MQUANT();
2214 101 s->cur_pic.qscale_table[mb_pos] = mquant;
2215 /* Set DC scale - y and c use the same so we only set y */
2216 101 s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)];
2217 101 dst_idx = 0;
2218
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 101 times.
707 for (i = 0; i < 6; i++) {
2219 606 v->a_avail = v->c_avail = 0;
2220 606 v->mb_type[s->block_index[i]] = 1;
2221 606 s->dc_val[s->block_index[i]] = 0;
2222 606 dst_idx += i >> 2;
2223 606 val = ((cbp >> (5 - i)) & 1);
2224
6/6
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 372 times.
✓ Branch 5 taken 32 times.
606 if (i == 2 || i == 3 || !s->first_slice_line)
2225 574 v->a_avail = v->mb_type[s->block_index[i] - s->block_wrap[i]];
2226
6/6
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 101 times.
✓ Branch 2 taken 404 times.
✓ Branch 3 taken 101 times.
✓ Branch 4 taken 392 times.
✓ Branch 5 taken 12 times.
606 if (i == 1 || i == 3 || s->mb_x)
2227 594 v->c_avail = v->mb_type[s->block_index[i] - 1];
2228
2229 606 ret = vc1_decode_intra_block(v, v->blocks[i], i, val, mquant,
2230
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 404 times.
606 (i & 4) ? v->codingset2 : v->codingset);
2231
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 606 times.
606 if (ret < 0)
2232 return ret;
2233 if (CONFIG_GRAY && i > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2234 continue;
2235 606 v->vc1dsp.vc1_inv_trans_8x8(v->blocks[i]);
2236
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 202 times.
606 if (i < 4) {
2237 404 stride_y = s->linesize << fieldtx;
2238
2/2
✓ Branch 0 taken 320 times.
✓ Branch 1 taken 84 times.
404 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
2239 } else {
2240 202 stride_y = s->uvlinesize;
2241 202 off = 0;
2242 }
2243 606 s->idsp.put_signed_pixels_clamped(v->blocks[i],
2244 606 s->dest[dst_idx] + off,
2245 stride_y);
2246 }
2247 } else {
2248 32539 s->mb_intra = v->is_intra[s->mb_x] = 0;
2249
2250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32539 times.
32539 if (v->dmb_is_raw)
2251 direct = get_bits1(gb);
2252 else
2253 32539 direct = v->direct_mb_plane[mb_pos];
2254
2255
2/2
✓ Branch 0 taken 8474 times.
✓ Branch 1 taken 24065 times.
32539 if (direct) {
2256
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8474 times.
8474 if (s->next_pic.ptr->field_picture)
2257 av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n");
2258 8474 s->mv[0][0][0] = s->cur_pic.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample);
2259 8474 s->mv[0][0][1] = s->cur_pic.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample);
2260 8474 s->mv[1][0][0] = s->cur_pic.motion_val[1][s->block_index[0]][0] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][0], v->bfraction, 1, s->quarter_sample);
2261 8474 s->mv[1][0][1] = s->cur_pic.motion_val[1][s->block_index[0]][1] = scale_mv(s->next_pic.motion_val[1][s->block_index[0]][1], v->bfraction, 1, s->quarter_sample);
2262
2263
2/2
✓ Branch 0 taken 4360 times.
✓ Branch 1 taken 4114 times.
8474 if (twomv) {
2264 4360 s->mv[0][2][0] = s->cur_pic.motion_val[0][s->block_index[2]][0] = scale_mv(s->next_pic.motion_val[1][s->block_index[2]][0], v->bfraction, 0, s->quarter_sample);
2265 4360 s->mv[0][2][1] = s->cur_pic.motion_val[0][s->block_index[2]][1] = scale_mv(s->next_pic.motion_val[1][s->block_index[2]][1], v->bfraction, 0, s->quarter_sample);
2266 4360 s->mv[1][2][0] = s->cur_pic.motion_val[1][s->block_index[2]][0] = scale_mv(s->next_pic.motion_val[1][s->block_index[2]][0], v->bfraction, 1, s->quarter_sample);
2267 4360 s->mv[1][2][1] = s->cur_pic.motion_val[1][s->block_index[2]][1] = scale_mv(s->next_pic.motion_val[1][s->block_index[2]][1], v->bfraction, 1, s->quarter_sample);
2268
2269
2/2
✓ Branch 0 taken 8720 times.
✓ Branch 1 taken 4360 times.
13080 for (i = 1; i < 4; i += 2) {
2270 8720 s->mv[0][i][0] = s->cur_pic.motion_val[0][s->block_index[i]][0] = s->mv[0][i-1][0];
2271 8720 s->mv[0][i][1] = s->cur_pic.motion_val[0][s->block_index[i]][1] = s->mv[0][i-1][1];
2272 8720 s->mv[1][i][0] = s->cur_pic.motion_val[1][s->block_index[i]][0] = s->mv[1][i-1][0];
2273 8720 s->mv[1][i][1] = s->cur_pic.motion_val[1][s->block_index[i]][1] = s->mv[1][i-1][1];
2274 }
2275 } else {
2276
2/2
✓ Branch 0 taken 12342 times.
✓ Branch 1 taken 4114 times.
16456 for (i = 1; i < 4; i++) {
2277 12342 s->mv[0][i][0] = s->cur_pic.motion_val[0][s->block_index[i]][0] = s->mv[0][0][0];
2278 12342 s->mv[0][i][1] = s->cur_pic.motion_val[0][s->block_index[i]][1] = s->mv[0][0][1];
2279 12342 s->mv[1][i][0] = s->cur_pic.motion_val[1][s->block_index[i]][0] = s->mv[1][0][0];
2280 12342 s->mv[1][i][1] = s->cur_pic.motion_val[1][s->block_index[i]][1] = s->mv[1][0][1];
2281 }
2282 }
2283 }
2284
2285
2/2
✓ Branch 0 taken 24065 times.
✓ Branch 1 taken 8474 times.
32539 if (!direct) {
2286
3/4
✓ Branch 0 taken 23850 times.
✓ Branch 1 taken 215 times.
✓ Branch 2 taken 23850 times.
✗ Branch 3 not taken.
24065 if (skipped || !s->mb_intra) {
2287 24065 bmvtype = decode012(gb);
2288
3/4
✓ Branch 0 taken 14341 times.
✓ Branch 1 taken 6232 times.
✓ Branch 2 taken 3492 times.
✗ Branch 3 not taken.
24065 switch (bmvtype) {
2289 14341 case 0:
2290 14341 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD;
2291 14341 break;
2292 6232 case 1:
2293 6232 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD;
2294 6232 break;
2295 3492 case 2:
2296 3492 bmvtype = BMV_TYPE_INTERPOLATED;
2297 }
2298 }
2299
2300
4/4
✓ Branch 0 taken 13086 times.
✓ Branch 1 taken 10979 times.
✓ Branch 2 taken 12364 times.
✓ Branch 3 taken 722 times.
24065 if (twomv && bmvtype != BMV_TYPE_INTERPOLATED)
2301 12364 mvsw = get_bits1(gb);
2302 }
2303
2304
2/2
✓ Branch 0 taken 30997 times.
✓ Branch 1 taken 1542 times.
32539 if (!skipped) { // inter MB
2305 30997 mb_has_coeffs = ff_vc1_mbmode_intfrp[0][idx_mbmode][3];
2306
2/2
✓ Branch 0 taken 26859 times.
✓ Branch 1 taken 4138 times.
30997 if (mb_has_coeffs)
2307 26859 cbp = 1 + get_vlc2(gb, v->cbpcy_vlc, VC1_CBPCY_P_VLC_BITS, 2);
2308
2/2
✓ Branch 0 taken 23850 times.
✓ Branch 1 taken 7147 times.
30997 if (!direct) {
2309
4/4
✓ Branch 0 taken 3483 times.
✓ Branch 1 taken 20367 times.
✓ Branch 2 taken 722 times.
✓ Branch 3 taken 2761 times.
23850 if (bmvtype == BMV_TYPE_INTERPOLATED && twomv) {
2310 722 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
2311
4/4
✓ Branch 0 taken 20367 times.
✓ Branch 1 taken 2761 times.
✓ Branch 2 taken 12364 times.
✓ Branch 3 taken 8003 times.
23128 } else if (bmvtype == BMV_TYPE_INTERPOLATED || twomv) {
2312 15125 v->twomvbp = get_vlc2(gb, v->twomvbp_vlc, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
2313 }
2314 }
2315
2316
2/2
✓ Branch 0 taken 185982 times.
✓ Branch 1 taken 30997 times.
216979 for (i = 0; i < 6; i++)
2317 185982 v->mb_type[s->block_index[i]] = 0;
2318 30997 fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[0][idx_mbmode][1];
2319 /* for all motion vector read MVDATA and motion compensate each block */
2320 30997 dst_idx = 0;
2321
2/2
✓ Branch 0 taken 7147 times.
✓ Branch 1 taken 23850 times.
30997 if (direct) {
2322
2/2
✓ Branch 0 taken 4360 times.
✓ Branch 1 taken 2787 times.
7147 if (twomv) {
2323
2/2
✓ Branch 0 taken 17440 times.
✓ Branch 1 taken 4360 times.
21800 for (i = 0; i < 4; i++) {
2324 17440 ff_vc1_mc_4mv_luma(v, i, 0, 0);
2325 17440 ff_vc1_mc_4mv_luma(v, i, 1, 1);
2326 }
2327 4360 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
2328 4360 ff_vc1_mc_4mv_chroma4(v, 1, 1, 1);
2329 } else {
2330 2787 ff_vc1_mc_1mv(v, 0);
2331 2787 ff_vc1_interp_mc(v);
2332 }
2333
4/4
✓ Branch 0 taken 13086 times.
✓ Branch 1 taken 10764 times.
✓ Branch 2 taken 722 times.
✓ Branch 3 taken 12364 times.
23850 } else if (twomv && bmvtype == BMV_TYPE_INTERPOLATED) {
2334 722 mvbp = v->fourmvbp;
2335
2/2
✓ Branch 0 taken 2888 times.
✓ Branch 1 taken 722 times.
3610 for (i = 0; i < 4; i++) {
2336
4/4
✓ Branch 0 taken 2166 times.
✓ Branch 1 taken 722 times.
✓ Branch 2 taken 722 times.
✓ Branch 3 taken 1444 times.
2888 dir = i==1 || i==3;
2337 2888 dmv_x = dmv_y = 0;
2338 2888 val = ((mvbp >> (3 - i)) & 1);
2339
2/2
✓ Branch 0 taken 2477 times.
✓ Branch 1 taken 411 times.
2888 if (val)
2340 2477 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2341
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 1444 times.
2888 j = i > 1 ? 2 : 0;
2342 2888 ff_vc1_pred_mv_intfr(v, j, dmv_x, dmv_y, 2, v->range_x, v->range_y, dir);
2343 2888 ff_vc1_mc_4mv_luma(v, j, dir, dir);
2344 2888 ff_vc1_mc_4mv_luma(v, j+1, dir, dir);
2345 }
2346
2347 722 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
2348 722 ff_vc1_mc_4mv_chroma4(v, 1, 1, 1);
2349
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 20367 times.
23128 } else if (bmvtype == BMV_TYPE_INTERPOLATED) {
2350 2761 mvbp = v->twomvbp;
2351 2761 dmv_x = dmv_y = 0;
2352
2/2
✓ Branch 0 taken 2691 times.
✓ Branch 1 taken 70 times.
2761 if (mvbp & 2)
2353 2691 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2354
2355 2761 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, 0);
2356 2761 ff_vc1_mc_1mv(v, 0);
2357
2358 2761 dmv_x = dmv_y = 0;
2359
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 113 times.
2761 if (mvbp & 1)
2360 2648 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2361
2362 2761 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, 1);
2363 2761 ff_vc1_interp_mc(v);
2364
2/2
✓ Branch 0 taken 12364 times.
✓ Branch 1 taken 8003 times.
20367 } else if (twomv) {
2365 12364 dir = bmvtype == BMV_TYPE_BACKWARD;
2366 12364 dir2 = dir;
2367
2/2
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 6511 times.
12364 if (mvsw)
2368 5853 dir2 = !dir;
2369 12364 mvbp = v->twomvbp;
2370 12364 dmv_x = dmv_y = 0;
2371
2/2
✓ Branch 0 taken 10627 times.
✓ Branch 1 taken 1737 times.
12364 if (mvbp & 2)
2372 10627 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2373 12364 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, dir);
2374
2375 12364 dmv_x = dmv_y = 0;
2376
2/2
✓ Branch 0 taken 10929 times.
✓ Branch 1 taken 1435 times.
12364 if (mvbp & 1)
2377 10929 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2378 12364 ff_vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, dir2);
2379
2380
2/2
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 6511 times.
12364 if (mvsw) {
2381
2/2
✓ Branch 0 taken 11706 times.
✓ Branch 1 taken 5853 times.
17559 for (i = 0; i < 2; i++) {
2382 11706 s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->cur_pic.motion_val[dir][s->block_index[i+2]][0] = s->cur_pic.motion_val[dir][s->block_index[i]][0];
2383 11706 s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->cur_pic.motion_val[dir][s->block_index[i+2]][1] = s->cur_pic.motion_val[dir][s->block_index[i]][1];
2384 11706 s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->cur_pic.motion_val[dir2][s->block_index[i]][0] = s->cur_pic.motion_val[dir2][s->block_index[i+2]][0];
2385 11706 s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->cur_pic.motion_val[dir2][s->block_index[i]][1] = s->cur_pic.motion_val[dir2][s->block_index[i+2]][1];
2386 }
2387 } else {
2388 6511 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, !dir);
2389 6511 ff_vc1_pred_mv_intfr(v, 2, 0, 0, 2, v->range_x, v->range_y, !dir);
2390 }
2391
2392 12364 ff_vc1_mc_4mv_luma(v, 0, dir, 0);
2393 12364 ff_vc1_mc_4mv_luma(v, 1, dir, 0);
2394 12364 ff_vc1_mc_4mv_luma(v, 2, dir2, 0);
2395 12364 ff_vc1_mc_4mv_luma(v, 3, dir2, 0);
2396 12364 ff_vc1_mc_4mv_chroma4(v, dir, dir2, 0);
2397 } else {
2398 8003 dir = bmvtype == BMV_TYPE_BACKWARD;
2399
2400 8003 mvbp = ff_vc1_mbmode_intfrp[0][idx_mbmode][2];
2401 8003 dmv_x = dmv_y = 0;
2402
2/2
✓ Branch 0 taken 7691 times.
✓ Branch 1 taken 312 times.
8003 if (mvbp)
2403 7691 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2404
2405 8003 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, dir);
2406 8003 v->blk_mv_type[s->block_index[0]] = 1;
2407 8003 v->blk_mv_type[s->block_index[1]] = 1;
2408 8003 v->blk_mv_type[s->block_index[2]] = 1;
2409 8003 v->blk_mv_type[s->block_index[3]] = 1;
2410 8003 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, !dir);
2411
2/2
✓ Branch 0 taken 16006 times.
✓ Branch 1 taken 8003 times.
24009 for (i = 0; i < 2; i++) {
2412 16006 s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->cur_pic.motion_val[!dir][s->block_index[i+2]][0] = s->cur_pic.motion_val[!dir][s->block_index[i]][0];
2413 16006 s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->cur_pic.motion_val[!dir][s->block_index[i+2]][1] = s->cur_pic.motion_val[!dir][s->block_index[i]][1];
2414 }
2415 8003 ff_vc1_mc_1mv(v, dir);
2416 }
2417
2418
2/2
✓ Branch 0 taken 26859 times.
✓ Branch 1 taken 4138 times.
30997 if (cbp)
2419
15/38
✓ Branch 0 taken 26859 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26859 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 26859 times.
✗ Branch 5 not taken.
✓ Branch 7 taken 4064 times.
✓ Branch 8 taken 22795 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 26859 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 26859 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 26859 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 26859 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 26859 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 26859 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 26859 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 26859 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 26859 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 26859 times.
26859 GET_MQUANT(); // p. 227
2420 30997 s->cur_pic.qscale_table[mb_pos] = mquant;
2421
3/4
✓ Branch 0 taken 30997 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 26859 times.
✓ Branch 3 taken 4138 times.
30997 if (!v->ttmbf && cbp)
2422 26859 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index], VC1_TTMB_VLC_BITS, 2);
2423
2/2
✓ Branch 0 taken 185982 times.
✓ Branch 1 taken 30997 times.
216979 for (i = 0; i < 6; i++) {
2424 185982 s->dc_val[s->block_index[i]] = 0;
2425 185982 dst_idx += i >> 2;
2426 185982 val = ((cbp >> (5 - i)) & 1);
2427
2/2
✓ Branch 0 taken 84336 times.
✓ Branch 1 taken 101646 times.
185982 if (!fieldtx)
2428
2/2
✓ Branch 0 taken 56224 times.
✓ Branch 1 taken 28112 times.
84336 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
2429 else
2430
2/2
✓ Branch 0 taken 67764 times.
✓ Branch 1 taken 33882 times.
101646 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
2431
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 70361 times.
185982 if (val) {
2432 346863 pat = vc1_decode_p_block(v, v->blocks[i], i, mquant, ttmb,
2433 115621 first_block, s->dest[dst_idx] + off,
2434
2/2
✓ Branch 0 taken 27250 times.
✓ Branch 1 taken 88371 times.
115621 (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
2435 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
2436
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115621 times.
115621 if (pat < 0)
2437 return pat;
2438 115621 block_cbp |= pat << (i << 2);
2439
3/4
✓ Branch 0 taken 115621 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92324 times.
✓ Branch 3 taken 23297 times.
115621 if (!v->ttmbf && ttmb < 8)
2440 92324 ttmb = -1;
2441 115621 first_block = 0;
2442 }
2443 }
2444
2445 } else { // skipped
2446 1542 dir = 0;
2447
2/2
✓ Branch 0 taken 9252 times.
✓ Branch 1 taken 1542 times.
10794 for (i = 0; i < 6; i++) {
2448 9252 v->mb_type[s->block_index[i]] = 0;
2449 9252 s->dc_val[s->block_index[i]] = 0;
2450 }
2451 1542 s->cur_pic.mb_type[mb_pos] = MB_TYPE_SKIP;
2452 1542 s->cur_pic.qscale_table[mb_pos] = 0;
2453 1542 v->blk_mv_type[s->block_index[0]] = 0;
2454 1542 v->blk_mv_type[s->block_index[1]] = 0;
2455 1542 v->blk_mv_type[s->block_index[2]] = 0;
2456 1542 v->blk_mv_type[s->block_index[3]] = 0;
2457
2458
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 1327 times.
1542 if (!direct) {
2459
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 206 times.
215 if (bmvtype == BMV_TYPE_INTERPOLATED) {
2460 9 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, 0);
2461 9 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, 1);
2462 } else {
2463 206 dir = bmvtype == BMV_TYPE_BACKWARD;
2464 206 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, dir);
2465
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if (mvsw) {
2466 int dir2 = dir;
2467 if (mvsw)
2468 dir2 = !dir;
2469 for (i = 0; i < 2; i++) {
2470 s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->cur_pic.motion_val[dir][s->block_index[i+2]][0] = s->cur_pic.motion_val[dir][s->block_index[i]][0];
2471 s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->cur_pic.motion_val[dir][s->block_index[i+2]][1] = s->cur_pic.motion_val[dir][s->block_index[i]][1];
2472 s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->cur_pic.motion_val[dir2][s->block_index[i]][0] = s->cur_pic.motion_val[dir2][s->block_index[i+2]][0];
2473 s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->cur_pic.motion_val[dir2][s->block_index[i]][1] = s->cur_pic.motion_val[dir2][s->block_index[i+2]][1];
2474 }
2475 } else {
2476 206 v->blk_mv_type[s->block_index[0]] = 1;
2477 206 v->blk_mv_type[s->block_index[1]] = 1;
2478 206 v->blk_mv_type[s->block_index[2]] = 1;
2479 206 v->blk_mv_type[s->block_index[3]] = 1;
2480 206 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, !dir);
2481
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 206 times.
618 for (i = 0; i < 2; i++) {
2482 412 s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->cur_pic.motion_val[!dir][s->block_index[i+2]][0] = s->cur_pic.motion_val[!dir][s->block_index[i]][0];
2483 412 s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->cur_pic.motion_val[!dir][s->block_index[i+2]][1] = s->cur_pic.motion_val[!dir][s->block_index[i]][1];
2484 }
2485 }
2486 }
2487 }
2488
2489 1542 ff_vc1_mc_1mv(v, dir);
2490
4/4
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 1327 times.
✓ Branch 2 taken 9 times.
✓ Branch 3 taken 206 times.
1542 if (direct || bmvtype == BMV_TYPE_INTERPOLATED) {
2491 1336 ff_vc1_interp_mc(v);
2492 }
2493 1542 v->fieldtx_plane[mb_pos] = 0;
2494 }
2495 }
2496 32640 v->cbp[s->mb_x] = block_cbp;
2497 32640 v->ttblk[s->mb_x] = block_tt;
2498
2499 32640 return 0;
2500 }
2501
2502 /** Decode blocks of I-frame
2503 */
2504 91 static void vc1_decode_i_blocks(VC1Context *v)
2505 {
2506 int k, j;
2507 91 MpegEncContext *s = &v->s;
2508 int cbp, val;
2509 int mb_pos;
2510
2511 /* select coding mode used for VLC tables selection */
2512
3/4
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 72 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
91 switch (v->y_ac_table_index) {
2513 11 case 0:
2514
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 2 times.
11 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2515 11 break;
2516 72 case 1:
2517 72 v->codingset = CS_HIGH_MOT_INTRA;
2518 72 break;
2519 8 case 2:
2520 8 v->codingset = CS_MID_RATE_INTRA;
2521 8 break;
2522 }
2523
2524
3/4
✓ Branch 0 taken 85 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
91 switch (v->c_ac_table_index) {
2525 85 case 0:
2526
2/2
✓ Branch 0 taken 15 times.
✓ Branch 1 taken 70 times.
85 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2527 85 break;
2528 5 case 1:
2529 5 v->codingset2 = CS_HIGH_MOT_INTER;
2530 5 break;
2531 1 case 2:
2532 1 v->codingset2 = CS_MID_RATE_INTER;
2533 1 break;
2534 }
2535
2536 /* Set DC scale - y and c use the same so we only set y */
2537 91 s->y_dc_scale = ff_wmv3_dc_scale_table[v->pq];
2538
2539 //do frame decode
2540 91 s->mb_x = s->mb_y = 0;
2541 91 s->mb_intra = 1;
2542 91 s->first_slice_line = 1;
2543
2/2
✓ Branch 0 taken 1022 times.
✓ Branch 1 taken 91 times.
1113 for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
2544 1022 s->mb_x = 0;
2545 1022 init_block_index(v);
2546
2/2
✓ Branch 0 taken 19180 times.
✓ Branch 1 taken 1022 times.
20202 for (; s->mb_x < v->end_mb_x; s->mb_x++) {
2547 19180 update_block_index(s);
2548 19180 s->bdsp.clear_blocks(v->block[v->cur_blk_idx][0]);
2549 19180 mb_pos = s->mb_x + s->mb_y * s->mb_width;
2550 19180 s->cur_pic.mb_type[mb_pos] = MB_TYPE_INTRA;
2551 19180 s->cur_pic.qscale_table[mb_pos] = v->pq;
2552
2/2
✓ Branch 0 taken 76720 times.
✓ Branch 1 taken 19180 times.
95900 for (int i = 0; i < 4; i++) {
2553 76720 s->cur_pic.motion_val[1][s->block_index[i]][0] = 0;
2554 76720 s->cur_pic.motion_val[1][s->block_index[i]][1] = 0;
2555 }
2556
2557 // do actual MB decoding and displaying
2558 19180 cbp = get_vlc2(&v->gb, ff_msmp4_mb_i_vlc,
2559 MSMP4_MB_INTRA_VLC_BITS, 2);
2560 19180 v->s.ac_pred = get_bits1(&v->gb);
2561
2562
2/2
✓ Branch 0 taken 115080 times.
✓ Branch 1 taken 19180 times.
134260 for (k = 0; k < 6; k++) {
2563 115080 v->mb_type[s->block_index[k]] = 1;
2564
2565 115080 val = ((cbp >> (5 - k)) & 1);
2566
2567
2/2
✓ Branch 0 taken 76720 times.
✓ Branch 1 taken 38360 times.
115080 if (k < 4)
2568 76720 val = vc1_coded_block_pred(&v->s, k, val);
2569 115080 cbp |= val << (5 - k);
2570
2571
2/2
✓ Branch 0 taken 76720 times.
✓ Branch 1 taken 38360 times.
115080 vc1_decode_i_block(v, v->block[v->cur_blk_idx][block_map[k]], k, val, (k < 4) ? v->codingset : v->codingset2);
2572
2573 if (CONFIG_GRAY && k > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2574 continue;
2575 115080 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[k]]);
2576 }
2577
2578
3/4
✓ Branch 0 taken 3580 times.
✓ Branch 1 taken 15600 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3580 times.
19180 if (v->overlap && v->pq >= 9) {
2579 ff_vc1_i_overlap_filter(v);
2580 if (v->rangeredfrm)
2581 for (k = 0; k < 6; k++)
2582 for (j = 0; j < 64; j++)
2583 v->block[v->cur_blk_idx][block_map[k]][j] *= 2;
2584 vc1_put_blocks_clamped(v, 1);
2585 } else {
2586
2/2
✓ Branch 0 taken 4400 times.
✓ Branch 1 taken 14780 times.
19180 if (v->rangeredfrm)
2587
2/2
✓ Branch 0 taken 26400 times.
✓ Branch 1 taken 4400 times.
30800 for (k = 0; k < 6; k++)
2588
2/2
✓ Branch 0 taken 1689600 times.
✓ Branch 1 taken 26400 times.
1716000 for (j = 0; j < 64; j++)
2589 1689600 v->block[v->cur_blk_idx][block_map[k]][j] = (v->block[v->cur_blk_idx][block_map[k]][j] - 64) * 2;
2590 19180 vc1_put_blocks_clamped(v, 0);
2591 }
2592
2593
2/2
✓ Branch 0 taken 13240 times.
✓ Branch 1 taken 5940 times.
19180 if (v->loop_filter)
2594 13240 ff_vc1_i_loop_filter(v);
2595
2596
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 19180 times.
19180 if (get_bits_left(&v->gb) < 0) {
2597 ff_er_add_slice(&s->er, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR);
2598 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
2599 get_bits_count(&v->gb), v->gb.size_in_bits);
2600 return;
2601 }
2602
2603 19180 v->topleft_blk_idx = (v->topleft_blk_idx + 1) % (v->end_mb_x + 2);
2604 19180 v->top_blk_idx = (v->top_blk_idx + 1) % (v->end_mb_x + 2);
2605 19180 v->left_blk_idx = (v->left_blk_idx + 1) % (v->end_mb_x + 2);
2606 19180 v->cur_blk_idx = (v->cur_blk_idx + 1) % (v->end_mb_x + 2);
2607 }
2608
2609 1022 s->first_slice_line = 0;
2610 }
2611
2612 /* This is intentionally mb_height and not end_mb_y - unlike in advanced
2613 * profile, these only differ are when decoding MSS2 rectangles. */
2614 91 ff_er_add_slice(&s->er, 0, 0, s->mb_width - 1, s->mb_height - 1, ER_MB_END);
2615 }
2616
2617 /** Decode blocks of I-frame for advanced profile
2618 */
2619 28 static int vc1_decode_i_blocks_adv(VC1Context *v)
2620 {
2621 int k;
2622 28 MpegEncContext *s = &v->s;
2623 28 GetBitContext *const gb = &v->gb;
2624 int cbp, val;
2625 int mb_pos;
2626 int mquant;
2627 int mqdiff;
2628
2629
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 28 times.
28 if (get_bits_left(gb) <= 1)
2630 return AVERROR_INVALIDDATA;
2631
2632 /* select coding mode used for VLC tables selection */
2633
3/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 21 times.
✗ Branch 3 not taken.
28 switch (v->y_ac_table_index) {
2634 2 case 0:
2635
1/2
✓ Branch 0 taken 2 times.
✗ Branch 1 not taken.
2 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2636 2 break;
2637 5 case 1:
2638 5 v->codingset = CS_HIGH_MOT_INTRA;
2639 5 break;
2640 21 case 2:
2641 21 v->codingset = CS_MID_RATE_INTRA;
2642 21 break;
2643 }
2644
2645
2/4
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
28 switch (v->c_ac_table_index) {
2646 23 case 0:
2647
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2648 23 break;
2649 case 1:
2650 v->codingset2 = CS_HIGH_MOT_INTER;
2651 break;
2652 5 case 2:
2653 5 v->codingset2 = CS_MID_RATE_INTER;
2654 5 break;
2655 }
2656
2657 // do frame decode
2658 28 s->mb_intra = 1;
2659 28 s->first_slice_line = 1;
2660 28 s->mb_x = 0;
2661 28 s->mb_y = s->start_mb_y;
2662
2/2
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 16 times.
28 if (s->start_mb_y) {
2663 12 memset(&s->coded_block[(2 * s->mb_y - 1) * s->b8_stride - 2], 0,
2664 12 (1 + s->b8_stride) * sizeof(*s->coded_block));
2665 }
2666
2/2
✓ Branch 0 taken 362 times.
✓ Branch 1 taken 28 times.
390 for (; s->mb_y < s->end_mb_y; s->mb_y++) {
2667 362 s->mb_x = 0;
2668 362 init_block_index(v);
2669
2/2
✓ Branch 0 taken 24228 times.
✓ Branch 1 taken 362 times.
24590 for (;s->mb_x < s->mb_width; s->mb_x++) {
2670 24228 mquant = v->pq;
2671 24228 update_block_index(s);
2672 24228 s->bdsp.clear_blocks(v->block[v->cur_blk_idx][0]);
2673 24228 mb_pos = s->mb_x + s->mb_y * s->mb_stride;
2674 24228 s->cur_pic.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
2675
2/2
✓ Branch 0 taken 96912 times.
✓ Branch 1 taken 24228 times.
121140 for (int i = 0; i < 4; i++) {
2676 96912 s->cur_pic.motion_val[1][s->block_index[i] + v->blocks_off][0] = 0;
2677 96912 s->cur_pic.motion_val[1][s->block_index[i] + v->blocks_off][1] = 0;
2678 }
2679
2680 // do actual MB decoding and displaying
2681
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24228 times.
24228 if (v->fieldtx_is_raw)
2682 v->fieldtx_plane[mb_pos] = get_bits1(gb);
2683
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24228 times.
24228 if (get_bits_left(gb) <= 1) {
2684 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2685 return 0;
2686 }
2687
2688 24228 cbp = get_vlc2(gb, ff_msmp4_mb_i_vlc,
2689 MSMP4_MB_INTRA_VLC_BITS, 2);
2690
2/2
✓ Branch 0 taken 5340 times.
✓ Branch 1 taken 18888 times.
24228 if (v->acpred_is_raw)
2691 5340 v->s.ac_pred = get_bits1(gb);
2692 else
2693 18888 v->s.ac_pred = v->acpred_plane[mb_pos];
2694
2695
3/4
✓ Branch 0 taken 798 times.
✓ Branch 1 taken 23430 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 798 times.
24228 if (v->condover == CONDOVER_SELECT && v->overflg_is_raw)
2696 v->over_flags_plane[mb_pos] = get_bits1(gb);
2697
2698
16/38
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 7908 times.
✓ Branch 2 taken 16320 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 16320 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 10 taken 12220 times.
✓ Branch 11 taken 4100 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 16320 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 16320 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 16320 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 16320 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 16320 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 16320 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 16320 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 16320 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 16320 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 16320 times.
24228 GET_MQUANT();
2699
2700 24228 s->cur_pic.qscale_table[mb_pos] = mquant;
2701 /* Set DC scale - y and c use the same so we only set y */
2702 24228 s->y_dc_scale = ff_wmv3_dc_scale_table[FFABS(mquant)];
2703
2704
2/2
✓ Branch 0 taken 145368 times.
✓ Branch 1 taken 24228 times.
169596 for (k = 0; k < 6; k++) {
2705 145368 v->mb_type[s->block_index[k]] = 1;
2706
2707 145368 val = ((cbp >> (5 - k)) & 1);
2708
2709
2/2
✓ Branch 0 taken 96912 times.
✓ Branch 1 taken 48456 times.
145368 if (k < 4)
2710 96912 val = vc1_coded_block_pred(&v->s, k, val);
2711 145368 cbp |= val << (5 - k);
2712
2713
6/6
✓ Branch 0 taken 6984 times.
✓ Branch 1 taken 138384 times.
✓ Branch 2 taken 5820 times.
✓ Branch 3 taken 1164 times.
✓ Branch 4 taken 1164 times.
✓ Branch 5 taken 4656 times.
145368 v->a_avail = !s->first_slice_line || (k == 2 || k == 3);
2714
6/6
✓ Branch 0 taken 2172 times.
✓ Branch 1 taken 143196 times.
✓ Branch 2 taken 1810 times.
✓ Branch 3 taken 362 times.
✓ Branch 4 taken 362 times.
✓ Branch 5 taken 1448 times.
145368 v->c_avail = !!s->mb_x || (k == 1 || k == 3);
2715
2716
2/2
✓ Branch 0 taken 96912 times.
✓ Branch 1 taken 48456 times.
145368 vc1_decode_i_block_adv(v, v->block[v->cur_blk_idx][block_map[k]], k, val,
2717 (k < 4) ? v->codingset : v->codingset2, mquant);
2718
2719 if (CONFIG_GRAY && k > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2720 continue;
2721 145368 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[k]]);
2722 }
2723
2724
5/6
✓ Branch 0 taken 7488 times.
✓ Branch 1 taken 16740 times.
✓ Branch 2 taken 7488 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 798 times.
✓ Branch 5 taken 6690 times.
24228 if (v->overlap && (v->pq >= 9 || v->condover != CONDOVER_NONE))
2725 798 ff_vc1_i_overlap_filter(v);
2726 24228 vc1_put_blocks_clamped(v, 1);
2727
2/2
✓ Branch 0 taken 23628 times.
✓ Branch 1 taken 600 times.
24228 if (v->loop_filter)
2728 23628 ff_vc1_i_loop_filter(v);
2729
2730
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 24228 times.
24228 if (get_bits_left(gb) < 0) {
2731 // TODO: may need modification to handle slice coding
2732 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2733 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
2734 get_bits_count(gb), gb->size_in_bits);
2735 return 0;
2736 }
2737
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 23900 times.
24228 inc_blk_idx(v->topleft_blk_idx);
2738
2/2
✓ Branch 0 taken 332 times.
✓ Branch 1 taken 23896 times.
24228 inc_blk_idx(v->top_blk_idx);
2739
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 23900 times.
24228 inc_blk_idx(v->left_blk_idx);
2740
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 23900 times.
24228 inc_blk_idx(v->cur_blk_idx);
2741 }
2742 362 s->first_slice_line = 0;
2743 }
2744
2745 28 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
2746 28 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
2747 28 return 0;
2748 }
2749
2750 917 static void vc1_decode_p_blocks(VC1Context *v)
2751 {
2752 917 MpegEncContext *s = &v->s;
2753 int apply_loop_filter;
2754 int ret;
2755
2756 /* select coding mode used for VLC tables selection */
2757
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
917 switch (v->c_ac_table_index) {
2758 270 case 0:
2759
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 20 times.
270 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2760 270 break;
2761 391 case 1:
2762 391 v->codingset = CS_HIGH_MOT_INTRA;
2763 391 break;
2764 256 case 2:
2765 256 v->codingset = CS_MID_RATE_INTRA;
2766 256 break;
2767 }
2768
2769
3/4
✓ Branch 0 taken 270 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
917 switch (v->c_ac_table_index) {
2770 270 case 0:
2771
2/2
✓ Branch 0 taken 250 times.
✓ Branch 1 taken 20 times.
270 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2772 270 break;
2773 391 case 1:
2774 391 v->codingset2 = CS_HIGH_MOT_INTER;
2775 391 break;
2776 256 case 2:
2777 256 v->codingset2 = CS_MID_RATE_INTER;
2778 256 break;
2779 }
2780
2781
3/4
✓ Branch 0 taken 867 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 867 times.
✗ Branch 3 not taken.
917 apply_loop_filter = v->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
2782 917 s->first_slice_line = 1;
2783 917 memset(v->cbp_base, 0, sizeof(v->cbp_base[0]) * 3 * s->mb_stride);
2784
2/2
✓ Branch 0 taken 5379 times.
✓ Branch 1 taken 916 times.
6295 for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
2785 5379 s->mb_x = 0;
2786 5379 init_block_index(v);
2787
2/2
✓ Branch 0 taken 206848 times.
✓ Branch 1 taken 5378 times.
212226 for (; s->mb_x < s->mb_width; s->mb_x++) {
2788 206848 update_block_index(s);
2789
2790
7/8
✓ Branch 0 taken 168928 times.
✓ Branch 1 taken 37920 times.
✓ Branch 2 taken 152608 times.
✓ Branch 3 taken 16320 times.
✓ Branch 4 taken 93838 times.
✓ Branch 5 taken 58770 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110158 times.
206848 if (v->fcm == ILACE_FIELD || (v->fcm == PROGRESSIVE && v->mv_type_is_raw) || v->skip_is_raw)
2791
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96690 times.
96690 if (get_bits_left(&v->gb) <= 1) {
2792 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2793 return;
2794 }
2795
2796
2/2
✓ Branch 0 taken 37920 times.
✓ Branch 1 taken 168928 times.
206848 if (v->fcm == ILACE_FIELD) {
2797 37920 ret = vc1_decode_p_mb_intfi(v);
2798
1/2
✓ Branch 0 taken 37920 times.
✗ Branch 1 not taken.
37920 if (apply_loop_filter)
2799 37920 ff_vc1_p_loop_filter(v);
2800
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 152608 times.
168928 } else if (v->fcm == ILACE_FRAME) {
2801 16320 ret = vc1_decode_p_mb_intfr(v);
2802
1/2
✓ Branch 0 taken 16320 times.
✗ Branch 1 not taken.
16320 if (apply_loop_filter)
2803 16320 ff_vc1_p_intfr_loop_filter(v);
2804 } else {
2805 152608 ret = vc1_decode_p_mb(v);
2806
2/2
✓ Branch 0 taken 93328 times.
✓ Branch 1 taken 59280 times.
152608 if (apply_loop_filter)
2807 93328 ff_vc1_p_loop_filter(v);
2808 }
2809
4/6
✓ Branch 0 taken 206848 times.
✗ Branch 1 not taken.
✓ Branch 3 taken 206847 times.
✓ Branch 4 taken 1 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 206847 times.
206848 if (ret < 0 || get_bits_left(&v->gb) < 0 || get_bits_count(&v->gb) < 0) {
2810 // TODO: may need modification to handle slice coding
2811 1 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2812 1 av_log(s->avctx, AV_LOG_ERROR, "Error or Bits overconsumption: %i > %i at %ix%i\n",
2813 1 get_bits_count(&v->gb), v->gb.size_in_bits, s->mb_x, s->mb_y);
2814 1 return;
2815 }
2816
2/2
✓ Branch 0 taken 4398 times.
✓ Branch 1 taken 202449 times.
206847 inc_blk_idx(v->topleft_blk_idx);
2817
2/2
✓ Branch 0 taken 4830 times.
✓ Branch 1 taken 202017 times.
206847 inc_blk_idx(v->top_blk_idx);
2818
2/2
✓ Branch 0 taken 4271 times.
✓ Branch 1 taken 202576 times.
206847 inc_blk_idx(v->left_blk_idx);
2819
2/2
✓ Branch 0 taken 4398 times.
✓ Branch 1 taken 202449 times.
206847 inc_blk_idx(v->cur_blk_idx);
2820 }
2821 5378 memmove(v->cbp_base,
2822 5378 v->cbp - s->mb_stride,
2823 5378 sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
2824 5378 memmove(v->ttblk_base,
2825 5378 v->ttblk - s->mb_stride,
2826 5378 sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
2827 5378 memmove(v->is_intra_base,
2828 5378 v->is_intra - s->mb_stride,
2829 5378 sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
2830 5378 memmove(v->luma_mv_base,
2831 5378 v->luma_mv - s->mb_stride,
2832 5378 sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
2833 5378 s->first_slice_line = 0;
2834 }
2835 916 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
2836 916 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
2837 }
2838
2839 109 static void vc1_decode_b_blocks(VC1Context *v)
2840 {
2841 109 MpegEncContext *s = &v->s;
2842
2843 /* select coding mode used for VLC tables selection */
2844
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
109 switch (v->c_ac_table_index) {
2845 14 case 0:
2846
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2847 14 break;
2848 16 case 1:
2849 16 v->codingset = CS_HIGH_MOT_INTRA;
2850 16 break;
2851 79 case 2:
2852 79 v->codingset = CS_MID_RATE_INTRA;
2853 79 break;
2854 }
2855
2856
3/4
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 16 times.
✓ Branch 2 taken 79 times.
✗ Branch 3 not taken.
109 switch (v->c_ac_table_index) {
2857 14 case 0:
2858
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2859 14 break;
2860 16 case 1:
2861 16 v->codingset2 = CS_HIGH_MOT_INTER;
2862 16 break;
2863 79 case 2:
2864 79 v->codingset2 = CS_MID_RATE_INTER;
2865 79 break;
2866 }
2867
2868 109 s->first_slice_line = 1;
2869
2/2
✓ Branch 0 taken 1700 times.
✓ Branch 1 taken 109 times.
1809 for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
2870 1700 s->mb_x = 0;
2871 1700 init_block_index(v);
2872
2/2
✓ Branch 0 taken 105120 times.
✓ Branch 1 taken 1700 times.
106820 for (; s->mb_x < s->mb_width; s->mb_x++) {
2873 105120 update_block_index(s);
2874
2875
4/6
✓ Branch 0 taken 53580 times.
✓ Branch 1 taken 51540 times.
✓ Branch 2 taken 53580 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 53580 times.
105120 if (v->fcm == ILACE_FIELD || v->skip_is_raw || v->dmb_is_raw)
2876
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 51540 times.
51540 if (get_bits_left(&v->gb) <= 1) {
2877 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2878 return;
2879 }
2880
2881
2/2
✓ Branch 0 taken 51540 times.
✓ Branch 1 taken 53580 times.
105120 if (v->fcm == ILACE_FIELD) {
2882 51540 vc1_decode_b_mb_intfi(v);
2883
1/2
✓ Branch 0 taken 51540 times.
✗ Branch 1 not taken.
51540 if (v->loop_filter)
2884 51540 ff_vc1_b_intfi_loop_filter(v);
2885
2/2
✓ Branch 0 taken 32640 times.
✓ Branch 1 taken 20940 times.
53580 } else if (v->fcm == ILACE_FRAME) {
2886 32640 vc1_decode_b_mb_intfr(v);
2887
1/2
✓ Branch 0 taken 32640 times.
✗ Branch 1 not taken.
32640 if (v->loop_filter)
2888 32640 ff_vc1_p_intfr_loop_filter(v);
2889 } else {
2890 20940 vc1_decode_b_mb(v);
2891
2/2
✓ Branch 0 taken 6090 times.
✓ Branch 1 taken 14850 times.
20940 if (v->loop_filter)
2892 6090 ff_vc1_i_loop_filter(v);
2893 }
2894
2/4
✓ Branch 1 taken 105120 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 105120 times.
105120 if (get_bits_left(&v->gb) < 0 || get_bits_count(&v->gb) < 0) {
2895 // TODO: may need modification to handle slice coding
2896 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2897 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
2898 get_bits_count(&v->gb), v->gb.size_in_bits, s->mb_x, s->mb_y);
2899 return;
2900 }
2901 }
2902 1700 memmove(v->cbp_base,
2903 1700 v->cbp - s->mb_stride,
2904 1700 sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
2905 1700 memmove(v->ttblk_base,
2906 1700 v->ttblk - s->mb_stride,
2907 1700 sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
2908 1700 memmove(v->is_intra_base,
2909 1700 v->is_intra - s->mb_stride,
2910 1700 sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
2911 1700 s->first_slice_line = 0;
2912 }
2913 109 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
2914 109 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
2915 }
2916
2917 67 static void vc1_decode_skip_blocks(VC1Context *v)
2918 {
2919 67 MpegEncContext *s = &v->s;
2920
2921
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 67 times.
67 if (!v->s.last_pic.data[0])
2922 return;
2923
2924 67 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_width - 1, s->end_mb_y - 1, ER_MB_END);
2925 67 s->first_slice_line = 1;
2926
2/2
✓ Branch 0 taken 1617 times.
✓ Branch 1 taken 67 times.
1684 for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
2927 1617 s->mb_x = 0;
2928 1617 init_block_index(v);
2929 1617 update_block_index(s);
2930 1617 memcpy(s->dest[0], s->last_pic.data[0] + s->mb_y * 16 * s->linesize, s->linesize * 16);
2931 1617 memcpy(s->dest[1], s->last_pic.data[1] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
2932 1617 memcpy(s->dest[2], s->last_pic.data[2] + s->mb_y * 8 * s->uvlinesize, s->uvlinesize * 8);
2933 1617 s->first_slice_line = 0;
2934 }
2935 }
2936
2937 1212 void ff_vc1_decode_blocks(VC1Context *v)
2938 {
2939
2940 1212 v->esc3_level_length = 0;
2941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1212 times.
1212 if (v->x8_type) {
2942 ff_intrax8_decode_picture(&v->x8, v->s.cur_pic.ptr,
2943 &v->gb, &v->s.mb_x, &v->s.mb_y,
2944 2 * v->pq + v->halfpq, v->pq * !v->pquantizer,
2945 v->loop_filter, v->s.low_delay);
2946
2947 ff_er_add_slice(&v->s.er, 0, 0,
2948 (v->s.mb_x >> 1) - 1, (v->s.mb_y >> 1) - 1,
2949 ER_MB_END);
2950 } else {
2951 1212 v->cur_blk_idx = 0;
2952 1212 v->left_blk_idx = -1;
2953 1212 v->topleft_blk_idx = 1;
2954 1212 v->top_blk_idx = 2;
2955
3/4
✓ Branch 0 taken 119 times.
✓ Branch 1 taken 984 times.
✓ Branch 2 taken 109 times.
✗ Branch 3 not taken.
1212 switch (v->s.pict_type) {
2956 119 case AV_PICTURE_TYPE_I:
2957
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 91 times.
119 if (v->profile == PROFILE_ADVANCED)
2958 28 vc1_decode_i_blocks_adv(v);
2959 else
2960 91 vc1_decode_i_blocks(v);
2961 119 break;
2962 984 case AV_PICTURE_TYPE_P:
2963
2/2
✓ Branch 0 taken 67 times.
✓ Branch 1 taken 917 times.
984 if (v->p_frame_skipped)
2964 67 vc1_decode_skip_blocks(v);
2965 else
2966 917 vc1_decode_p_blocks(v);
2967 984 break;
2968 109 case AV_PICTURE_TYPE_B:
2969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109 times.
109 if (v->bi_type) {
2970 if (v->profile == PROFILE_ADVANCED)
2971 vc1_decode_i_blocks_adv(v);
2972 else
2973 vc1_decode_i_blocks(v);
2974 } else
2975 109 vc1_decode_b_blocks(v);
2976 109 break;
2977 }
2978 }
2979 1212 }
2980