FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vc1_block.c
Date: 2022-07-06 18:02:43
Exec Total Coverage
Lines: 1845 1955 94.4%
Branches: 1637 2216 73.9%

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