FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/vc1_mc.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 659 751 87.7%
Functions: 9 11 81.8%
Branches: 362 467 77.5%

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 "h264chroma.h"
31 #include "mathops.h"
32 #include "mpegvideo.h"
33 #include "vc1.h"
34
35 static av_always_inline void vc1_scale_luma(uint8_t *srcY,
36 int k, int linesize)
37 {
38 int i, j;
39 for (j = 0; j < k; j++) {
40 for (i = 0; i < k; i++)
41 srcY[i] = ((srcY[i] - 128) >> 1) + 128;
42 srcY += linesize;
43 }
44 }
45
46 static av_always_inline void vc1_scale_chroma(uint8_t *srcU, uint8_t *srcV,
47 int k, int uvlinesize)
48 {
49 int i, j;
50 for (j = 0; j < k; j++) {
51 for (i = 0; i < k; i++) {
52 srcU[i] = ((srcU[i] - 128) >> 1) + 128;
53 srcV[i] = ((srcV[i] - 128) >> 1) + 128;
54 }
55 srcU += uvlinesize;
56 srcV += uvlinesize;
57 }
58 }
59
60 3813 static av_always_inline void vc1_lut_scale_luma(uint8_t *srcY,
61 const uint8_t *lut1, const uint8_t *lut2,
62 int k, int linesize)
63 {
64 int i, j;
65
66
1/2
✓ Branch 0 taken 37708 times.
✗ Branch 1 not taken.
37708 for (j = 0; j < k; j += 2) {
67
2/2
✓ Branch 0 taken 708856 times.
✓ Branch 1 taken 37708 times.
746564 for (i = 0; i < k; i++)
68 708856 srcY[i] = lut1[srcY[i]];
69 37708 srcY += linesize;
70
71
2/2
✓ Branch 0 taken 3813 times.
✓ Branch 1 taken 33895 times.
37708 if (j + 1 == k)
72 3813 break;
73
74
2/2
✓ Branch 0 taken 637253 times.
✓ Branch 1 taken 33895 times.
671148 for (i = 0; i < k; i++)
75 637253 srcY[i] = lut2[srcY[i]];
76 33895 srcY += linesize;
77 }
78 3813 }
79
80 3813 static av_always_inline void vc1_lut_scale_chroma(uint8_t *srcU, uint8_t *srcV,
81 const uint8_t *lut1, const uint8_t *lut2,
82 int k, int uvlinesize)
83 {
84 int i, j;
85
86
1/2
✓ Branch 0 taken 19065 times.
✗ Branch 1 not taken.
19065 for (j = 0; j < k; j += 2) {
87
2/2
✓ Branch 0 taken 171585 times.
✓ Branch 1 taken 19065 times.
190650 for (i = 0; i < k; i++) {
88 171585 srcU[i] = lut1[srcU[i]];
89 171585 srcV[i] = lut1[srcV[i]];
90 }
91 19065 srcU += uvlinesize;
92 19065 srcV += uvlinesize;
93
94
2/2
✓ Branch 0 taken 3813 times.
✓ Branch 1 taken 15252 times.
19065 if (j + 1 == k)
95 3813 break;
96
97
2/2
✓ Branch 0 taken 137268 times.
✓ Branch 1 taken 15252 times.
152520 for (i = 0; i < k; i++) {
98 137268 srcU[i] = lut2[srcU[i]];
99 137268 srcV[i] = lut2[srcV[i]];
100 }
101 15252 srcU += uvlinesize;
102 15252 srcV += uvlinesize;
103 }
104 3813 }
105
106 static const uint8_t popcount4[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
107
108 23544 static av_always_inline int get_luma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty)
109 {
110 23544 MpegEncContext *s = &v->s;
111 23544 int idx = v->mv_f[dir][s->block_index[0] + v->blocks_off] |
112 23544 (v->mv_f[dir][s->block_index[1] + v->blocks_off] << 1) |
113 23544 (v->mv_f[dir][s->block_index[2] + v->blocks_off] << 2) |
114 23544 (v->mv_f[dir][s->block_index[3] + v->blocks_off] << 3);
115 static const uint8_t index2[16] = { 0, 0, 0, 0x23, 0, 0x13, 0x03, 0, 0, 0x12, 0x02, 0, 0x01, 0, 0, 0 };
116 23544 int opp_count = popcount4[idx];
117
118
4/5
✓ Branch 0 taken 16547 times.
✓ Branch 1 taken 2829 times.
✓ Branch 2 taken 2560 times.
✓ Branch 3 taken 1608 times.
✗ Branch 4 not taken.
23544 switch (opp_count) {
119 16547 case 0:
120 case 4:
121 16547 *tx = median4(s->mv[dir][0][0], s->mv[dir][1][0], s->mv[dir][2][0], s->mv[dir][3][0]);
122 16547 *ty = median4(s->mv[dir][0][1], s->mv[dir][1][1], s->mv[dir][2][1], s->mv[dir][3][1]);
123 16547 break;
124 2829 case 1:
125
4/4
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 1624 times.
✓ Branch 3 taken 1205 times.
2829 *tx = mid_pred(s->mv[dir][idx < 2][0], s->mv[dir][1 + (idx < 4)][0], s->mv[dir][2 + (idx < 8)][0]);
126
4/4
✓ Branch 0 taken 2240 times.
✓ Branch 1 taken 589 times.
✓ Branch 2 taken 1624 times.
✓ Branch 3 taken 1205 times.
2829 *ty = mid_pred(s->mv[dir][idx < 2][1], s->mv[dir][1 + (idx < 4)][1], s->mv[dir][2 + (idx < 8)][1]);
127 2829 break;
128 2560 case 3:
129
4/4
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 1438 times.
✓ Branch 3 taken 1122 times.
2560 *tx = mid_pred(s->mv[dir][idx > 0xd][0], s->mv[dir][1 + (idx > 0xb)][0], s->mv[dir][2 + (idx > 0x7)][0]);
130
4/4
✓ Branch 0 taken 1985 times.
✓ Branch 1 taken 575 times.
✓ Branch 2 taken 1438 times.
✓ Branch 3 taken 1122 times.
2560 *ty = mid_pred(s->mv[dir][idx > 0xd][1], s->mv[dir][1 + (idx > 0xb)][1], s->mv[dir][2 + (idx > 0x7)][1]);
131 2560 break;
132 1608 case 2:
133 1608 *tx = (s->mv[dir][index2[idx] >> 4][0] + s->mv[dir][index2[idx] & 0xf][0]) / 2;
134 1608 *ty = (s->mv[dir][index2[idx] >> 4][1] + s->mv[dir][index2[idx] & 0xf][1]) / 2;
135 1608 break;
136 }
137 23544 return opp_count;
138 }
139
140 26576 static av_always_inline int get_chroma_mv(VC1Context *v, int dir, int16_t *tx, int16_t *ty)
141 {
142 26576 MpegEncContext *s = &v->s;
143 79728 int idx = !v->mb_type[0][s->block_index[0]] |
144
2/2
✓ Branch 0 taken 23921 times.
✓ Branch 1 taken 2655 times.
26576 (!v->mb_type[0][s->block_index[1]] << 1) |
145
2/2
✓ Branch 0 taken 23906 times.
✓ Branch 1 taken 2670 times.
26576 (!v->mb_type[0][s->block_index[2]] << 2) |
146
2/2
✓ Branch 0 taken 23887 times.
✓ Branch 1 taken 2689 times.
26576 (!v->mb_type[0][s->block_index[3]] << 3);
147 static const uint8_t index2[16] = { 0, 0, 0, 0x01, 0, 0x02, 0x12, 0, 0, 0x03, 0x13, 0, 0x23, 0, 0, 0 };
148 26576 int valid_count = popcount4[idx];
149
150
4/4
✓ Branch 0 taken 20627 times.
✓ Branch 1 taken 3043 times.
✓ Branch 2 taken 1688 times.
✓ Branch 3 taken 1218 times.
26576 switch (valid_count) {
151 20627 case 4:
152 20627 *tx = median4(s->mv[dir][0][0], s->mv[dir][1][0], s->mv[dir][2][0], s->mv[dir][3][0]);
153 20627 *ty = median4(s->mv[dir][0][1], s->mv[dir][1][1], s->mv[dir][2][1], s->mv[dir][3][1]);
154 20627 break;
155 3043 case 3:
156
4/4
✓ Branch 0 taken 2246 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 1460 times.
✓ Branch 3 taken 1583 times.
3043 *tx = mid_pred(s->mv[dir][idx > 0xd][0], s->mv[dir][1 + (idx > 0xb)][0], s->mv[dir][2 + (idx > 0x7)][0]);
157
4/4
✓ Branch 0 taken 2246 times.
✓ Branch 1 taken 797 times.
✓ Branch 2 taken 1460 times.
✓ Branch 3 taken 1583 times.
3043 *ty = mid_pred(s->mv[dir][idx > 0xd][1], s->mv[dir][1 + (idx > 0xb)][1], s->mv[dir][2 + (idx > 0x7)][1]);
158 3043 break;
159 1688 case 2:
160 1688 *tx = (s->mv[dir][index2[idx] >> 4][0] + s->mv[dir][index2[idx] & 0xf][0]) / 2;
161 1688 *ty = (s->mv[dir][index2[idx] >> 4][1] + s->mv[dir][index2[idx] & 0xf][1]) / 2;
162 1688 break;
163 1218 default:
164 1218 return 0;
165 }
166 25358 return valid_count;
167 }
168
169 /** Do motion compensation over 1 macroblock
170 * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c
171 */
172 207678 void ff_vc1_mc_1mv(VC1Context *v, int dir)
173 {
174 207678 MpegEncContext *s = &v->s;
175 207678 H264ChromaContext *h264chroma = &v->h264chroma;
176 uint8_t *srcY, *srcU, *srcV;
177 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
178 207678 int v_edge_pos = s->v_edge_pos >> v->field_mode;
179 int i;
180 const uint8_t (*luty)[256], (*lutuv)[256];
181 int use_ic;
182 int interlace;
183 int linesize, uvlinesize;
184
185
2/2
✓ Branch 0 taken 62711 times.
✓ Branch 1 taken 144967 times.
207678 if ((!v->field_mode ||
186
4/4
✓ Branch 0 taken 15788 times.
✓ Branch 1 taken 46923 times.
✓ Branch 2 taken 5911 times.
✓ Branch 3 taken 9877 times.
62711 (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 150878 times.
150878 !v->s.last_pic.data[0])
188 return;
189
190 207678 linesize = s->cur_pic.ptr->f->linesize[0];
191 207678 uvlinesize = s->cur_pic.ptr->f->linesize[1];
192
193 207678 mx = s->mv[dir][0][0];
194 207678 my = s->mv[dir][0][1];
195
196 // store motion vectors for further use in B-frames
197
2/2
✓ Branch 0 taken 129731 times.
✓ Branch 1 taken 77947 times.
207678 if (s->pict_type == AV_PICTURE_TYPE_P) {
198
2/2
✓ Branch 0 taken 518924 times.
✓ Branch 1 taken 129731 times.
648655 for (i = 0; i < 4; i++) {
199 518924 s->cur_pic.motion_val[1][s->block_index[i] + v->blocks_off][0] = mx;
200 518924 s->cur_pic.motion_val[1][s->block_index[i] + v->blocks_off][1] = my;
201 }
202 }
203
204 207678 uvmx = (mx + ((mx & 3) == 3)) >> 1;
205 207678 uvmy = (my + ((my & 3) == 3)) >> 1;
206 207678 v->luma_mv[s->mb_x][0] = uvmx;
207 207678 v->luma_mv[s->mb_x][1] = uvmy;
208
209
2/2
✓ Branch 0 taken 62711 times.
✓ Branch 1 taken 144967 times.
207678 if (v->field_mode &&
210
2/2
✓ Branch 0 taken 36191 times.
✓ Branch 1 taken 26520 times.
62711 v->cur_field_type != v->ref_field_type[dir]) {
211 36191 my = my - 2 + 4 * v->cur_field_type;
212 36191 uvmy = uvmy - 2 + 4 * v->cur_field_type;
213 }
214
215 // fastuvmc shall be ignored for interlaced frame picture
216
3/4
✓ Branch 0 taken 37054 times.
✓ Branch 1 taken 170624 times.
✓ Branch 2 taken 37054 times.
✗ Branch 3 not taken.
207678 if (v->fastuvmc && (v->fcm != ILACE_FRAME)) {
217
2/2
✓ Branch 0 taken 16361 times.
✓ Branch 1 taken 20693 times.
37054 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
218
2/2
✓ Branch 0 taken 11726 times.
✓ Branch 1 taken 25328 times.
37054 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
219 }
220
2/2
✓ Branch 0 taken 181247 times.
✓ Branch 1 taken 26431 times.
207678 if (!dir) {
221
6/6
✓ Branch 0 taken 48786 times.
✓ Branch 1 taken 132461 times.
✓ Branch 2 taken 32469 times.
✓ Branch 3 taken 16317 times.
✓ Branch 4 taken 24516 times.
✓ Branch 5 taken 7953 times.
181247 if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
222 24516 srcY = s->cur_pic.data[0];
223 24516 srcU = s->cur_pic.data[1];
224 24516 srcV = s->cur_pic.data[2];
225 24516 luty = v->curr_luty;
226 24516 lutuv = v->curr_lutuv;
227 24516 use_ic = *v->curr_use_ic;
228 24516 interlace = 1;
229 } else {
230 156731 srcY = s->last_pic.data[0];
231 156731 srcU = s->last_pic.data[1];
232 156731 srcV = s->last_pic.data[2];
233 156731 luty = v->last_luty;
234 156731 lutuv = v->last_lutuv;
235 156731 use_ic = v->last_use_ic;
236 156731 interlace = v->last_interlaced;
237 }
238 } else {
239 26431 srcY = s->next_pic.data[0];
240 26431 srcU = s->next_pic.data[1];
241 26431 srcV = s->next_pic.data[2];
242 26431 luty = v->next_luty;
243 26431 lutuv = v->next_lutuv;
244 26431 use_ic = v->next_use_ic;
245 26431 interlace = v->next_interlaced;
246 }
247
248
2/4
✓ Branch 0 taken 207678 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 207678 times.
207678 if (!srcY || !srcU) {
249 av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
250 return;
251 }
252
253 207678 src_x = s->mb_x * 16 + (mx >> 2);
254 207678 src_y = s->mb_y * 16 + (my >> 2);
255 207678 uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
256 207678 uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
257
258
2/2
✓ Branch 0 taken 88639 times.
✓ Branch 1 taken 119039 times.
207678 if (v->profile != PROFILE_ADVANCED) {
259 88639 src_x = av_clip( src_x, -16, s->mb_width * 16);
260 88639 src_y = av_clip( src_y, -16, s->mb_height * 16);
261 88639 uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
262 88639 uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
263 } else {
264 119039 src_x = av_clip( src_x, -17, s->avctx->coded_width);
265 119039 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
266
2/2
✓ Branch 0 taken 23152 times.
✓ Branch 1 taken 95887 times.
119039 if (v->fcm == ILACE_FRAME) {
267 23152 src_y = av_clip(src_y, -18 + (src_y & 1), s->avctx->coded_height + (src_y & 1));
268 23152 uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->avctx->coded_height >> 1) + (uvsrc_y & 1));
269 } else {
270 95887 src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
271 95887 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
272 }
273 }
274
275 207678 srcY += src_y * s->linesize + src_x;
276 207678 srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
277 207678 srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
278
279
4/4
✓ Branch 0 taken 62711 times.
✓ Branch 1 taken 144967 times.
✓ Branch 2 taken 15788 times.
✓ Branch 3 taken 46923 times.
207678 if (v->field_mode && v->ref_field_type[dir]) {
280 15788 srcY += linesize;
281 15788 srcU += uvlinesize;
282 15788 srcV += uvlinesize;
283 }
284
285 /* for grayscale we should not try to read from unknown area */
286 if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) {
287 srcU = s->sc.edge_emu_buffer + 18 * s->linesize;
288 srcV = s->sc.edge_emu_buffer + 18 * s->linesize;
289 }
290
291
3/4
✓ Branch 0 taken 207678 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203865 times.
✓ Branch 3 taken 3813 times.
207678 if (v->rangeredfrm || use_ic
292
2/4
✓ Branch 0 taken 203865 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203865 times.
✗ Branch 3 not taken.
203865 || s->h_edge_pos < 22 || v_edge_pos < 22
293
2/2
✓ Branch 0 taken 197274 times.
✓ Branch 1 taken 6591 times.
203865 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx&3) - 16 - s->mspel * 3
294
2/2
✓ Branch 0 taken 14192 times.
✓ Branch 1 taken 183082 times.
197274 || (unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
295 24596 uint8_t *ubuf = s->sc.edge_emu_buffer + 19 * s->linesize;
296 24596 uint8_t *vbuf = ubuf + 9 * s->uvlinesize;
297 24596 const int k = 17 + s->mspel * 2;
298
299 24596 srcY -= s->mspel * (1 + s->linesize);
300
2/2
✓ Branch 0 taken 6950 times.
✓ Branch 1 taken 17646 times.
24596 if (interlace) {
301 5419 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
302 srcY,
303 6950 linesize << 1,
304 6950 linesize << 1,
305 k,
306 1531 v->field_mode ? k : k + 1 >> 1,
307 6950 src_x - s->mspel,
308 6950 src_y - s->mspel >> !v->field_mode,
309 s->h_edge_pos,
310
2/2
✓ Branch 0 taken 1531 times.
✓ Branch 1 taken 5419 times.
6950 s->v_edge_pos >> 1);
311
2/2
✓ Branch 0 taken 1531 times.
✓ Branch 1 taken 5419 times.
6950 if (!v->field_mode)
312 1531 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + linesize,
313 1531 srcY + linesize,
314 1531 linesize << 1,
315 1531 linesize << 1,
316 k,
317 k >> 1,
318 1531 src_x - s->mspel,
319 1531 src_y - s->mspel + 1 >> 1,
320 s->h_edge_pos,
321 1531 s->v_edge_pos >> 1);
322 } else
323 17646 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
324 srcY,
325 linesize,
326 linesize,
327 k,
328 v->field_mode ? (k << 1) - 1 : k,
329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17646 times.
17646 src_x - s->mspel,
330
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17646 times.
17646 v->field_mode ? 2 * (src_y - s->mspel) + v->ref_field_type[dir] :
331 17646 src_y - s->mspel,
332 s->h_edge_pos,
333 s->v_edge_pos);
334 24596 srcY = s->sc.edge_emu_buffer;
335
2/2
✓ Branch 0 taken 6950 times.
✓ Branch 1 taken 17646 times.
24596 if (interlace) {
336 6950 s->vdsp.emulated_edge_mc(ubuf,
337 srcU,
338 6950 uvlinesize << 1,
339 6950 uvlinesize << 1,
340 9,
341 6950 v->field_mode ? 9 : 5,
342 uvsrc_x,
343 6950 uvsrc_y >> !v->field_mode,
344 6950 s->h_edge_pos >> 1,
345
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 1531 times.
6950 s->v_edge_pos >> 2);
346 6950 s->vdsp.emulated_edge_mc(vbuf,
347 srcV,
348 6950 uvlinesize << 1,
349 6950 uvlinesize << 1,
350 9,
351 6950 v->field_mode ? 9 : 5,
352 uvsrc_x,
353 6950 uvsrc_y >> !v->field_mode,
354 6950 s->h_edge_pos >> 1,
355
2/2
✓ Branch 0 taken 5419 times.
✓ Branch 1 taken 1531 times.
6950 s->v_edge_pos >> 2);
356
2/2
✓ Branch 0 taken 1531 times.
✓ Branch 1 taken 5419 times.
6950 if (!v->field_mode) {
357 1531 s->vdsp.emulated_edge_mc(ubuf + uvlinesize,
358 1531 srcU + uvlinesize,
359 1531 uvlinesize << 1,
360 1531 uvlinesize << 1,
361 9,
362 4,
363 uvsrc_x,
364 1531 uvsrc_y + 1 >> 1,
365 1531 s->h_edge_pos >> 1,
366 1531 s->v_edge_pos >> 2);
367 1531 s->vdsp.emulated_edge_mc(vbuf + uvlinesize,
368 1531 srcV + uvlinesize,
369 1531 uvlinesize << 1,
370 1531 uvlinesize << 1,
371 9,
372 4,
373 uvsrc_x,
374 1531 uvsrc_y + 1 >> 1,
375 1531 s->h_edge_pos >> 1,
376 1531 s->v_edge_pos >> 2);
377 }
378 } else {
379 35292 s->vdsp.emulated_edge_mc(ubuf,
380 srcU,
381 uvlinesize,
382 uvlinesize,
383 9,
384
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17646 times.
17646 v->field_mode ? 17 : 9,
385 uvsrc_x,
386 v->field_mode ? 2 * uvsrc_y + v->ref_field_type[dir] : uvsrc_y,
387 17646 s->h_edge_pos >> 1,
388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17646 times.
17646 s->v_edge_pos >> 1);
389 35292 s->vdsp.emulated_edge_mc(vbuf,
390 srcV,
391 uvlinesize,
392 uvlinesize,
393 9,
394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17646 times.
17646 v->field_mode ? 17 : 9,
395 uvsrc_x,
396 v->field_mode ? 2 * uvsrc_y + v->ref_field_type[dir] : uvsrc_y,
397 17646 s->h_edge_pos >> 1,
398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17646 times.
17646 s->v_edge_pos >> 1);
399 }
400 24596 srcU = ubuf;
401 24596 srcV = vbuf;
402 /* if we deal with range reduction we need to scale source blocks */
403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24596 times.
24596 if (v->rangeredfrm) {
404 vc1_scale_luma(srcY, k, s->linesize);
405 vc1_scale_chroma(srcU, srcV, 9, s->uvlinesize);
406 }
407 /* if we deal with intensity compensation we need to scale source blocks */
408
2/2
✓ Branch 0 taken 3813 times.
✓ Branch 1 taken 20783 times.
24596 if (use_ic) {
409 7626 vc1_lut_scale_luma(srcY,
410 3813 luty[v->field_mode ? v->ref_field_type[dir] : ((0 + src_y - s->mspel) & 1)],
411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3813 times.
3813 luty[v->field_mode ? v->ref_field_type[dir] : ((1 + src_y - s->mspel) & 1)],
412
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3813 times.
3813 k, s->linesize);
413 7626 vc1_lut_scale_chroma(srcU, srcV,
414 3813 lutuv[v->field_mode ? v->ref_field_type[dir] : ((0 + uvsrc_y) & 1)],
415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3813 times.
3813 lutuv[v->field_mode ? v->ref_field_type[dir] : ((1 + uvsrc_y) & 1)],
416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3813 times.
3813 9, s->uvlinesize);
417 }
418 24596 srcY += s->mspel * (1 + s->linesize);
419 }
420
421
2/2
✓ Branch 0 taken 124256 times.
✓ Branch 1 taken 83422 times.
207678 if (s->mspel) {
422 124256 dxy = ((my & 3) << 2) | (mx & 3);
423 124256 v->vc1dsp.put_vc1_mspel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, v->rnd);
424 } else { // hpel mc - always used for luma
425 83422 dxy = (my & 2) | ((mx & 2) >> 1);
426
2/2
✓ Branch 0 taken 34949 times.
✓ Branch 1 taken 48473 times.
83422 if (!v->rnd)
427 34949 s->hdsp.put_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
428 else
429 48473 s->hdsp.put_no_rnd_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
430 }
431
432 if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
433 return;
434 /* Chroma MC always uses qpel bilinear */
435 207678 uvmx = (uvmx & 3) << 1;
436 207678 uvmy = (uvmy & 3) << 1;
437
2/2
✓ Branch 0 taken 105062 times.
✓ Branch 1 taken 102616 times.
207678 if (!v->rnd) {
438 105062 h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
439 105062 h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
440 } else {
441 102616 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
442 102616 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
443 }
444
2/2
✓ Branch 0 taken 62711 times.
✓ Branch 1 taken 144967 times.
207678 if (v->field_mode) {
445 62711 v->mv_f[dir][s->block_index[4] + v->mb_off] = v->cur_field_type != v->ref_field_type[dir];
446 62711 v->mv_f[dir][s->block_index[5] + v->mb_off] = v->cur_field_type != v->ref_field_type[dir];
447 }
448 }
449
450 /** Do motion compensation for 4-MV macroblock - luminance block
451 */
452 278096 void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
453 {
454 278096 MpegEncContext *s = &v->s;
455 uint8_t *srcY;
456 int dxy, mx, my, src_x, src_y;
457 int off;
458
2/2
✓ Branch 0 taken 116452 times.
✓ Branch 1 taken 161644 times.
278096 int fieldmv = (v->fcm == ILACE_FRAME) ? v->blk_mv_type[s->block_index[n]] : 0;
459 278096 int v_edge_pos = s->v_edge_pos >> v->field_mode;
460 const uint8_t (*luty)[256];
461 int use_ic;
462 int interlace;
463 int linesize;
464
465
2/2
✓ Branch 0 taken 65904 times.
✓ Branch 1 taken 212192 times.
278096 if ((!v->field_mode ||
466
4/4
✓ Branch 0 taken 24818 times.
✓ Branch 1 taken 41086 times.
✓ Branch 2 taken 12642 times.
✓ Branch 3 taken 12176 times.
65904 (v->ref_field_type[dir] == 1 && v->cur_field_type == 1)) &&
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 224834 times.
224834 !v->s.last_pic.data[0])
468 return;
469
470 278096 linesize = s->cur_pic.ptr->f->linesize[0];
471
472 278096 mx = s->mv[dir][n][0];
473 278096 my = s->mv[dir][n][1];
474
475
2/2
✓ Branch 0 taken 221322 times.
✓ Branch 1 taken 56774 times.
278096 if (!dir) {
476
6/6
✓ Branch 0 taken 47840 times.
✓ Branch 1 taken 173482 times.
✓ Branch 2 taken 27394 times.
✓ Branch 3 taken 20446 times.
✓ Branch 4 taken 19053 times.
✓ Branch 5 taken 8341 times.
221322 if (v->field_mode && (v->cur_field_type != v->ref_field_type[dir]) && v->second_field) {
477 19053 srcY = s->cur_pic.data[0];
478 19053 luty = v->curr_luty;
479 19053 use_ic = *v->curr_use_ic;
480 19053 interlace = 1;
481 } else {
482 202269 srcY = s->last_pic.data[0];
483 202269 luty = v->last_luty;
484 202269 use_ic = v->last_use_ic;
485 202269 interlace = v->last_interlaced;
486 }
487 } else {
488 56774 srcY = s->next_pic.data[0];
489 56774 luty = v->next_luty;
490 56774 use_ic = v->next_use_ic;
491 56774 interlace = v->next_interlaced;
492 }
493
494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 278096 times.
278096 if (!srcY) {
495 av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
496 return;
497 }
498
499
2/2
✓ Branch 0 taken 65904 times.
✓ Branch 1 taken 212192 times.
278096 if (v->field_mode) {
500
2/2
✓ Branch 0 taken 33310 times.
✓ Branch 1 taken 32594 times.
65904 if (v->cur_field_type != v->ref_field_type[dir])
501 33310 my = my - 2 + 4 * v->cur_field_type;
502 }
503
504
6/6
✓ Branch 0 taken 150352 times.
✓ Branch 1 taken 127744 times.
✓ Branch 2 taken 37540 times.
✓ Branch 3 taken 112812 times.
✓ Branch 4 taken 7068 times.
✓ Branch 5 taken 30472 times.
278096 if (s->pict_type == AV_PICTURE_TYPE_P && n == 3 && v->field_mode) {
505 7068 int opp_count = get_luma_mv(v, 0,
506 7068 &s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0],
507 7068 &s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1]);
508 7068 int k, f = opp_count > 2;
509
2/2
✓ Branch 0 taken 28272 times.
✓ Branch 1 taken 7068 times.
35340 for (k = 0; k < 4; k++)
510 28272 v->mv_f[1][s->block_index[k] + v->blocks_off] = f;
511 }
512
513
2/2
✓ Branch 0 taken 116452 times.
✓ Branch 1 taken 161644 times.
278096 if (v->fcm == ILACE_FRAME) { // not sure if needed for other types of picture
514 int qx, qy;
515 116452 int width = s->avctx->coded_width;
516 116452 int height = s->avctx->coded_height >> 1;
517
2/2
✓ Branch 0 taken 26340 times.
✓ Branch 1 taken 90112 times.
116452 if (s->pict_type == AV_PICTURE_TYPE_P) {
518 26340 s->cur_pic.motion_val[1][s->block_index[n] + v->blocks_off][0] = mx;
519 26340 s->cur_pic.motion_val[1][s->block_index[n] + v->blocks_off][1] = my;
520 }
521 116452 qx = (s->mb_x * 16) + (mx >> 2);
522 116452 qy = (s->mb_y * 8) + (my >> 3);
523
524
2/2
✓ Branch 0 taken 244 times.
✓ Branch 1 taken 116208 times.
116452 if (qx < -17)
525 244 mx -= 4 * (qx + 17);
526
2/2
✓ Branch 0 taken 704 times.
✓ Branch 1 taken 115504 times.
116208 else if (qx > width)
527 704 mx -= 4 * (qx - width);
528
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 116432 times.
116452 if (qy < -18)
529 20 my -= 8 * (qy + 18);
530
2/2
✓ Branch 0 taken 443 times.
✓ Branch 1 taken 115989 times.
116432 else if (qy > height + 1)
531 443 my -= 8 * (qy - height - 1);
532 }
533
534
4/4
✓ Branch 0 taken 116452 times.
✓ Branch 1 taken 161644 times.
✓ Branch 2 taken 113636 times.
✓ Branch 3 taken 2816 times.
278096 if ((v->fcm == ILACE_FRAME) && fieldmv)
535
2/2
✓ Branch 0 taken 56818 times.
✓ Branch 1 taken 56818 times.
113636 off = ((n > 1) ? s->linesize : 0) + (n & 1) * 8;
536 else
537 164460 off = s->linesize * 4 * (n & 2) + (n & 1) * 8;
538
539 278096 src_x = s->mb_x * 16 + (n & 1) * 8 + (mx >> 2);
540
2/2
✓ Branch 0 taken 164460 times.
✓ Branch 1 taken 113636 times.
278096 if (!fieldmv)
541 164460 src_y = s->mb_y * 16 + (n & 2) * 4 + (my >> 2);
542 else
543 113636 src_y = s->mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
544
545
2/2
✓ Branch 0 taken 19626 times.
✓ Branch 1 taken 258470 times.
278096 if (v->profile != PROFILE_ADVANCED) {
546 19626 src_x = av_clip(src_x, -16, s->mb_width * 16);
547 19626 src_y = av_clip(src_y, -16, s->mb_height * 16);
548 } else {
549 258470 src_x = av_clip(src_x, -17, s->avctx->coded_width);
550
2/2
✓ Branch 0 taken 116452 times.
✓ Branch 1 taken 142018 times.
258470 if (v->fcm == ILACE_FRAME)
551 116452 src_y = av_clip(src_y, -18 + (src_y & 1), s->avctx->coded_height + (src_y & 1));
552 else
553 142018 src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
554 }
555
556 278096 srcY += src_y * s->linesize + src_x;
557
4/4
✓ Branch 0 taken 65904 times.
✓ Branch 1 taken 212192 times.
✓ Branch 2 taken 24818 times.
✓ Branch 3 taken 41086 times.
278096 if (v->field_mode && v->ref_field_type[dir])
558 24818 srcY += linesize;
559
560
2/4
✓ Branch 0 taken 278096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 278096 times.
✗ Branch 3 not taken.
278096 if (v->rangeredfrm || use_ic
561
2/4
✓ Branch 0 taken 278096 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 278096 times.
✗ Branch 3 not taken.
278096 || s->h_edge_pos < 13 || v_edge_pos < 23
562
2/2
✓ Branch 0 taken 271625 times.
✓ Branch 1 taken 6471 times.
278096 || (unsigned)(src_x - s->mspel) > s->h_edge_pos - (mx & 3) - 8 - s->mspel * 2
563
2/2
✓ Branch 0 taken 10387 times.
✓ Branch 1 taken 261238 times.
271625 || (unsigned)(src_y - (s->mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->mspel * 2) << fieldmv)) {
564 16858 const int k = 9 + s->mspel * 2;
565
566 16858 srcY -= s->mspel * (1 + (s->linesize << fieldmv));
567 /* check emulate edge stride and offset */
568
2/2
✓ Branch 0 taken 11658 times.
✓ Branch 1 taken 5200 times.
16858 if (interlace) {
569 5736 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
570 srcY,
571 11658 linesize << 1,
572 11658 linesize << 1,
573 k,
574 5922 v->field_mode ? k : (k << fieldmv) + 1 >> 1,
575 11658 src_x - s->mspel,
576 11658 src_y - (s->mspel << fieldmv) >> !v->field_mode,
577 s->h_edge_pos,
578
2/2
✓ Branch 0 taken 5922 times.
✓ Branch 1 taken 5736 times.
11658 s->v_edge_pos >> 1);
579
4/4
✓ Branch 0 taken 5922 times.
✓ Branch 1 taken 5736 times.
✓ Branch 2 taken 114 times.
✓ Branch 3 taken 5808 times.
11658 if (!v->field_mode && !fieldmv)
580 114 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + linesize,
581 114 srcY + linesize,
582 114 linesize << 1,
583 114 linesize << 1,
584 k,
585 k >> 1,
586 114 src_x - s->mspel,
587 114 src_y - s->mspel + 1 >> 1,
588 s->h_edge_pos,
589 114 s->v_edge_pos >> 1);
590 } else
591 5200 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
592 srcY,
593 linesize,
594 linesize,
595 k,
596 v->field_mode ? (k << 1) - 1 : k << fieldmv,
597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5200 times.
5200 src_x - s->mspel,
598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5200 times.
5200 v->field_mode ? 2 * (src_y - s->mspel) + v->ref_field_type[dir] :
599 5200 src_y - (s->mspel << fieldmv),
600 s->h_edge_pos,
601 s->v_edge_pos);
602 16858 srcY = s->sc.edge_emu_buffer;
603 /* if we deal with range reduction we need to scale source blocks */
604
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16858 times.
16858 if (v->rangeredfrm) {
605 vc1_scale_luma(srcY, k, s->linesize << fieldmv);
606 }
607 /* if we deal with intensity compensation we need to scale source blocks */
608
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16858 times.
16858 if (use_ic) {
609 vc1_lut_scale_luma(srcY,
610 luty[v->field_mode ? v->ref_field_type[dir] : (((0<<fieldmv)+src_y - (s->mspel << fieldmv)) & 1)],
611 luty[v->field_mode ? v->ref_field_type[dir] : (((1<<fieldmv)+src_y - (s->mspel << fieldmv)) & 1)],
612 k, s->linesize << fieldmv);
613 }
614 16858 srcY += s->mspel * (1 + (s->linesize << fieldmv));
615 }
616
617
1/2
✓ Branch 0 taken 278096 times.
✗ Branch 1 not taken.
278096 if (s->mspel) {
618 278096 dxy = ((my & 3) << 2) | (mx & 3);
619
2/2
✓ Branch 0 taken 20328 times.
✓ Branch 1 taken 257768 times.
278096 if (avg)
620 20328 v->vc1dsp.avg_vc1_mspel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
621 else
622 257768 v->vc1dsp.put_vc1_mspel_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize << fieldmv, v->rnd);
623 } else { // hpel mc - always used for luma
624 dxy = (my & 2) | ((mx & 2) >> 1);
625 if (!v->rnd)
626 s->hdsp.put_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
627 else
628 s->hdsp.put_no_rnd_pixels_tab[1][dxy](s->dest[0] + off, srcY, s->linesize, 8);
629 }
630 }
631
632 /** Do motion compensation for 4-MV macroblock - both chroma blocks
633 */
634 43052 void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
635 {
636 43052 MpegEncContext *s = &v->s;
637 43052 H264ChromaContext *h264chroma = &v->h264chroma;
638 uint8_t *srcU, *srcV;
639 int uvmx, uvmy, uvsrc_x, uvsrc_y;
640 int16_t tx, ty;
641 int chroma_ref_type;
642 43052 int v_edge_pos = s->v_edge_pos >> v->field_mode;
643 const uint8_t (*lutuv)[256];
644 int use_ic;
645 int interlace;
646 int uvlinesize;
647
648
3/4
✓ Branch 0 taken 26576 times.
✓ Branch 1 taken 16476 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26576 times.
43052 if (!v->field_mode && !v->s.last_pic.data[0])
649 1218 return;
650 if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
651 return;
652
653 /* calculate chroma MV vector from four luma MVs */
654
3/4
✓ Branch 0 taken 16476 times.
✓ Branch 1 taken 26576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 16476 times.
43052 if (!v->field_mode || !v->numref) {
655 26576 int valid_count = get_chroma_mv(v, dir, &tx, &ty);
656
2/2
✓ Branch 0 taken 1218 times.
✓ Branch 1 taken 25358 times.
26576 if (!valid_count) {
657 1218 s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0] = 0;
658 1218 s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1] = 0;
659 1218 v->luma_mv[s->mb_x][0] = v->luma_mv[s->mb_x][1] = 0;
660 1218 return; //no need to do MC for intra blocks
661 }
662 25358 chroma_ref_type = v->ref_field_type[dir];
663 } else {
664 16476 int opp_count = get_luma_mv(v, dir, &tx, &ty);
665 16476 chroma_ref_type = v->cur_field_type ^ (opp_count > 2);
666 }
667
7/8
✓ Branch 0 taken 16476 times.
✓ Branch 1 taken 25358 times.
✓ Branch 2 taken 6083 times.
✓ Branch 3 taken 10393 times.
✓ Branch 4 taken 3408 times.
✓ Branch 5 taken 2675 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 3408 times.
41834 if (v->field_mode && chroma_ref_type == 1 && v->cur_field_type == 1 && !v->s.last_pic.data[0])
668 return;
669 41834 s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][0] = tx;
670 41834 s->cur_pic.motion_val[1][s->block_index[0] + v->blocks_off][1] = ty;
671
672 41834 uvlinesize = s->cur_pic.ptr->f->linesize[1];
673
674 41834 uvmx = (tx + ((tx & 3) == 3)) >> 1;
675 41834 uvmy = (ty + ((ty & 3) == 3)) >> 1;
676
677 41834 v->luma_mv[s->mb_x][0] = uvmx;
678 41834 v->luma_mv[s->mb_x][1] = uvmy;
679
680
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41834 times.
41834 if (v->fastuvmc) {
681 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
682 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
683 }
684 // Field conversion bias
685
2/2
✓ Branch 0 taken 7711 times.
✓ Branch 1 taken 34123 times.
41834 if (v->cur_field_type != chroma_ref_type)
686 7711 uvmy += 2 - 4 * chroma_ref_type;
687
688 41834 uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
689 41834 uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
690
691
2/2
✓ Branch 0 taken 5416 times.
✓ Branch 1 taken 36418 times.
41834 if (v->profile != PROFILE_ADVANCED) {
692 5416 uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
693 5416 uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
694 } else {
695 36418 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
696 36418 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
697 }
698
699
2/2
✓ Branch 0 taken 37318 times.
✓ Branch 1 taken 4516 times.
41834 if (!dir) {
700
6/6
✓ Branch 0 taken 11960 times.
✓ Branch 1 taken 25358 times.
✓ Branch 2 taken 6433 times.
✓ Branch 3 taken 5527 times.
✓ Branch 4 taken 4584 times.
✓ Branch 5 taken 1849 times.
37318 if (v->field_mode && (v->cur_field_type != chroma_ref_type) && v->second_field) {
701 4584 srcU = s->cur_pic.data[1];
702 4584 srcV = s->cur_pic.data[2];
703 4584 lutuv = v->curr_lutuv;
704 4584 use_ic = *v->curr_use_ic;
705 4584 interlace = 1;
706 } else {
707 32734 srcU = s->last_pic.data[1];
708 32734 srcV = s->last_pic.data[2];
709 32734 lutuv = v->last_lutuv;
710 32734 use_ic = v->last_use_ic;
711 32734 interlace = v->last_interlaced;
712 }
713 } else {
714 4516 srcU = s->next_pic.data[1];
715 4516 srcV = s->next_pic.data[2];
716 4516 lutuv = v->next_lutuv;
717 4516 use_ic = v->next_use_ic;
718 4516 interlace = v->next_interlaced;
719 }
720
721
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 41834 times.
41834 if (!srcU) {
722 av_log(v->s.avctx, AV_LOG_ERROR, "Referenced frame missing.\n");
723 return;
724 }
725
726 41834 srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
727 41834 srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
728
729
2/2
✓ Branch 0 taken 16476 times.
✓ Branch 1 taken 25358 times.
41834 if (v->field_mode) {
730
2/2
✓ Branch 0 taken 6083 times.
✓ Branch 1 taken 10393 times.
16476 if (chroma_ref_type) {
731 6083 srcU += uvlinesize;
732 6083 srcV += uvlinesize;
733 }
734 }
735
736
2/4
✓ Branch 0 taken 41834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41834 times.
✗ Branch 3 not taken.
41834 if (v->rangeredfrm || use_ic
737
2/4
✓ Branch 0 taken 41834 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 41834 times.
✗ Branch 3 not taken.
41834 || s->h_edge_pos < 18 || v_edge_pos < 18
738
2/2
✓ Branch 0 taken 40719 times.
✓ Branch 1 taken 1115 times.
41834 || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 9
739
2/2
✓ Branch 0 taken 2052 times.
✓ Branch 1 taken 38667 times.
40719 || (unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
740
2/2
✓ Branch 0 taken 1640 times.
✓ Branch 1 taken 1527 times.
3167 if (interlace) {
741 1640 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
742 srcU,
743 1640 uvlinesize << 1,
744 1640 uvlinesize << 1,
745 9,
746 1640 v->field_mode ? 9 : 5,
747 uvsrc_x,
748 1640 uvsrc_y >> !v->field_mode,
749 1640 s->h_edge_pos >> 1,
750
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 s->v_edge_pos >> 2);
751 1640 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16,
752 srcV,
753 1640 uvlinesize << 1,
754 1640 uvlinesize << 1,
755 9,
756 1640 v->field_mode ? 9 : 5,
757 uvsrc_x,
758 1640 uvsrc_y >> !v->field_mode,
759 1640 s->h_edge_pos >> 1,
760
1/2
✓ Branch 0 taken 1640 times.
✗ Branch 1 not taken.
1640 s->v_edge_pos >> 2);
761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1640 times.
1640 if (!v->field_mode) {
762 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + uvlinesize,
763 srcU + uvlinesize,
764 uvlinesize << 1,
765 uvlinesize << 1,
766 9,
767 4,
768 uvsrc_x,
769 uvsrc_y + 1 >> 1,
770 s->h_edge_pos >> 1,
771 s->v_edge_pos >> 2);
772 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16 + uvlinesize,
773 srcV + uvlinesize,
774 uvlinesize << 1,
775 uvlinesize << 1,
776 9,
777 4,
778 uvsrc_x,
779 uvsrc_y + 1 >> 1,
780 s->h_edge_pos >> 1,
781 s->v_edge_pos >> 2);
782 }
783 } else {
784 3054 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
785 srcU,
786 uvlinesize,
787 uvlinesize,
788 9,
789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1527 times.
1527 v->field_mode ? 17 : 9,
790 uvsrc_x,
791 v->field_mode ? 2 * uvsrc_y + chroma_ref_type : uvsrc_y,
792 1527 s->h_edge_pos >> 1,
793
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1527 times.
1527 s->v_edge_pos >> 1);
794 3054 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16,
795 srcV,
796 uvlinesize,
797 uvlinesize,
798 9,
799
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1527 times.
1527 v->field_mode ? 17 : 9,
800 uvsrc_x,
801 v->field_mode ? 2 * uvsrc_y + chroma_ref_type : uvsrc_y,
802 1527 s->h_edge_pos >> 1,
803
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1527 times.
1527 s->v_edge_pos >> 1);
804 }
805 3167 srcU = s->sc.edge_emu_buffer;
806 3167 srcV = s->sc.edge_emu_buffer + 16;
807
808 /* if we deal with range reduction we need to scale source blocks */
809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3167 times.
3167 if (v->rangeredfrm) {
810 vc1_scale_chroma(srcU, srcV, 9, s->uvlinesize);
811 }
812 /* if we deal with intensity compensation we need to scale source blocks */
813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3167 times.
3167 if (use_ic) {
814 vc1_lut_scale_chroma(srcU, srcV,
815 lutuv[v->field_mode ? chroma_ref_type : ((0 + uvsrc_y) & 1)],
816 lutuv[v->field_mode ? chroma_ref_type : ((1 + uvsrc_y) & 1)],
817 9, s->uvlinesize);
818 }
819 }
820
821 /* Chroma MC always uses qpel bilinear */
822 41834 uvmx = (uvmx & 3) << 1;
823 41834 uvmy = (uvmy & 3) << 1;
824
2/2
✓ Branch 0 taken 22434 times.
✓ Branch 1 taken 19400 times.
41834 if (!v->rnd) {
825 22434 h264chroma->put_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
826 22434 h264chroma->put_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
827 } else {
828 19400 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
829 19400 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
830 }
831
2/2
✓ Branch 0 taken 16476 times.
✓ Branch 1 taken 25358 times.
41834 if (v->field_mode) {
832 16476 v->mv_f[dir][s->block_index[4] + v->mb_off] = v->cur_field_type != chroma_ref_type;
833 16476 v->mv_f[dir][s->block_index[5] + v->mb_off] = v->cur_field_type != chroma_ref_type;
834 }
835 }
836
837 /** Do motion compensation for 4-MV interlaced frame chroma macroblock (both U and V)
838 */
839 29113 void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
840 {
841 29113 MpegEncContext *s = &v->s;
842 29113 H264ChromaContext *h264chroma = &v->h264chroma;
843 uint8_t *srcU, *srcV;
844 int uvsrc_x, uvsrc_y;
845 int uvmx_field[4], uvmy_field[4];
846 int i, off, tx, ty;
847 29113 int fieldmv = v->blk_mv_type[s->block_index[0]];
848 static const uint8_t s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
849
2/2
✓ Branch 0 taken 28409 times.
✓ Branch 1 taken 704 times.
29113 int v_dist = fieldmv ? 1 : 4; // vertical offset for lower sub-blocks
850 29113 int v_edge_pos = s->v_edge_pos >> 1;
851 int use_ic;
852 int interlace;
853 int uvlinesize;
854 const uint8_t (*lutuv)[256];
855
856 if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
857 return;
858
859 29113 uvlinesize = s->cur_pic.ptr->f->linesize[1];
860
861
2/2
✓ Branch 0 taken 116452 times.
✓ Branch 1 taken 29113 times.
145565 for (i = 0; i < 4; i++) {
862
2/2
✓ Branch 0 taken 58226 times.
✓ Branch 1 taken 58226 times.
116452 int d = i < 2 ? dir: dir2;
863 116452 tx = s->mv[d][i][0];
864 116452 uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
865 116452 ty = s->mv[d][i][1];
866
2/2
✓ Branch 0 taken 113636 times.
✓ Branch 1 taken 2816 times.
116452 if (fieldmv)
867 113636 uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
868 else
869 2816 uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
870 }
871
872
2/2
✓ Branch 0 taken 116452 times.
✓ Branch 1 taken 29113 times.
145565 for (i = 0; i < 4; i++) {
873
2/2
✓ Branch 0 taken 58226 times.
✓ Branch 1 taken 58226 times.
116452 off = (i & 1) * 4 + ((i & 2) ? v_dist * s->uvlinesize : 0);
874 116452 uvsrc_x = s->mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
875
2/2
✓ Branch 0 taken 58226 times.
✓ Branch 1 taken 58226 times.
116452 uvsrc_y = s->mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
876 // FIXME: implement proper pull-back (see vc1cropmv.c, vc1CROPMV_ChromaPullBack())
877 116452 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
878
1/2
✓ Branch 0 taken 116452 times.
✗ Branch 1 not taken.
116452 if (v->fcm == ILACE_FRAME)
879 116452 uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->avctx->coded_height >> 1) + (uvsrc_y & 1));
880 else
881 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
882
4/4
✓ Branch 0 taken 58226 times.
✓ Branch 1 taken 58226 times.
✓ Branch 2 taken 38710 times.
✓ Branch 3 taken 77742 times.
116452 if (i < 2 ? dir : dir2) {
883 38710 srcU = s->next_pic.data[1];
884 38710 srcV = s->next_pic.data[2];
885 38710 lutuv = v->next_lutuv;
886 38710 use_ic = v->next_use_ic;
887 38710 interlace = v->next_interlaced;
888 } else {
889 77742 srcU = s->last_pic.data[1];
890 77742 srcV = s->last_pic.data[2];
891 77742 lutuv = v->last_lutuv;
892 77742 use_ic = v->last_use_ic;
893 77742 interlace = v->last_interlaced;
894 }
895
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 116452 times.
116452 if (!srcU)
896 return;
897 116452 srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
898 116452 srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
899 116452 uvmx_field[i] = (uvmx_field[i] & 3) << 1;
900 116452 uvmy_field[i] = (uvmy_field[i] & 3) << 1;
901
902
1/2
✓ Branch 0 taken 116452 times.
✗ Branch 1 not taken.
116452 if (use_ic
903
2/4
✓ Branch 0 taken 116452 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 116452 times.
✗ Branch 3 not taken.
116452 || s->h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
904
2/2
✓ Branch 0 taken 113912 times.
✓ Branch 1 taken 2540 times.
116452 || (unsigned)uvsrc_x > (s->h_edge_pos >> 1) - 5
905
2/2
✓ Branch 0 taken 2887 times.
✓ Branch 1 taken 111025 times.
113912 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
906
1/2
✓ Branch 0 taken 5427 times.
✗ Branch 1 not taken.
5427 if (interlace) {
907 5427 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
908 srcU,
909 5427 uvlinesize << 1,
910 5427 uvlinesize << 1,
911 5,
912 5427 (5 << fieldmv) + 1 >> 1,
913 uvsrc_x,
914 uvsrc_y >> 1,
915 5427 s->h_edge_pos >> 1,
916 5427 s->v_edge_pos >> 2);
917 5427 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16,
918 srcV,
919 5427 uvlinesize << 1,
920 5427 uvlinesize << 1,
921 5,
922 5427 (5 << fieldmv) + 1 >> 1,
923 uvsrc_x,
924 uvsrc_y >> 1,
925 5427 s->h_edge_pos >> 1,
926 5427 s->v_edge_pos >> 2);
927
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 5319 times.
5427 if (!fieldmv) {
928 108 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + uvlinesize,
929 108 srcU + uvlinesize,
930 108 uvlinesize << 1,
931 108 uvlinesize << 1,
932 5,
933 2,
934 uvsrc_x,
935 108 uvsrc_y + 1 >> 1,
936 108 s->h_edge_pos >> 1,
937 108 s->v_edge_pos >> 2);
938 108 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16 + uvlinesize,
939 108 srcV + uvlinesize,
940 108 uvlinesize << 1,
941 108 uvlinesize << 1,
942 5,
943 2,
944 uvsrc_x,
945 108 uvsrc_y + 1 >> 1,
946 108 s->h_edge_pos >> 1,
947 108 s->v_edge_pos >> 2);
948 }
949 } else {
950 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
951 srcU,
952 uvlinesize,
953 uvlinesize,
954 5,
955 5 << fieldmv,
956 uvsrc_x,
957 uvsrc_y,
958 s->h_edge_pos >> 1,
959 s->v_edge_pos >> 1);
960 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + 16,
961 srcV,
962 uvlinesize,
963 uvlinesize,
964 5,
965 5 << fieldmv,
966 uvsrc_x,
967 uvsrc_y,
968 s->h_edge_pos >> 1,
969 s->v_edge_pos >> 1);
970 }
971 5427 srcU = s->sc.edge_emu_buffer;
972 5427 srcV = s->sc.edge_emu_buffer + 16;
973
974 /* if we deal with intensity compensation we need to scale source blocks */
975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5427 times.
5427 if (use_ic) {
976 vc1_lut_scale_chroma(srcU, srcV,
977 lutuv[(uvsrc_y + (0 << fieldmv)) & 1],
978 lutuv[(uvsrc_y + (1 << fieldmv)) & 1],
979 5, s->uvlinesize << fieldmv);
980 }
981 }
982
2/2
✓ Branch 0 taken 20328 times.
✓ Branch 1 taken 96124 times.
116452 if (avg) {
983
2/2
✓ Branch 0 taken 10832 times.
✓ Branch 1 taken 9496 times.
20328 if (!v->rnd) {
984 10832 h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
985 10832 h264chroma->avg_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
986 } else {
987 9496 v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
988 9496 v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
989 }
990 } else {
991
2/2
✓ Branch 0 taken 53028 times.
✓ Branch 1 taken 43096 times.
96124 if (!v->rnd) {
992 53028 h264chroma->put_h264_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
993 53028 h264chroma->put_h264_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
994 } else {
995 43096 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[1] + off, srcU, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
996 43096 v->vc1dsp.put_no_rnd_vc1_chroma_pixels_tab[1](s->dest[2] + off, srcV, s->uvlinesize << fieldmv, 4, uvmx_field[i], uvmy_field[i]);
997 }
998 }
999 }
1000 }
1001
1002 /** Motion compensation for direct or interpolated blocks in B-frames
1003 */
1004 28266 void ff_vc1_interp_mc(VC1Context *v)
1005 {
1006 28266 MpegEncContext *s = &v->s;
1007 28266 H264ChromaContext *h264chroma = &v->h264chroma;
1008 uint8_t *srcY, *srcU, *srcV;
1009 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
1010 28266 int v_edge_pos = s->v_edge_pos >> v->field_mode;
1011 28266 int use_ic = v->next_use_ic;
1012 28266 int interlace = v->next_interlaced;
1013 int linesize, uvlinesize;
1014
1015
3/4
✓ Branch 0 taken 15610 times.
✓ Branch 1 taken 12656 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 15610 times.
28266 if (!v->field_mode && !v->s.next_pic.data[0])
1016 return;
1017
1018 28266 linesize = s->cur_pic.ptr->f->linesize[0];
1019 28266 uvlinesize = s->cur_pic.ptr->f->linesize[1];
1020
1021 28266 mx = s->mv[1][0][0];
1022 28266 my = s->mv[1][0][1];
1023 28266 uvmx = (mx + ((mx & 3) == 3)) >> 1;
1024 28266 uvmy = (my + ((my & 3) == 3)) >> 1;
1025
4/4
✓ Branch 0 taken 12656 times.
✓ Branch 1 taken 15610 times.
✓ Branch 2 taken 5223 times.
✓ Branch 3 taken 7433 times.
28266 if (v->field_mode && v->cur_field_type != v->ref_field_type[1]) {
1026 5223 my = my - 2 + 4 * v->cur_field_type;
1027 5223 uvmy = uvmy - 2 + 4 * v->cur_field_type;
1028 }
1029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 28266 times.
28266 if (v->fastuvmc) {
1030 uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
1031 uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
1032 }
1033 28266 srcY = s->next_pic.data[0];
1034 28266 srcU = s->next_pic.data[1];
1035 28266 srcV = s->next_pic.data[2];
1036
1037 28266 src_x = s->mb_x * 16 + (mx >> 2);
1038 28266 src_y = s->mb_y * 16 + (my >> 2);
1039 28266 uvsrc_x = s->mb_x * 8 + (uvmx >> 2);
1040 28266 uvsrc_y = s->mb_y * 8 + (uvmy >> 2);
1041
1042
2/2
✓ Branch 0 taken 5166 times.
✓ Branch 1 taken 23100 times.
28266 if (v->profile != PROFILE_ADVANCED) {
1043 5166 src_x = av_clip( src_x, -16, s->mb_width * 16);
1044 5166 src_y = av_clip( src_y, -16, s->mb_height * 16);
1045 5166 uvsrc_x = av_clip(uvsrc_x, -8, s->mb_width * 8);
1046 5166 uvsrc_y = av_clip(uvsrc_y, -8, s->mb_height * 8);
1047 } else {
1048 23100 src_x = av_clip( src_x, -17, s->avctx->coded_width);
1049 23100 uvsrc_x = av_clip(uvsrc_x, -8, s->avctx->coded_width >> 1);
1050
2/2
✓ Branch 0 taken 6884 times.
✓ Branch 1 taken 16216 times.
23100 if (v->fcm == ILACE_FRAME) {
1051 6884 src_y = av_clip(src_y, -18 + (src_y & 1), s->avctx->coded_height + (src_y & 1));
1052 6884 uvsrc_y = av_clip(uvsrc_y, -8 + (uvsrc_y & 1), (s->avctx->coded_height >> 1) + (uvsrc_y & 1));
1053 } else {
1054 16216 src_y = av_clip(src_y, -18, s->avctx->coded_height + 1);
1055 16216 uvsrc_y = av_clip(uvsrc_y, -8, s->avctx->coded_height >> 1);
1056 }
1057 }
1058
1059 28266 srcY += src_y * s->linesize + src_x;
1060 28266 srcU += uvsrc_y * s->uvlinesize + uvsrc_x;
1061 28266 srcV += uvsrc_y * s->uvlinesize + uvsrc_x;
1062
1063
4/4
✓ Branch 0 taken 12656 times.
✓ Branch 1 taken 15610 times.
✓ Branch 2 taken 4716 times.
✓ Branch 3 taken 7940 times.
28266 if (v->field_mode && v->ref_field_type[1]) {
1064 4716 srcY += linesize;
1065 4716 srcU += uvlinesize;
1066 4716 srcV += uvlinesize;
1067 }
1068
1069 /* for grayscale we should not try to read from unknown area */
1070 if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY) {
1071 srcU = s->sc.edge_emu_buffer + 18 * s->linesize;
1072 srcV = s->sc.edge_emu_buffer + 18 * s->linesize;
1073 }
1074
1075
4/8
✓ Branch 0 taken 28266 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28266 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 28266 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 28266 times.
✗ Branch 7 not taken.
28266 if (v->rangeredfrm || s->h_edge_pos < 22 || v_edge_pos < 22 || use_ic
1076
2/2
✓ Branch 0 taken 27224 times.
✓ Branch 1 taken 1042 times.
28266 || (unsigned)(src_x - 1) > s->h_edge_pos - (mx & 3) - 16 - 3
1077
2/2
✓ Branch 0 taken 2434 times.
✓ Branch 1 taken 24790 times.
27224 || (unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
1078 3476 uint8_t *ubuf = s->sc.edge_emu_buffer + 19 * s->linesize;
1079 3476 uint8_t *vbuf = ubuf + 9 * s->uvlinesize;
1080 3476 const int k = 17 + s->mspel * 2;
1081
1082 3476 srcY -= s->mspel * (1 + s->linesize);
1083
2/2
✓ Branch 0 taken 2034 times.
✓ Branch 1 taken 1442 times.
3476 if (interlace) {
1084 1601 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
1085 srcY,
1086 2034 linesize << 1,
1087 2034 linesize << 1,
1088 k,
1089 433 v->field_mode ? k : (k + 1 >> 1),
1090 2034 src_x - s->mspel,
1091 2034 src_y - s->mspel >> !v->field_mode,
1092 s->h_edge_pos,
1093
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 1601 times.
2034 s->v_edge_pos >> 1);
1094
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 1601 times.
2034 if (!v->field_mode)
1095 433 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer + linesize,
1096 433 srcY + linesize,
1097 433 linesize << 1,
1098 433 linesize << 1,
1099 k,
1100 k >> 1,
1101 433 src_x - s->mspel,
1102 433 src_y - s->mspel + 1 >> 1,
1103 s->h_edge_pos,
1104 433 s->v_edge_pos >> 1);
1105 } else
1106 1442 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer,
1107 srcY,
1108 linesize,
1109 linesize,
1110 k,
1111 v->field_mode ? (k << 1) - 1 : k,
1112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 src_x - s->mspel,
1113
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 v->field_mode ? 2 * (src_y - s->mspel) + v->ref_field_type[1] :
1114 1442 src_y - s->mspel,
1115 s->h_edge_pos,
1116 s->v_edge_pos);
1117 3476 srcY = s->sc.edge_emu_buffer;
1118
2/2
✓ Branch 0 taken 2034 times.
✓ Branch 1 taken 1442 times.
3476 if (interlace) {
1119 2034 s->vdsp.emulated_edge_mc(ubuf,
1120 srcU,
1121 2034 uvlinesize << 1,
1122 2034 uvlinesize << 1,
1123 9,
1124 2034 v->field_mode ? 9 : 5,
1125 uvsrc_x,
1126 2034 uvsrc_y >> !v->field_mode,
1127 2034 s->h_edge_pos >> 1,
1128
2/2
✓ Branch 0 taken 1601 times.
✓ Branch 1 taken 433 times.
2034 s->v_edge_pos >> 2);
1129 2034 s->vdsp.emulated_edge_mc(vbuf,
1130 srcV,
1131 2034 uvlinesize << 1,
1132 2034 uvlinesize << 1,
1133 9,
1134 2034 v->field_mode ? 9 : 5,
1135 uvsrc_x,
1136 2034 uvsrc_y >> !v->field_mode,
1137 2034 s->h_edge_pos >> 1,
1138
2/2
✓ Branch 0 taken 1601 times.
✓ Branch 1 taken 433 times.
2034 s->v_edge_pos >> 2);
1139
2/2
✓ Branch 0 taken 433 times.
✓ Branch 1 taken 1601 times.
2034 if (!v->field_mode) {
1140 433 s->vdsp.emulated_edge_mc(ubuf + uvlinesize,
1141 433 srcU + uvlinesize,
1142 433 uvlinesize << 1,
1143 433 uvlinesize << 1,
1144 9,
1145 4,
1146 uvsrc_x,
1147 433 uvsrc_y + 1 >> 1,
1148 433 s->h_edge_pos >> 1,
1149 433 s->v_edge_pos >> 2);
1150 433 s->vdsp.emulated_edge_mc(vbuf + uvlinesize,
1151 433 srcV + uvlinesize,
1152 433 uvlinesize << 1,
1153 433 uvlinesize << 1,
1154 9,
1155 4,
1156 uvsrc_x,
1157 433 uvsrc_y + 1 >> 1,
1158 433 s->h_edge_pos >> 1,
1159 433 s->v_edge_pos >> 2);
1160 }
1161 } else {
1162 2884 s->vdsp.emulated_edge_mc(ubuf,
1163 srcU,
1164 uvlinesize,
1165 uvlinesize,
1166 9,
1167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 v->field_mode ? 17 : 9,
1168 uvsrc_x,
1169 v->field_mode ? 2 * uvsrc_y + v->ref_field_type[1] : uvsrc_y,
1170 1442 s->h_edge_pos >> 1,
1171
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 s->v_edge_pos >> 1);
1172 2884 s->vdsp.emulated_edge_mc(vbuf,
1173 srcV,
1174 uvlinesize,
1175 uvlinesize,
1176 9,
1177
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 v->field_mode ? 17 : 9,
1178 uvsrc_x,
1179 v->field_mode ? 2 * uvsrc_y + v->ref_field_type[1] : uvsrc_y,
1180 1442 s->h_edge_pos >> 1,
1181
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1442 times.
1442 s->v_edge_pos >> 1);
1182 }
1183 3476 srcU = ubuf;
1184 3476 srcV = vbuf;
1185 /* if we deal with range reduction we need to scale source blocks */
1186
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3476 times.
3476 if (v->rangeredfrm) {
1187 vc1_scale_luma(srcY, k, s->linesize);
1188 vc1_scale_chroma(srcU, srcV, 9, s->uvlinesize);
1189 }
1190
1191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3476 times.
3476 if (use_ic) {
1192 const uint8_t (*luty )[256] = v->next_luty;
1193 const uint8_t (*lutuv)[256] = v->next_lutuv;
1194 vc1_lut_scale_luma(srcY,
1195 luty[v->field_mode ? v->ref_field_type[1] : ((0+src_y - s->mspel) & 1)],
1196 luty[v->field_mode ? v->ref_field_type[1] : ((1+src_y - s->mspel) & 1)],
1197 k, s->linesize);
1198 vc1_lut_scale_chroma(srcU, srcV,
1199 lutuv[v->field_mode ? v->ref_field_type[1] : ((0+uvsrc_y) & 1)],
1200 lutuv[v->field_mode ? v->ref_field_type[1] : ((1+uvsrc_y) & 1)],
1201 9, s->uvlinesize);
1202 }
1203 3476 srcY += s->mspel * (1 + s->linesize);
1204 }
1205
1206
2/2
✓ Branch 0 taken 21617 times.
✓ Branch 1 taken 6649 times.
28266 if (s->mspel) {
1207 21617 dxy = ((my & 3) << 2) | (mx & 3);
1208 21617 v->vc1dsp.avg_vc1_mspel_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, v->rnd);
1209 } else { // hpel mc
1210 6649 dxy = (my & 2) | ((mx & 2) >> 1);
1211
1212
2/2
✓ Branch 0 taken 3673 times.
✓ Branch 1 taken 2976 times.
6649 if (!v->rnd)
1213 3673 s->hdsp.avg_pixels_tab[0][dxy](s->dest[0], srcY, s->linesize, 16);
1214 else
1215 2976 s->hdsp.avg_no_rnd_pixels_tab[dxy](s->dest[0], srcY, s->linesize, 16);
1216 }
1217
1218 if (CONFIG_GRAY && s->avctx->flags & AV_CODEC_FLAG_GRAY)
1219 return;
1220 /* Chroma MC always uses qpel bilinear */
1221 28266 uvmx = (uvmx & 3) << 1;
1222 28266 uvmy = (uvmy & 3) << 1;
1223
2/2
✓ Branch 0 taken 17299 times.
✓ Branch 1 taken 10967 times.
28266 if (!v->rnd) {
1224 17299 h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
1225 17299 h264chroma->avg_h264_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
1226 } else {
1227 10967 v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[1], srcU, s->uvlinesize, 8, uvmx, uvmy);
1228 10967 v->vc1dsp.avg_no_rnd_vc1_chroma_pixels_tab[0](s->dest[2], srcV, s->uvlinesize, 8, uvmx, uvmy);
1229 }
1230 }
1231