FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/mpegvideo_motion.c
Date: 2024-04-18 20:30:25
Exec Total Coverage
Lines: 370 409 90.5%
Functions: 13 13 100.0%
Branches: 155 202 76.7%

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