FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/mpegvideo_motion.c
Date: 2024-04-20 14:10:07
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 2644484 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 2644484 int dxy = 0;
45 2644484 int emu = 0;
46
47 2644484 src_x += motion_x >> 1;
48 2644484 src_y += motion_y >> 1;
49
50 /* WARNING: do no forget half pels */
51 2644484 src_x = av_clip(src_x, -16, s->width); // FIXME unneeded for emu?
52
2/2
✓ Branch 0 taken 2642570 times.
✓ Branch 1 taken 1914 times.
2644484 if (src_x != s->width)
53 2642570 dxy |= motion_x & 1;
54 2644484 src_y = av_clip(src_y, -16, s->height);
55
2/2
✓ Branch 0 taken 2642149 times.
✓ Branch 1 taken 2335 times.
2644484 if (src_y != s->height)
56 2642149 dxy |= (motion_y & 1) << 1;
57 2644484 src += src_y * s->linesize + src_x;
58
59
3/4
✓ Branch 0 taken 2644484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2601436 times.
✓ Branch 3 taken 43048 times.
2644484 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
60
3/4
✓ Branch 0 taken 2601436 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46739 times.
✓ Branch 3 taken 2554697 times.
2601436 (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
61 89787 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 89787 src = s->sc.edge_emu_buffer;
67 89787 emu = 1;
68 }
69 2644484 pix_op[dxy](dest, src, s->linesize, 8);
70 2644484 return emu;
71 }
72
73 static av_always_inline
74 9029484 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 9029484 v_edge_pos = s->v_edge_pos >> field_based;
96 9029484 linesize = s->current_picture.f->linesize[0] << field_based;
97 9029484 uvlinesize = s->current_picture.f->linesize[1] << field_based;
98 9029484 block_y_half = (field_based | is_16x8);
99
100 9029484 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
101 9029484 src_x = s->mb_x * 16 + (motion_x >> 1);
102 9029484 src_y = (mb_y << (4 - block_y_half)) + (motion_y >> 1);
103
104
4/4
✓ Branch 0 taken 4036253 times.
✓ Branch 1 taken 4993231 times.
✓ Branch 2 taken 3830296 times.
✓ Branch 3 taken 205957 times.
9029484 if (!is_mpeg12 && s->out_format == FMT_H263) {
105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3830296 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3830296 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 3830296 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
113 3830296 uvsrc_x = src_x >> 1;
114 3830296 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 4993231 times.
✓ Branch 2 taken 205957 times.
✗ Branch 3 not taken.
5199188 } 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 4319337 times.
✓ Branch 1 taken 673894 times.
4993231 if (s->chroma_y_shift) {
125 4319337 mx = motion_x / 2;
126 4319337 my = motion_y / 2;
127 4319337 uvdxy = ((my & 1) << 1) | (mx & 1);
128 4319337 uvsrc_x = s->mb_x * 8 + (mx >> 1);
129 4319337 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 9029484 ptr_y = ref_picture[0] + src_y * linesize + src_x;
147 9029484 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
148 9029484 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
149
150
3/4
✓ Branch 0 taken 9029484 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8892328 times.
✓ Branch 3 taken 137156 times.
9029484 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15 , 0) ||
151
3/4
✓ Branch 0 taken 8892328 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 149897 times.
✓ Branch 3 taken 8742431 times.
8892328 (unsigned)src_y >= FFMAX( v_edge_pos - (motion_y & 1) - h + 1, 0)) {
152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287053 times.
287053 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 287053 src_y = (unsigned)src_y << field_based;
161 287053 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 287053 ptr_y = s->sc.edge_emu_buffer;
167 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
168 287053 uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
169 287053 uint8_t *vbuf = ubuf + 10 * s->uvlinesize;
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287053 times.
287053 if (s->workaround_bugs & FF_BUG_IEDGE)
171 vbuf -= s->uvlinesize;
172 287053 uvsrc_y = (unsigned)uvsrc_y << field_based;
173 287053 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
174 s->uvlinesize, s->uvlinesize,
175 9, 9 + field_based,
176 uvsrc_x, uvsrc_y,
177 287053 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
178 287053 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
179 s->uvlinesize, s->uvlinesize,
180 9, 9 + field_based,
181 uvsrc_x, uvsrc_y,
182 287053 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
183 287053 ptr_cb = ubuf;
184 287053 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 230444 times.
✓ Branch 1 taken 8799040 times.
9029484 if (bottom_field) {
191 230444 dest_y += s->linesize;
192 230444 dest_cb += s->uvlinesize;
193 230444 dest_cr += s->uvlinesize;
194 }
195
196
2/2
✓ Branch 0 taken 721272 times.
✓ Branch 1 taken 8308212 times.
9029484 if (field_select) {
197 721272 ptr_y += s->linesize;
198 721272 ptr_cb += s->uvlinesize;
199 721272 ptr_cr += s->uvlinesize;
200 }
201
202 9029484 pix_op[0][dxy](dest_y, ptr_y, linesize, h);
203
204 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
205 9029484 pix_op[s->chroma_x_shift][uvdxy]
206 9029484 (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
207 9029484 pix_op[s->chroma_x_shift][uvdxy]
208 9029484 (dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
209 }
210
2/2
✓ Branch 0 taken 4036253 times.
✓ Branch 1 taken 4993231 times.
9029484 if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
211
2/2
✓ Branch 0 taken 205957 times.
✓ Branch 1 taken 3830296 times.
4036253 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 8568596 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 4532343 times.
✓ Branch 1 taken 4036253 times.
8568596 if (s->out_format == FMT_MPEG1)
224 4532343 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 4036253 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 8568596 }
233
234 460888 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 460888 times.
✗ Branch 1 not taken.
460888 if (s->out_format == FMT_MPEG1)
243 460888 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 460888 }
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 685209 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 685209 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 685209 mx = ff_h263_round_chroma(mx);
453 685209 my = ff_h263_round_chroma(my);
454
455 685209 dxy = ((my & 1) << 1) | (mx & 1);
456 685209 mx >>= 1;
457 685209 my >>= 1;
458
459 685209 src_x = s->mb_x * 8 + mx;
460 685209 src_y = s->mb_y * 8 + my;
461 685209 src_x = av_clip(src_x, -8, (s->width >> 1));
462
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 685207 times.
685209 if (src_x == (s->width >> 1))
463 2 dxy &= ~1;
464 685209 src_y = av_clip(src_y, -8, (s->height >> 1));
465
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 685195 times.
685209 if (src_y == (s->height >> 1))
466 14 dxy &= ~2;
467
468 685209 offset = src_y * s->uvlinesize + src_x;
469 685209 ptr = ref_picture[1] + offset;
470
3/4
✓ Branch 0 taken 685209 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 658229 times.
✓ Branch 3 taken 26980 times.
685209 if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 7, 0) ||
471
3/4
✓ Branch 0 taken 658229 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28766 times.
✓ Branch 3 taken 629463 times.
658229 (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 7, 0)) {
472 55746 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
473 s->uvlinesize, s->uvlinesize,
474 9, 9, src_x, src_y,
475 55746 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
476 55746 ptr = s->sc.edge_emu_buffer;
477 55746 emu = 1;
478 }
479 685209 pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
480
481 685209 ptr = ref_picture[2] + offset;
482
2/2
✓ Branch 0 taken 55746 times.
✓ Branch 1 taken 629463 times.
685209 if (emu) {
483 55746 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
484 s->uvlinesize, s->uvlinesize,
485 9, 9, src_x, src_y,
486 55746 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
487 55746 ptr = s->sc.edge_emu_buffer;
488 }
489 685209 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
490 685209 }
491
492 9470693 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 9131397 times.
9470693 const int shift = s->quarter_sample ? 2 : 1;
497 9470693 const int mx = (s->mv[dir][0][0] >> shift) + 16 * s->mb_x + 8;
498 9470693 const int my = (s->mv[dir][0][1] >> shift) + 16 * s->mb_y;
499 9470693 int off = mx + (my + (s->mb_x & 3) * 4) * s->linesize + 64;
500
501 9470693 s->vdsp.prefetch(pix[0] + off, s->linesize, 4);
502 9470693 off = (mx >> 1) + ((my >> 1) + (s->mb_x & 7)) * s->uvlinesize + 64;
503 9470693 s->vdsp.prefetch(pix[1] + off, pix[2] - pix[1], 2);
504 9470693 }
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 581967 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 581967 int mb_x = s->mb_x;
605 581967 int mb_y = s->mb_y;
606 uint8_t *dest;
607 const uint8_t *ptr;
608
609 581967 mx = 0;
610 581967 my = 0;
611
2/2
✓ Branch 0 taken 126531 times.
✓ Branch 1 taken 455436 times.
581967 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 1821744 times.
✓ Branch 1 taken 455436 times.
2277180 for (i = 0; i < 4; i++) {
647 1821744 hpel_motion(s,
648 1821744 dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
649 ref_picture[0],
650 1821744 mb_x * 16 + (i & 1) * 8,
651 1821744 mb_y * 16 + (i >> 1) * 8,
652 1821744 pix_op[1],
653 s->mv[dir][i][0],
654 s->mv[dir][i][1]);
655
656 1821744 mx += s->mv[dir][i][0];
657 1821744 my += s->mv[dir][i][1];
658 }
659 }
660
661 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))
662 581967 chroma_4mv_motion(s, dest_cb, dest_cr,
663 581967 ref_picture, pix_op[1], mx, my);
664 581967 }
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 9470693 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 9470693 int mb_y = s->mb_y;
690
691
5/6
✓ Branch 0 taken 5014720 times.
✓ Branch 1 taken 4455973 times.
✓ Branch 2 taken 103242 times.
✓ Branch 3 taken 4911478 times.
✓ Branch 4 taken 103242 times.
✗ Branch 5 not taken.
9470693 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 7899428 times.
✓ Branch 1 taken 581967 times.
✓ Branch 2 taken 579242 times.
✓ Branch 3 taken 285623 times.
✓ Branch 4 taken 21191 times.
✗ Branch 5 not taken.
9367451 switch (s->mv_type) {
697 7899428 case MV_TYPE_16X16:
698
3/4
✓ Branch 0 taken 4329511 times.
✓ Branch 1 taken 3569917 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4329511 times.
7899428 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 4329511 times.
✓ Branch 1 taken 3569917 times.
✓ Branch 2 taken 212765 times.
✓ Branch 3 taken 4116746 times.
7899428 } 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 4116746 times.
✓ Branch 1 taken 3569917 times.
7686663 } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
706
3/4
✓ Branch 0 taken 80493 times.
✓ Branch 1 taken 4036253 times.
✓ Branch 2 taken 80493 times.
✗ Branch 3 not taken.
4116746 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 7606170 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 7899428 break;
716 581967 case MV_TYPE_8X8:
717
1/2
✓ Branch 0 taken 581967 times.
✗ Branch 1 not taken.
581967 if (!is_mpeg12)
718 581967 apply_8x8(s, dest_y, dest_cb, dest_cr,
719 dir, ref_picture, qpix_op, pix_op);
720 581967 break;
721 579242 case MV_TYPE_FIELD:
722
2/2
✓ Branch 0 taken 230444 times.
✓ Branch 1 taken 348798 times.
579242 if (s->picture_structure == PICT_FRAME) {
723
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 230444 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
230444 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 230444 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 230444 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 50618 times.
✓ Branch 1 taken 298180 times.
✓ Branch 2 taken 39610 times.
✓ Branch 3 taken 11008 times.
✓ Branch 4 taken 7799 times.
✓ Branch 5 taken 31811 times.
348798 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 316987 times.
316987 || !ref_picture[0]) {
744 31811 ref_picture = s->current_picture_ptr->f->data;
745 }
746
747 348798 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 579242 break;
753 285623 case MV_TYPE_16X8:
754
1/2
✓ Branch 0 taken 285623 times.
✗ Branch 1 not taken.
285623 if (CONFIG_SMALL || is_mpeg12) {
755
2/2
✓ Branch 0 taken 571246 times.
✓ Branch 1 taken 285623 times.
856869 for (i = 0; i < 2; i++) {
756 uint8_t *const *ref2picture;
757
758
2/2
✓ Branch 0 taken 77124 times.
✓ Branch 1 taken 494122 times.
571246 if ((s->picture_structure == s->field_select[dir][i] + 1 ||
759
4/4
✓ Branch 0 taken 73730 times.
✓ Branch 1 taken 3394 times.
✓ Branch 2 taken 8030 times.
✓ Branch 3 taken 65700 times.
77124 s->pict_type == AV_PICTURE_TYPE_B || s->first_field) &&
760
1/2
✓ Branch 0 taken 505546 times.
✗ Branch 1 not taken.
505546 ref_picture[0]) {
761 505546 ref2picture = ref_picture;
762 } else {
763 65700 ref2picture = s->current_picture_ptr->f->data;
764 }
765
766 571246 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 571246 8, 1, (mb_y & ~1) + i);
771
772 571246 dest_y += 16 * s->linesize;
773 571246 dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
774 571246 dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
775 }
776 285623 break;
777 }
778 case MV_TYPE_DMV:
779
1/2
✓ Branch 0 taken 21191 times.
✗ Branch 1 not taken.
21191 if (CONFIG_SMALL || is_mpeg12) {
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21191 times.
21191 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 21191 times.
21191 if (!ref_picture[0]) {
791 ref_picture = s->current_picture_ptr->f->data;
792 }
793
2/2
✓ Branch 0 taken 42382 times.
✓ Branch 1 taken 21191 times.
63573 for (i = 0; i < 2; i++) {
794 42382 mpeg_motion(s, dest_y, dest_cb, dest_cr,
795 42382 s->picture_structure != i + 1,
796 ref_picture, pix_op,
797 42382 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 42382 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 36274 times.
✓ Branch 1 taken 6108 times.
42382 if (!s->first_field)
806 36274 ref_picture = s->current_picture_ptr->f->data;
807 }
808 }
809 21191 break;
810 }
811 default: av_assert2(0);
812 }
813 }
814
815 9470693 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 9470693 prefetch_motion(s, ref_picture, dir);
823
824 #if !CONFIG_SMALL
825
2/2
✓ Branch 0 taken 4455973 times.
✓ Branch 1 taken 5014720 times.
9470693 if (s->out_format == FMT_MPEG1)
826 4455973 mpv_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
827 ref_picture, pix_op, qpix_op, 1);
828 else
829 #endif
830 5014720 mpv_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
831 ref_picture, pix_op, qpix_op, 0);
832 9470693 }
833