FFmpeg coverage


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