FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/mpegvideo_motion.c
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 369 407 90.7%
Functions: 13 13 100.0%
Branches: 152 196 77.6%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2000,2001 Fabrice Bellard
3 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
4 *
5 * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni@gmx.at>
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 #include "config_components.h"
25
26 #include "libavutil/avassert.h"
27 #include "libavutil/internal.h"
28 #include "libavutil/mem_internal.h"
29
30 #include "avcodec.h"
31 #include "h261.h"
32 #include "mpegutils.h"
33 #include "mpegvideo.h"
34 #include "mpeg4videodec.h"
35 #include "qpeldsp.h"
36 #include "wmv2.h"
37
38 2643712 static inline int hpel_motion(MpegEncContext *s,
39 uint8_t *dest, uint8_t *src,
40 int src_x, int src_y,
41 const op_pixels_func *pix_op,
42 int motion_x, int motion_y)
43 {
44 2643712 int dxy = 0;
45 2643712 int emu = 0;
46
47 2643712 src_x += motion_x >> 1;
48 2643712 src_y += motion_y >> 1;
49
50 /* WARNING: do no forget half pels */
51 2643712 src_x = av_clip(src_x, -16, s->width); // FIXME unneeded for emu?
52
2/2
✓ Branch 0 taken 2641789 times.
✓ Branch 1 taken 1923 times.
2643712 if (src_x != s->width)
53 2641789 dxy |= motion_x & 1;
54 2643712 src_y = av_clip(src_y, -16, s->height);
55
2/2
✓ Branch 0 taken 2641377 times.
✓ Branch 1 taken 2335 times.
2643712 if (src_y != s->height)
56 2641377 dxy |= (motion_y & 1) << 1;
57 2643712 src += src_y * s->linesize + src_x;
58
59
3/4
✓ Branch 0 taken 2643712 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2600682 times.
✓ Branch 3 taken 43030 times.
2643712 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
60
3/4
✓ Branch 0 taken 2600682 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46738 times.
✓ Branch 3 taken 2553944 times.
2600682 (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
61 89768 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, src,
62 s->linesize, s->linesize,
63 9, 9,
64 src_x, src_y,
65 s->h_edge_pos, s->v_edge_pos);
66 89768 src = s->sc.edge_emu_buffer;
67 89768 emu = 1;
68 }
69 2643712 pix_op[dxy](dest, src, s->linesize, 8);
70 2643712 return emu;
71 }
72
73 static av_always_inline
74 9088716 void mpeg_motion_internal(MpegEncContext *s,
75 uint8_t *dest_y,
76 uint8_t *dest_cb,
77 uint8_t *dest_cr,
78 int field_based,
79 int bottom_field,
80 int field_select,
81 uint8_t *const *ref_picture,
82 const op_pixels_func (*pix_op)[4],
83 int motion_x,
84 int motion_y,
85 int h,
86 int is_mpeg12,
87 int is_16x8,
88 int mb_y)
89 {
90 const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
91 int dxy, uvdxy, mx, my, src_x, src_y,
92 uvsrc_x, uvsrc_y, v_edge_pos, block_y_half;
93 ptrdiff_t uvlinesize, linesize;
94
95 9088716 v_edge_pos = s->v_edge_pos >> field_based;
96 9088716 linesize = s->cur_pic.linesize[0] << field_based;
97 9088716 uvlinesize = s->cur_pic.linesize[1] << field_based;
98 9088716 block_y_half = (field_based | is_16x8);
99
100 9088716 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
101 9088716 src_x = s->mb_x * 16 + (motion_x >> 1);
102 9088716 src_y = (mb_y << (4 - block_y_half)) + (motion_y >> 1);
103
104
4/4
✓ Branch 0 taken 4067335 times.
✓ Branch 1 taken 5021381 times.
✓ Branch 2 taken 3861049 times.
✓ Branch 3 taken 206286 times.
9088716 if (!is_mpeg12 && s->out_format == FMT_H263) {
105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3861049 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3861049 if ((s->workaround_bugs & FF_BUG_HPEL_CHROMA) && field_based) {
106 mx = (motion_x >> 1) | (motion_x & 1);
107 my = motion_y >> 1;
108 uvdxy = ((my & 1) << 1) | (mx & 1);
109 uvsrc_x = s->mb_x * 8 + (mx >> 1);
110 uvsrc_y = (mb_y << (3 - block_y_half)) + (my >> 1);
111 } else {
112 3861049 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
113 3861049 uvsrc_x = src_x >> 1;
114 3861049 uvsrc_y = src_y >> 1;
115 }
116 // Even chroma mv's are full pel in H261
117
2/2
✓ Branch 0 taken 206286 times.
✓ Branch 1 taken 5021381 times.
5227667 } else if (!CONFIG_SMALL && !is_mpeg12 ||
118 CONFIG_SMALL && s->out_format == FMT_H261) {
119 av_assert2(s->out_format == FMT_H261);
120 206286 mx = motion_x / 4;
121 206286 my = motion_y / 4;
122 206286 uvdxy = 0;
123 206286 uvsrc_x = s->mb_x * 8 + mx;
124 206286 uvsrc_y = mb_y * 8 + my;
125 } else {
126 av_assert2(s->out_format == FMT_MPEG1);
127
2/2
✓ Branch 0 taken 4347487 times.
✓ Branch 1 taken 673894 times.
5021381 if (s->chroma_y_shift) {
128 4347487 mx = motion_x / 2;
129 4347487 my = motion_y / 2;
130 4347487 uvdxy = ((my & 1) << 1) | (mx & 1);
131 4347487 uvsrc_x = s->mb_x * 8 + (mx >> 1);
132 4347487 uvsrc_y = (mb_y << (3 - block_y_half)) + (my >> 1);
133 } else {
134
1/2
✓ Branch 0 taken 673894 times.
✗ Branch 1 not taken.
673894 if (s->chroma_x_shift) {
135 // Chroma422
136 673894 mx = motion_x / 2;
137 673894 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
138 673894 uvsrc_x = s->mb_x * 8 + (mx >> 1);
139 673894 uvsrc_y = src_y;
140 } else {
141 // Chroma444
142 uvdxy = dxy;
143 uvsrc_x = src_x;
144 uvsrc_y = src_y;
145 }
146 }
147 }
148
149 9088716 ptr_y = ref_picture[0] + src_y * linesize + src_x;
150 9088716 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
151 9088716 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
152
153
3/4
✓ Branch 0 taken 9088716 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8950108 times.
✓ Branch 3 taken 138608 times.
9088716 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15 , 0) ||
154
3/4
✓ Branch 0 taken 8950108 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 151328 times.
✓ Branch 3 taken 8798780 times.
8950108 (unsigned)src_y >= FFMAX( v_edge_pos - (motion_y & 1) - h + 1, 0)) {
155
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289936 times.
289936 if (is_mpeg12 || (CONFIG_SMALL &&
156 (s->codec_id == AV_CODEC_ID_MPEG2VIDEO ||
157 s->codec_id == AV_CODEC_ID_MPEG1VIDEO))) {
158 av_log(s->avctx, AV_LOG_DEBUG,
159 "MPEG motion vector out of boundary (%d %d)\n", src_x,
160 src_y);
161 return;
162 }
163 289936 src_y = (unsigned)src_y << field_based;
164 289936 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
165 s->linesize, s->linesize,
166 17, 17 + field_based,
167 src_x, src_y,
168 s->h_edge_pos, s->v_edge_pos);
169 289936 ptr_y = s->sc.edge_emu_buffer;
170 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
171 289936 uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
172 289936 uint8_t *vbuf = ubuf + 10 * s->uvlinesize;
173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 289936 times.
289936 if (s->workaround_bugs & FF_BUG_IEDGE)
174 vbuf -= s->uvlinesize;
175 289936 uvsrc_y = (unsigned)uvsrc_y << field_based;
176 289936 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
177 s->uvlinesize, s->uvlinesize,
178 9, 9 + field_based,
179 uvsrc_x, uvsrc_y,
180 289936 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
181 289936 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
182 s->uvlinesize, s->uvlinesize,
183 9, 9 + field_based,
184 uvsrc_x, uvsrc_y,
185 289936 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
186 289936 ptr_cb = ubuf;
187 289936 ptr_cr = vbuf;
188 }
189 }
190
191 /* FIXME use this for field pix too instead of the obnoxious hack which
192 * changes picture.data */
193
2/2
✓ Branch 0 taken 230425 times.
✓ Branch 1 taken 8858291 times.
9088716 if (bottom_field) {
194 230425 dest_y += s->linesize;
195 230425 dest_cb += s->uvlinesize;
196 230425 dest_cr += s->uvlinesize;
197 }
198
199
2/2
✓ Branch 0 taken 737316 times.
✓ Branch 1 taken 8351400 times.
9088716 if (field_select) {
200 737316 ptr_y += s->linesize;
201 737316 ptr_cb += s->uvlinesize;
202 737316 ptr_cr += s->uvlinesize;
203 }
204
205 9088716 pix_op[0][dxy](dest_y, ptr_y, linesize, h);
206
207 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
208 9088716 pix_op[s->chroma_x_shift][uvdxy]
209 9088716 (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
210 9088716 pix_op[s->chroma_x_shift][uvdxy]
211 9088716 (dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
212 }
213
2/2
✓ Branch 0 taken 4067335 times.
✓ Branch 1 taken 5021381 times.
9088716 if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
214
2/2
✓ Branch 0 taken 206286 times.
✓ Branch 1 taken 3861049 times.
4067335 s->out_format == FMT_H261) {
215 206286 ff_h261_loop_filter(s);
216 }
217 }
218 /* apply one mpeg motion vector to the three components */
219 8627866 static void mpeg_motion(MpegEncContext *s,
220 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
221 int field_select, uint8_t *const *ref_picture,
222 const op_pixels_func (*pix_op)[4],
223 int motion_x, int motion_y, int h, int is_16x8, int mb_y)
224 {
225 #if !CONFIG_SMALL
226
2/2
✓ Branch 0 taken 4560531 times.
✓ Branch 1 taken 4067335 times.
8627866 if (s->out_format == FMT_MPEG1)
227 4560531 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
228 field_select, ref_picture, pix_op,
229 motion_x, motion_y, h, 1, is_16x8, mb_y);
230 else
231 #endif
232 4067335 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 0, 0,
233 field_select, ref_picture, pix_op,
234 motion_x, motion_y, h, 0, is_16x8, mb_y);
235 8627866 }
236
237 460850 static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
238 uint8_t *dest_cb, uint8_t *dest_cr,
239 int bottom_field, int field_select,
240 uint8_t *const *ref_picture,
241 const op_pixels_func (*pix_op)[4],
242 int motion_x, int motion_y, int mb_y)
243 {
244 #if !CONFIG_SMALL
245
1/2
✓ Branch 0 taken 460850 times.
✗ Branch 1 not taken.
460850 if (s->out_format == FMT_MPEG1)
246 460850 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
247 bottom_field, field_select, ref_picture, pix_op,
248 motion_x, motion_y, 8, 1, 0, mb_y);
249 else
250 #endif
251 mpeg_motion_internal(s, dest_y, dest_cb, dest_cr, 1,
252 bottom_field, field_select, ref_picture, pix_op,
253 motion_x, motion_y, 8, 0, 0, mb_y);
254 460850 }
255
256 // FIXME: SIMDify, avg variant, 16x16 version
257 412968 static inline void put_obmc(uint8_t *dst, uint8_t *const src[5], int stride)
258 {
259 int x;
260 412968 uint8_t *const top = src[1];
261 412968 uint8_t *const left = src[2];
262 412968 uint8_t *const mid = src[0];
263 412968 uint8_t *const right = src[3];
264 412968 uint8_t *const bottom = src[4];
265 #define OBMC_FILTER(x, t, l, m, r, b)\
266 dst[x]= (t*top[x] + l*left[x] + m*mid[x] + r*right[x] + b*bottom[x] + 4)>>3
267 #define OBMC_FILTER4(x, t, l, m, r, b)\
268 OBMC_FILTER(x , t, l, m, r, b);\
269 OBMC_FILTER(x+1 , t, l, m, r, b);\
270 OBMC_FILTER(x +stride, t, l, m, r, b);\
271 OBMC_FILTER(x+1+stride, t, l, m, r, b);
272
273 412968 x = 0;
274 412968 OBMC_FILTER (x , 2, 2, 4, 0, 0);
275 412968 OBMC_FILTER (x + 1, 2, 1, 5, 0, 0);
276 412968 OBMC_FILTER4(x + 2, 2, 1, 5, 0, 0);
277 412968 OBMC_FILTER4(x + 4, 2, 0, 5, 1, 0);
278 412968 OBMC_FILTER (x + 6, 2, 0, 5, 1, 0);
279 412968 OBMC_FILTER (x + 7, 2, 0, 4, 2, 0);
280 412968 x += stride;
281 412968 OBMC_FILTER (x , 1, 2, 5, 0, 0);
282 412968 OBMC_FILTER (x + 1, 1, 2, 5, 0, 0);
283 412968 OBMC_FILTER (x + 6, 1, 0, 5, 2, 0);
284 412968 OBMC_FILTER (x + 7, 1, 0, 5, 2, 0);
285 412968 x += stride;
286 412968 OBMC_FILTER4(x , 1, 2, 5, 0, 0);
287 412968 OBMC_FILTER4(x + 2, 1, 1, 6, 0, 0);
288 412968 OBMC_FILTER4(x + 4, 1, 0, 6, 1, 0);
289 412968 OBMC_FILTER4(x + 6, 1, 0, 5, 2, 0);
290 412968 x += 2 * stride;
291 412968 OBMC_FILTER4(x , 0, 2, 5, 0, 1);
292 412968 OBMC_FILTER4(x + 2, 0, 1, 6, 0, 1);
293 412968 OBMC_FILTER4(x + 4, 0, 0, 6, 1, 1);
294 412968 OBMC_FILTER4(x + 6, 0, 0, 5, 2, 1);
295 412968 x += 2*stride;
296 412968 OBMC_FILTER (x , 0, 2, 5, 0, 1);
297 412968 OBMC_FILTER (x + 1, 0, 2, 5, 0, 1);
298 412968 OBMC_FILTER4(x + 2, 0, 1, 5, 0, 2);
299 412968 OBMC_FILTER4(x + 4, 0, 0, 5, 1, 2);
300 412968 OBMC_FILTER (x + 6, 0, 0, 5, 2, 1);
301 412968 OBMC_FILTER (x + 7, 0, 0, 5, 2, 1);
302 412968 x += stride;
303 412968 OBMC_FILTER (x , 0, 2, 4, 0, 2);
304 412968 OBMC_FILTER (x + 1, 0, 1, 5, 0, 2);
305 412968 OBMC_FILTER (x + 6, 0, 0, 5, 1, 2);
306 412968 OBMC_FILTER (x + 7, 0, 0, 4, 2, 2);
307 412968 }
308
309 /* obmc for 1 8x8 luma block */
310 412968 static inline void obmc_motion(MpegEncContext *s,
311 uint8_t *dest, uint8_t *src,
312 int src_x, int src_y,
313 const op_pixels_func *pix_op,
314 int16_t mv[5][2] /* mid top left right bottom */)
315 #define MID 0
316 {
317 int i;
318 uint8_t *ptr[5];
319
320 av_assert2(s->quarter_sample == 0);
321
322
2/2
✓ Branch 0 taken 2064840 times.
✓ Branch 1 taken 412968 times.
2477808 for (i = 0; i < 5; i++) {
323
6/6
✓ Branch 0 taken 1651872 times.
✓ Branch 1 taken 412968 times.
✓ Branch 2 taken 1342174 times.
✓ Branch 3 taken 309698 times.
✓ Branch 4 taken 1242100 times.
✓ Branch 5 taken 100074 times.
2064840 if (i && mv[i][0] == mv[MID][0] && mv[i][1] == mv[MID][1]) {
324 1242100 ptr[i] = ptr[MID];
325 } else {
326 822740 ptr[i] = s->sc.obmc_scratchpad + 8 * (i & 1) +
327 822740 s->linesize * 8 * (i >> 1);
328 822740 hpel_motion(s, ptr[i], src, src_x, src_y, pix_op,
329 822740 mv[i][0], mv[i][1]);
330 }
331 }
332
333 412968 put_obmc(dest, ptr, s->linesize);
334 412968 }
335
336 212765 static inline void qpel_motion(MpegEncContext *s,
337 uint8_t *dest_y,
338 uint8_t *dest_cb,
339 uint8_t *dest_cr,
340 int field_based, int bottom_field,
341 int field_select, uint8_t *const *ref_picture,
342 const op_pixels_func (*pix_op)[4],
343 const qpel_mc_func (*qpix_op)[16],
344 int motion_x, int motion_y, int h)
345 {
346 const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
347 int dxy, uvdxy, mx, my, src_x, src_y, uvsrc_x, uvsrc_y, v_edge_pos;
348 ptrdiff_t linesize, uvlinesize;
349
350 212765 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
351
352 212765 src_x = s->mb_x * 16 + (motion_x >> 2);
353 212765 src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
354
355 212765 v_edge_pos = s->v_edge_pos >> field_based;
356 212765 linesize = s->linesize << field_based;
357 212765 uvlinesize = s->uvlinesize << field_based;
358
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212765 times.
212765 if (field_based) {
360 mx = motion_x / 2;
361 my = motion_y >> 1;
362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212765 times.
212765 } else if (s->workaround_bugs & FF_BUG_QPEL_CHROMA2) {
363 static const int rtab[8] = { 0, 0, 1, 1, 0, 0, 0, 1 };
364 mx = (motion_x >> 1) + rtab[motion_x & 7];
365 my = (motion_y >> 1) + rtab[motion_y & 7];
366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212765 times.
212765 } else if (s->workaround_bugs & FF_BUG_QPEL_CHROMA) {
367 mx = (motion_x >> 1) | (motion_x & 1);
368 my = (motion_y >> 1) | (motion_y & 1);
369 } else {
370 212765 mx = motion_x / 2;
371 212765 my = motion_y / 2;
372 }
373 212765 mx = (mx >> 1) | (mx & 1);
374 212765 my = (my >> 1) | (my & 1);
375
376 212765 uvdxy = (mx & 1) | ((my & 1) << 1);
377 212765 mx >>= 1;
378 212765 my >>= 1;
379
380 212765 uvsrc_x = s->mb_x * 8 + mx;
381 212765 uvsrc_y = s->mb_y * (8 >> field_based) + my;
382
383 212765 ptr_y = ref_picture[0] + src_y * linesize + src_x;
384 212765 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
385 212765 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
386
387
3/4
✓ Branch 0 taken 212765 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 203216 times.
✓ Branch 3 taken 9549 times.
212765 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 3) - 15 , 0) ||
388
3/4
✓ Branch 0 taken 203216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11156 times.
✓ Branch 3 taken 192060 times.
203216 (unsigned)src_y >= FFMAX( v_edge_pos - (motion_y & 3) - h + 1, 0)) {
389 20705 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr_y,
390 s->linesize, s->linesize,
391 17, 17 + field_based,
392 src_x, src_y * (1 << field_based),
393 s->h_edge_pos, s->v_edge_pos);
394 20705 ptr_y = s->sc.edge_emu_buffer;
395 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
396 20705 uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
397 20705 uint8_t *vbuf = ubuf + 10 * s->uvlinesize;
398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20705 times.
20705 if (s->workaround_bugs & FF_BUG_IEDGE)
399 vbuf -= s->uvlinesize;
400 20705 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
401 s->uvlinesize, s->uvlinesize,
402 9, 9 + field_based,
403 uvsrc_x, uvsrc_y * (1 << field_based),
404 20705 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
405 20705 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
406 s->uvlinesize, s->uvlinesize,
407 9, 9 + field_based,
408 uvsrc_x, uvsrc_y * (1 << field_based),
409 20705 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
410 20705 ptr_cb = ubuf;
411 20705 ptr_cr = vbuf;
412 }
413 }
414
415
1/2
✓ Branch 0 taken 212765 times.
✗ Branch 1 not taken.
212765 if (!field_based)
416 212765 qpix_op[0][dxy](dest_y, ptr_y, linesize);
417 else {
418 if (bottom_field) {
419 dest_y += s->linesize;
420 dest_cb += s->uvlinesize;
421 dest_cr += s->uvlinesize;
422 }
423
424 if (field_select) {
425 ptr_y += s->linesize;
426 ptr_cb += s->uvlinesize;
427 ptr_cr += s->uvlinesize;
428 }
429 // damn interlaced mode
430 // FIXME boundary mirroring is not exactly correct here
431 qpix_op[1][dxy](dest_y, ptr_y, linesize);
432 qpix_op[1][dxy](dest_y + 8, ptr_y + 8, linesize);
433 }
434 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
435 212765 pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1);
436 212765 pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1);
437 }
438 212765 }
439
440 /**
441 * H.263 chroma 4mv motion compensation.
442 */
443 685016 static void chroma_4mv_motion(MpegEncContext *s,
444 uint8_t *dest_cb, uint8_t *dest_cr,
445 uint8_t *const *ref_picture,
446 const op_pixels_func *pix_op,
447 int mx, int my)
448 {
449 const uint8_t *ptr;
450 685016 int src_x, src_y, dxy, emu = 0;
451 ptrdiff_t offset;
452
453 /* In case of 8X8, we construct a single chroma motion vector
454 * with a special rounding */
455 685016 mx = ff_h263_round_chroma(mx);
456 685016 my = ff_h263_round_chroma(my);
457
458 685016 dxy = ((my & 1) << 1) | (mx & 1);
459 685016 mx >>= 1;
460 685016 my >>= 1;
461
462 685016 src_x = s->mb_x * 8 + mx;
463 685016 src_y = s->mb_y * 8 + my;
464 685016 src_x = av_clip(src_x, -8, (s->width >> 1));
465
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 685014 times.
685016 if (src_x == (s->width >> 1))
466 2 dxy &= ~1;
467 685016 src_y = av_clip(src_y, -8, (s->height >> 1));
468
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 685002 times.
685016 if (src_y == (s->height >> 1))
469 14 dxy &= ~2;
470
471 685016 offset = src_y * s->uvlinesize + src_x;
472 685016 ptr = ref_picture[1] + offset;
473
3/4
✓ Branch 0 taken 685016 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 658045 times.
✓ Branch 3 taken 26971 times.
685016 if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 7, 0) ||
474
3/4
✓ Branch 0 taken 658045 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28764 times.
✓ Branch 3 taken 629281 times.
658045 (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 7, 0)) {
475 55735 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
476 s->uvlinesize, s->uvlinesize,
477 9, 9, src_x, src_y,
478 55735 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
479 55735 ptr = s->sc.edge_emu_buffer;
480 55735 emu = 1;
481 }
482 685016 pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
483
484 685016 ptr = ref_picture[2] + offset;
485
2/2
✓ Branch 0 taken 55735 times.
✓ Branch 1 taken 629281 times.
685016 if (emu) {
486 55735 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
487 s->uvlinesize, s->uvlinesize,
488 9, 9, src_x, src_y,
489 55735 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
490 55735 ptr = s->sc.edge_emu_buffer;
491 }
492 685016 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
493 685016 }
494
495 9518835 static inline void prefetch_motion(MpegEncContext *s, uint8_t *const *pix, int dir)
496 {
497 /* fetch pixels for estimated mv 4 macroblocks ahead
498 * optimized for 64byte cache lines */
499
2/2
✓ Branch 0 taken 339296 times.
✓ Branch 1 taken 9179539 times.
9518835 const int shift = s->quarter_sample ? 2 : 1;
500 9518835 const int mx = (s->mv[dir][0][0] >> shift) + 16 * s->mb_x + 8;
501 9518835 const int my = (s->mv[dir][0][1] >> shift) + 16 * s->mb_y;
502 9518835 int off = mx + (my + (s->mb_x & 3) * 4) * s->linesize + 64;
503
504 9518835 s->vdsp.prefetch(pix[0] + off, s->linesize, 4);
505 9518835 off = (mx >> 1) + ((my >> 1) + (s->mb_x & 7)) * s->uvlinesize + 64;
506 9518835 s->vdsp.prefetch(pix[1] + off, pix[2] - pix[1], 2);
507 9518835 }
508
509 103242 static inline void apply_obmc(MpegEncContext *s,
510 uint8_t *dest_y,
511 uint8_t *dest_cb,
512 uint8_t *dest_cr,
513 uint8_t *const *ref_picture,
514 const op_pixels_func (*pix_op)[4])
515 {
516 103242 LOCAL_ALIGNED_8(int16_t, mv_cache, [4], [4][2]);
517 103242 const MPVWorkPicture *cur_frame = &s->cur_pic;
518 103242 int mb_x = s->mb_x;
519 103242 int mb_y = s->mb_y;
520 103242 const int xy = mb_x + mb_y * s->mb_stride;
521 103242 const int mot_stride = s->b8_stride;
522 103242 const int mot_xy = mb_x * 2 + mb_y * 2 * mot_stride;
523 int mx, my, i;
524
525 av_assert2(!s->mb_skipped);
526
527 103242 AV_COPY32(mv_cache[1][1], cur_frame->motion_val[0][mot_xy]);
528 103242 AV_COPY32(mv_cache[1][2], cur_frame->motion_val[0][mot_xy + 1]);
529
530 103242 AV_COPY32(mv_cache[2][1],
531 cur_frame->motion_val[0][mot_xy + mot_stride]);
532 103242 AV_COPY32(mv_cache[2][2],
533 cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
534
535 103242 AV_COPY32(mv_cache[3][1],
536 cur_frame->motion_val[0][mot_xy + mot_stride]);
537 103242 AV_COPY32(mv_cache[3][2],
538 cur_frame->motion_val[0][mot_xy + mot_stride + 1]);
539
540
4/4
✓ Branch 0 taken 97570 times.
✓ Branch 1 taken 5672 times.
✓ Branch 2 taken 2068 times.
✓ Branch 3 taken 95502 times.
103242 if (mb_y == 0 || IS_INTRA(cur_frame->mb_type[xy - s->mb_stride])) {
541 7740 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
542 7740 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
543 } else {
544 95502 AV_COPY32(mv_cache[0][1],
545 cur_frame->motion_val[0][mot_xy - mot_stride]);
546 95502 AV_COPY32(mv_cache[0][2],
547 cur_frame->motion_val[0][mot_xy - mot_stride + 1]);
548 }
549
550
4/4
✓ Branch 0 taken 98604 times.
✓ Branch 1 taken 4638 times.
✓ Branch 2 taken 1848 times.
✓ Branch 3 taken 96756 times.
103242 if (mb_x == 0 || IS_INTRA(cur_frame->mb_type[xy - 1])) {
551 6486 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
552 6486 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
553 } else {
554 96756 AV_COPY32(mv_cache[1][0], cur_frame->motion_val[0][mot_xy - 1]);
555 96756 AV_COPY32(mv_cache[2][0],
556 cur_frame->motion_val[0][mot_xy - 1 + mot_stride]);
557 }
558
559
4/4
✓ Branch 0 taken 98684 times.
✓ Branch 1 taken 4558 times.
✓ Branch 2 taken 1971 times.
✓ Branch 3 taken 96713 times.
103242 if (mb_x + 1 >= s->mb_width || IS_INTRA(cur_frame->mb_type[xy + 1])) {
560 6529 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
561 6529 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
562 } else {
563 96713 AV_COPY32(mv_cache[1][3], cur_frame->motion_val[0][mot_xy + 2]);
564 96713 AV_COPY32(mv_cache[2][3],
565 cur_frame->motion_val[0][mot_xy + 2 + mot_stride]);
566 }
567
568 103242 mx = 0;
569 103242 my = 0;
570
2/2
✓ Branch 0 taken 412968 times.
✓ Branch 1 taken 103242 times.
516210 for (i = 0; i < 4; i++) {
571 412968 const int x = (i & 1) + 1;
572 412968 const int y = (i >> 1) + 1;
573 412968 int16_t mv[5][2] = {
574 412968 { mv_cache[y][x][0], mv_cache[y][x][1] },
575 412968 { mv_cache[y - 1][x][0], mv_cache[y - 1][x][1] },
576 412968 { mv_cache[y][x - 1][0], mv_cache[y][x - 1][1] },
577 412968 { mv_cache[y][x + 1][0], mv_cache[y][x + 1][1] },
578 412968 { mv_cache[y + 1][x][0], mv_cache[y + 1][x][1] }
579 };
580 // FIXME cleanup
581 412968 obmc_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
582 ref_picture[0],
583 412968 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >> 1) * 8,
584 412968 pix_op[1],
585 mv);
586
587 412968 mx += mv[0][0];
588 412968 my += mv[0][1];
589 }
590 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))
591 103242 chroma_4mv_motion(s, dest_cb, dest_cr,
592 103242 ref_picture, pix_op[1],
593 mx, my);
594 103242 }
595
596 581774 static inline void apply_8x8(MpegEncContext *s,
597 uint8_t *dest_y,
598 uint8_t *dest_cb,
599 uint8_t *dest_cr,
600 int dir,
601 uint8_t *const *ref_picture,
602 const qpel_mc_func (*qpix_op)[16],
603 const op_pixels_func (*pix_op)[4])
604 {
605 int dxy, mx, my, src_x, src_y;
606 int i;
607 581774 int mb_x = s->mb_x;
608 581774 int mb_y = s->mb_y;
609 uint8_t *dest;
610 const uint8_t *ptr;
611
612 581774 mx = 0;
613 581774 my = 0;
614
2/2
✓ Branch 0 taken 126531 times.
✓ Branch 1 taken 455243 times.
581774 if (s->quarter_sample) {
615
2/2
✓ Branch 0 taken 506124 times.
✓ Branch 1 taken 126531 times.
632655 for (i = 0; i < 4; i++) {
616 506124 int motion_x = s->mv[dir][i][0];
617 506124 int motion_y = s->mv[dir][i][1];
618
619 506124 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
620 506124 src_x = mb_x * 16 + (motion_x >> 2) + (i & 1) * 8;
621 506124 src_y = mb_y * 16 + (motion_y >> 2) + (i >> 1) * 8;
622
623 /* WARNING: do no forget half pels */
624 506124 src_x = av_clip(src_x, -16, s->width);
625
2/2
✓ Branch 0 taken 698 times.
✓ Branch 1 taken 505426 times.
506124 if (src_x == s->width)
626 698 dxy &= ~3;
627 506124 src_y = av_clip(src_y, -16, s->height);
628
2/2
✓ Branch 0 taken 838 times.
✓ Branch 1 taken 505286 times.
506124 if (src_y == s->height)
629 838 dxy &= ~12;
630
631 506124 ptr = ref_picture[0] + (src_y * s->linesize) + (src_x);
632
3/4
✓ Branch 0 taken 506124 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 494465 times.
✓ Branch 3 taken 11659 times.
506124 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 3) - 7, 0) ||
633
3/4
✓ Branch 0 taken 494465 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12714 times.
✓ Branch 3 taken 481751 times.
494465 (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 3) - 7, 0)) {
634 24373 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
635 s->linesize, s->linesize,
636 9, 9,
637 src_x, src_y,
638 s->h_edge_pos,
639 s->v_edge_pos);
640 24373 ptr = s->sc.edge_emu_buffer;
641 }
642 506124 dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
643 506124 qpix_op[1][dxy](dest, ptr, s->linesize);
644
645 506124 mx += s->mv[dir][i][0] / 2;
646 506124 my += s->mv[dir][i][1] / 2;
647 }
648 } else {
649
2/2
✓ Branch 0 taken 1820972 times.
✓ Branch 1 taken 455243 times.
2276215 for (i = 0; i < 4; i++) {
650 1820972 hpel_motion(s,
651 1820972 dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
652 ref_picture[0],
653 1820972 mb_x * 16 + (i & 1) * 8,
654 1820972 mb_y * 16 + (i >> 1) * 8,
655 1820972 pix_op[1],
656 s->mv[dir][i][0],
657 s->mv[dir][i][1]);
658
659 1820972 mx += s->mv[dir][i][0];
660 1820972 my += s->mv[dir][i][1];
661 }
662 }
663
664 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))
665 581774 chroma_4mv_motion(s, dest_cb, dest_cr,
666 581774 ref_picture, pix_op[1], mx, my);
667 581774 }
668
669 /**
670 * motion compensation of a single macroblock
671 * @param s context
672 * @param dest_y luma destination pointer
673 * @param dest_cb chroma cb/u destination pointer
674 * @param dest_cr chroma cr/v destination pointer
675 * @param dir direction (0->forward, 1->backward)
676 * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
677 * @param pix_op halfpel motion compensation function (average or put normally)
678 * @param qpix_op qpel motion compensation function (average or put normally)
679 * the motion vectors are taken from s->mv and the MV type from s->mv_type
680 */
681 9518835 static av_always_inline void mpv_motion_internal(MpegEncContext *s,
682 uint8_t *dest_y,
683 uint8_t *dest_cb,
684 uint8_t *dest_cr,
685 int dir,
686 uint8_t *const *ref_picture,
687 const op_pixels_func (*pix_op)[4],
688 const qpel_mc_func (*qpix_op)[16],
689 int is_mpeg12)
690 {
691 int i;
692 9518835 int mb_y = s->mb_y;
693
694
5/6
✓ Branch 0 taken 5045609 times.
✓ Branch 1 taken 4473226 times.
✓ Branch 2 taken 103242 times.
✓ Branch 3 taken 4942367 times.
✓ Branch 4 taken 103242 times.
✗ Branch 5 not taken.
9518835 if (!is_mpeg12 && s->obmc && s->pict_type != AV_PICTURE_TYPE_B) {
695 103242 apply_obmc(s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
696 103242 return;
697 }
698
699
5/6
✓ Branch 0 taken 7929017 times.
✓ Branch 1 taken 581774 times.
✓ Branch 2 taken 587072 times.
✓ Branch 3 taken 295810 times.
✓ Branch 4 taken 21920 times.
✗ Branch 5 not taken.
9415593 switch (s->mv_type) {
700 7929017 case MV_TYPE_16X16:
701
3/4
✓ Branch 0 taken 4360593 times.
✓ Branch 1 taken 3568424 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4360593 times.
7929017 if (CONFIG_MPEG4_DECODER && !is_mpeg12 && s->mcsel) {
702 ff_mpeg4_mcsel_motion(s, dest_y, dest_cb, dest_cr, ref_picture);
703
4/4
✓ Branch 0 taken 4360593 times.
✓ Branch 1 taken 3568424 times.
✓ Branch 2 taken 212765 times.
✓ Branch 3 taken 4147828 times.
7929017 } else if (!is_mpeg12 && s->quarter_sample) {
704 212765 qpel_motion(s, dest_y, dest_cb, dest_cr,
705 0, 0, 0,
706 ref_picture, pix_op, qpix_op,
707 s->mv[dir][0][0], s->mv[dir][0][1], 16);
708
2/2
✓ Branch 0 taken 4147828 times.
✓ Branch 1 taken 3568424 times.
7716252 } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
709
3/4
✓ Branch 0 taken 80493 times.
✓ Branch 1 taken 4067335 times.
✓ Branch 2 taken 80493 times.
✗ Branch 3 not taken.
4147828 s->mspel && s->codec_id == AV_CODEC_ID_WMV2) {
710 80493 ff_mspel_motion(s, dest_y, dest_cb, dest_cr,
711 ref_picture, pix_op,
712 s->mv[dir][0][0], s->mv[dir][0][1], 16);
713 } else {
714 7635759 mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
715 ref_picture, pix_op,
716 s->mv[dir][0][0], s->mv[dir][0][1], 16, 0, mb_y);
717 }
718 7929017 break;
719 581774 case MV_TYPE_8X8:
720
1/2
✓ Branch 0 taken 581774 times.
✗ Branch 1 not taken.
581774 if (!is_mpeg12)
721 581774 apply_8x8(s, dest_y, dest_cb, dest_cr,
722 dir, ref_picture, qpix_op, pix_op);
723 581774 break;
724 587072 case MV_TYPE_FIELD:
725 // Only MPEG-1/2 can have a picture_structure != PICT_FRAME here.
726 if (!CONFIG_SMALL)
727 av_assert2(is_mpeg12 || s->picture_structure == PICT_FRAME);
728
1/2
✓ Branch 0 taken 587072 times.
✗ Branch 1 not taken.
587072 if ((!CONFIG_SMALL && !is_mpeg12) ||
729
2/2
✓ Branch 0 taken 230425 times.
✓ Branch 1 taken 356647 times.
587072 s->picture_structure == PICT_FRAME) {
730
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 230425 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
230425 if (!is_mpeg12 && s->quarter_sample) {
731 for (i = 0; i < 2; i++)
732 qpel_motion(s, dest_y, dest_cb, dest_cr,
733 1, i, s->field_select[dir][i],
734 ref_picture, pix_op, qpix_op,
735 s->mv[dir][i][0], s->mv[dir][i][1], 8);
736 } else {
737 /* top field */
738 230425 mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
739 0, s->field_select[dir][0],
740 ref_picture, pix_op,
741 s->mv[dir][0][0], s->mv[dir][0][1], mb_y);
742 /* bottom field */
743 230425 mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
744 1, s->field_select[dir][1],
745 ref_picture, pix_op,
746 s->mv[dir][1][0], s->mv[dir][1][1], mb_y);
747 }
748 } else {
749 av_assert2(s->out_format == FMT_MPEG1);
750
2/2
✓ Branch 0 taken 51622 times.
✓ Branch 1 taken 305025 times.
356647 if (s->picture_structure != s->field_select[dir][0] + 1 &&
751
4/4
✓ Branch 0 taken 40614 times.
✓ Branch 1 taken 11008 times.
✓ Branch 2 taken 32768 times.
✓ Branch 3 taken 7846 times.
51622 s->pict_type != AV_PICTURE_TYPE_B && !s->first_field) {
752 32768 ref_picture = s->cur_pic.ptr->f->data;
753 }
754
755 356647 mpeg_motion(s, dest_y, dest_cb, dest_cr,
756 s->field_select[dir][0],
757 ref_picture, pix_op,
758 s->mv[dir][0][0], s->mv[dir][0][1], 16, 0, mb_y >> 1);
759 }
760 587072 break;
761 295810 case MV_TYPE_16X8:
762
1/2
✓ Branch 0 taken 295810 times.
✗ Branch 1 not taken.
295810 if (CONFIG_SMALL || is_mpeg12) {
763
2/2
✓ Branch 0 taken 591620 times.
✓ Branch 1 taken 295810 times.
887430 for (i = 0; i < 2; i++) {
764 uint8_t *const *ref2picture;
765
766
2/2
✓ Branch 0 taken 80768 times.
✓ Branch 1 taken 510852 times.
591620 if (s->picture_structure == s->field_select[dir][i] + 1 ||
767
4/4
✓ Branch 0 taken 77374 times.
✓ Branch 1 taken 3394 times.
✓ Branch 2 taken 8310 times.
✓ Branch 3 taken 69064 times.
80768 s->pict_type == AV_PICTURE_TYPE_B || s->first_field) {
768 522556 ref2picture = ref_picture;
769 } else {
770 69064 ref2picture = s->cur_pic.ptr->f->data;
771 }
772
773 591620 mpeg_motion(s, dest_y, dest_cb, dest_cr,
774 s->field_select[dir][i],
775 ref2picture, pix_op,
776 s->mv[dir][i][0], s->mv[dir][i][1],
777 591620 8, 1, (mb_y & ~1) + i);
778
779 591620 dest_y += 16 * s->linesize;
780 591620 dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
781 591620 dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
782 }
783 295810 break;
784 }
785 case MV_TYPE_DMV:
786
1/2
✓ Branch 0 taken 21920 times.
✗ Branch 1 not taken.
21920 if (CONFIG_SMALL || is_mpeg12) {
787
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21920 times.
21920 if (s->picture_structure == PICT_FRAME) {
788 for (i = 0; i < 2; i++) {
789 for (int j = 0; j < 2; j++)
790 mpeg_motion_field(s, dest_y, dest_cb, dest_cr,
791 j, j ^ i, ref_picture, pix_op,
792 s->mv[dir][2 * i + j][0],
793 s->mv[dir][2 * i + j][1], mb_y);
794 pix_op = s->hdsp.avg_pixels_tab;
795 }
796 } else {
797
2/2
✓ Branch 0 taken 43840 times.
✓ Branch 1 taken 21920 times.
65760 for (i = 0; i < 2; i++) {
798 43840 mpeg_motion(s, dest_y, dest_cb, dest_cr,
799 43840 s->picture_structure != i + 1,
800 ref_picture, pix_op,
801 43840 s->mv[dir][2 * i][0], s->mv[dir][2 * i][1],
802 16, 0, mb_y >> 1);
803
804 // after put we make avg of the same block
805 43840 pix_op = s->hdsp.avg_pixels_tab;
806
807 /* opposite parity is always in the same frame if this is
808 * second field */
809
2/2
✓ Branch 0 taken 37572 times.
✓ Branch 1 taken 6268 times.
43840 if (!s->first_field)
810 37572 ref_picture = s->cur_pic.ptr->f->data;
811 }
812 }
813 21920 break;
814 }
815 default: av_assert2(0);
816 }
817 }
818
819 9518835 void ff_mpv_motion(MpegEncContext *s,
820 uint8_t *dest_y, uint8_t *dest_cb,
821 uint8_t *dest_cr, int dir,
822 uint8_t *const *ref_picture,
823 const op_pixels_func (*pix_op)[4],
824 const qpel_mc_func (*qpix_op)[16])
825 {
826 av_assert2(s->out_format == FMT_MPEG1 ||
827 s->out_format == FMT_H263 ||
828 s->out_format == FMT_H261);
829 9518835 prefetch_motion(s, ref_picture, dir);
830
831 #if !CONFIG_SMALL
832
2/2
✓ Branch 0 taken 4473226 times.
✓ Branch 1 taken 5045609 times.
9518835 if (s->out_format == FMT_MPEG1)
833 4473226 mpv_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
834 ref_picture, pix_op, qpix_op, 1);
835 else
836 #endif
837 5045609 mpv_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
838 ref_picture, pix_op, qpix_op, 0);
839 9518835 }
840