FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vc1_block.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 1825 1936 94.3%
Functions: 25 25 100.0%
Branches: 1615 2194 73.6%

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