FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vc1_block.c
Date: 2022-11-26 13:19:19
Exec Total Coverage
Lines: 1824 1934 94.3%
Branches: 1616 2194 73.7%

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 9784 static inline void init_block_index(VC1Context *v)
58 {
59 9784 MpegEncContext *s = &v->s;
60 9784 ff_init_block_index(s);
61
4/4
✓ Branch 0 taken 1308 times.
✓ Branch 1 taken 8476 times.
✓ Branch 2 taken 654 times.
✓ Branch 3 taken 654 times.
9784 if (v->field_mode && !(v->second_field ^ v->tff)) {
62 654 s->dest[0] += s->current_picture_ptr->f->linesize[0];
63 654 s->dest[1] += s->current_picture_ptr->f->linesize[1];
64 654 s->dest[2] += s->current_picture_ptr->f->linesize[2];
65 }
66 9784 }
67
68 340610 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 340610 ff_update_block_index(s, 8, 0, s->chroma_x_shift);
73 340610 }
74
75 /** @} */ //Bitplane group
76
77 233873 static void vc1_put_blocks_clamped(VC1Context *v, int put_signed)
78 {
79 233873 MpegEncContext *s = &v->s;
80 uint8_t *dest;
81 233873 int block_count = CONFIG_GRAY && (s->avctx->flags & AV_CODEC_FLAG_GRAY) ? 4 : 6;
82 233873 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 196460 times.
✓ Branch 1 taken 37413 times.
✓ Branch 2 taken 172340 times.
✓ Branch 3 taken 24120 times.
233873 if (!s->first_slice_line && v->fcm != ILACE_FRAME) {
91
2/2
✓ Branch 0 taken 167094 times.
✓ Branch 1 taken 5246 times.
172340 if (s->mb_x) {
92
2/2
✓ Branch 0 taken 1002564 times.
✓ Branch 1 taken 167094 times.
1169658 for (i = 0; i < block_count; i++) {
93
4/4
✓ Branch 0 taken 334188 times.
✓ Branch 1 taken 668376 times.
✓ Branch 2 taken 252811 times.
✓ Branch 3 taken 749753 times.
1670940 if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i] - 1] :
94 668376 v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i] - 2]) {
95 252811 dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + ((i & 1) - 2) * 8;
96
2/2
✓ Branch 0 taken 171349 times.
✓ Branch 1 taken 81462 times.
252811 if (put_signed)
97
4/4
✓ Branch 0 taken 55930 times.
✓ Branch 1 taken 115419 times.
✓ Branch 2 taken 55930 times.
✓ Branch 3 taken 115419 times.
227279 s->idsp.put_signed_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]],
98 55930 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 27154 times.
✓ Branch 1 taken 54308 times.
✓ Branch 2 taken 27154 times.
✓ Branch 3 taken 54308 times.
108616 s->idsp.put_pixels_clamped(v->block[v->topleft_blk_idx][block_map[i]],
102 27154 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 5246 times.
✓ Branch 1 taken 167094 times.
172340 if (s->mb_x == v->end_mb_x - 1) {
108
2/2
✓ Branch 0 taken 31476 times.
✓ Branch 1 taken 5246 times.
36722 for (i = 0; i < block_count; i++) {
109
4/4
✓ Branch 0 taken 10492 times.
✓ Branch 1 taken 20984 times.
✓ Branch 2 taken 10035 times.
✓ Branch 3 taken 21441 times.
52460 if (i > 3 ? v->mb_type[0][s->block_index[i] - s->block_wrap[i]] :
110 20984 v->mb_type[0][s->block_index[i] - 2 * s->block_wrap[i]]) {
111 10035 dest = s->dest[0] + ((i & 2) - 4) * 4 * s->linesize + (i & 1) * 8;
112
2/2
✓ Branch 0 taken 5037 times.
✓ Branch 1 taken 4998 times.
10035 if (put_signed)
113
4/4
✓ Branch 0 taken 1622 times.
✓ Branch 1 taken 3415 times.
✓ Branch 2 taken 1622 times.
✓ Branch 3 taken 3415 times.
6659 s->idsp.put_signed_pixels_clamped(v->block[v->top_blk_idx][block_map[i]],
114 1622 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 1666 times.
✓ Branch 1 taken 3332 times.
✓ Branch 2 taken 1666 times.
✓ Branch 3 taken 3332 times.
6664 s->idsp.put_pixels_clamped(v->block[v->top_blk_idx][block_map[i]],
118 1666 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 196460 times.
✓ Branch 1 taken 37413 times.
✓ Branch 2 taken 24120 times.
✓ Branch 3 taken 172340 times.
233873 if (s->mb_y == s->end_mb_y - 1 || v->fcm == ILACE_FRAME) {
125
2/2
✓ Branch 0 taken 60318 times.
✓ Branch 1 taken 1215 times.
61533 if (s->mb_x) {
126
2/2
✓ Branch 0 taken 24276 times.
✓ Branch 1 taken 36042 times.
60318 if (v->fcm == ILACE_FRAME)
127 24276 fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x - 1];
128
2/2
✓ Branch 0 taken 361908 times.
✓ Branch 1 taken 60318 times.
422226 for (i = 0; i < block_count; i++) {
129
4/4
✓ Branch 0 taken 120636 times.
✓ Branch 1 taken 241272 times.
✓ Branch 2 taken 133561 times.
✓ Branch 3 taken 228347 times.
603180 if (i > 3 ? v->mb_type[0][s->block_index[i] - 1] :
130 241272 v->mb_type[0][s->block_index[i] - 2]) {
131
2/2
✓ Branch 0 taken 18414 times.
✓ Branch 1 taken 115147 times.
133561 if (fieldtx)
132 18414 dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + ((i & 1) - 2) * 8;
133 else
134 115147 dest = s->dest[0] + (i & 2) * 4 * s->linesize + ((i & 1) - 2) * 8;
135
2/2
✓ Branch 0 taken 126871 times.
✓ Branch 1 taken 6690 times.
133561 if (put_signed)
136
4/4
✓ Branch 0 taken 41650 times.
✓ Branch 1 taken 85221 times.
✓ Branch 2 taken 41650 times.
✓ Branch 3 taken 85221 times.
253742 s->idsp.put_signed_pixels_clamped(v->block[v->left_blk_idx][block_map[i]],
137 41650 i > 3 ? s->dest[i - 3] - 8 : dest,
138 85221 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
139 else
140
4/4
✓ Branch 0 taken 2230 times.
✓ Branch 1 taken 4460 times.
✓ Branch 2 taken 2230 times.
✓ Branch 3 taken 4460 times.
13380 s->idsp.put_pixels_clamped(v->block[v->left_blk_idx][block_map[i]],
141 2230 i > 3 ? s->dest[i - 3] - 8 : dest,
142 4460 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
143 }
144 }
145 }
146
2/2
✓ Branch 0 taken 1215 times.
✓ Branch 1 taken 60318 times.
61533 if (s->mb_x == v->end_mb_x - 1) {
147
2/2
✓ Branch 0 taken 204 times.
✓ Branch 1 taken 1011 times.
1215 if (v->fcm == ILACE_FRAME)
148 204 fieldtx = v->fieldtx_plane[s->mb_y * s->mb_stride + s->mb_x];
149
2/2
✓ Branch 0 taken 7290 times.
✓ Branch 1 taken 1215 times.
8505 for (i = 0; i < block_count; i++) {
150
2/2
✓ Branch 0 taken 2843 times.
✓ Branch 1 taken 4447 times.
7290 if (v->mb_type[0][s->block_index[i]]) {
151
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 2681 times.
2843 if (fieldtx)
152 162 dest = s->dest[0] + ((i & 2) >> 1) * s->linesize + (i & 1) * 8;
153 else
154 2681 dest = s->dest[0] + (i & 2) * 4 * s->linesize + (i & 1) * 8;
155
2/2
✓ Branch 0 taken 2333 times.
✓ Branch 1 taken 510 times.
2843 if (put_signed)
156
4/4
✓ Branch 0 taken 764 times.
✓ Branch 1 taken 1569 times.
✓ Branch 2 taken 764 times.
✓ Branch 3 taken 1569 times.
4666 s->idsp.put_signed_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]],
157 764 i > 3 ? s->dest[i - 3] : dest,
158 1569 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
159 else
160
4/4
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 340 times.
✓ Branch 2 taken 170 times.
✓ Branch 3 taken 340 times.
1020 s->idsp.put_pixels_clamped(v->block[v->cur_blk_idx][block_map[i]],
161 170 i > 3 ? s->dest[i - 3] : dest,
162 340 i > 3 ? s->uvlinesize : s->linesize << fieldtx);
163 }
164 }
165 }
166 }
167 233873 }
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[s->mv_table_index].table, \
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 118892 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 118892 GetBitContext *gb = &v->s.gb;
273 int bits, esc;
274 int val, sign;
275
276
2/2
✓ Branch 0 taken 59109 times.
✓ Branch 1 taken 59783 times.
118892 if (v->numref) {
277 59109 bits = VC1_2REF_MVDATA_VLC_BITS;
278 59109 esc = 125;
279 } else {
280 59783 bits = VC1_1REF_MVDATA_VLC_BITS;
281 59783 esc = 71;
282 }
283 118892 extend_x = v->dmvrange & 1;
284 118892 extend_y = (v->dmvrange >> 1) & 1;
285 118892 index = get_vlc2(gb, v->imv_vlc->table, bits, 3);
286
2/2
✓ Branch 0 taken 8896 times.
✓ Branch 1 taken 109996 times.
118892 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 109996 times.
109996 av_assert0(index < esc);
297 109996 index1 = (index + 1) % 9;
298
2/2
✓ Branch 0 taken 84682 times.
✓ Branch 1 taken 25314 times.
109996 if (index1 != 0) {
299 84682 val = get_bits(gb, index1 + extend_x);
300 84682 sign = 0 - (val & 1);
301 84682 *dmv_x = (sign ^ ((val >> 1) + offset_table[extend_x][index1])) - sign;
302 } else
303 25314 *dmv_x = 0;
304 109996 index1 = (index + 1) / 9;
305
2/2
✓ Branch 0 taken 76703 times.
✓ Branch 1 taken 33293 times.
109996 if (index1 > v->numref) {
306 76703 val = get_bits(gb, (index1 >> v->numref) + extend_y);
307 76703 sign = 0 - (val & 1);
308 76703 *dmv_y = (sign ^ ((val >> 1) + offset_table[extend_y][index1 >> v->numref])) - sign;
309 } else
310 33293 *dmv_y = 0;
311
3/4
✓ Branch 0 taken 58695 times.
✓ Branch 1 taken 51301 times.
✓ Branch 2 taken 58695 times.
✗ Branch 3 not taken.
109996 if (v->numref && pred_flag)
312 58695 *pred_flag = index1 & 1;
313 }
314 118892 }
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 93660 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
2/2
✓ Branch 0 taken 62440 times.
✓ Branch 1 taken 31220 times.
93660 if (n < 4) scale = s->y_dc_scale;
358 31220 else scale = s->c_dc_scale;
359
360 93660 wrap = s->block_wrap[n];
361 93660 dc_val = s->dc_val[0] + s->block_index[n];
362
363 /* B A
364 * C X
365 */
366 93660 c = dc_val[ - 1];
367 93660 b = dc_val[ - 1 - wrap];
368 93660 a = dc_val[ - wrap];
369
370
3/4
✓ Branch 0 taken 57840 times.
✓ Branch 1 taken 35820 times.
✓ Branch 2 taken 57840 times.
✗ Branch 3 not taken.
93660 if (pq < 9 || !overlap) {
371 /* Set outer values */
372
6/6
✓ Branch 0 taken 7200 times.
✓ Branch 1 taken 86460 times.
✓ Branch 2 taken 6000 times.
✓ Branch 3 taken 1200 times.
✓ Branch 4 taken 4800 times.
✓ Branch 5 taken 1200 times.
93660 if (s->first_slice_line && (n != 2 && n != 3))
373 4800 b = a = dcpred[scale];
374
6/6
✓ Branch 0 taken 5508 times.
✓ Branch 1 taken 88152 times.
✓ Branch 2 taken 4590 times.
✓ Branch 3 taken 918 times.
✓ Branch 4 taken 3672 times.
✓ Branch 5 taken 918 times.
93660 if (s->mb_x == 0 && (n != 1 && n != 3))
375 3672 b = c = dcpred[scale];
376 } else {
377 /* Set outer values */
378 if (s->first_slice_line && (n != 2 && n != 3))
379 b = a = 0;
380 if (s->mb_x == 0 && (n != 1 && n != 3))
381 b = c = 0;
382 }
383
384
2/2
✓ Branch 0 taken 63372 times.
✓ Branch 1 taken 30288 times.
93660 if (abs(a - b) <= abs(b - c)) {
385 63372 pred = c;
386 63372 *dir_ptr = 1; // left
387 } else {
388 30288 pred = a;
389 30288 *dir_ptr = 0; // top
390 }
391
392 /* update predictor */
393 93660 *dc_val_ptr = &dc_val[0];
394 93660 return pred;
395 }
396
397
398 /** Get predicted DC value
399 * prediction dir: left=0, top=1
400 * @param s MpegEncContext
401 * @param overlap flag indicating that overlap filtering is used
402 * @param pq integer part of picture quantizer
403 * @param[in] n block index in the current MB
404 * @param a_avail flag indicating top block availability
405 * @param c_avail flag indicating left block availability
406 * @param dc_val_ptr Pointer to DC predictor
407 * @param dir_ptr Prediction direction for use in AC prediction
408 */
409 307504 static inline int ff_vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n,
410 int a_avail, int c_avail,
411 int16_t **dc_val_ptr, int *dir_ptr)
412 {
413 int a, b, c, wrap, pred;
414 int16_t *dc_val;
415 307504 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
416 307504 int q1, q2 = 0;
417 int dqscale_index;
418
419 /* scale predictors if needed */
420 307504 q1 = FFABS(s->current_picture.qscale_table[mb_pos]);
421 307504 dqscale_index = s->y_dc_scale_table[q1] - 1;
422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 307504 times.
307504 if (dqscale_index < 0)
423 return 0;
424
425 307504 wrap = s->block_wrap[n];
426 307504 dc_val = s->dc_val[0] + s->block_index[n];
427
428 /* B A
429 * C X
430 */
431 307504 c = dc_val[ - 1];
432 307504 b = dc_val[ - 1 - wrap];
433 307504 a = dc_val[ - wrap];
434
435
6/6
✓ Branch 0 taken 214201 times.
✓ Branch 1 taken 93303 times.
✓ Branch 2 taken 163945 times.
✓ Branch 3 taken 50256 times.
✓ Branch 4 taken 113632 times.
✓ Branch 5 taken 50313 times.
307504 if (c_avail && (n != 1 && n != 3)) {
436 113632 q2 = FFABS(s->current_picture.qscale_table[mb_pos - 1]);
437
3/4
✓ Branch 0 taken 113632 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5816 times.
✓ Branch 3 taken 107816 times.
113632 if (q2 && q2 != q1)
438 5816 c = (int)((unsigned)c * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
439 }
440
6/6
✓ Branch 0 taken 195939 times.
✓ Branch 1 taken 111565 times.
✓ Branch 2 taken 145647 times.
✓ Branch 3 taken 50292 times.
✓ Branch 4 taken 95301 times.
✓ Branch 5 taken 50346 times.
307504 if (a_avail && (n != 2 && n != 3)) {
441 95301 q2 = FFABS(s->current_picture.qscale_table[mb_pos - s->mb_stride]);
442
3/4
✓ Branch 0 taken 95301 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5480 times.
✓ Branch 3 taken 89821 times.
95301 if (q2 && q2 != q1)
443 5480 a = (int)((unsigned)a * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
444 }
445
6/6
✓ Branch 0 taken 195939 times.
✓ Branch 1 taken 111565 times.
✓ Branch 2 taken 155770 times.
✓ Branch 3 taken 40169 times.
✓ Branch 4 taken 105964 times.
✓ Branch 5 taken 49806 times.
307504 if (a_avail && c_avail && (n != 3)) {
446 105964 int off = mb_pos;
447
2/2
✓ Branch 0 taken 82210 times.
✓ Branch 1 taken 23754 times.
105964 if (n != 1)
448 82210 off--;
449
2/2
✓ Branch 0 taken 77634 times.
✓ Branch 1 taken 28330 times.
105964 if (n != 2)
450 77634 off -= s->mb_stride;
451 105964 q2 = FFABS(s->current_picture.qscale_table[off]);
452
4/4
✓ Branch 0 taken 105246 times.
✓ Branch 1 taken 718 times.
✓ Branch 2 taken 7387 times.
✓ Branch 3 taken 97859 times.
105964 if (q2 && q2 != q1)
453 7387 b = (int)((unsigned)b * s->y_dc_scale_table[q2] * ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
454 }
455
456
6/6
✓ Branch 0 taken 214201 times.
✓ Branch 1 taken 93303 times.
✓ Branch 2 taken 155770 times.
✓ Branch 3 taken 58431 times.
✓ Branch 4 taken 102675 times.
✓ Branch 5 taken 53095 times.
307504 if (c_avail && (!a_avail || abs(a - b) <= abs(b - c))) {
457 161106 pred = c;
458 161106 *dir_ptr = 1; // left
459
2/2
✓ Branch 0 taken 93264 times.
✓ Branch 1 taken 53134 times.
146398 } else if (a_avail) {
460 93264 pred = a;
461 93264 *dir_ptr = 0; // top
462 } else {
463 53134 pred = 0;
464 53134 *dir_ptr = 1; // left
465 }
466
467 /* update predictor */
468 307504 *dc_val_ptr = &dc_val[0];
469 307504 return pred;
470 }
471
472 /** @} */ // Block group
473
474 /**
475 * @name VC1 Macroblock-level functions in Simple/Main Profiles
476 * @see 7.1.4, p91 and 8.1.1.7, p(1)04
477 * @{
478 */
479
480 110896 static inline int vc1_coded_block_pred(MpegEncContext * s, int n,
481 uint8_t **coded_block_ptr)
482 {
483 int xy, wrap, pred, a, b, c;
484
485 110896 xy = s->block_index[n];
486 110896 wrap = s->b8_stride;
487
488 /* B C
489 * A X
490 */
491 110896 a = s->coded_block[xy - 1 ];
492 110896 b = s->coded_block[xy - 1 - wrap];
493 110896 c = s->coded_block[xy - wrap];
494
495
2/2
✓ Branch 0 taken 98007 times.
✓ Branch 1 taken 12889 times.
110896 if (b == c) {
496 98007 pred = a;
497 } else {
498 12889 pred = c;
499 }
500
501 /* store value */
502 110896 *coded_block_ptr = &s->coded_block[xy];
503
504 110896 return pred;
505 }
506
507 /**
508 * Decode one AC coefficient
509 * @param v The VC1 context
510 * @param last Last coefficient
511 * @param skip How much zero coefficients to skip
512 * @param value Decoded AC coefficient value
513 * @param codingset set of VLC to decode data
514 * @see 8.1.3.4
515 */
516 7231154 static int vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip,
517 int *value, int codingset)
518 {
519 7231154 GetBitContext *gb = &v->s.gb;
520 int index, run, level, lst, sign;
521
522 7231154 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7231154 times.
7231154 if (index < 0)
524 return index;
525
2/2
✓ Branch 0 taken 7170750 times.
✓ Branch 1 taken 60404 times.
7231154 if (index != ff_vc1_ac_sizes[codingset] - 1) {
526 7170750 run = vc1_index_decode_table[codingset][index][0];
527 7170750 level = vc1_index_decode_table[codingset][index][1];
528
3/4
✓ Branch 0 taken 5930966 times.
✓ Branch 1 taken 1239784 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 5930966 times.
7170750 lst = index >= vc1_last_decode_table[codingset] || get_bits_left(gb) < 0;
529 7170750 sign = get_bits1(gb);
530 } else {
531 60404 int escape = decode210(gb);
532
2/2
✓ Branch 0 taken 53118 times.
✓ Branch 1 taken 7286 times.
60404 if (escape != 2) {
533 53118 index = get_vlc2(gb, ff_vc1_ac_coeff_table[codingset].table, AC_VLC_BITS, 3);
534
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53118 times.
53118 if (index >= ff_vc1_ac_sizes[codingset] - 1U)
535 return AVERROR_INVALIDDATA;
536 53118 run = vc1_index_decode_table[codingset][index][0];
537 53118 level = vc1_index_decode_table[codingset][index][1];
538 53118 lst = index >= vc1_last_decode_table[codingset];
539
2/2
✓ Branch 0 taken 26521 times.
✓ Branch 1 taken 26597 times.
53118 if (escape == 0) {
540
2/2
✓ Branch 0 taken 10804 times.
✓ Branch 1 taken 15717 times.
26521 if (lst)
541 10804 level += vc1_last_delta_level_table[codingset][run];
542 else
543 15717 level += vc1_delta_level_table[codingset][run];
544 } else {
545
2/2
✓ Branch 0 taken 9537 times.
✓ Branch 1 taken 17060 times.
26597 if (lst)
546 9537 run += vc1_last_delta_run_table[codingset][level] + 1;
547 else
548 17060 run += vc1_delta_run_table[codingset][level] + 1;
549 }
550 53118 sign = get_bits1(gb);
551 } else {
552 7286 lst = get_bits1(gb);
553
2/2
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 6910 times.
7286 if (v->s.esc3_level_length == 0) {
554
4/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 311 times.
✓ Branch 2 taken 7 times.
✓ Branch 3 taken 58 times.
376 if (v->pq < 8 || v->dquantfrm) { // table 59
555 318 v->s.esc3_level_length = get_bits(gb, 3);
556
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 296 times.
318 if (!v->s.esc3_level_length)
557 22 v->s.esc3_level_length = get_bits(gb, 2) + 8;
558 } else { // table 60
559 58 v->s.esc3_level_length = get_unary(gb, 1, 6) + 2;
560 }
561 376 v->s.esc3_run_length = 3 + get_bits(gb, 2);
562 }
563 7286 run = get_bits(gb, v->s.esc3_run_length);
564 7286 sign = get_bits1(gb);
565 7286 level = get_bits(gb, v->s.esc3_level_length);
566 }
567 }
568
569 7231154 *last = lst;
570 7231154 *skip = run;
571 7231154 *value = (level ^ -sign) + sign;
572
573 7231154 return 0;
574 }
575
576 /** Decode intra block in intra frames - should be faster than decode_intra_block
577 * @param v VC1Context
578 * @param block block to decode
579 * @param[in] n subblock index
580 * @param coded are AC coeffs present or not
581 * @param codingset set of VLC to decode data
582 */
583 93660 static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n,
584 int coded, int codingset)
585 {
586 93660 GetBitContext *gb = &v->s.gb;
587 93660 MpegEncContext *s = &v->s;
588 93660 int dc_pred_dir = 0; /* Direction of the DC prediction used */
589 int i;
590 int16_t *dc_val;
591 int16_t *ac_val, *ac_val2;
592 int dcdiff, scale;
593
594 /* Get DC differential */
595
2/2
✓ Branch 0 taken 62440 times.
✓ Branch 1 taken 31220 times.
93660 if (n < 4) {
596 62440 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table,
597 MSMP4_DC_VLC_BITS, 3);
598 } else {
599 31220 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table,
600 MSMP4_DC_VLC_BITS, 3);
601 }
602
2/2
✓ Branch 0 taken 68920 times.
✓ Branch 1 taken 24740 times.
93660 if (dcdiff) {
603
4/4
✓ Branch 0 taken 61970 times.
✓ Branch 1 taken 6950 times.
✓ Branch 2 taken 9094 times.
✓ Branch 3 taken 52876 times.
68920 const int m = (v->pq == 1 || v->pq == 2) ? 3 - v->pq : 0;
604
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 68919 times.
68920 if (dcdiff == 119 /* ESC index value */) {
605 1 dcdiff = get_bits(gb, 8 + m);
606 } else {
607
2/2
✓ Branch 0 taken 16043 times.
✓ Branch 1 taken 52876 times.
68919 if (m)
608 16043 dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
609 }
610
2/2
✓ Branch 1 taken 35830 times.
✓ Branch 2 taken 33090 times.
68920 if (get_bits1(gb))
611 35830 dcdiff = -dcdiff;
612 }
613
614 /* Prediction */
615 93660 dcdiff += vc1_i_pred_dc(&v->s, v->overlap, v->pq, n, &dc_val, &dc_pred_dir);
616 93660 *dc_val = dcdiff;
617
618 /* Store the quantized DC coeff, used for prediction */
619
2/2
✓ Branch 0 taken 62440 times.
✓ Branch 1 taken 31220 times.
93660 if (n < 4)
620 62440 scale = s->y_dc_scale;
621 else
622 31220 scale = s->c_dc_scale;
623 93660 block[0] = dcdiff * scale;
624
625 93660 ac_val = s->ac_val[0][s->block_index[n]];
626 93660 ac_val2 = ac_val;
627
2/2
✓ Branch 0 taken 63372 times.
✓ Branch 1 taken 30288 times.
93660 if (dc_pred_dir) // left
628 63372 ac_val -= 16;
629 else // top
630 30288 ac_val -= 16 * s->block_wrap[n];
631
632 93660 scale = v->pq * 2 + v->halfpq;
633
634 //AC Decoding
635 93660 i = !!coded;
636
637
2/2
✓ Branch 0 taken 43682 times.
✓ Branch 1 taken 49978 times.
93660 if (coded) {
638 43682 int last = 0, skip, value;
639 const uint8_t *zz_table;
640 int k;
641
642
2/2
✓ Branch 0 taken 9801 times.
✓ Branch 1 taken 33881 times.
43682 if (v->s.ac_pred) {
643
2/2
✓ Branch 0 taken 3230 times.
✓ Branch 1 taken 6571 times.
9801 if (!dc_pred_dir)
644 3230 zz_table = v->zz_8x8[2];
645 else
646 6571 zz_table = v->zz_8x8[3];
647 } else
648 33881 zz_table = v->zz_8x8[1];
649
650
2/2
✓ Branch 0 taken 577295 times.
✓ Branch 1 taken 43682 times.
620977 while (!last) {
651 577295 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 577295 times.
577295 if (ret < 0)
653 return ret;
654 577295 i += skip;
655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 577295 times.
577295 if (i > 63)
656 break;
657 577295 block[zz_table[i++]] = value;
658 }
659
660 /* apply AC prediction if needed */
661
2/2
✓ Branch 0 taken 9801 times.
✓ Branch 1 taken 33881 times.
43682 if (s->ac_pred) {
662 int sh;
663
2/2
✓ Branch 0 taken 6571 times.
✓ Branch 1 taken 3230 times.
9801 if (dc_pred_dir) { // left
664 6571 sh = v->left_blk_sh;
665 } else { // top
666 3230 sh = v->top_blk_sh;
667 3230 ac_val += 8;
668 }
669
2/2
✓ Branch 0 taken 68607 times.
✓ Branch 1 taken 9801 times.
78408 for (k = 1; k < 8; k++)
670 68607 block[k << sh] += ac_val[k];
671 }
672 /* save AC coeffs for further prediction */
673
2/2
✓ Branch 0 taken 305774 times.
✓ Branch 1 taken 43682 times.
349456 for (k = 1; k < 8; k++) {
674 305774 ac_val2[k] = block[k << v->left_blk_sh];
675 305774 ac_val2[k + 8] = block[k << v->top_blk_sh];
676 }
677
678 /* scale AC coeffs */
679
2/2
✓ Branch 0 taken 2751966 times.
✓ Branch 1 taken 43682 times.
2795648 for (k = 1; k < 64; k++)
680
2/2
✓ Branch 0 taken 577252 times.
✓ Branch 1 taken 2174714 times.
2751966 if (block[k]) {
681 577252 block[k] *= scale;
682
2/2
✓ Branch 0 taken 66373 times.
✓ Branch 1 taken 510879 times.
577252 if (!v->pquantizer)
683
2/2
✓ Branch 0 taken 33005 times.
✓ Branch 1 taken 33368 times.
66373 block[k] += (block[k] < 0) ? -v->pq : v->pq;
684 }
685
686 } else {
687 int k;
688
689 49978 memset(ac_val2, 0, 16 * 2);
690
691 /* apply AC prediction if needed */
692
2/2
✓ Branch 0 taken 3825 times.
✓ Branch 1 taken 46153 times.
49978 if (s->ac_pred) {
693 int sh;
694
2/2
✓ Branch 0 taken 2909 times.
✓ Branch 1 taken 916 times.
3825 if (dc_pred_dir) { //left
695 2909 sh = v->left_blk_sh;
696 } else { // top
697 916 sh = v->top_blk_sh;
698 916 ac_val += 8;
699 916 ac_val2 += 8;
700 }
701 3825 memcpy(ac_val2, ac_val, 8 * 2);
702
2/2
✓ Branch 0 taken 26775 times.
✓ Branch 1 taken 3825 times.
30600 for (k = 1; k < 8; k++) {
703 26775 block[k << sh] = ac_val[k] * scale;
704
4/4
✓ Branch 0 taken 19978 times.
✓ Branch 1 taken 6797 times.
✓ Branch 2 taken 583 times.
✓ Branch 3 taken 19395 times.
26775 if (!v->pquantizer && block[k << sh])
705
2/2
✓ Branch 0 taken 265 times.
✓ Branch 1 taken 318 times.
583 block[k << sh] += (block[k << sh] < 0) ? -v->pq : v->pq;
706 }
707 }
708 }
709
2/2
✓ Branch 0 taken 13626 times.
✓ Branch 1 taken 80034 times.
93660 if (s->ac_pred) i = 63;
710 93660 s->block_last_index[n] = i;
711
712 93660 return 0;
713 }
714
715 /** Decode intra block in intra frames - should be faster than decode_intra_block
716 * @param v VC1Context
717 * @param block block to decode
718 * @param[in] n subblock number
719 * @param coded are AC coeffs present or not
720 * @param codingset set of VLC to decode data
721 * @param mquant quantizer value for this macroblock
722 */
723 72684 static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n,
724 int coded, int codingset, int mquant)
725 {
726 72684 GetBitContext *gb = &v->s.gb;
727 72684 MpegEncContext *s = &v->s;
728 72684 int dc_pred_dir = 0; /* Direction of the DC prediction used */
729 int i;
730 72684 int16_t *dc_val = NULL;
731 int16_t *ac_val, *ac_val2;
732 int dcdiff;
733 72684 int a_avail = v->a_avail, c_avail = v->c_avail;
734 72684 int use_pred = s->ac_pred;
735 int scale;
736 72684 int q1, q2 = 0;
737 72684 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
738 72684 int quant = FFABS(mquant);
739
740 /* Get DC differential */
741
2/2
✓ Branch 0 taken 48456 times.
✓ Branch 1 taken 24228 times.
72684 if (n < 4) {
742 48456 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table,
743 MSMP4_DC_VLC_BITS, 3);
744 } else {
745 24228 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table,
746 MSMP4_DC_VLC_BITS, 3);
747 }
748
2/2
✓ Branch 0 taken 50133 times.
✓ Branch 1 taken 22551 times.
72684 if (dcdiff) {
749
4/4
✓ Branch 0 taken 45971 times.
✓ Branch 1 taken 4162 times.
✓ Branch 2 taken 2383 times.
✓ Branch 3 taken 43588 times.
50133 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
750
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 50132 times.
50133 if (dcdiff == 119 /* ESC index value */) {
751 1 dcdiff = get_bits(gb, 8 + m);
752 } else {
753
2/2
✓ Branch 0 taken 6545 times.
✓ Branch 1 taken 43587 times.
50132 if (m)
754 6545 dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
755 }
756
2/2
✓ Branch 1 taken 25831 times.
✓ Branch 2 taken 24302 times.
50133 if (get_bits1(gb))
757 25831 dcdiff = -dcdiff;
758 }
759
760 /* Prediction */
761 72684 dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, quant, n, v->a_avail, v->c_avail, &dc_val, &dc_pred_dir);
762 72684 *dc_val = dcdiff;
763
764 /* Store the quantized DC coeff, used for prediction */
765
2/2
✓ Branch 0 taken 48456 times.
✓ Branch 1 taken 24228 times.
72684 if (n < 4)
766 48456 scale = s->y_dc_scale;
767 else
768 24228 scale = s->c_dc_scale;
769 72684 block[0] = dcdiff * scale;
770
771 /* check if AC is needed at all */
772
4/4
✓ Branch 0 taken 2328 times.
✓ Branch 1 taken 70356 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 2286 times.
72684 if (!a_avail && !c_avail)
773 42 use_pred = 0;
774
775
2/2
✓ Branch 0 taken 23724 times.
✓ Branch 1 taken 48960 times.
72684 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
776
777 72684 ac_val = s->ac_val[0][s->block_index[n]];
778 72684 ac_val2 = ac_val;
779
2/2
✓ Branch 0 taken 48137 times.
✓ Branch 1 taken 24547 times.
72684 if (dc_pred_dir) // left
780 48137 ac_val -= 16;
781 else // top
782 24547 ac_val -= 16 * s->block_wrap[n];
783
784 72684 q1 = s->current_picture.qscale_table[mb_pos];
785
2/2
✓ Branch 0 taken 12114 times.
✓ Branch 1 taken 60570 times.
72684 if (n == 3)
786 12114 q2 = q1;
787
2/2
✓ Branch 0 taken 40639 times.
✓ Branch 1 taken 19931 times.
60570 else if (dc_pred_dir) {
788
2/2
✓ Branch 0 taken 8215 times.
✓ Branch 1 taken 32424 times.
40639 if (n == 1)
789 8215 q2 = q1;
790
3/4
✓ Branch 0 taken 32382 times.
✓ Branch 1 taken 42 times.
✓ Branch 2 taken 32382 times.
✗ Branch 3 not taken.
32424 else if (c_avail && mb_pos)
791 32382 q2 = s->current_picture.qscale_table[mb_pos - 1];
792 } else {
793
2/2
✓ Branch 0 taken 4905 times.
✓ Branch 1 taken 15026 times.
19931 if (n == 2)
794 4905 q2 = q1;
795
2/4
✓ Branch 0 taken 15026 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15026 times.
✗ Branch 3 not taken.
15026 else if (a_avail && mb_pos >= s->mb_stride)
796 15026 q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
797 }
798
799 //AC Decoding
800 72684 i = 1;
801
802
2/2
✓ Branch 0 taken 65520 times.
✓ Branch 1 taken 7164 times.
72684 if (coded) {
803 65520 int last = 0, skip, value;
804 const uint8_t *zz_table;
805 int k;
806
807
2/2
✓ Branch 0 taken 16184 times.
✓ Branch 1 taken 49336 times.
65520 if (v->s.ac_pred) {
808
4/4
✓ Branch 0 taken 12 times.
✓ Branch 1 taken 16172 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 9 times.
16184 if (!use_pred && v->fcm == ILACE_FRAME) {
809 3 zz_table = v->zzi_8x8;
810 } else {
811
2/2
✓ Branch 0 taken 5968 times.
✓ Branch 1 taken 10213 times.
16181 if (!dc_pred_dir) // top
812 5968 zz_table = v->zz_8x8[2];
813 else // left
814 10213 zz_table = v->zz_8x8[3];
815 }
816 } else {
817
2/2
✓ Branch 0 taken 12456 times.
✓ Branch 1 taken 36880 times.
49336 if (v->fcm != ILACE_FRAME)
818 12456 zz_table = v->zz_8x8[1];
819 else
820 36880 zz_table = v->zzi_8x8;
821 }
822
823
2/2
✓ Branch 0 taken 780405 times.
✓ Branch 1 taken 65520 times.
845925 while (!last) {
824 780405 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780405 times.
780405 if (ret < 0)
826 return ret;
827 780405 i += skip;
828
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 780405 times.
780405 if (i > 63)
829 break;
830 780405 block[zz_table[i++]] = value;
831 }
832
833 /* apply AC prediction if needed */
834
2/2
✓ Branch 0 taken 16172 times.
✓ Branch 1 taken 49348 times.
65520 if (use_pred) {
835 int sh;
836
2/2
✓ Branch 0 taken 10204 times.
✓ Branch 1 taken 5968 times.
16172 if (dc_pred_dir) { // left
837 10204 sh = v->left_blk_sh;
838 } else { // top
839 5968 sh = v->top_blk_sh;
840 5968 ac_val += 8;
841 }
842 /* scale predictors if needed*/
843
2/2
✓ Branch 0 taken 5966 times.
✓ Branch 1 taken 10206 times.
16172 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
844
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16172 times.
16172 if (q1 < 1)
845 return AVERROR_INVALIDDATA;
846
1/2
✓ Branch 0 taken 16172 times.
✗ Branch 1 not taken.
16172 if (q2)
847
2/2
✓ Branch 0 taken 5966 times.
✓ Branch 1 taken 10206 times.
16172 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
848
3/4
✓ Branch 0 taken 16172 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1017 times.
✓ Branch 3 taken 15155 times.
16172 if (q2 && q1 != q2) {
849
2/2
✓ Branch 0 taken 7119 times.
✓ Branch 1 taken 1017 times.
8136 for (k = 1; k < 8; k++)
850 7119 block[k << sh] += (int)(ac_val[k] * (unsigned)q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
851 } else {
852
2/2
✓ Branch 0 taken 106085 times.
✓ Branch 1 taken 15155 times.
121240 for (k = 1; k < 8; k++)
853 106085 block[k << sh] += ac_val[k];
854 }
855 }
856 /* save AC coeffs for further prediction */
857
2/2
✓ Branch 0 taken 458640 times.
✓ Branch 1 taken 65520 times.
524160 for (k = 1; k < 8; k++) {
858 458640 ac_val2[k ] = block[k << v->left_blk_sh];
859 458640 ac_val2[k + 8] = block[k << v->top_blk_sh];
860 }
861
862 /* scale AC coeffs */
863
2/2
✓ Branch 0 taken 4127760 times.
✓ Branch 1 taken 65520 times.
4193280 for (k = 1; k < 64; k++)
864
2/2
✓ Branch 0 taken 779370 times.
✓ Branch 1 taken 3348390 times.
4127760 if (block[k]) {
865 779370 block[k] *= scale;
866
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 779370 times.
779370 if (!v->pquantizer)
867 block[k] += (block[k] < 0) ? -quant : quant;
868 }
869
870 } else { // no AC coeffs
871 int k;
872
873 7164 memset(ac_val2, 0, 16 * 2);
874
875 /* apply AC prediction if needed */
876
2/2
✓ Branch 0 taken 1708 times.
✓ Branch 1 taken 5456 times.
7164 if (use_pred) {
877 int sh;
878
2/2
✓ Branch 0 taken 1468 times.
✓ Branch 1 taken 240 times.
1708 if (dc_pred_dir) { // left
879 1468 sh = v->left_blk_sh;
880 } else { // top
881 240 sh = v->top_blk_sh;
882 240 ac_val += 8;
883 240 ac_val2 += 8;
884 }
885 1708 memcpy(ac_val2, ac_val, 8 * 2);
886
2/2
✓ Branch 0 taken 1345 times.
✓ Branch 1 taken 363 times.
1708 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1708 times.
1708 if (q1 < 1)
888 return AVERROR_INVALIDDATA;
889
1/2
✓ Branch 0 taken 1708 times.
✗ Branch 1 not taken.
1708 if (q2)
890
2/2
✓ Branch 0 taken 1345 times.
✓ Branch 1 taken 363 times.
1708 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
891
3/4
✓ Branch 0 taken 1708 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 1603 times.
1708 if (q2 && q1 != q2) {
892
2/2
✓ Branch 0 taken 735 times.
✓ Branch 1 taken 105 times.
840 for (k = 1; k < 8; k++)
893 735 ac_val2[k] = (int)(ac_val2[k] * q2 * (unsigned)ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
894 }
895
2/2
✓ Branch 0 taken 11956 times.
✓ Branch 1 taken 1708 times.
13664 for (k = 1; k < 8; k++) {
896 11956 block[k << sh] = ac_val2[k] * scale;
897
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11956 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11956 if (!v->pquantizer && block[k << sh])
898 block[k << sh] += (block[k << sh] < 0) ? -quant : quant;
899 }
900 }
901 }
902
2/2
✓ Branch 0 taken 17880 times.
✓ Branch 1 taken 54804 times.
72684 if (use_pred) i = 63;
903 72684 s->block_last_index[n] = i;
904
905 72684 return 0;
906 }
907
908 /** Decode intra block in inter frames - more generic version than vc1_decode_i_block
909 * @param v VC1Context
910 * @param block block to decode
911 * @param[in] n subblock index
912 * @param coded are AC coeffs present or not
913 * @param mquant block quantizer
914 * @param codingset set of VLC to decode data
915 */
916 234820 static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n,
917 int coded, int mquant, int codingset)
918 {
919 234820 GetBitContext *gb = &v->s.gb;
920 234820 MpegEncContext *s = &v->s;
921 234820 int dc_pred_dir = 0; /* Direction of the DC prediction used */
922 int i;
923 234820 int16_t *dc_val = NULL;
924 int16_t *ac_val, *ac_val2;
925 int dcdiff;
926 234820 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
927 234820 int a_avail = v->a_avail, c_avail = v->c_avail;
928 234820 int use_pred = s->ac_pred;
929 int scale;
930 234820 int q1, q2 = 0;
931 234820 int quant = FFABS(mquant);
932
933 234820 s->bdsp.clear_block(block);
934
935 /* XXX: Guard against dumb values of mquant */
936 234820 quant = av_clip_uintp2(quant, 5);
937
938 /* Set DC scale - y and c use the same */
939 234820 s->y_dc_scale = s->y_dc_scale_table[quant];
940 234820 s->c_dc_scale = s->c_dc_scale_table[quant];
941
942 /* Get DC differential */
943
2/2
✓ Branch 0 taken 158444 times.
✓ Branch 1 taken 76376 times.
234820 if (n < 4) {
944 158444 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_luma_vlc[s->dc_table_index].table,
945 MSMP4_DC_VLC_BITS, 3);
946 } else {
947 76376 dcdiff = get_vlc2(&s->gb, ff_msmp4_dc_chroma_vlc[s->dc_table_index].table,
948 MSMP4_DC_VLC_BITS, 3);
949 }
950
2/2
✓ Branch 0 taken 189282 times.
✓ Branch 1 taken 45538 times.
234820 if (dcdiff) {
951
3/4
✓ Branch 0 taken 189282 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18284 times.
✓ Branch 3 taken 170998 times.
189282 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
952
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 189279 times.
189282 if (dcdiff == 119 /* ESC index value */) {
953 3 dcdiff = get_bits(gb, 8 + m);
954 } else {
955
2/2
✓ Branch 0 taken 18284 times.
✓ Branch 1 taken 170995 times.
189279 if (m)
956 18284 dcdiff = (dcdiff << m) + get_bits(gb, m) - ((1 << m) - 1);
957 }
958
2/2
✓ Branch 1 taken 106032 times.
✓ Branch 2 taken 83250 times.
189282 if (get_bits1(gb))
959 106032 dcdiff = -dcdiff;
960 }
961
962 /* Prediction */
963 234820 dcdiff += ff_vc1_pred_dc(&v->s, v->overlap, quant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
964 234820 *dc_val = dcdiff;
965
966 /* Store the quantized DC coeff, used for prediction */
967
968
2/2
✓ Branch 0 taken 158444 times.
✓ Branch 1 taken 76376 times.
234820 if (n < 4) {
969 158444 block[0] = dcdiff * s->y_dc_scale;
970 } else {
971 76376 block[0] = dcdiff * s->c_dc_scale;
972 }
973
974 //AC Decoding
975 234820 i = 1;
976
977 /* check if AC is needed at all and adjust direction if needed */
978
2/2
✓ Branch 0 taken 109237 times.
✓ Branch 1 taken 125583 times.
234820 if (!a_avail) dc_pred_dir = 1;
979
2/2
✓ Branch 0 taken 92579 times.
✓ Branch 1 taken 142241 times.
234820 if (!c_avail) dc_pred_dir = 0;
980
4/4
✓ Branch 0 taken 109237 times.
✓ Branch 1 taken 125583 times.
✓ Branch 2 taken 53092 times.
✓ Branch 3 taken 56145 times.
234820 if (!a_avail && !c_avail) use_pred = 0;
981 234820 ac_val = s->ac_val[0][s->block_index[n]];
982 234820 ac_val2 = ac_val;
983
984
2/2
✓ Branch 0 taken 231268 times.
✓ Branch 1 taken 3552 times.
234820 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
985
986
2/2
✓ Branch 0 taken 113011 times.
✓ Branch 1 taken 121809 times.
234820 if (dc_pred_dir) //left
987 113011 ac_val -= 16;
988 else //top
989 121809 ac_val -= 16 * s->block_wrap[n];
990
991 234820 q1 = s->current_picture.qscale_table[mb_pos];
992
5/6
✓ Branch 0 taken 113011 times.
✓ Branch 1 taken 121809 times.
✓ Branch 2 taken 113011 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 112932 times.
✓ Branch 5 taken 79 times.
234820 if (dc_pred_dir && c_avail && mb_pos)
993 112932 q2 = s->current_picture.qscale_table[mb_pos - 1];
994
6/6
✓ Branch 0 taken 121809 times.
✓ Branch 1 taken 113011 times.
✓ Branch 2 taken 68717 times.
✓ Branch 3 taken 53092 times.
✓ Branch 4 taken 67195 times.
✓ Branch 5 taken 1522 times.
234820 if (!dc_pred_dir && a_avail && mb_pos >= s->mb_stride)
995 67195 q2 = s->current_picture.qscale_table[mb_pos - s->mb_stride];
996
4/4
✓ Branch 0 taken 113011 times.
✓ Branch 1 taken 121809 times.
✓ Branch 2 taken 33871 times.
✓ Branch 3 taken 79140 times.
234820 if (dc_pred_dir && n == 1)
997 33871 q2 = q1;
998
4/4
✓ Branch 0 taken 121809 times.
✓ Branch 1 taken 113011 times.
✓ Branch 2 taken 28266 times.
✓ Branch 3 taken 93543 times.
234820 if (!dc_pred_dir && n == 2)
999 28266 q2 = q1;
1000
2/2
✓ Branch 0 taken 39659 times.
✓ Branch 1 taken 195161 times.
234820 if (n == 3) q2 = q1;
1001
1002
2/2
✓ Branch 0 taken 162495 times.
✓ Branch 1 taken 72325 times.
234820 if (coded) {
1003 162495 int last = 0, skip, value;
1004 int k;
1005
1006
2/2
✓ Branch 0 taken 1519294 times.
✓ Branch 1 taken 162495 times.
1681789 while (!last) {
1007 1519294 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, codingset);
1008
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1519294 times.
1519294 if (ret < 0)
1009 return ret;
1010 1519294 i += skip;
1011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1519294 times.
1519294 if (i > 63)
1012 break;
1013
2/2
✓ Branch 0 taken 925288 times.
✓ Branch 1 taken 594006 times.
1519294 if (v->fcm == PROGRESSIVE)
1014 925288 block[v->zz_8x8[0][i++]] = value;
1015 else {
1016
4/4
✓ Branch 0 taken 182095 times.
✓ Branch 1 taken 411911 times.
✓ Branch 2 taken 19188 times.
✓ Branch 3 taken 162907 times.
594006 if (use_pred && (v->fcm == ILACE_FRAME)) {
1017
2/2
✓ Branch 0 taken 8623 times.
✓ Branch 1 taken 10565 times.
19188 if (!dc_pred_dir) // top
1018 8623 block[v->zz_8x8[2][i++]] = value;
1019 else // left
1020 10565 block[v->zz_8x8[3][i++]] = value;
1021 } else {
1022 574818 block[v->zzi_8x8[i++]] = value;
1023 }
1024 }
1025 }
1026
1027 /* apply AC prediction if needed */
1028
2/2
✓ Branch 0 taken 42460 times.
✓ Branch 1 taken 120035 times.
162495 if (use_pred) {
1029 /* scale predictors if needed*/
1030
2/2
✓ Branch 0 taken 41568 times.
✓ Branch 1 taken 892 times.
42460 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
1031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 42460 times.
42460 if (q1 < 1)
1032 return AVERROR_INVALIDDATA;
1033
1/2
✓ Branch 0 taken 42460 times.
✗ Branch 1 not taken.
42460 if (q2)
1034
2/2
✓ Branch 0 taken 41458 times.
✓ Branch 1 taken 1002 times.
42460 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
1035
3/4
✓ Branch 0 taken 42460 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 354 times.
✓ Branch 3 taken 42106 times.
42460 if (q2 && q1 != q2) {
1036
2/2
✓ Branch 0 taken 235 times.
✓ Branch 1 taken 119 times.
354 if (dc_pred_dir) { // left
1037
2/2
✓ Branch 0 taken 1645 times.
✓ Branch 1 taken 235 times.
1880 for (k = 1; k < 8; k++)
1038 1645 block[k << v->left_blk_sh] += (int)(ac_val[k] * q2 * (unsigned)ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1039 } else { //top
1040
2/2
✓ Branch 0 taken 833 times.
✓ Branch 1 taken 119 times.
952 for (k = 1; k < 8; k++)
1041 833 block[k << v->top_blk_sh] += (int)(ac_val[k + 8] * q2 * (unsigned)ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1042 }
1043 } else {
1044
2/2
✓ Branch 0 taken 25305 times.
✓ Branch 1 taken 16801 times.
42106 if (dc_pred_dir) { // left
1045
2/2
✓ Branch 0 taken 177135 times.
✓ Branch 1 taken 25305 times.
202440 for (k = 1; k < 8; k++)
1046 177135 block[k << v->left_blk_sh] += ac_val[k];
1047 } else { // top
1048
2/2
✓ Branch 0 taken 117607 times.
✓ Branch 1 taken 16801 times.
134408 for (k = 1; k < 8; k++)
1049 117607 block[k << v->top_blk_sh] += ac_val[k + 8];
1050 }
1051 }
1052 }
1053 /* save AC coeffs for further prediction */
1054
2/2
✓ Branch 0 taken 1137465 times.
✓ Branch 1 taken 162495 times.
1299960 for (k = 1; k < 8; k++) {
1055 1137465 ac_val2[k ] = block[k << v->left_blk_sh];
1056 1137465 ac_val2[k + 8] = block[k << v->top_blk_sh];
1057 }
1058
1059 /* scale AC coeffs */
1060
2/2
✓ Branch 0 taken 10237185 times.
✓ Branch 1 taken 162495 times.
10399680 for (k = 1; k < 64; k++)
1061
2/2
✓ Branch 0 taken 1522244 times.
✓ Branch 1 taken 8714941 times.
10237185 if (block[k]) {
1062 1522244 block[k] *= scale;
1063
2/2
✓ Branch 0 taken 28424 times.
✓ Branch 1 taken 1493820 times.
1522244 if (!v->pquantizer)
1064
2/2
✓ Branch 0 taken 14356 times.
✓ Branch 1 taken 14068 times.
28424 block[k] += (block[k] < 0) ? -quant : quant;
1065 }
1066
1067
2/2
✓ Branch 0 taken 42460 times.
✓ Branch 1 taken 120035 times.
162495 if (use_pred) i = 63;
1068 } else { // no AC coeffs
1069 int k;
1070
1071 72325 memset(ac_val2, 0, 16 * 2);
1072
2/2
✓ Branch 0 taken 34015 times.
✓ Branch 1 taken 38310 times.
72325 if (dc_pred_dir) { // left
1073
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 27331 times.
34015 if (use_pred) {
1074 6684 memcpy(ac_val2, ac_val, 8 * 2);
1075
2/2
✓ Branch 0 taken 5949 times.
✓ Branch 1 taken 735 times.
6684 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
1076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6684 times.
6684 if (q1 < 1)
1077 return AVERROR_INVALIDDATA;
1078
1/2
✓ Branch 0 taken 6684 times.
✗ Branch 1 not taken.
6684 if (q2)
1079
2/2
✓ Branch 0 taken 5949 times.
✓ Branch 1 taken 735 times.
6684 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
1080
3/4
✓ Branch 0 taken 6684 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 32 times.
✓ Branch 3 taken 6652 times.
6684 if (q2 && q1 != q2) {
1081
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 32 times.
256 for (k = 1; k < 8; k++)
1082 224 ac_val2[k] = (int)(ac_val2[k] * (unsigned)q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1083 }
1084 }
1085 } else { // top
1086
2/2
✓ Branch 0 taken 2665 times.
✓ Branch 1 taken 35645 times.
38310 if (use_pred) {
1087 2665 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
1088
2/2
✓ Branch 0 taken 2573 times.
✓ Branch 1 taken 92 times.
2665 q1 = FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->halfpq) - 1;
1089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2665 times.
2665 if (q1 < 1)
1090 return AVERROR_INVALIDDATA;
1091
1/2
✓ Branch 0 taken 2665 times.
✗ Branch 1 not taken.
2665 if (q2)
1092
2/2
✓ Branch 0 taken 2574 times.
✓ Branch 1 taken 91 times.
2665 q2 = FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->halfpq) - 1;
1093
3/4
✓ Branch 0 taken 2665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 2652 times.
2665 if (q2 && q1 != q2) {
1094
2/2
✓ Branch 0 taken 91 times.
✓ Branch 1 taken 13 times.
104 for (k = 1; k < 8; k++)
1095 91 ac_val2[k + 8] = (int)(ac_val2[k + 8] * (unsigned)q2 * ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1096 }
1097 }
1098 }
1099
1100 /* apply AC prediction if needed */
1101
2/2
✓ Branch 0 taken 9349 times.
✓ Branch 1 taken 62976 times.
72325 if (use_pred) {
1102
2/2
✓ Branch 0 taken 6684 times.
✓ Branch 1 taken 2665 times.
9349 if (dc_pred_dir) { // left
1103
2/2
✓ Branch 0 taken 46788 times.
✓ Branch 1 taken 6684 times.
53472 for (k = 1; k < 8; k++) {
1104 46788 block[k << v->left_blk_sh] = ac_val2[k] * scale;
1105
4/4
✓ Branch 0 taken 5341 times.
✓ Branch 1 taken 41447 times.
✓ Branch 2 taken 127 times.
✓ Branch 3 taken 5214 times.
46788 if (!v->pquantizer && block[k << v->left_blk_sh])
1106
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;
1107 }
1108 } else { // top
1109
2/2
✓ Branch 0 taken 18655 times.
✓ Branch 1 taken 2665 times.
21320 for (k = 1; k < 8; k++) {
1110 18655 block[k << v->top_blk_sh] = ac_val2[k + 8] * scale;
1111
4/4
✓ Branch 0 taken 3493 times.
✓ Branch 1 taken 15162 times.
✓ Branch 2 taken 129 times.
✓ Branch 3 taken 3364 times.
18655 if (!v->pquantizer && block[k << v->top_blk_sh])
1112
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;
1113 }
1114 }
1115 9349 i = 63;
1116 }
1117 }
1118 234820 s->block_last_index[n] = i;
1119
1120 234820 return 0;
1121 }
1122
1123 /** Decode P block
1124 */
1125 703814 static int vc1_decode_p_block(VC1Context *v, int16_t block[64], int n,
1126 int mquant, int ttmb, int first_block,
1127 uint8_t *dst, int linesize, int skip_block,
1128 int *ttmb_out)
1129 {
1130 703814 MpegEncContext *s = &v->s;
1131 703814 GetBitContext *gb = &s->gb;
1132 int i, j;
1133 703814 int subblkpat = 0;
1134 int scale, off, idx, last, skip, value;
1135 703814 int ttblk = ttmb & 7;
1136 703814 int pat = 0;
1137 703814 int quant = FFABS(mquant);
1138
1139 703814 s->bdsp.clear_block(block);
1140
1141
2/2
✓ Branch 0 taken 327570 times.
✓ Branch 1 taken 376244 times.
703814 if (ttmb == -1) {
1142 327570 ttblk = ff_vc1_ttblk_to_tt[v->tt_index][get_vlc2(gb, ff_vc1_ttblk_vlc[v->tt_index].table, VC1_TTBLK_VLC_BITS, 1)];
1143 }
1144
2/2
✓ Branch 0 taken 77928 times.
✓ Branch 1 taken 625886 times.
703814 if (ttblk == TT_4X4) {
1145 77928 subblkpat = ~(get_vlc2(gb, ff_vc1_subblkpat_vlc[v->tt_index].table, VC1_SUBBLKPAT_VLC_BITS, 1) + 1);
1146 }
1147
4/4
✓ Branch 0 taken 351162 times.
✓ Branch 1 taken 352652 times.
✓ Branch 2 taken 273234 times.
✓ Branch 3 taken 77928 times.
703814 if ((ttblk != TT_8X8 && ttblk != TT_4X4)
1148
7/8
✓ Branch 0 taken 273234 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 107598 times.
✓ Branch 3 taken 165636 times.
✓ Branch 4 taken 43051 times.
✓ Branch 5 taken 64547 times.
✓ Branch 6 taken 12570 times.
✓ Branch 7 taken 30481 times.
273234 && ((v->ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
1149
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 242753 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
242753 || (!v->res_rtm_flag && !first_block))) {
1150 30481 subblkpat = decode012(gb);
1151
2/2
✓ Branch 0 taken 11134 times.
✓ Branch 1 taken 19347 times.
30481 if (subblkpat)
1152 11134 subblkpat ^= 3; // swap decoded pattern bits
1153
4/4
✓ Branch 0 taken 27632 times.
✓ Branch 1 taken 2849 times.
✓ Branch 2 taken 2871 times.
✓ Branch 3 taken 24761 times.
30481 if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM)
1154 5720 ttblk = TT_8X4;
1155
4/4
✓ Branch 0 taken 28242 times.
✓ Branch 1 taken 2239 times.
✓ Branch 2 taken 1740 times.
✓ Branch 3 taken 26502 times.
30481 if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT)
1156 3979 ttblk = TT_4X8;
1157 }
1158
2/2
✓ Branch 0 taken 673678 times.
✓ Branch 1 taken 30136 times.
703814 scale = quant * 2 + ((mquant < 0) ? 0 : v->halfpq);
1159
1160 // convert transforms like 8X4_TOP to generic TT and SUBBLKPAT
1161
4/4
✓ Branch 0 taken 684998 times.
✓ Branch 1 taken 18816 times.
✓ Branch 2 taken 20119 times.
✓ Branch 3 taken 664879 times.
703814 if (ttblk == TT_8X4_TOP || ttblk == TT_8X4_BOTTOM) {
1162
2/2
✓ Branch 0 taken 18816 times.
✓ Branch 1 taken 20119 times.
38935 subblkpat = 2 - (ttblk == TT_8X4_TOP);
1163 38935 ttblk = TT_8X4;
1164 }
1165
4/4
✓ Branch 0 taken 679721 times.
✓ Branch 1 taken 24093 times.
✓ Branch 2 taken 23541 times.
✓ Branch 3 taken 656180 times.
703814 if (ttblk == TT_4X8_RIGHT || ttblk == TT_4X8_LEFT) {
1166
2/2
✓ Branch 0 taken 23541 times.
✓ Branch 1 taken 24093 times.
47634 subblkpat = 2 - (ttblk == TT_4X8_LEFT);
1167 47634 ttblk = TT_4X8;
1168 }
1169
4/5
✓ Branch 0 taken 352652 times.
✓ Branch 1 taken 77928 times.
✓ Branch 2 taken 134020 times.
✓ Branch 3 taken 139214 times.
✗ Branch 4 not taken.
703814 switch (ttblk) {
1170 352652 case TT_8X8:
1171 352652 pat = 0xF;
1172 352652 i = 0;
1173 352652 last = 0;
1174
2/2
✓ Branch 0 taken 2074333 times.
✓ Branch 1 taken 352652 times.
2426985 while (!last) {
1175 2074333 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2074333 times.
2074333 if (ret < 0)
1177 return ret;
1178 2074333 i += skip;
1179
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2074333 times.
2074333 if (i > 63)
1180 break;
1181
2/2
✓ Branch 0 taken 934770 times.
✓ Branch 1 taken 1139563 times.
2074333 if (!v->fcm)
1182 934770 idx = v->zz_8x8[0][i++];
1183 else
1184 1139563 idx = v->zzi_8x8[i++];
1185 2074333 block[idx] = value * scale;
1186
2/2
✓ Branch 0 taken 201139 times.
✓ Branch 1 taken 1873194 times.
2074333 if (!v->pquantizer)
1187
2/2
✓ Branch 0 taken 100867 times.
✓ Branch 1 taken 100272 times.
201139 block[idx] += (block[idx] < 0) ? -quant : quant;
1188 }
1189
1/2
✓ Branch 0 taken 352652 times.
✗ Branch 1 not taken.
352652 if (!skip_block) {
1190
2/2
✓ Branch 0 taken 48583 times.
✓ Branch 1 taken 304069 times.
352652 if (i == 1)
1191 48583 v->vc1dsp.vc1_inv_trans_8x8_dc(dst, linesize, block);
1192 else {
1193 304069 v->vc1dsp.vc1_inv_trans_8x8(block);
1194 304069 s->idsp.add_pixels_clamped(block, dst, linesize);
1195 }
1196 }
1197 352652 break;
1198 77928 case TT_4X4:
1199 77928 pat = ~subblkpat & 0xF;
1200
2/2
✓ Branch 0 taken 311712 times.
✓ Branch 1 taken 77928 times.
389640 for (j = 0; j < 4; j++) {
1201 311712 last = subblkpat & (1 << (3 - j));
1202 311712 i = 0;
1203 311712 off = (j & 1) * 4 + (j & 2) * 16;
1204
2/2
✓ Branch 0 taken 506656 times.
✓ Branch 1 taken 311712 times.
818368 while (!last) {
1205 506656 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1206
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 506656 times.
506656 if (ret < 0)
1207 return ret;
1208 506656 i += skip;
1209
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 506656 times.
506656 if (i > 15)
1210 break;
1211
2/2
✓ Branch 0 taken 283472 times.
✓ Branch 1 taken 223184 times.
506656 if (!v->fcm)
1212 283472 idx = ff_vc1_simple_progressive_4x4_zz[i++];
1213 else
1214 223184 idx = ff_vc1_adv_interlaced_4x4_zz[i++];
1215 506656 block[idx + off] = value * scale;
1216
2/2
✓ Branch 0 taken 9718 times.
✓ Branch 1 taken 496938 times.
506656 if (!v->pquantizer)
1217
2/2
✓ Branch 0 taken 4862 times.
✓ Branch 1 taken 4856 times.
9718 block[idx + off] += (block[idx + off] < 0) ? -quant : quant;
1218 }
1219
3/4
✓ Branch 0 taken 190131 times.
✓ Branch 1 taken 121581 times.
✓ Branch 2 taken 190131 times.
✗ Branch 3 not taken.
311712 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
1220
2/2
✓ Branch 0 taken 21184 times.
✓ Branch 1 taken 168947 times.
190131 if (i == 1)
1221 21184 v->vc1dsp.vc1_inv_trans_4x4_dc(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off);
1222 else
1223 168947 v->vc1dsp.vc1_inv_trans_4x4(dst + (j & 1) * 4 + (j & 2) * 2 * linesize, linesize, block + off);
1224 }
1225 }
1226 77928 break;
1227 134020 case TT_8X4:
1228 134020 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
1229
2/2
✓ Branch 0 taken 268040 times.
✓ Branch 1 taken 134020 times.
402060 for (j = 0; j < 2; j++) {
1230 268040 last = subblkpat & (1 << (1 - j));
1231 268040 i = 0;
1232 268040 off = j * 32;
1233
2/2
✓ Branch 0 taken 896591 times.
✓ Branch 1 taken 268040 times.
1164631 while (!last) {
1234 896591 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 896591 times.
896591 if (ret < 0)
1236 return ret;
1237 896591 i += skip;
1238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 896591 times.
896591 if (i > 31)
1239 break;
1240
2/2
✓ Branch 0 taken 470573 times.
✓ Branch 1 taken 426018 times.
896591 if (!v->fcm)
1241 470573 idx = v->zz_8x4[i++] + off;
1242 else
1243 426018 idx = ff_vc1_adv_interlaced_8x4_zz[i++] + off;
1244 896591 block[idx] = value * scale;
1245
2/2
✓ Branch 0 taken 9538 times.
✓ Branch 1 taken 887053 times.
896591 if (!v->pquantizer)
1246
2/2
✓ Branch 0 taken 4864 times.
✓ Branch 1 taken 4674 times.
9538 block[idx] += (block[idx] < 0) ? -quant : quant;
1247 }
1248
3/4
✓ Branch 0 taken 222413 times.
✓ Branch 1 taken 45627 times.
✓ Branch 2 taken 222413 times.
✗ Branch 3 not taken.
268040 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1249
2/2
✓ Branch 0 taken 15798 times.
✓ Branch 1 taken 206615 times.
222413 if (i == 1)
1250 15798 v->vc1dsp.vc1_inv_trans_8x4_dc(dst + j * 4 * linesize, linesize, block + off);
1251 else
1252 206615 v->vc1dsp.vc1_inv_trans_8x4(dst + j * 4 * linesize, linesize, block + off);
1253 }
1254 }
1255 134020 break;
1256 139214 case TT_4X8:
1257 139214 pat = ~(subblkpat * 5) & 0xF;
1258
2/2
✓ Branch 0 taken 278428 times.
✓ Branch 1 taken 139214 times.
417642 for (j = 0; j < 2; j++) {
1259 278428 last = subblkpat & (1 << (1 - j));
1260 278428 i = 0;
1261 278428 off = j * 4;
1262
2/2
✓ Branch 0 taken 876580 times.
✓ Branch 1 taken 278428 times.
1155008 while (!last) {
1263 876580 int ret = vc1_decode_ac_coeff(v, &last, &skip, &value, v->codingset2);
1264
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 876580 times.
876580 if (ret < 0)
1265 return ret;
1266 876580 i += skip;
1267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 876580 times.
876580 if (i > 31)
1268 break;
1269
2/2
✓ Branch 0 taken 431900 times.
✓ Branch 1 taken 444680 times.
876580 if (!v->fcm)
1270 431900 idx = v->zz_4x8[i++] + off;
1271 else
1272 444680 idx = ff_vc1_adv_interlaced_4x8_zz[i++] + off;
1273 876580 block[idx] = value * scale;
1274
2/2
✓ Branch 0 taken 10845 times.
✓ Branch 1 taken 865735 times.
876580 if (!v->pquantizer)
1275
2/2
✓ Branch 0 taken 5474 times.
✓ Branch 1 taken 5371 times.
10845 block[idx] += (block[idx] < 0) ? -quant : quant;
1276 }
1277
3/4
✓ Branch 0 taken 226352 times.
✓ Branch 1 taken 52076 times.
✓ Branch 2 taken 226352 times.
✗ Branch 3 not taken.
278428 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1278
2/2
✓ Branch 0 taken 17898 times.
✓ Branch 1 taken 208454 times.
226352 if (i == 1)
1279 17898 v->vc1dsp.vc1_inv_trans_4x8_dc(dst + j * 4, linesize, block + off);
1280 else
1281 208454 v->vc1dsp.vc1_inv_trans_4x8(dst + j*4, linesize, block + off);
1282 }
1283 }
1284 139214 break;
1285 }
1286
2/2
✓ Branch 0 taken 646349 times.
✓ Branch 1 taken 57465 times.
703814 if (ttmb_out)
1287 646349 *ttmb_out |= ttblk << (n * 4);
1288 703814 return pat;
1289 }
1290
1291 /** @} */ // Macroblock group
1292
1293 static const uint8_t size_table[6] = { 0, 2, 3, 4, 5, 8 };
1294
1295 /** Decode one P-frame MB
1296 */
1297 152584 static int vc1_decode_p_mb(VC1Context *v)
1298 {
1299 152584 MpegEncContext *s = &v->s;
1300 152584 GetBitContext *gb = &s->gb;
1301 int i, j;
1302 152584 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1303 int cbp; /* cbp decoding stuff */
1304 int mqdiff, mquant; /* MB quantization */
1305 152584 int ttmb = v->ttfrm; /* MB Transform type */
1306
1307 152584 int mb_has_coeffs = 1; /* last_flag */
1308 int dmv_x, dmv_y; /* Differential MV components */
1309 int index, index1; /* LUT indexes */
1310 int val, sign; /* temp values */
1311 152584 int first_block = 1;
1312 int dst_idx, off;
1313 int skipped, fourmv;
1314 152584 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
1315
1316 152584 mquant = v->pq; /* lossy initialization */
1317
1318
2/2
✓ Branch 0 taken 58770 times.
✓ Branch 1 taken 93814 times.
152584 if (v->mv_type_is_raw)
1319 58770 fourmv = get_bits1(gb);
1320 else
1321 93814 fourmv = v->mv_type_mb_plane[mb_pos];
1322
2/2
✓ Branch 0 taken 58470 times.
✓ Branch 1 taken 94114 times.
152584 if (v->skip_is_raw)
1323 58470 skipped = get_bits1(gb);
1324 else
1325 94114 skipped = v->s.mbskip_table[mb_pos];
1326
1327
2/2
✓ Branch 0 taken 126008 times.
✓ Branch 1 taken 26576 times.
152584 if (!fourmv) { /* 1MV mode */
1328
2/2
✓ Branch 0 taken 113891 times.
✓ Branch 1 taken 12117 times.
126008 if (!skipped) {
1329
20/20
✓ Branch 1 taken 92366 times.
✓ Branch 2 taken 21525 times.
✓ Branch 3 taken 23732 times.
✓ Branch 4 taken 90159 times.
✓ Branch 5 taken 1950 times.
✓ Branch 6 taken 88209 times.
✓ Branch 9 taken 24985 times.
✓ Branch 10 taken 63224 times.
✓ Branch 11 taken 22380 times.
✓ Branch 12 taken 40844 times.
✓ Branch 13 taken 153 times.
✓ Branch 14 taken 22227 times.
✓ Branch 15 taken 47276 times.
✓ Branch 16 taken 15948 times.
✓ Branch 18 taken 22380 times.
✓ Branch 19 taken 40844 times.
✓ Branch 20 taken 130 times.
✓ Branch 21 taken 22250 times.
✓ Branch 22 taken 49130 times.
✓ Branch 23 taken 14094 times.
113891 GET_MVDATA(dmv_x, dmv_y);
1330
1331
2/2
✓ Branch 0 taken 24985 times.
✓ Branch 1 taken 88906 times.
113891 if (s->mb_intra) {
1332 24985 s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
1333 24985 s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
1334 }
1335
2/2
✓ Branch 0 taken 24985 times.
✓ Branch 1 taken 88906 times.
113891 s->current_picture.mb_type[mb_pos] = s->mb_intra ? MB_TYPE_INTRA : MB_TYPE_16x16;
1336 113891 ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
1337
1338 /* FIXME Set DC val for inter block ? */
1339
4/4
✓ Branch 0 taken 24985 times.
✓ Branch 1 taken 88906 times.
✓ Branch 2 taken 2748 times.
✓ Branch 3 taken 22237 times.
113891 if (s->mb_intra && !mb_has_coeffs) {
1340
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();
1341 2748 s->ac_pred = get_bits1(gb);
1342 2748 cbp = 0;
1343
2/2
✓ Branch 0 taken 92366 times.
✓ Branch 1 taken 18777 times.
111143 } else if (mb_has_coeffs) {
1344
2/2
✓ Branch 0 taken 22237 times.
✓ Branch 1 taken 70129 times.
92366 if (s->mb_intra)
1345 22237 s->ac_pred = get_bits1(gb);
1346 92366 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1347
25/38
✓ Branch 0 taken 8173 times.
✓ Branch 1 taken 84193 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8173 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 203 times.
✓ Branch 15 taken 203 times.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 2065 times.
✓ Branch 20 taken 6108 times.
✓ Branch 21 taken 37 times.
✓ Branch 22 taken 2028 times.
✓ Branch 23 taken 5900 times.
✓ Branch 24 taken 2273 times.
✓ Branch 25 taken 340 times.
✓ Branch 26 taken 5560 times.
✓ Branch 27 taken 108 times.
✓ Branch 28 taken 8065 times.
✓ Branch 29 taken 6 times.
✓ Branch 30 taken 102 times.
✓ Branch 31 taken 303 times.
✓ Branch 32 taken 7870 times.
✓ Branch 33 taken 1 times.
✓ Branch 34 taken 302 times.
✓ Branch 35 taken 8173 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 8173 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 8173 times.
92366 GET_MQUANT();
1348 } else {
1349 18777 mquant = v->pq;
1350 18777 cbp = 0;
1351 }
1352 113891 s->current_picture.qscale_table[mb_pos] = mquant;
1353
1354
6/6
✓ Branch 0 taken 75248 times.
✓ Branch 1 taken 38643 times.
✓ Branch 2 taken 53768 times.
✓ Branch 3 taken 21480 times.
✓ Branch 4 taken 42234 times.
✓ Branch 5 taken 11534 times.
113891 if (!v->ttmbf && !s->mb_intra && mb_has_coeffs)
1355 42234 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table,
1356 VC1_TTMB_VLC_BITS, 2);
1357
2/2
✓ Branch 0 taken 88906 times.
✓ Branch 1 taken 24985 times.
113891 if (!s->mb_intra) ff_vc1_mc_1mv(v, 0);
1358 113891 dst_idx = 0;
1359
2/2
✓ Branch 0 taken 683346 times.
✓ Branch 1 taken 113891 times.
797237 for (i = 0; i < 6; i++) {
1360 683346 s->dc_val[0][s->block_index[i]] = 0;
1361 683346 dst_idx += i >> 2;
1362 683346 val = ((cbp >> (5 - i)) & 1);
1363
2/2
✓ Branch 0 taken 455564 times.
✓ Branch 1 taken 227782 times.
683346 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
1364 683346 v->mb_type[0][s->block_index[i]] = s->mb_intra;
1365
2/2
✓ Branch 0 taken 149910 times.
✓ Branch 1 taken 533436 times.
683346 if (s->mb_intra) {
1366 /* check if prediction blocks A and C are available */
1367 149910 v->a_avail = v->c_avail = 0;
1368
6/6
✓ Branch 0 taken 124925 times.
✓ Branch 1 taken 24985 times.
✓ Branch 2 taken 99940 times.
✓ Branch 3 taken 24985 times.
✓ Branch 4 taken 60556 times.
✓ Branch 5 taken 39384 times.
149910 if (i == 2 || i == 3 || !s->first_slice_line)
1369 110526 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
1370
6/6
✓ Branch 0 taken 124925 times.
✓ Branch 1 taken 24985 times.
✓ Branch 2 taken 99940 times.
✓ Branch 3 taken 24985 times.
✓ Branch 4 taken 97324 times.
✓ Branch 5 taken 2616 times.
149910 if (i == 1 || i == 3 || s->mb_x)
1371 147294 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1372
1373 149910 vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, val, mquant,
1374
2/2
✓ Branch 0 taken 49970 times.
✓ Branch 1 taken 99940 times.
149910 (i & 4) ? v->codingset2 : v->codingset);
1375 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1376 continue;
1377 149910 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 149910 times.
149910 if (v->rangeredfrm)
1379 for (j = 0; j < 64; j++)
1380 v->block[v->cur_blk_idx][block_map[i]][j] *= 2;
1381 149910 block_cbp |= 0xF << (i << 2);
1382 149910 block_intra |= 1 << i;
1383
2/2
✓ Branch 0 taken 219458 times.
✓ Branch 1 taken 313978 times.
533436 } else if (val) {
1384 658374 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb, first_block,
1385
2/2
✓ Branch 0 taken 33600 times.
✓ Branch 1 taken 185858 times.
219458 s->dest[dst_idx] + off, (i & 4) ? s->uvlinesize : s->linesize,
1386 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
1387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 219458 times.
219458 if (pat < 0)
1388 return pat;
1389 219458 block_cbp |= pat << (i << 2);
1390
4/4
✓ Branch 0 taken 131418 times.
✓ Branch 1 taken 88040 times.
✓ Branch 2 taken 87522 times.
✓ Branch 3 taken 43896 times.
219458 if (!v->ttmbf && ttmb < 8)
1391 87522 ttmb = -1;
1392 219458 first_block = 0;
1393 }
1394 }
1395 } else { // skipped
1396 12117 s->mb_intra = 0;
1397
2/2
✓ Branch 0 taken 72702 times.
✓ Branch 1 taken 12117 times.
84819 for (i = 0; i < 6; i++) {
1398 72702 v->mb_type[0][s->block_index[i]] = 0;
1399 72702 s->dc_val[0][s->block_index[i]] = 0;
1400 }
1401 12117 s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
1402 12117 s->current_picture.qscale_table[mb_pos] = 0;
1403 12117 ff_vc1_pred_mv(v, 0, 0, 0, 1, v->range_x, v->range_y, v->mb_type[0], 0, 0);
1404 12117 ff_vc1_mc_1mv(v, 0);
1405 }
1406 } else { // 4MV mode
1407
2/2
✓ Branch 0 taken 22855 times.
✓ Branch 1 taken 3721 times.
26576 if (!skipped /* unskipped MB */) {
1408 22855 int intra_count = 0, coded_inter = 0;
1409 int is_intra[6], is_coded[6];
1410 /* Get CBPCY */
1411 22855 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1412
2/2
✓ Branch 0 taken 137130 times.
✓ Branch 1 taken 22855 times.
159985 for (i = 0; i < 6; i++) {
1413 137130 val = ((cbp >> (5 - i)) & 1);
1414 137130 s->dc_val[0][s->block_index[i]] = 0;
1415 137130 s->mb_intra = 0;
1416
2/2
✓ Branch 0 taken 91420 times.
✓ Branch 1 taken 45710 times.
137130 if (i < 4) {
1417 91420 dmv_x = dmv_y = 0;
1418 91420 s->mb_intra = 0;
1419 91420 mb_has_coeffs = 0;
1420
2/2
✓ Branch 0 taken 71997 times.
✓ Branch 1 taken 19423 times.
91420 if (val) {
1421
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);
1422 }
1423 91420 ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);
1424
2/2
✓ Branch 0 taken 80856 times.
✓ Branch 1 taken 10564 times.
91420 if (!s->mb_intra)
1425 80856 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1426 91420 intra_count += s->mb_intra;
1427 91420 is_intra[i] = s->mb_intra;
1428 91420 is_coded[i] = mb_has_coeffs;
1429 }
1430
2/2
✓ Branch 0 taken 45710 times.
✓ Branch 1 taken 91420 times.
137130 if (i & 4) {
1431 45710 is_intra[i] = (intra_count >= 3);
1432 45710 is_coded[i] = val;
1433 }
1434
2/2
✓ Branch 0 taken 22855 times.
✓ Branch 1 taken 114275 times.
137130 if (i == 4)
1435 22855 ff_vc1_mc_4mv_chroma(v, 0);
1436 137130 v->mb_type[0][s->block_index[i]] = is_intra[i];
1437
2/2
✓ Branch 0 taken 52317 times.
✓ Branch 1 taken 84813 times.
137130 if (!coded_inter)
1438 52317 coded_inter = !is_intra[i] & is_coded[i];
1439 }
1440 // if there are no coded blocks then don't do anything more
1441 22855 dst_idx = 0;
1442
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)
1443 2699 goto end;
1444
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();
1445 20156 s->current_picture.qscale_table[mb_pos] = mquant;
1446 /* test if block is intra and has pred */
1447 {
1448 20156 int intrapred = 0;
1449
2/2
✓ Branch 0 taken 106282 times.
✓ Branch 1 taken 16462 times.
122744 for (i = 0; i < 6; i++)
1450
2/2
✓ Branch 0 taken 7257 times.
✓ Branch 1 taken 99025 times.
106282 if (is_intra[i]) {
1451
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[0][s->block_index[i] - s->block_wrap[i]])
1452
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[0][s->block_index[i] - 1])) {
1453 3694 intrapred = 1;
1454 3694 break;
1455 }
1456 }
1457
2/2
✓ Branch 0 taken 3694 times.
✓ Branch 1 taken 16462 times.
20156 if (intrapred)
1458 3694 s->ac_pred = get_bits1(gb);
1459 else
1460 16462 s->ac_pred = 0;
1461 }
1462
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)
1463 18220 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
1464
2/2
✓ Branch 0 taken 120936 times.
✓ Branch 1 taken 20156 times.
141092 for (i = 0; i < 6; i++) {
1465 120936 dst_idx += i >> 2;
1466
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);
1467 120936 s->mb_intra = is_intra[i];
1468
2/2
✓ Branch 0 taken 13000 times.
✓ Branch 1 taken 107936 times.
120936 if (is_intra[i]) {
1469 /* check if prediction blocks A and C are available */
1470 13000 v->a_avail = v->c_avail = 0;
1471
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)
1472 10021 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
1473
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)
1474 12804 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1475
1476 13000 vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, is_coded[i], mquant,
1477
2/2
✓ Branch 0 taken 2436 times.
✓ Branch 1 taken 10564 times.
13000 (i & 4) ? v->codingset2 : v->codingset);
1478 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1479 continue;
1480 13000 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1481
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13000 times.
13000 if (v->rangeredfrm)
1482 for (j = 0; j < 64; j++)
1483 v->block[v->cur_blk_idx][block_map[i]][j] *= 2;
1484 13000 block_cbp |= 0xF << (i << 2);
1485 13000 block_intra |= 1 << i;
1486
2/2
✓ Branch 0 taken 66705 times.
✓ Branch 1 taken 41231 times.
107936 } else if (is_coded[i]) {
1487 200115 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb,
1488 66705 first_block, s->dest[dst_idx] + off,
1489
2/2
✓ Branch 0 taken 15468 times.
✓ Branch 1 taken 51237 times.
66705 (i & 4) ? s->uvlinesize : s->linesize,
1490 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY),
1491 &block_tt);
1492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66705 times.
66705 if (pat < 0)
1493 return pat;
1494 66705 block_cbp |= pat << (i << 2);
1495
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)
1496 44004 ttmb = -1;
1497 66705 first_block = 0;
1498 }
1499 }
1500 } else { // skipped MB
1501 3721 s->mb_intra = 0;
1502 3721 s->current_picture.qscale_table[mb_pos] = 0;
1503
2/2
✓ Branch 0 taken 22326 times.
✓ Branch 1 taken 3721 times.
26047 for (i = 0; i < 6; i++) {
1504 22326 v->mb_type[0][s->block_index[i]] = 0;
1505 22326 s->dc_val[0][s->block_index[i]] = 0;
1506 }
1507
2/2
✓ Branch 0 taken 14884 times.
✓ Branch 1 taken 3721 times.
18605 for (i = 0; i < 4; i++) {
1508 14884 ff_vc1_pred_mv(v, i, 0, 0, 0, v->range_x, v->range_y, v->mb_type[0], 0, 0);
1509 14884 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1510 }
1511 3721 ff_vc1_mc_4mv_chroma(v, 0);
1512 3721 s->current_picture.qscale_table[mb_pos] = 0;
1513 }
1514 }
1515 152584 end:
1516
3/4
✓ Branch 0 taken 107404 times.
✓ Branch 1 taken 45180 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 107404 times.
152584 if (v->overlap && v->pq >= 9)
1517 ff_vc1_p_overlap_filter(v);
1518 152584 vc1_put_blocks_clamped(v, 1);
1519
1520 152584 v->cbp[s->mb_x] = block_cbp;
1521 152584 v->ttblk[s->mb_x] = block_tt;
1522 152584 v->is_intra[s->mb_x] = block_intra;
1523
1524 152584 return 0;
1525 }
1526
1527 /* Decode one macroblock in an interlaced frame p picture */
1528
1529 16320 static int vc1_decode_p_mb_intfr(VC1Context *v)
1530 {
1531 16320 MpegEncContext *s = &v->s;
1532 16320 GetBitContext *gb = &s->gb;
1533 int i;
1534 16320 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1535 16320 int cbp = 0; /* cbp decoding stuff */
1536 int mqdiff, mquant; /* MB quantization */
1537 16320 int ttmb = v->ttfrm; /* MB Transform type */
1538
1539 16320 int mb_has_coeffs = 1; /* last_flag */
1540 int dmv_x, dmv_y; /* Differential MV components */
1541 int val; /* temp value */
1542 16320 int first_block = 1;
1543 int dst_idx, off;
1544 16320 int skipped, fourmv = 0, twomv = 0;
1545 16320 int block_cbp = 0, pat, block_tt = 0;
1546 16320 int idx_mbmode = 0, mvbp;
1547 int fieldtx;
1548
1549 16320 mquant = v->pq; /* Lossy initialization */
1550
1551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if (v->skip_is_raw)
1552 skipped = get_bits1(gb);
1553 else
1554 16320 skipped = v->s.mbskip_table[mb_pos];
1555
2/2
✓ Branch 0 taken 16307 times.
✓ Branch 1 taken 13 times.
16320 if (!skipped) {
1556
1/2
✓ Branch 0 taken 16307 times.
✗ Branch 1 not taken.
16307 if (v->fourmvswitch)
1557 16307 idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_4MV_MBMODE_VLC_BITS, 2); // try getting this done
1558 else
1559 idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2); // in a single line
1560
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]) {
1561 /* store the motion vector type in a flag (useful later) */
1562 704 case MV_PMODE_INTFR_4MV:
1563 704 fourmv = 1;
1564 704 v->blk_mv_type[s->block_index[0]] = 0;
1565 704 v->blk_mv_type[s->block_index[1]] = 0;
1566 704 v->blk_mv_type[s->block_index[2]] = 0;
1567 704 v->blk_mv_type[s->block_index[3]] = 0;
1568 704 break;
1569 1084 case MV_PMODE_INTFR_4MV_FIELD:
1570 1084 fourmv = 1;
1571 1084 v->blk_mv_type[s->block_index[0]] = 1;
1572 1084 v->blk_mv_type[s->block_index[1]] = 1;
1573 1084 v->blk_mv_type[s->block_index[2]] = 1;
1574 1084 v->blk_mv_type[s->block_index[3]] = 1;
1575 1084 break;
1576 4797 case MV_PMODE_INTFR_2MV_FIELD:
1577 4797 twomv = 1;
1578 4797 v->blk_mv_type[s->block_index[0]] = 1;
1579 4797 v->blk_mv_type[s->block_index[1]] = 1;
1580 4797 v->blk_mv_type[s->block_index[2]] = 1;
1581 4797 v->blk_mv_type[s->block_index[3]] = 1;
1582 4797 break;
1583 8046 case MV_PMODE_INTFR_1MV:
1584 8046 v->blk_mv_type[s->block_index[0]] = 0;
1585 8046 v->blk_mv_type[s->block_index[1]] = 0;
1586 8046 v->blk_mv_type[s->block_index[2]] = 0;
1587 8046 v->blk_mv_type[s->block_index[3]] = 0;
1588 8046 break;
1589 }
1590
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
1591
2/2
✓ Branch 0 taken 6704 times.
✓ Branch 1 taken 1676 times.
8380 for (i = 0; i < 4; i++) {
1592 6704 s->current_picture.motion_val[1][s->block_index[i]][0] = 0;
1593 6704 s->current_picture.motion_val[1][s->block_index[i]][1] = 0;
1594 }
1595 1676 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
1596 1676 s->mb_intra = 1;
1597 1676 s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
1598 1676 fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
1599 1676 mb_has_coeffs = get_bits1(gb);
1600
2/2
✓ Branch 0 taken 1615 times.
✓ Branch 1 taken 61 times.
1676 if (mb_has_coeffs)
1601 1615 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1602 1676 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
1603
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();
1604 1676 s->current_picture.qscale_table[mb_pos] = mquant;
1605 /* Set DC scale - y and c use the same (not sure if necessary here) */
1606
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 347 times.
1676 s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)];
1607
2/2
✓ Branch 0 taken 1329 times.
✓ Branch 1 taken 347 times.
1676 s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)];
1608 1676 dst_idx = 0;
1609
2/2
✓ Branch 0 taken 10056 times.
✓ Branch 1 taken 1676 times.
11732 for (i = 0; i < 6; i++) {
1610 10056 v->a_avail = v->c_avail = 0;
1611 10056 v->mb_type[0][s->block_index[i]] = 1;
1612 10056 s->dc_val[0][s->block_index[i]] = 0;
1613 10056 dst_idx += i >> 2;
1614 10056 val = ((cbp >> (5 - i)) & 1);
1615
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)
1616 9840 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
1617
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)
1618 10000 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1619
1620 10056 vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, val, mquant,
1621
2/2
✓ Branch 0 taken 3352 times.
✓ Branch 1 taken 6704 times.
10056 (i & 4) ? v->codingset2 : v->codingset);
1622 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1623 continue;
1624 10056 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1625
2/2
✓ Branch 0 taken 6704 times.
✓ Branch 1 taken 3352 times.
10056 if (i < 4)
1626
2/2
✓ Branch 0 taken 1876 times.
✓ Branch 1 taken 4828 times.
6704 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->linesize : (i & 1) * 8 + 4 * (i & 2) * s->linesize;
1627 else
1628 3352 off = 0;
1629 10056 block_cbp |= 0xf << (i << 2);
1630 }
1631
1632 } else { // inter MB
1633 14631 mb_has_coeffs = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][3];
1634
2/2
✓ Branch 0 taken 13330 times.
✓ Branch 1 taken 1301 times.
14631 if (mb_has_coeffs)
1635 13330 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1636
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) {
1637 4797 v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
1638 } else {
1639
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)
1640
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)) {
1641 1788 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
1642 }
1643 }
1644 14631 s->mb_intra = v->is_intra[s->mb_x] = 0;
1645
2/2
✓ Branch 0 taken 87786 times.
✓ Branch 1 taken 14631 times.
102417 for (i = 0; i < 6; i++)
1646 87786 v->mb_type[0][s->block_index[i]] = 0;
1647 14631 fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][1];
1648 /* for all motion vector read MVDATA and motion compensate each block */
1649 14631 dst_idx = 0;
1650
2/2
✓ Branch 0 taken 1788 times.
✓ Branch 1 taken 12843 times.
14631 if (fourmv) {
1651 1788 mvbp = v->fourmvbp;
1652
2/2
✓ Branch 0 taken 7152 times.
✓ Branch 1 taken 1788 times.
8940 for (i = 0; i < 4; i++) {
1653 7152 dmv_x = dmv_y = 0;
1654
2/2
✓ Branch 0 taken 5798 times.
✓ Branch 1 taken 1354 times.
7152 if (mvbp & (8 >> i))
1655 5798 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1656 7152 ff_vc1_pred_mv_intfr(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, 0);
1657 7152 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1658 }
1659 1788 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
1660
2/2
✓ Branch 0 taken 4797 times.
✓ Branch 1 taken 8046 times.
12843 } else if (twomv) {
1661 4797 mvbp = v->twomvbp;
1662 4797 dmv_x = dmv_y = 0;
1663
2/2
✓ Branch 0 taken 4513 times.
✓ Branch 1 taken 284 times.
4797 if (mvbp & 2) {
1664 4513 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1665 }
1666 4797 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, 0);
1667 4797 ff_vc1_mc_4mv_luma(v, 0, 0, 0);
1668 4797 ff_vc1_mc_4mv_luma(v, 1, 0, 0);
1669 4797 dmv_x = dmv_y = 0;
1670
2/2
✓ Branch 0 taken 4517 times.
✓ Branch 1 taken 280 times.
4797 if (mvbp & 1) {
1671 4517 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1672 }
1673 4797 ff_vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, 0);
1674 4797 ff_vc1_mc_4mv_luma(v, 2, 0, 0);
1675 4797 ff_vc1_mc_4mv_luma(v, 3, 0, 0);
1676 4797 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
1677 } else {
1678 8046 mvbp = ff_vc1_mbmode_intfrp[v->fourmvswitch][idx_mbmode][2];
1679 8046 dmv_x = dmv_y = 0;
1680
2/2
✓ Branch 0 taken 7892 times.
✓ Branch 1 taken 154 times.
8046 if (mvbp) {
1681 7892 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
1682 }
1683 8046 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, 0);
1684 8046 ff_vc1_mc_1mv(v, 0);
1685 }
1686
2/2
✓ Branch 0 taken 13330 times.
✓ Branch 1 taken 1301 times.
14631 if (cbp)
1687
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
1688 14631 s->current_picture.qscale_table[mb_pos] = mquant;
1689
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)
1690 13330 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
1691
2/2
✓ Branch 0 taken 87786 times.
✓ Branch 1 taken 14631 times.
102417 for (i = 0; i < 6; i++) {
1692 87786 s->dc_val[0][s->block_index[i]] = 0;
1693 87786 dst_idx += i >> 2;
1694 87786 val = ((cbp >> (5 - i)) & 1);
1695
2/2
✓ Branch 0 taken 70050 times.
✓ Branch 1 taken 17736 times.
87786 if (!fieldtx)
1696
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);
1697 else
1698
4/4
✓ Branch 0 taken 11824 times.
✓ Branch 1 taken 5912 times.
✓ Branch 2 taken 5912 times.
✓ Branch 3 taken 5912 times.
17736 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
1699
2/2
✓ Branch 0 taken 63627 times.
✓ Branch 1 taken 24159 times.
87786 if (val) {
1700 190881 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb,
1701 63627 first_block, s->dest[dst_idx] + off,
1702
2/2
✓ Branch 0 taken 20177 times.
✓ Branch 1 taken 43450 times.
63627 (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
1703 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
1704
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63627 times.
63627 if (pat < 0)
1705 return pat;
1706 63627 block_cbp |= pat << (i << 2);
1707
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)
1708 44047 ttmb = -1;
1709 63627 first_block = 0;
1710 }
1711 }
1712 }
1713 } else { // skipped
1714 13 s->mb_intra = v->is_intra[s->mb_x] = 0;
1715
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 13 times.
91 for (i = 0; i < 6; i++) {
1716 78 v->mb_type[0][s->block_index[i]] = 0;
1717 78 s->dc_val[0][s->block_index[i]] = 0;
1718 }
1719 13 s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
1720 13 s->current_picture.qscale_table[mb_pos] = 0;
1721 13 v->blk_mv_type[s->block_index[0]] = 0;
1722 13 v->blk_mv_type[s->block_index[1]] = 0;
1723 13 v->blk_mv_type[s->block_index[2]] = 0;
1724 13 v->blk_mv_type[s->block_index[3]] = 0;
1725 13 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, 0);
1726 13 ff_vc1_mc_1mv(v, 0);
1727 13 v->fieldtx_plane[mb_pos] = 0;
1728 }
1729
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)
1730 ff_vc1_p_overlap_filter(v);
1731 16320 vc1_put_blocks_clamped(v, 1);
1732
1733 16320 v->cbp[s->mb_x] = block_cbp;
1734 16320 v->ttblk[s->mb_x] = block_tt;
1735
1736 16320 return 0;
1737 }
1738
1739 37245 static int vc1_decode_p_mb_intfi(VC1Context *v)
1740 {
1741 37245 MpegEncContext *s = &v->s;
1742 37245 GetBitContext *gb = &s->gb;
1743 int i;
1744 37245 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1745 37245 int cbp = 0; /* cbp decoding stuff */
1746 int mqdiff, mquant; /* MB quantization */
1747 37245 int ttmb = v->ttfrm; /* MB Transform type */
1748
1749 37245 int mb_has_coeffs = 1; /* last_flag */
1750 int dmv_x, dmv_y; /* Differential MV components */
1751 int val; /* temp values */
1752 37245 int first_block = 1;
1753 int dst_idx, off;
1754 37245 int pred_flag = 0;
1755 37245 int block_cbp = 0, pat, block_tt = 0;
1756 37245 int idx_mbmode = 0;
1757
1758 37245 mquant = v->pq; /* Lossy initialization */
1759
1760 37245 idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
1761
2/2
✓ Branch 0 taken 9990 times.
✓ Branch 1 taken 27255 times.
37245 if (idx_mbmode <= 1) { // intra MB
1762 9990 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
1763 9990 s->mb_intra = 1;
1764 9990 s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
1765 9990 s->current_picture.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
1766 9990 s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
1767
16/38
✓ Branch 0 taken 2966 times.
✓ Branch 1 taken 7024 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.
9990 GET_MQUANT();
1768 9990 s->current_picture.qscale_table[mb_pos] = mquant;
1769 /* Set DC scale - y and c use the same (not sure if necessary here) */
1770
2/2
✓ Branch 0 taken 9801 times.
✓ Branch 1 taken 189 times.
9990 s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)];
1771
2/2
✓ Branch 0 taken 9801 times.
✓ Branch 1 taken 189 times.
9990 s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)];
1772 9990 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
1773 9990 mb_has_coeffs = idx_mbmode & 1;
1774
2/2
✓ Branch 0 taken 9243 times.
✓ Branch 1 taken 747 times.
9990 if (mb_has_coeffs)
1775 9243 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
1776 9990 dst_idx = 0;
1777
2/2
✓ Branch 0 taken 59940 times.
✓ Branch 1 taken 9990 times.
69930 for (i = 0; i < 6; i++) {
1778 59940 v->a_avail = v->c_avail = 0;
1779 59940 v->mb_type[0][s->block_index[i]] = 1;
1780 59940 s->dc_val[0][s->block_index[i]] = 0;
1781 59940 dst_idx += i >> 2;
1782 59940 val = ((cbp >> (5 - i)) & 1);
1783
6/6
✓ Branch 0 taken 49950 times.
✓ Branch 1 taken 9990 times.
✓ Branch 2 taken 39960 times.
✓ Branch 3 taken 9990 times.
✓ Branch 4 taken 37472 times.
✓ Branch 5 taken 2488 times.
59940 if (i == 2 || i == 3 || !s->first_slice_line)
1784 57452 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
1785
6/6
✓ Branch 0 taken 49950 times.
✓ Branch 1 taken 9990 times.
✓ Branch 2 taken 39960 times.
✓ Branch 3 taken 9990 times.
✓ Branch 4 taken 39220 times.
✓ Branch 5 taken 740 times.
59940 if (i == 1 || i == 3 || s->mb_x)
1786 59200 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1787
1788 59940 vc1_decode_intra_block(v, v->block[v->cur_blk_idx][block_map[i]], i, val, mquant,
1789
2/2
✓ Branch 0 taken 19980 times.
✓ Branch 1 taken 39960 times.
59940 (i & 4) ? v->codingset2 : v->codingset);
1790 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1791 continue;
1792 59940 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[i]]);
1793
2/2
✓ Branch 0 taken 39960 times.
✓ Branch 1 taken 19980 times.
59940 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->linesize);
1794 59940 block_cbp |= 0xf << (i << 2);
1795 }
1796 } else {
1797 27255 s->mb_intra = v->is_intra[s->mb_x] = 0;
1798 27255 s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
1799
2/2
✓ Branch 0 taken 163530 times.
✓ Branch 1 taken 27255 times.
190785 for (i = 0; i < 6; i++)
1800 163530 v->mb_type[0][s->block_index[i]] = 0;
1801
2/2
✓ Branch 0 taken 20405 times.
✓ Branch 1 taken 6850 times.
27255 if (idx_mbmode <= 5) { // 1-MV
1802 20405 dmv_x = dmv_y = pred_flag = 0;
1803
2/2
✓ Branch 0 taken 15790 times.
✓ Branch 1 taken 4615 times.
20405 if (idx_mbmode & 1) {
1804 15790 get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag);
1805 }
1806 20405 ff_vc1_pred_mv(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0);
1807 20405 ff_vc1_mc_1mv(v, 0);
1808 20405 mb_has_coeffs = !(idx_mbmode & 2);
1809 } else { // 4-MV
1810 6850 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
1811
2/2
✓ Branch 0 taken 27400 times.
✓ Branch 1 taken 6850 times.
34250 for (i = 0; i < 4; i++) {
1812 27400 dmv_x = dmv_y = pred_flag = 0;
1813
2/2
✓ Branch 0 taken 8342 times.
✓ Branch 1 taken 19058 times.
27400 if (v->fourmvbp & (8 >> i))
1814 8342 get_mvdata_interlaced(v, &dmv_x, &dmv_y, &pred_flag);
1815 27400 ff_vc1_pred_mv(v, i, dmv_x, dmv_y, 0, v->range_x, v->range_y, v->mb_type[0], pred_flag, 0);
1816 27400 ff_vc1_mc_4mv_luma(v, i, 0, 0);
1817 }
1818 6850 ff_vc1_mc_4mv_chroma(v, 0);
1819 6850 mb_has_coeffs = idx_mbmode & 1;
1820 }
1821
2/2
✓ Branch 0 taken 20418 times.
✓ Branch 1 taken 6837 times.
27255 if (mb_has_coeffs)
1822 20418 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1823
2/2
✓ Branch 0 taken 20418 times.
✓ Branch 1 taken 6837 times.
27255 if (cbp) {
1824
16/38
✓ Branch 0 taken 12145 times.
✓ Branch 1 taken 8273 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.
20418 GET_MQUANT();
1825 }
1826 27255 s->current_picture.qscale_table[mb_pos] = mquant;
1827
3/4
✓ Branch 0 taken 27255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 20418 times.
✓ Branch 3 taken 6837 times.
27255 if (!v->ttmbf && cbp) {
1828 20418 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
1829 }
1830 27255 dst_idx = 0;
1831
2/2
✓ Branch 0 taken 163530 times.
✓ Branch 1 taken 27255 times.
190785 for (i = 0; i < 6; i++) {
1832 163530 s->dc_val[0][s->block_index[i]] = 0;
1833 163530 dst_idx += i >> 2;
1834 163530 val = ((cbp >> (5 - i)) & 1);
1835
2/2
✓ Branch 0 taken 109020 times.
✓ Branch 1 taken 54510 times.
163530 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->linesize;
1836
2/2
✓ Branch 0 taken 89468 times.
✓ Branch 1 taken 74062 times.
163530 if (val) {
1837 268404 pat = vc1_decode_p_block(v, v->block[v->cur_blk_idx][block_map[i]], i, mquant, ttmb,
1838 89468 first_block, s->dest[dst_idx] + off,
1839
2/2
✓ Branch 0 taken 23840 times.
✓ Branch 1 taken 65628 times.
89468 (i & 4) ? s->uvlinesize : s->linesize,
1840 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY),
1841 &block_tt);
1842
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 89468 times.
89468 if (pat < 0)
1843 return pat;
1844 89468 block_cbp |= pat << (i << 2);
1845
3/4
✓ Branch 0 taken 89468 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58173 times.
✓ Branch 3 taken 31295 times.
89468 if (!v->ttmbf && ttmb < 8)
1846 58173 ttmb = -1;
1847 89468 first_block = 0;
1848 }
1849 }
1850 }
1851
3/4
✓ Branch 0 taken 20925 times.
✓ Branch 1 taken 16320 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 20925 times.
37245 if (v->overlap && v->pq >= 9)
1852 ff_vc1_p_overlap_filter(v);
1853 37245 vc1_put_blocks_clamped(v, 1);
1854
1855 37245 v->cbp[s->mb_x] = block_cbp;
1856 37245 v->ttblk[s->mb_x] = block_tt;
1857
1858 37245 return 0;
1859 }
1860
1861 /** Decode one B-frame MB (in Main profile)
1862 */
1863 20940 static int vc1_decode_b_mb(VC1Context *v)
1864 {
1865 20940 MpegEncContext *s = &v->s;
1866 20940 GetBitContext *gb = &s->gb;
1867 int i, j;
1868 20940 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
1869 20940 int cbp = 0; /* cbp decoding stuff */
1870 int mqdiff, mquant; /* MB quantization */
1871 20940 int ttmb = v->ttfrm; /* MB Transform type */
1872 20940 int mb_has_coeffs = 0; /* last_flag */
1873 int index, index1; /* LUT indexes */
1874 int val, sign; /* temp values */
1875 20940 int first_block = 1;
1876 int dst_idx, off;
1877 int skipped, direct;
1878 int dmv_x[2], dmv_y[2];
1879 20940 int bmvtype = BMV_TYPE_BACKWARD;
1880
1881 20940 mquant = v->pq; /* lossy initialization */
1882 20940 s->mb_intra = 0;
1883
1884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20940 times.
20940 if (v->dmb_is_raw)
1885 direct = get_bits1(gb);
1886 else
1887 20940 direct = v->direct_mb_plane[mb_pos];
1888
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20940 times.
20940 if (v->skip_is_raw)
1889 skipped = get_bits1(gb);
1890 else
1891 20940 skipped = v->s.mbskip_table[mb_pos];
1892
1893 20940 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1894
2/2
✓ Branch 0 taken 125640 times.
✓ Branch 1 taken 20940 times.
146580 for (i = 0; i < 6; i++) {
1895 125640 v->mb_type[0][s->block_index[i]] = 0;
1896 125640 s->dc_val[0][s->block_index[i]] = 0;
1897 }
1898 20940 s->current_picture.qscale_table[mb_pos] = 0;
1899
1900
2/2
✓ Branch 0 taken 18371 times.
✓ Branch 1 taken 2569 times.
20940 if (!direct) {
1901
2/2
✓ Branch 0 taken 15906 times.
✓ Branch 1 taken 2465 times.
18371 if (!skipped) {
1902
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]);
1903 15906 dmv_x[1] = dmv_x[0];
1904 15906 dmv_y[1] = dmv_y[0];
1905 }
1906
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) {
1907 18201 bmvtype = decode012(gb);
1908
3/4
✓ Branch 0 taken 8021 times.
✓ Branch 1 taken 4023 times.
✓ Branch 2 taken 6157 times.
✗ Branch 3 not taken.
18201 switch (bmvtype) {
1909 8021 case 0:
1910 8021 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD;
1911 8021 break;
1912 4023 case 1:
1913 4023 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD;
1914 4023 break;
1915 6157 case 2:
1916 6157 bmvtype = BMV_TYPE_INTERPOLATED;
1917 6157 dmv_x[0] = dmv_y[0] = 0;
1918 }
1919 }
1920 }
1921
2/2
✓ Branch 0 taken 125640 times.
✓ Branch 1 taken 20940 times.
146580 for (i = 0; i < 6; i++)
1922 125640 v->mb_type[0][s->block_index[i]] = s->mb_intra;
1923
1924
2/2
✓ Branch 0 taken 3578 times.
✓ Branch 1 taken 17362 times.
20940 if (skipped) {
1925
2/2
✓ Branch 0 taken 1113 times.
✓ Branch 1 taken 2465 times.
3578 if (direct)
1926 1113 bmvtype = BMV_TYPE_INTERPOLATED;
1927 3578 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1928 3578 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1929 3578 return 0;
1930 }
1931
2/2
✓ Branch 0 taken 1456 times.
✓ Branch 1 taken 15906 times.
17362 if (direct) {
1932 1456 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1933
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();
1934 1456 s->mb_intra = 0;
1935 1456 s->current_picture.qscale_table[mb_pos] = mquant;
1936
1/2
✓ Branch 0 taken 1456 times.
✗ Branch 1 not taken.
1456 if (!v->ttmbf)
1937 1456 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
1938 1456 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1939 1456 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1940 1456 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1941 } else {
1942
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) {
1943 /* no coded blocks - effectively skipped */
1944 1035 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1945 1035 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1946 1035 return 0;
1947 }
1948
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) {
1949 GET_MQUANT();
1950 s->current_picture.qscale_table[mb_pos] = mquant;
1951 s->ac_pred = get_bits1(gb);
1952 cbp = 0;
1953 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1954 } else {
1955
2/2
✓ Branch 0 taken 5289 times.
✓ Branch 1 taken 9582 times.
14871 if (bmvtype == BMV_TYPE_INTERPOLATED) {
1956
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]);
1957
2/2
✓ Branch 0 taken 475 times.
✓ Branch 1 taken 4814 times.
5289 if (!mb_has_coeffs) {
1958 /* interpolated skipped block */
1959 475 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1960 475 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1961 475 return 0;
1962 }
1963 }
1964 14396 ff_vc1_pred_b_mv(v, dmv_x, dmv_y, direct, bmvtype);
1965
2/2
✓ Branch 0 taken 14226 times.
✓ Branch 1 taken 170 times.
14396 if (!s->mb_intra) {
1966 14226 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1967 }
1968
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 14226 times.
14396 if (s->mb_intra)
1969 170 s->ac_pred = get_bits1(gb);
1970 14396 cbp = get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
1971
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();
1972 14396 s->current_picture.qscale_table[mb_pos] = mquant;
1973
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)
1974 14226 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
1975 }
1976 }
1977 15852 dst_idx = 0;
1978
2/2
✓ Branch 0 taken 95112 times.
✓ Branch 1 taken 15852 times.
110964 for (i = 0; i < 6; i++) {
1979 95112 s->dc_val[0][s->block_index[i]] = 0;
1980 95112 dst_idx += i >> 2;
1981 95112 val = ((cbp >> (5 - i)) & 1);
1982
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);
1983 95112 v->mb_type[0][s->block_index[i]] = s->mb_intra;
1984
2/2
✓ Branch 0 taken 1020 times.
✓ Branch 1 taken 94092 times.
95112 if (s->mb_intra) {
1985 /* check if prediction blocks A and C are available */
1986 1020 v->a_avail = v->c_avail = 0;
1987
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)
1988 996 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
1989
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)
1990 992 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
1991
1992 1020 vc1_decode_intra_block(v, s->block[i], i, val, mquant,
1993
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 680 times.
1020 (i & 4) ? v->codingset2 : v->codingset);
1994 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
1995 continue;
1996 1020 v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
1997
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1020 times.
1020 if (v->rangeredfrm)
1998 for (j = 0; j < 64; j++)
1999 s->block[i][j] *= 2;
2000 1020 s->idsp.put_signed_pixels_clamped(s->block[i],
2001 1020 s->dest[dst_idx] + off,
2002
2/2
✓ Branch 0 taken 340 times.
✓ Branch 1 taken 680 times.
1020 i & 4 ? s->uvlinesize
2003 : s->linesize);
2004
2/2
✓ Branch 0 taken 57465 times.
✓ Branch 1 taken 36627 times.
94092 } else if (val) {
2005 172395 int pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
2006 57465 first_block, s->dest[dst_idx] + off,
2007
2/2
✓ Branch 0 taken 10287 times.
✓ Branch 1 taken 47178 times.
57465 (i & 4) ? s->uvlinesize : s->linesize,
2008 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), NULL);
2009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 57465 times.
57465 if (pat < 0)
2010 return pat;
2011
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)
2012 54531 ttmb = -1;
2013 57465 first_block = 0;
2014 }
2015 }
2016 15852 return 0;
2017 }
2018
2019 /** Decode one B-frame MB (in interlaced field B picture)
2020 */
2021 51540 static int vc1_decode_b_mb_intfi(VC1Context *v)
2022 {
2023 51540 MpegEncContext *s = &v->s;
2024 51540 GetBitContext *gb = &s->gb;
2025 int i, j;
2026 51540 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
2027 51540 int cbp = 0; /* cbp decoding stuff */
2028 int mqdiff, mquant; /* MB quantization */
2029 51540 int ttmb = v->ttfrm; /* MB Transform type */
2030 51540 int mb_has_coeffs = 0; /* last_flag */
2031 int val; /* temp value */
2032 51540 int first_block = 1;
2033 int dst_idx, off;
2034 int fwd;
2035 int dmv_x[2], dmv_y[2], pred_flag[2];
2036 51540 int bmvtype = BMV_TYPE_BACKWARD;
2037 51540 int block_cbp = 0, pat, block_tt = 0;
2038 int idx_mbmode;
2039
2040 51540 mquant = v->pq; /* Lossy initialization */
2041 51540 s->mb_intra = 0;
2042
2043 51540 idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_IF_MBMODE_VLC_BITS, 2);
2044
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 51492 times.
51540 if (idx_mbmode <= 1) { // intra MB
2045 48 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
2046 48 s->mb_intra = 1;
2047 48 s->current_picture.motion_val[1][s->block_index[0]][0] = 0;
2048 48 s->current_picture.motion_val[1][s->block_index[0]][1] = 0;
2049 48 s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
2050
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();
2051 48 s->current_picture.qscale_table[mb_pos] = mquant;
2052 /* Set DC scale - y and c use the same (not sure if necessary here) */
2053
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
48 s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)];
2054
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 32 times.
48 s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)];
2055 48 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
2056 48 mb_has_coeffs = idx_mbmode & 1;
2057
2/2
✓ Branch 0 taken 33 times.
✓ Branch 1 taken 15 times.
48 if (mb_has_coeffs)
2058 33 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_ICBPCY_VLC_BITS, 2);
2059 48 dst_idx = 0;
2060
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 48 times.
336 for (i = 0; i < 6; i++) {
2061 288 v->a_avail = v->c_avail = 0;
2062 288 v->mb_type[0][s->block_index[i]] = 1;
2063 288 s->dc_val[0][s->block_index[i]] = 0;
2064 288 dst_idx += i >> 2;
2065 288 val = ((cbp >> (5 - i)) & 1);
2066
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)
2067 288 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
2068
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)
2069 284 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
2070
2071 288 vc1_decode_intra_block(v, s->block[i], i, val, mquant,
2072
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 192 times.
288 (i & 4) ? v->codingset2 : v->codingset);
2073 if (CONFIG_GRAY && (i > 3) && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2074 continue;
2075 288 v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
2076
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 288 times.
288 if (v->rangeredfrm)
2077 for (j = 0; j < 64; j++)
2078 s->block[i][j] <<= 1;
2079
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);
2080 288 s->idsp.put_signed_pixels_clamped(s->block[i],
2081 288 s->dest[dst_idx] + off,
2082
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 192 times.
288 (i & 4) ? s->uvlinesize
2083 : s->linesize);
2084 }
2085 } else {
2086 51492 s->mb_intra = v->is_intra[s->mb_x] = 0;
2087 51492 s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_16x16;
2088
2/2
✓ Branch 0 taken 308952 times.
✓ Branch 1 taken 51492 times.
360444 for (i = 0; i < 6; i++)
2089 308952 v->mb_type[0][s->block_index[i]] = 0;
2090
2/2
✓ Branch 0 taken 675 times.
✓ Branch 1 taken 50817 times.
51492 if (v->fmb_is_raw)
2091 675 fwd = v->forward_mb_plane[mb_pos] = get_bits1(gb);
2092 else
2093 50817 fwd = v->forward_mb_plane[mb_pos];
2094
2/2
✓ Branch 0 taken 42084 times.
✓ Branch 1 taken 9408 times.
51492 if (idx_mbmode <= 5) { // 1-MV
2095 42084 int interpmvp = 0;
2096 42084 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2097 42084 pred_flag[0] = pred_flag[1] = 0;
2098
2/2
✓ Branch 0 taken 15503 times.
✓ Branch 1 taken 26581 times.
42084 if (fwd)
2099 15503 bmvtype = BMV_TYPE_FORWARD;
2100 else {
2101 26581 bmvtype = decode012(gb);
2102
3/4
✓ Branch 0 taken 13925 times.
✓ Branch 1 taken 6770 times.
✓ Branch 2 taken 5886 times.
✗ Branch 3 not taken.
26581 switch (bmvtype) {
2103 13925 case 0:
2104 13925 bmvtype = BMV_TYPE_BACKWARD;
2105 13925 break;
2106 6770 case 1:
2107 6770 bmvtype = BMV_TYPE_DIRECT;
2108 6770 break;
2109 5886 case 2:
2110 5886 bmvtype = BMV_TYPE_INTERPOLATED;
2111 5886 interpmvp = get_bits1(gb);
2112 }
2113 }
2114 42084 v->bmvtype = bmvtype;
2115
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) {
2116 20242 get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD], &dmv_y[bmvtype == BMV_TYPE_BACKWARD], &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
2117 }
2118
2/2
✓ Branch 0 taken 4685 times.
✓ Branch 1 taken 37399 times.
42084 if (interpmvp) {
2119 4685 get_mvdata_interlaced(v, &dmv_x[1], &dmv_y[1], &pred_flag[1]);
2120 }
2121
2/2
✓ Branch 0 taken 6770 times.
✓ Branch 1 taken 35314 times.
42084 if (bmvtype == BMV_TYPE_DIRECT) {
2122 6770 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2123 6770 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2124
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6770 times.
6770 if (!s->next_picture_ptr->field_picture) {
2125 av_log(s->avctx, AV_LOG_ERROR, "Mixed field/frame direct mode not supported\n");
2126 return AVERROR_INVALIDDATA;
2127 }
2128 }
2129 42084 ff_vc1_pred_b_mv_intfi(v, 0, dmv_x, dmv_y, 1, pred_flag);
2130 42084 vc1_b_mc(v, dmv_x, dmv_y, (bmvtype == BMV_TYPE_DIRECT), bmvtype);
2131 42084 mb_has_coeffs = !(idx_mbmode & 2);
2132 } else { // 4-MV
2133
2/2
✓ Branch 0 taken 4892 times.
✓ Branch 1 taken 4516 times.
9408 if (fwd)
2134 4892 bmvtype = BMV_TYPE_FORWARD;
2135 9408 v->bmvtype = bmvtype;
2136 9408 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
2137
2/2
✓ Branch 0 taken 37632 times.
✓ Branch 1 taken 9408 times.
47040 for (i = 0; i < 4; i++) {
2138 37632 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2139 37632 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2140
2/2
✓ Branch 0 taken 10050 times.
✓ Branch 1 taken 27582 times.
37632 if (v->fourmvbp & (8 >> i)) {
2141 10050 get_mvdata_interlaced(v, &dmv_x[bmvtype == BMV_TYPE_BACKWARD],
2142 10050 &dmv_y[bmvtype == BMV_TYPE_BACKWARD],
2143 10050 &pred_flag[bmvtype == BMV_TYPE_BACKWARD]);
2144 }
2145 37632 ff_vc1_pred_b_mv_intfi(v, i, dmv_x, dmv_y, 0, pred_flag);
2146 37632 ff_vc1_mc_4mv_luma(v, i, bmvtype == BMV_TYPE_BACKWARD, 0);
2147 }
2148 9408 ff_vc1_mc_4mv_chroma(v, bmvtype == BMV_TYPE_BACKWARD);
2149 9408 mb_has_coeffs = idx_mbmode & 1;
2150 }
2151
2/2
✓ Branch 0 taken 30972 times.
✓ Branch 1 taken 20520 times.
51492 if (mb_has_coeffs)
2152 30972 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
2153
2/2
✓ Branch 0 taken 30972 times.
✓ Branch 1 taken 20520 times.
51492 if (cbp) {
2154
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();
2155 }
2156 51492 s->current_picture.qscale_table[mb_pos] = mquant;
2157
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) {
2158 30972 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
2159 }
2160 51492 dst_idx = 0;
2161
2/2
✓ Branch 0 taken 308952 times.
✓ Branch 1 taken 51492 times.
360444 for (i = 0; i < 6; i++) {
2162 308952 s->dc_val[0][s->block_index[i]] = 0;
2163 308952 dst_idx += i >> 2;
2164 308952 val = ((cbp >> (5 - i)) & 1);
2165
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;
2166
2/2
✓ Branch 0 taken 91470 times.
✓ Branch 1 taken 217482 times.
308952 if (val) {
2167 274410 pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
2168 91470 first_block, s->dest[dst_idx] + off,
2169
2/2
✓ Branch 0 taken 20546 times.
✓ Branch 1 taken 70924 times.
91470 (i & 4) ? s->uvlinesize : s->linesize,
2170 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
2171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 91470 times.
91470 if (pat < 0)
2172 return pat;
2173 91470 block_cbp |= pat << (i << 2);
2174
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)
2175 69969 ttmb = -1;
2176 91470 first_block = 0;
2177 }
2178 }
2179 }
2180 51540 v->cbp[s->mb_x] = block_cbp;
2181 51540 v->ttblk[s->mb_x] = block_tt;
2182
2183 51540 return 0;
2184 }
2185
2186 /** Decode one B-frame MB (in interlaced frame B picture)
2187 */
2188 32640 static int vc1_decode_b_mb_intfr(VC1Context *v)
2189 {
2190 32640 MpegEncContext *s = &v->s;
2191 32640 GetBitContext *gb = &s->gb;
2192 int i, j;
2193 32640 int mb_pos = s->mb_x + s->mb_y * s->mb_stride;
2194 32640 int cbp = 0; /* cbp decoding stuff */
2195 int mqdiff, mquant; /* MB quantization */
2196 32640 int ttmb = v->ttfrm; /* MB Transform type */
2197 32640 int mvsw = 0; /* motion vector switch */
2198 32640 int mb_has_coeffs = 1; /* last_flag */
2199 int dmv_x, dmv_y; /* Differential MV components */
2200 int val; /* temp value */
2201 32640 int first_block = 1;
2202 int dst_idx, off;
2203 32640 int skipped, direct, twomv = 0;
2204 32640 int block_cbp = 0, pat, block_tt = 0;
2205 32640 int idx_mbmode = 0, mvbp;
2206 int stride_y, fieldtx;
2207 32640 int bmvtype = BMV_TYPE_BACKWARD;
2208 int dir, dir2;
2209
2210 32640 mquant = v->pq; /* Lossy initialization */
2211 32640 s->mb_intra = 0;
2212
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32640 times.
32640 if (v->skip_is_raw)
2213 skipped = get_bits1(gb);
2214 else
2215 32640 skipped = v->s.mbskip_table[mb_pos];
2216
2217
2/2
✓ Branch 0 taken 31098 times.
✓ Branch 1 taken 1542 times.
32640 if (!skipped) {
2218 31098 idx_mbmode = get_vlc2(gb, v->mbmode_vlc->table, VC1_INTFR_NON4MV_MBMODE_VLC_BITS, 2);
2219
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) {
2220 17446 twomv = 1;
2221 17446 v->blk_mv_type[s->block_index[0]] = 1;
2222 17446 v->blk_mv_type[s->block_index[1]] = 1;
2223 17446 v->blk_mv_type[s->block_index[2]] = 1;
2224 17446 v->blk_mv_type[s->block_index[3]] = 1;
2225 } else {
2226 13652 v->blk_mv_type[s->block_index[0]] = 0;
2227 13652 v->blk_mv_type[s->block_index[1]] = 0;
2228 13652 v->blk_mv_type[s->block_index[2]] = 0;
2229 13652 v->blk_mv_type[s->block_index[3]] = 0;
2230 }
2231 }
2232
2233
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
2234
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 101 times.
505 for (i = 0; i < 4; i++) {
2235 404 s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = 0;
2236 404 s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = 0;
2237 404 s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = 0;
2238 404 s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = 0;
2239 }
2240 101 v->is_intra[s->mb_x] = 0x3f; // Set the bitfield to all 1.
2241 101 s->mb_intra = 1;
2242 101 s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
2243 101 fieldtx = v->fieldtx_plane[mb_pos] = get_bits1(gb);
2244 101 mb_has_coeffs = get_bits1(gb);
2245
1/2
✓ Branch 0 taken 101 times.
✗ Branch 1 not taken.
101 if (mb_has_coeffs)
2246 101 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
2247 101 v->s.ac_pred = v->acpred_plane[mb_pos] = get_bits1(gb);
2248
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();
2249 101 s->current_picture.qscale_table[mb_pos] = mquant;
2250 /* Set DC scale - y and c use the same (not sure if necessary here) */
2251
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 12 times.
101 s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)];
2252
2/2
✓ Branch 0 taken 89 times.
✓ Branch 1 taken 12 times.
101 s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)];
2253 101 dst_idx = 0;
2254
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 101 times.
707 for (i = 0; i < 6; i++) {
2255 606 v->a_avail = v->c_avail = 0;
2256 606 v->mb_type[0][s->block_index[i]] = 1;
2257 606 s->dc_val[0][s->block_index[i]] = 0;
2258 606 dst_idx += i >> 2;
2259 606 val = ((cbp >> (5 - i)) & 1);
2260
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)
2261 574 v->a_avail = v->mb_type[0][s->block_index[i] - s->block_wrap[i]];
2262
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)
2263 594 v->c_avail = v->mb_type[0][s->block_index[i] - 1];
2264
2265 606 vc1_decode_intra_block(v, s->block[i], i, val, mquant,
2266
2/2
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 404 times.
606 (i & 4) ? v->codingset2 : v->codingset);
2267 if (CONFIG_GRAY && i > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2268 continue;
2269 606 v->vc1dsp.vc1_inv_trans_8x8(s->block[i]);
2270
2/2
✓ Branch 0 taken 404 times.
✓ Branch 1 taken 202 times.
606 if (i < 4) {
2271 404 stride_y = s->linesize << fieldtx;
2272
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;
2273 } else {
2274 202 stride_y = s->uvlinesize;
2275 202 off = 0;
2276 }
2277 606 s->idsp.put_signed_pixels_clamped(s->block[i],
2278 606 s->dest[dst_idx] + off,
2279 stride_y);
2280 }
2281 } else {
2282 32539 s->mb_intra = v->is_intra[s->mb_x] = 0;
2283
2284
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 32539 times.
32539 if (v->dmb_is_raw)
2285 direct = get_bits1(gb);
2286 else
2287 32539 direct = v->direct_mb_plane[mb_pos];
2288
2289
2/2
✓ Branch 0 taken 8474 times.
✓ Branch 1 taken 24065 times.
32539 if (direct) {
2290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8474 times.
8474 if (s->next_picture_ptr->field_picture)
2291 av_log(s->avctx, AV_LOG_WARNING, "Mixed frame/field direct mode not supported\n");
2292 8474 s->mv[0][0][0] = s->current_picture.motion_val[0][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 0, s->quarter_sample);
2293 8474 s->mv[0][0][1] = s->current_picture.motion_val[0][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 0, s->quarter_sample);
2294 8474 s->mv[1][0][0] = s->current_picture.motion_val[1][s->block_index[0]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][0], v->bfraction, 1, s->quarter_sample);
2295 8474 s->mv[1][0][1] = s->current_picture.motion_val[1][s->block_index[0]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[0]][1], v->bfraction, 1, s->quarter_sample);
2296
2297
2/2
✓ Branch 0 taken 4360 times.
✓ Branch 1 taken 4114 times.
8474 if (twomv) {
2298 4360 s->mv[0][2][0] = s->current_picture.motion_val[0][s->block_index[2]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][0], v->bfraction, 0, s->quarter_sample);
2299 4360 s->mv[0][2][1] = s->current_picture.motion_val[0][s->block_index[2]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][1], v->bfraction, 0, s->quarter_sample);
2300 4360 s->mv[1][2][0] = s->current_picture.motion_val[1][s->block_index[2]][0] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][0], v->bfraction, 1, s->quarter_sample);
2301 4360 s->mv[1][2][1] = s->current_picture.motion_val[1][s->block_index[2]][1] = scale_mv(s->next_picture.motion_val[1][s->block_index[2]][1], v->bfraction, 1, s->quarter_sample);
2302
2303
2/2
✓ Branch 0 taken 8720 times.
✓ Branch 1 taken 4360 times.
13080 for (i = 1; i < 4; i += 2) {
2304 8720 s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = s->mv[0][i-1][0];
2305 8720 s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = s->mv[0][i-1][1];
2306 8720 s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = s->mv[1][i-1][0];
2307 8720 s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = s->mv[1][i-1][1];
2308 }
2309 } else {
2310
2/2
✓ Branch 0 taken 12342 times.
✓ Branch 1 taken 4114 times.
16456 for (i = 1; i < 4; i++) {
2311 12342 s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0] = s->mv[0][0][0];
2312 12342 s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1] = s->mv[0][0][1];
2313 12342 s->mv[1][i][0] = s->current_picture.motion_val[1][s->block_index[i]][0] = s->mv[1][0][0];
2314 12342 s->mv[1][i][1] = s->current_picture.motion_val[1][s->block_index[i]][1] = s->mv[1][0][1];
2315 }
2316 }
2317 }
2318
2319
2/2
✓ Branch 0 taken 24065 times.
✓ Branch 1 taken 8474 times.
32539 if (!direct) {
2320
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) {
2321 24065 bmvtype = decode012(gb);
2322
3/4
✓ Branch 0 taken 14341 times.
✓ Branch 1 taken 6232 times.
✓ Branch 2 taken 3492 times.
✗ Branch 3 not taken.
24065 switch (bmvtype) {
2323 14341 case 0:
2324 14341 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_BACKWARD : BMV_TYPE_FORWARD;
2325 14341 break;
2326 6232 case 1:
2327 6232 bmvtype = (v->bfraction >= (B_FRACTION_DEN/2)) ? BMV_TYPE_FORWARD : BMV_TYPE_BACKWARD;
2328 6232 break;
2329 3492 case 2:
2330 3492 bmvtype = BMV_TYPE_INTERPOLATED;
2331 }
2332 }
2333
2334
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)
2335 12364 mvsw = get_bits1(gb);
2336 }
2337
2338
2/2
✓ Branch 0 taken 30997 times.
✓ Branch 1 taken 1542 times.
32539 if (!skipped) { // inter MB
2339 30997 mb_has_coeffs = ff_vc1_mbmode_intfrp[0][idx_mbmode][3];
2340
2/2
✓ Branch 0 taken 26859 times.
✓ Branch 1 taken 4138 times.
30997 if (mb_has_coeffs)
2341 26859 cbp = 1 + get_vlc2(&v->s.gb, v->cbpcy_vlc->table, VC1_CBPCY_P_VLC_BITS, 2);
2342
2/2
✓ Branch 0 taken 23850 times.
✓ Branch 1 taken 7147 times.
30997 if (!direct) {
2343
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) {
2344 722 v->fourmvbp = get_vlc2(gb, v->fourmvbp_vlc->table, VC1_4MV_BLOCK_PATTERN_VLC_BITS, 1);
2345
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) {
2346 15125 v->twomvbp = get_vlc2(gb, v->twomvbp_vlc->table, VC1_2MV_BLOCK_PATTERN_VLC_BITS, 1);
2347 }
2348 }
2349
2350
2/2
✓ Branch 0 taken 185982 times.
✓ Branch 1 taken 30997 times.
216979 for (i = 0; i < 6; i++)
2351 185982 v->mb_type[0][s->block_index[i]] = 0;
2352 30997 fieldtx = v->fieldtx_plane[mb_pos] = ff_vc1_mbmode_intfrp[0][idx_mbmode][1];
2353 /* for all motion vector read MVDATA and motion compensate each block */
2354 30997 dst_idx = 0;
2355
2/2
✓ Branch 0 taken 7147 times.
✓ Branch 1 taken 23850 times.
30997 if (direct) {
2356
2/2
✓ Branch 0 taken 4360 times.
✓ Branch 1 taken 2787 times.
7147 if (twomv) {
2357
2/2
✓ Branch 0 taken 17440 times.
✓ Branch 1 taken 4360 times.
21800 for (i = 0; i < 4; i++) {
2358 17440 ff_vc1_mc_4mv_luma(v, i, 0, 0);
2359 17440 ff_vc1_mc_4mv_luma(v, i, 1, 1);
2360 }
2361 4360 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
2362 4360 ff_vc1_mc_4mv_chroma4(v, 1, 1, 1);
2363 } else {
2364 2787 ff_vc1_mc_1mv(v, 0);
2365 2787 ff_vc1_interp_mc(v);
2366 }
2367
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) {
2368 722 mvbp = v->fourmvbp;
2369
2/2
✓ Branch 0 taken 2888 times.
✓ Branch 1 taken 722 times.
3610 for (i = 0; i < 4; i++) {
2370
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;
2371 2888 dmv_x = dmv_y = 0;
2372 2888 val = ((mvbp >> (3 - i)) & 1);
2373
2/2
✓ Branch 0 taken 2477 times.
✓ Branch 1 taken 411 times.
2888 if (val)
2374 2477 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2375
2/2
✓ Branch 0 taken 1444 times.
✓ Branch 1 taken 1444 times.
2888 j = i > 1 ? 2 : 0;
2376 2888 ff_vc1_pred_mv_intfr(v, j, dmv_x, dmv_y, 2, v->range_x, v->range_y, dir);
2377 2888 ff_vc1_mc_4mv_luma(v, j, dir, dir);
2378 2888 ff_vc1_mc_4mv_luma(v, j+1, dir, dir);
2379 }
2380
2381 722 ff_vc1_mc_4mv_chroma4(v, 0, 0, 0);
2382 722 ff_vc1_mc_4mv_chroma4(v, 1, 1, 1);
2383
2/2
✓ Branch 0 taken 2761 times.
✓ Branch 1 taken 20367 times.
23128 } else if (bmvtype == BMV_TYPE_INTERPOLATED) {
2384 2761 mvbp = v->twomvbp;
2385 2761 dmv_x = dmv_y = 0;
2386
2/2
✓ Branch 0 taken 2691 times.
✓ Branch 1 taken 70 times.
2761 if (mvbp & 2)
2387 2691 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2388
2389 2761 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, 0);
2390 2761 ff_vc1_mc_1mv(v, 0);
2391
2392 2761 dmv_x = dmv_y = 0;
2393
2/2
✓ Branch 0 taken 2648 times.
✓ Branch 1 taken 113 times.
2761 if (mvbp & 1)
2394 2648 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2395
2396 2761 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, 1);
2397 2761 ff_vc1_interp_mc(v);
2398
2/2
✓ Branch 0 taken 12364 times.
✓ Branch 1 taken 8003 times.
20367 } else if (twomv) {
2399 12364 dir = bmvtype == BMV_TYPE_BACKWARD;
2400 12364 dir2 = dir;
2401
2/2
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 6511 times.
12364 if (mvsw)
2402 5853 dir2 = !dir;
2403 12364 mvbp = v->twomvbp;
2404 12364 dmv_x = dmv_y = 0;
2405
2/2
✓ Branch 0 taken 10627 times.
✓ Branch 1 taken 1737 times.
12364 if (mvbp & 2)
2406 10627 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2407 12364 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 2, v->range_x, v->range_y, dir);
2408
2409 12364 dmv_x = dmv_y = 0;
2410
2/2
✓ Branch 0 taken 10929 times.
✓ Branch 1 taken 1435 times.
12364 if (mvbp & 1)
2411 10929 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2412 12364 ff_vc1_pred_mv_intfr(v, 2, dmv_x, dmv_y, 2, v->range_x, v->range_y, dir2);
2413
2414
2/2
✓ Branch 0 taken 5853 times.
✓ Branch 1 taken 6511 times.
12364 if (mvsw) {
2415
2/2
✓ Branch 0 taken 11706 times.
✓ Branch 1 taken 5853 times.
17559 for (i = 0; i < 2; i++) {
2416 11706 s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->current_picture.motion_val[dir][s->block_index[i+2]][0] = s->current_picture.motion_val[dir][s->block_index[i]][0];
2417 11706 s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->current_picture.motion_val[dir][s->block_index[i+2]][1] = s->current_picture.motion_val[dir][s->block_index[i]][1];
2418 11706 s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->current_picture.motion_val[dir2][s->block_index[i]][0] = s->current_picture.motion_val[dir2][s->block_index[i+2]][0];
2419 11706 s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->current_picture.motion_val[dir2][s->block_index[i]][1] = s->current_picture.motion_val[dir2][s->block_index[i+2]][1];
2420 }
2421 } else {
2422 6511 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, !dir);
2423 6511 ff_vc1_pred_mv_intfr(v, 2, 0, 0, 2, v->range_x, v->range_y, !dir);
2424 }
2425
2426 12364 ff_vc1_mc_4mv_luma(v, 0, dir, 0);
2427 12364 ff_vc1_mc_4mv_luma(v, 1, dir, 0);
2428 12364 ff_vc1_mc_4mv_luma(v, 2, dir2, 0);
2429 12364 ff_vc1_mc_4mv_luma(v, 3, dir2, 0);
2430 12364 ff_vc1_mc_4mv_chroma4(v, dir, dir2, 0);
2431 } else {
2432 8003 dir = bmvtype == BMV_TYPE_BACKWARD;
2433
2434 8003 mvbp = ff_vc1_mbmode_intfrp[0][idx_mbmode][2];
2435 8003 dmv_x = dmv_y = 0;
2436
2/2
✓ Branch 0 taken 7691 times.
✓ Branch 1 taken 312 times.
8003 if (mvbp)
2437 7691 get_mvdata_interlaced(v, &dmv_x, &dmv_y, 0);
2438
2439 8003 ff_vc1_pred_mv_intfr(v, 0, dmv_x, dmv_y, 1, v->range_x, v->range_y, dir);
2440 8003 v->blk_mv_type[s->block_index[0]] = 1;
2441 8003 v->blk_mv_type[s->block_index[1]] = 1;
2442 8003 v->blk_mv_type[s->block_index[2]] = 1;
2443 8003 v->blk_mv_type[s->block_index[3]] = 1;
2444 8003 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, !dir);
2445
2/2
✓ Branch 0 taken 16006 times.
✓ Branch 1 taken 8003 times.
24009 for (i = 0; i < 2; i++) {
2446 16006 s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->current_picture.motion_val[!dir][s->block_index[i+2]][0] = s->current_picture.motion_val[!dir][s->block_index[i]][0];
2447 16006 s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->current_picture.motion_val[!dir][s->block_index[i+2]][1] = s->current_picture.motion_val[!dir][s->block_index[i]][1];
2448 }
2449 8003 ff_vc1_mc_1mv(v, dir);
2450 }
2451
2452
2/2
✓ Branch 0 taken 26859 times.
✓ Branch 1 taken 4138 times.
30997 if (cbp)
2453
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
2454 30997 s->current_picture.qscale_table[mb_pos] = mquant;
2455
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)
2456 26859 ttmb = get_vlc2(gb, ff_vc1_ttmb_vlc[v->tt_index].table, VC1_TTMB_VLC_BITS, 2);
2457
2/2
✓ Branch 0 taken 185982 times.
✓ Branch 1 taken 30997 times.
216979 for (i = 0; i < 6; i++) {
2458 185982 s->dc_val[0][s->block_index[i]] = 0;
2459 185982 dst_idx += i >> 2;
2460 185982 val = ((cbp >> (5 - i)) & 1);
2461
2/2
✓ Branch 0 taken 84336 times.
✓ Branch 1 taken 101646 times.
185982 if (!fieldtx)
2462
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);
2463 else
2464
4/4
✓ Branch 0 taken 67764 times.
✓ Branch 1 taken 33882 times.
✓ Branch 2 taken 33882 times.
✓ Branch 3 taken 33882 times.
101646 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->linesize));
2465
2/2
✓ Branch 0 taken 115621 times.
✓ Branch 1 taken 70361 times.
185982 if (val) {
2466 346863 pat = vc1_decode_p_block(v, s->block[i], i, mquant, ttmb,
2467 115621 first_block, s->dest[dst_idx] + off,
2468
2/2
✓ Branch 0 taken 27250 times.
✓ Branch 1 taken 88371 times.
115621 (i & 4) ? s->uvlinesize : (s->linesize << fieldtx),
2469 CONFIG_GRAY && (i & 4) && (s->avctx->flags & AV_CODEC_FLAG_GRAY), &block_tt);
2470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 115621 times.
115621 if (pat < 0)
2471 return pat;
2472 115621 block_cbp |= pat << (i << 2);
2473
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)
2474 92324 ttmb = -1;
2475 115621 first_block = 0;
2476 }
2477 }
2478
2479 } else { // skipped
2480 1542 dir = 0;
2481
2/2
✓ Branch 0 taken 9252 times.
✓ Branch 1 taken 1542 times.
10794 for (i = 0; i < 6; i++) {
2482 9252 v->mb_type[0][s->block_index[i]] = 0;
2483 9252 s->dc_val[0][s->block_index[i]] = 0;
2484 }
2485 1542 s->current_picture.mb_type[mb_pos] = MB_TYPE_SKIP;
2486 1542 s->current_picture.qscale_table[mb_pos] = 0;
2487 1542 v->blk_mv_type[s->block_index[0]] = 0;
2488 1542 v->blk_mv_type[s->block_index[1]] = 0;
2489 1542 v->blk_mv_type[s->block_index[2]] = 0;
2490 1542 v->blk_mv_type[s->block_index[3]] = 0;
2491
2492
2/2
✓ Branch 0 taken 215 times.
✓ Branch 1 taken 1327 times.
1542 if (!direct) {
2493
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 206 times.
215 if (bmvtype == BMV_TYPE_INTERPOLATED) {
2494 9 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, 0);
2495 9 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, 1);
2496 } else {
2497 206 dir = bmvtype == BMV_TYPE_BACKWARD;
2498 206 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 1, v->range_x, v->range_y, dir);
2499
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 206 times.
206 if (mvsw) {
2500 int dir2 = dir;
2501 if (mvsw)
2502 dir2 = !dir;
2503 for (i = 0; i < 2; i++) {
2504 s->mv[dir][i+2][0] = s->mv[dir][i][0] = s->current_picture.motion_val[dir][s->block_index[i+2]][0] = s->current_picture.motion_val[dir][s->block_index[i]][0];
2505 s->mv[dir][i+2][1] = s->mv[dir][i][1] = s->current_picture.motion_val[dir][s->block_index[i+2]][1] = s->current_picture.motion_val[dir][s->block_index[i]][1];
2506 s->mv[dir2][i+2][0] = s->mv[dir2][i][0] = s->current_picture.motion_val[dir2][s->block_index[i]][0] = s->current_picture.motion_val[dir2][s->block_index[i+2]][0];
2507 s->mv[dir2][i+2][1] = s->mv[dir2][i][1] = s->current_picture.motion_val[dir2][s->block_index[i]][1] = s->current_picture.motion_val[dir2][s->block_index[i+2]][1];
2508 }
2509 } else {
2510 206 v->blk_mv_type[s->block_index[0]] = 1;
2511 206 v->blk_mv_type[s->block_index[1]] = 1;
2512 206 v->blk_mv_type[s->block_index[2]] = 1;
2513 206 v->blk_mv_type[s->block_index[3]] = 1;
2514 206 ff_vc1_pred_mv_intfr(v, 0, 0, 0, 2, v->range_x, v->range_y, !dir);
2515
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 206 times.
618 for (i = 0; i < 2; i++) {
2516 412 s->mv[!dir][i+2][0] = s->mv[!dir][i][0] = s->current_picture.motion_val[!dir][s->block_index[i+2]][0] = s->current_picture.motion_val[!dir][s->block_index[i]][0];
2517 412 s->mv[!dir][i+2][1] = s->mv[!dir][i][1] = s->current_picture.motion_val[!dir][s->block_index[i+2]][1] = s->current_picture.motion_val[!dir][s->block_index[i]][1];
2518 }
2519 }
2520 }
2521 }
2522
2523 1542 ff_vc1_mc_1mv(v, dir);
2524
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) {
2525 1336 ff_vc1_interp_mc(v);
2526 }
2527 1542 v->fieldtx_plane[mb_pos] = 0;
2528 }
2529 }
2530 32640 v->cbp[s->mb_x] = block_cbp;
2531 32640 v->ttblk[s->mb_x] = block_tt;
2532
2533 32640 return 0;
2534 }
2535
2536 /** Decode blocks of I-frame
2537 */
2538 85 static void vc1_decode_i_blocks(VC1Context *v)
2539 {
2540 int k, j;
2541 85 MpegEncContext *s = &v->s;
2542 int cbp, val;
2543 uint8_t *coded_val;
2544 int mb_pos;
2545
2546 /* select coding mode used for VLC tables selection */
2547
3/4
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 70 times.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
85 switch (v->y_ac_table_index) {
2548 7 case 0:
2549
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 2 times.
7 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2550 7 break;
2551 70 case 1:
2552 70 v->codingset = CS_HIGH_MOT_INTRA;
2553 70 break;
2554 8 case 2:
2555 8 v->codingset = CS_MID_RATE_INTRA;
2556 8 break;
2557 }
2558
2559
3/4
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 5 times.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
85 switch (v->c_ac_table_index) {
2560 79 case 0:
2561
2/2
✓ Branch 0 taken 11 times.
✓ Branch 1 taken 68 times.
79 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2562 79 break;
2563 5 case 1:
2564 5 v->codingset2 = CS_HIGH_MOT_INTER;
2565 5 break;
2566 1 case 2:
2567 1 v->codingset2 = CS_MID_RATE_INTER;
2568 1 break;
2569 }
2570
2571 /* Set DC scale - y and c use the same */
2572 85 s->y_dc_scale = s->y_dc_scale_table[v->pq];
2573 85 s->c_dc_scale = s->c_dc_scale_table[v->pq];
2574
2575 //do frame decode
2576 85 s->mb_x = s->mb_y = 0;
2577 85 s->mb_intra = 1;
2578 85 s->first_slice_line = 1;
2579
2/2
✓ Branch 0 taken 918 times.
✓ Branch 1 taken 85 times.
1003 for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
2580 918 s->mb_x = 0;
2581 918 init_block_index(v);
2582
2/2
✓ Branch 0 taken 15610 times.
✓ Branch 1 taken 918 times.
16528 for (; s->mb_x < v->end_mb_x; s->mb_x++) {
2583 15610 update_block_index(s);
2584 15610 s->bdsp.clear_blocks(v->block[v->cur_blk_idx][0]);
2585 15610 mb_pos = s->mb_x + s->mb_y * s->mb_width;
2586 15610 s->current_picture.mb_type[mb_pos] = MB_TYPE_INTRA;
2587 15610 s->current_picture.qscale_table[mb_pos] = v->pq;
2588
2/2
✓ Branch 0 taken 62440 times.
✓ Branch 1 taken 15610 times.
78050 for (int i = 0; i < 4; i++) {
2589 62440 s->current_picture.motion_val[1][s->block_index[i]][0] = 0;
2590 62440 s->current_picture.motion_val[1][s->block_index[i]][1] = 0;
2591 }
2592
2593 // do actual MB decoding and displaying
2594 15610 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table,
2595 MSMP4_MB_INTRA_VLC_BITS, 2);
2596 15610 v->s.ac_pred = get_bits1(&v->s.gb);
2597
2598
2/2
✓ Branch 0 taken 93660 times.
✓ Branch 1 taken 15610 times.
109270 for (k = 0; k < 6; k++) {
2599 93660 v->mb_type[0][s->block_index[k]] = 1;
2600
2601 93660 val = ((cbp >> (5 - k)) & 1);
2602
2603
2/2
✓ Branch 0 taken 62440 times.
✓ Branch 1 taken 31220 times.
93660 if (k < 4) {
2604 62440 int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
2605 62440 val = val ^ pred;
2606 62440 *coded_val = val;
2607 }
2608 93660 cbp |= val << (5 - k);
2609
2610
2/2
✓ Branch 0 taken 62440 times.
✓ Branch 1 taken 31220 times.
93660 vc1_decode_i_block(v, v->block[v->cur_blk_idx][block_map[k]], k, val, (k < 4) ? v->codingset : v->codingset2);
2611
2612 if (CONFIG_GRAY && k > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2613 continue;
2614 93660 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[k]]);
2615 }
2616
2617
3/4
✓ Branch 0 taken 1790 times.
✓ Branch 1 taken 13820 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1790 times.
15610 if (v->overlap && v->pq >= 9) {
2618 ff_vc1_i_overlap_filter(v);
2619 if (v->rangeredfrm)
2620 for (k = 0; k < 6; k++)
2621 for (j = 0; j < 64; j++)
2622 v->block[v->cur_blk_idx][block_map[k]][j] *= 2;
2623 vc1_put_blocks_clamped(v, 1);
2624 } else {
2625
2/2
✓ Branch 0 taken 4240 times.
✓ Branch 1 taken 11370 times.
15610 if (v->rangeredfrm)
2626
2/2
✓ Branch 0 taken 25440 times.
✓ Branch 1 taken 4240 times.
29680 for (k = 0; k < 6; k++)
2627
2/2
✓ Branch 0 taken 1628160 times.
✓ Branch 1 taken 25440 times.
1653600 for (j = 0; j < 64; j++)
2628 1628160 v->block[v->cur_blk_idx][block_map[k]][j] = (v->block[v->cur_blk_idx][block_map[k]][j] - 64) * 2;
2629 15610 vc1_put_blocks_clamped(v, 0);
2630 }
2631
2632
2/2
✓ Branch 0 taken 12640 times.
✓ Branch 1 taken 2970 times.
15610 if (v->s.loop_filter)
2633 12640 ff_vc1_i_loop_filter(v);
2634
2635
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 15610 times.
15610 if (get_bits_left(&s->gb) < 0) {
2636 ff_er_add_slice(&s->er, 0, 0, s->mb_x, s->mb_y, ER_MB_ERROR);
2637 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
2638 get_bits_count(&s->gb), s->gb.size_in_bits);
2639 return;
2640 }
2641
2642 15610 v->topleft_blk_idx = (v->topleft_blk_idx + 1) % (v->end_mb_x + 2);
2643 15610 v->top_blk_idx = (v->top_blk_idx + 1) % (v->end_mb_x + 2);
2644 15610 v->left_blk_idx = (v->left_blk_idx + 1) % (v->end_mb_x + 2);
2645 15610 v->cur_blk_idx = (v->cur_blk_idx + 1) % (v->end_mb_x + 2);
2646 }
2647
2648 918 s->first_slice_line = 0;
2649 }
2650
2651 /* This is intentionally mb_height and not end_mb_y - unlike in advanced
2652 * profile, these only differ are when decoding MSS2 rectangles. */
2653 85 ff_er_add_slice(&s->er, 0, 0, s->mb_width - 1, s->mb_height - 1, ER_MB_END);
2654 }
2655
2656 /** Decode blocks of I-frame for advanced profile
2657 */
2658 14 static int vc1_decode_i_blocks_adv(VC1Context *v)
2659 {
2660 int k;
2661 14 MpegEncContext *s = &v->s;
2662 int cbp, val;
2663 uint8_t *coded_val;
2664 int mb_pos;
2665 int mquant;
2666 int mqdiff;
2667 14 GetBitContext *gb = &s->gb;
2668
2669
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 14 times.
14 if (get_bits_left(gb) <= 1)
2670 return AVERROR_INVALIDDATA;
2671
2672 /* select coding mode used for VLC tables selection */
2673
3/4
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 2 times.
✓ Branch 2 taken 11 times.
✗ Branch 3 not taken.
14 switch (v->y_ac_table_index) {
2674 1 case 0:
2675
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2676 1 break;
2677 2 case 1:
2678 2 v->codingset = CS_HIGH_MOT_INTRA;
2679 2 break;
2680 11 case 2:
2681 11 v->codingset = CS_MID_RATE_INTRA;
2682 11 break;
2683 }
2684
2685
2/4
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
14 switch (v->c_ac_table_index) {
2686 12 case 0:
2687
1/2
✓ Branch 0 taken 12 times.
✗ Branch 1 not taken.
12 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2688 12 break;
2689 case 1:
2690 v->codingset2 = CS_HIGH_MOT_INTER;
2691 break;
2692 2 case 2:
2693 2 v->codingset2 = CS_MID_RATE_INTER;
2694 2 break;
2695 }
2696
2697 // do frame decode
2698 14 s->mb_x = s->mb_y = 0;
2699 14 s->mb_intra = 1;
2700 14 s->first_slice_line = 1;
2701 14 s->mb_y = s->start_mb_y;
2702
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 8 times.
14 if (s->start_mb_y) {
2703 6 s->mb_x = 0;
2704 6 init_block_index(v);
2705 6 memset(&s->coded_block[s->block_index[0] - s->b8_stride], 0,
2706 6 (1 + s->b8_stride) * sizeof(*s->coded_block));
2707 }
2708
2/2
✓ Branch 0 taken 181 times.
✓ Branch 1 taken 14 times.
195 for (; s->mb_y < s->end_mb_y; s->mb_y++) {
2709 181 s->mb_x = 0;
2710 181 init_block_index(v);
2711
2/2
✓ Branch 0 taken 12114 times.
✓ Branch 1 taken 181 times.
12295 for (;s->mb_x < s->mb_width; s->mb_x++) {
2712 12114 mquant = v->pq;
2713 12114 update_block_index(s);
2714 12114 s->bdsp.clear_blocks(v->block[v->cur_blk_idx][0]);
2715 12114 mb_pos = s->mb_x + s->mb_y * s->mb_stride;
2716 12114 s->current_picture.mb_type[mb_pos + v->mb_off] = MB_TYPE_INTRA;
2717
2/2
✓ Branch 0 taken 48456 times.
✓ Branch 1 taken 12114 times.
60570 for (int i = 0; i < 4; i++) {
2718 48456 s->current_picture.motion_val[1][s->block_index[i] + v->blocks_off][0] = 0;
2719 48456 s->current_picture.motion_val[1][s->block_index[i] + v->blocks_off][1] = 0;
2720 }
2721
2722 // do actual MB decoding and displaying
2723
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12114 times.
12114 if (v->fieldtx_is_raw)
2724 v->fieldtx_plane[mb_pos] = get_bits1(&v->s.gb);
2725
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12114 times.
12114 if (get_bits_left(&v->s.gb) <= 1) {
2726 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2727 return 0;
2728 }
2729
2730 12114 cbp = get_vlc2(&v->s.gb, ff_msmp4_mb_i_vlc.table,
2731 MSMP4_MB_INTRA_VLC_BITS, 2);
2732
2/2
✓ Branch 0 taken 2670 times.
✓ Branch 1 taken 9444 times.
12114 if (v->acpred_is_raw)
2733 2670 v->s.ac_pred = get_bits1(&v->s.gb);
2734 else
2735 9444 v->s.ac_pred = v->acpred_plane[mb_pos];
2736
2737
3/4
✓ Branch 0 taken 399 times.
✓ Branch 1 taken 11715 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 399 times.
12114 if (v->condover == CONDOVER_SELECT && v->overflg_is_raw)
2738 v->over_flags_plane[mb_pos] = get_bits1(&v->s.gb);
2739
2740
16/38
✓ Branch 0 taken 8160 times.
✓ Branch 1 taken 3954 times.
✓ Branch 2 taken 8160 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8160 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✓ Branch 10 taken 6110 times.
✓ Branch 11 taken 2050 times.
✗ Branch 13 not taken.
✓ Branch 14 taken 8160 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 8160 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 8160 times.
✗ Branch 19 not taken.
✓ Branch 20 taken 8160 times.
✗ Branch 21 not taken.
✗ Branch 22 not taken.
✗ Branch 23 not taken.
✓ Branch 24 taken 8160 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 8160 times.
✗ Branch 29 not taken.
✗ Branch 30 not taken.
✗ Branch 31 not taken.
✓ Branch 32 taken 8160 times.
✗ Branch 33 not taken.
✗ Branch 34 not taken.
✓ Branch 35 taken 8160 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 8160 times.
✗ Branch 38 not taken.
✗ Branch 39 not taken.
✓ Branch 40 taken 8160 times.
12114 GET_MQUANT();
2741
2742 12114 s->current_picture.qscale_table[mb_pos] = mquant;
2743 /* Set DC scale - y and c use the same */
2744
2/2
✓ Branch 0 taken 3954 times.
✓ Branch 1 taken 8160 times.
12114 s->y_dc_scale = s->y_dc_scale_table[FFABS(mquant)];
2745
2/2
✓ Branch 0 taken 3954 times.
✓ Branch 1 taken 8160 times.
12114 s->c_dc_scale = s->c_dc_scale_table[FFABS(mquant)];
2746
2747
2/2
✓ Branch 0 taken 72684 times.
✓ Branch 1 taken 12114 times.
84798 for (k = 0; k < 6; k++) {
2748 72684 v->mb_type[0][s->block_index[k]] = 1;
2749
2750 72684 val = ((cbp >> (5 - k)) & 1);
2751
2752
2/2
✓ Branch 0 taken 48456 times.
✓ Branch 1 taken 24228 times.
72684 if (k < 4) {
2753 48456 int pred = vc1_coded_block_pred(&v->s, k, &coded_val);
2754 48456 val = val ^ pred;
2755 48456 *coded_val = val;
2756 }
2757 72684 cbp |= val << (5 - k);
2758
2759
6/6
✓ Branch 0 taken 3492 times.
✓ Branch 1 taken 69192 times.
✓ Branch 2 taken 2910 times.
✓ Branch 3 taken 582 times.
✓ Branch 4 taken 582 times.
✓ Branch 5 taken 2328 times.
72684 v->a_avail = !s->first_slice_line || (k == 2 || k == 3);
2760
6/6
✓ Branch 0 taken 1086 times.
✓ Branch 1 taken 71598 times.
✓ Branch 2 taken 905 times.
✓ Branch 3 taken 181 times.
✓ Branch 4 taken 181 times.
✓ Branch 5 taken 724 times.
72684 v->c_avail = !!s->mb_x || (k == 1 || k == 3);
2761
2762
2/2
✓ Branch 0 taken 48456 times.
✓ Branch 1 taken 24228 times.
72684 vc1_decode_i_block_adv(v, v->block[v->cur_blk_idx][block_map[k]], k, val,
2763 (k < 4) ? v->codingset : v->codingset2, mquant);
2764
2765 if (CONFIG_GRAY && k > 3 && (s->avctx->flags & AV_CODEC_FLAG_GRAY))
2766 continue;
2767 72684 v->vc1dsp.vc1_inv_trans_8x8(v->block[v->cur_blk_idx][block_map[k]]);
2768 }
2769
2770
5/6
✓ Branch 0 taken 3744 times.
✓ Branch 1 taken 8370 times.
✓ Branch 2 taken 3744 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 399 times.
✓ Branch 5 taken 3345 times.
12114 if (v->overlap && (v->pq >= 9 || v->condover != CONDOVER_NONE))
2771 399 ff_vc1_i_overlap_filter(v);
2772 12114 vc1_put_blocks_clamped(v, 1);
2773
2/2
✓ Branch 0 taken 11814 times.
✓ Branch 1 taken 300 times.
12114 if (v->s.loop_filter)
2774 11814 ff_vc1_i_loop_filter(v);
2775
2776
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 12114 times.
12114 if (get_bits_left(&s->gb) < 0) {
2777 // TODO: may need modification to handle slice coding
2778 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2779 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i\n",
2780 get_bits_count(&s->gb), s->gb.size_in_bits);
2781 return 0;
2782 }
2783
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 11950 times.
12114 inc_blk_idx(v->topleft_blk_idx);
2784
2/2
✓ Branch 0 taken 166 times.
✓ Branch 1 taken 11948 times.
12114 inc_blk_idx(v->top_blk_idx);
2785
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 11950 times.
12114 inc_blk_idx(v->left_blk_idx);
2786
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 11950 times.
12114 inc_blk_idx(v->cur_blk_idx);
2787 }
2788 181 s->first_slice_line = 0;
2789 }
2790
2791 14 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
2792 14 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
2793 14 return 0;
2794 }
2795
2796 915 static void vc1_decode_p_blocks(VC1Context *v)
2797 {
2798 915 MpegEncContext *s = &v->s;
2799 int apply_loop_filter;
2800
2801 /* select coding mode used for VLC tables selection */
2802
3/4
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
915 switch (v->c_ac_table_index) {
2803 268 case 0:
2804
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 20 times.
268 v->codingset = (v->pqindex <= 8) ? CS_HIGH_RATE_INTRA : CS_LOW_MOT_INTRA;
2805 268 break;
2806 391 case 1:
2807 391 v->codingset = CS_HIGH_MOT_INTRA;
2808 391 break;
2809 256 case 2:
2810 256 v->codingset = CS_MID_RATE_INTRA;
2811 256 break;
2812 }
2813
2814
3/4
✓ Branch 0 taken 268 times.
✓ Branch 1 taken 391 times.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
915 switch (v->c_ac_table_index) {
2815 268 case 0:
2816
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 20 times.
268 v->codingset2 = (v->pqindex <= 8) ? CS_HIGH_RATE_INTER : CS_LOW_MOT_INTER;
2817 268 break;
2818 391 case 1:
2819 391 v->codingset2 = CS_HIGH_MOT_INTER;
2820 391 break;
2821 256 case 2:
2822 256 v->codingset2 = CS_MID_RATE_INTER;
2823 256 break;
2824 }
2825
2826
3/4
✓ Branch 0 taken 865 times.
✓ Branch 1 taken 50 times.
✓ Branch 2 taken 865 times.
✗ Branch 3 not taken.
915 apply_loop_filter = s->loop_filter && !(s->avctx->skip_loop_filter >= AVDISCARD_NONKEY);
2827 915 s->first_slice_line = 1;
2828 915 memset(v->cbp_base, 0, sizeof(v->cbp_base[0]) * 3 * s->mb_stride);
2829
2/2
✓ Branch 0 taken 5362 times.
✓ Branch 1 taken 915 times.
6277 for (s->mb_y = s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
2830 5362 s->mb_x = 0;
2831 5362 init_block_index(v);
2832
2/2
✓ Branch 0 taken 206149 times.
✓ Branch 1 taken 5362 times.
211511 for (; s->mb_x < s->mb_width; s->mb_x++) {
2833 206149 update_block_index(s);
2834
2835
7/8
✓ Branch 0 taken 168904 times.
✓ Branch 1 taken 37245 times.
✓ Branch 2 taken 152584 times.
✓ Branch 3 taken 16320 times.
✓ Branch 4 taken 93814 times.
✓ Branch 5 taken 58770 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 110134 times.
206149 if (v->fcm == ILACE_FIELD || (v->fcm == PROGRESSIVE && v->mv_type_is_raw) || v->skip_is_raw)
2836
1/2
✗ Branch 1 not taken.
✓ Branch 2 taken 96015 times.
96015 if (get_bits_left(&v->s.gb) <= 1) {
2837 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2838 return;
2839 }
2840
2841
2/2
✓ Branch 0 taken 37245 times.
✓ Branch 1 taken 168904 times.
206149 if (v->fcm == ILACE_FIELD) {
2842 37245 vc1_decode_p_mb_intfi(v);
2843
1/2
✓ Branch 0 taken 37245 times.
✗ Branch 1 not taken.
37245 if (apply_loop_filter)
2844 37245 ff_vc1_p_loop_filter(v);
2845
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 152584 times.
168904 } else if (v->fcm == ILACE_FRAME) {
2846 16320 vc1_decode_p_mb_intfr(v);
2847
1/2
✓ Branch 0 taken 16320 times.
✗ Branch 1 not taken.
16320 if (apply_loop_filter)
2848 16320 ff_vc1_p_intfr_loop_filter(v);
2849 } else {
2850 152584 vc1_decode_p_mb(v);
2851
2/2
✓ Branch 0 taken 93304 times.
✓ Branch 1 taken 59280 times.
152584 if (apply_loop_filter)
2852 93304 ff_vc1_p_loop_filter(v);
2853 }
2854
2/4
✓ Branch 1 taken 206149 times.
✗ Branch 2 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 206149 times.
206149 if (get_bits_left(&s->gb) < 0 || get_bits_count(&s->gb) < 0) {
2855 // TODO: may need modification to handle slice coding
2856 ff_er_add_slice(&s->er, 0, s->start_mb_y, s->mb_x, s->mb_y, ER_MB_ERROR);
2857 av_log(s->avctx, AV_LOG_ERROR, "Bits overconsumption: %i > %i at %ix%i\n",
2858 get_bits_count(&s->gb), s->gb.size_in_bits, s->mb_x, s->mb_y);
2859 return;
2860 }
2861
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 201766 times.
206149 inc_blk_idx(v->topleft_blk_idx);
2862
2/2
✓ Branch 0 taken 4815 times.
✓ Branch 1 taken 201334 times.
206149 inc_blk_idx(v->top_blk_idx);
2863
2/2
✓ Branch 0 taken 4256 times.
✓ Branch 1 taken 201893 times.
206149 inc_blk_idx(v->left_blk_idx);
2864
2/2
✓ Branch 0 taken 4383 times.
✓ Branch 1 taken 201766 times.
206149 inc_blk_idx(v->cur_blk_idx);
2865 }
2866 5362 memmove(v->cbp_base,
2867 5362 v->cbp - s->mb_stride,
2868 5362 sizeof(v->cbp_base[0]) * 2 * s->mb_stride);
2869 5362 memmove(v->ttblk_base,
2870 5362 v->ttblk - s->mb_stride,
2871 5362 sizeof(v->ttblk_base[0]) * 2 * s->mb_stride);
2872 5362 memmove(v->is_intra_base,
2873 5362 v->is_intra - s->mb_stride,
2874 5362 sizeof(v->is_intra_base[0]) * 2 * s->mb_stride);
2875 5362 memmove(v->luma_mv_base,
2876 5362 v->luma_mv - s->mb_stride,
2877 5362 sizeof(v->luma_mv_base[0]) * 2 * s->mb_stride);
2878 5362 s->first_slice_line = 0;
2879 }
2880 915 ff_er_add_slice(&s->er, 0, s->start_mb_y << v->field_mode, s->mb_width - 1,
2881 915 (s->end_mb_y << v->field_mode) - 1, ER_MB_END);
2882 }
2883
2884 109 static void vc1_decode_b_blocks(VC1Context *v)
2885 {
2886 109 MpegEncContext *s = &v->s;
2887
2888 /* select coding mode used for VLC tables selection */
2889
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) {
2890 14 case 0:
2891
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;
2892 14 break;
2893 16 case 1:
2894 16 v->codingset = CS_HIGH_MOT_INTRA;
2895 16 break;
2896 79 case 2:
2897 79 v->codingset = CS_MID_RATE_INTRA;
2898 79 break;
2899 }
2900
2901
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) {
2902 14 case 0:
2903
1/2
✓ Branch 0 taken 14 times.
✗ Branch 1 not taken.
14