FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavcodec/mpegvideo_motion.c
Date: 2022-11-26 13:19:19
Exec Total Coverage
Lines: 370 409 90.5%
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 2640948 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 2640948 int dxy = 0;
45 2640948 int emu = 0;
46
47 2640948 src_x += motion_x >> 1;
48 2640948 src_y += motion_y >> 1;
49
50 /* WARNING: do no forget half pels */
51 2640948 src_x = av_clip(src_x, -16, s->width); // FIXME unneeded for emu?
52
2/2
✓ Branch 0 taken 2639034 times.
✓ Branch 1 taken 1914 times.
2640948 if (src_x != s->width)
53 2639034 dxy |= motion_x & 1;
54 2640948 src_y = av_clip(src_y, -16, s->height);
55
2/2
✓ Branch 0 taken 2638613 times.
✓ Branch 1 taken 2335 times.
2640948 if (src_y != s->height)
56 2638613 dxy |= (motion_y & 1) << 1;
57 2640948 src += src_y * s->linesize + src_x;
58
59
3/4
✓ Branch 0 taken 2640948 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2597974 times.
✓ Branch 3 taken 42974 times.
2640948 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 7, 0) ||
60
3/4
✓ Branch 0 taken 2597974 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 46711 times.
✓ Branch 3 taken 2551263 times.
2597974 (unsigned)src_y >= FFMAX(s->v_edge_pos - (motion_y & 1) - 7, 0)) {
61 89685 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 89685 src = s->sc.edge_emu_buffer;
67 89685 emu = 1;
68 }
69 2640948 pix_op[dxy](dest, src, s->linesize, 8);
70 2640948 return emu;
71 }
72
73 static av_always_inline
74 8215358 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 8215358 v_edge_pos = s->v_edge_pos >> field_based;
96 8215358 linesize = s->current_picture.f->linesize[0] << field_based;
97 8215358 uvlinesize = s->current_picture.f->linesize[1] << field_based;
98 8215358 block_y_half = (field_based | is_16x8);
99
100 8215358 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
101 8215358 src_x = s->mb_x * 16 + (motion_x >> 1);
102 8215358 src_y = (mb_y << (4 - block_y_half)) + (motion_y >> 1);
103
104
4/4
✓ Branch 0 taken 4029043 times.
✓ Branch 1 taken 4186315 times.
✓ Branch 2 taken 3823086 times.
✓ Branch 3 taken 205957 times.
8215358 if (!is_mpeg12 && s->out_format == FMT_H263) {
105
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3823086 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3823086 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 3823086 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
113 3823086 uvsrc_x = src_x >> 1;
114 3823086 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 4186315 times.
✓ Branch 2 taken 205957 times.
✗ Branch 3 not taken.
4392272 } 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 3512421 times.
✓ Branch 1 taken 673894 times.
4186315 if (s->chroma_y_shift) {
125 3512421 mx = motion_x / 2;
126 3512421 my = motion_y / 2;
127 3512421 uvdxy = ((my & 1) << 1) | (mx & 1);
128 3512421 uvsrc_x = s->mb_x * 8 + (mx >> 1);
129 3512421 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 8215358 ptr_y = ref_picture[0] + src_y * linesize + src_x;
147 8215358 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
148 8215358 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
149
150
3/4
✓ Branch 0 taken 8215358 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8077902 times.
✓ Branch 3 taken 137456 times.
8215358 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 1) - 15 , 0) ||
151
3/4
✓ Branch 0 taken 8077902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 150328 times.
✓ Branch 3 taken 7927574 times.
8077902 (unsigned)src_y >= FFMAX( v_edge_pos - (motion_y & 1) - h + 1, 0)) {
152
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287784 times.
287784 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 287784 src_y = (unsigned)src_y << field_based;
161 287784 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 287784 ptr_y = s->sc.edge_emu_buffer;
167 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
168 287784 uint8_t *ubuf = s->sc.edge_emu_buffer + 18 * s->linesize;
169 287784 uint8_t *vbuf = ubuf + 10 * s->uvlinesize;
170
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 287784 times.
287784 if (s->workaround_bugs & FF_BUG_IEDGE)
171 vbuf -= s->uvlinesize;
172 287784 uvsrc_y = (unsigned)uvsrc_y << field_based;
173 287784 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
174 s->uvlinesize, s->uvlinesize,
175 9, 9 + field_based,
176 uvsrc_x, uvsrc_y,
177 287784 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
178 287784 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
179 s->uvlinesize, s->uvlinesize,
180 9, 9 + field_based,
181 uvsrc_x, uvsrc_y,
182 287784 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
183 287784 ptr_cb = ubuf;
184 287784 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 221516 times.
✓ Branch 1 taken 7993842 times.
8215358 if (bottom_field) {
191 221516 dest_y += s->linesize;
192 221516 dest_cb += s->uvlinesize;
193 221516 dest_cr += s->uvlinesize;
194 }
195
196
2/2
✓ Branch 0 taken 516847 times.
✓ Branch 1 taken 7698511 times.
8215358 if (field_select) {
197 516847 ptr_y += s->linesize;
198 516847 ptr_cb += s->uvlinesize;
199 516847 ptr_cr += s->uvlinesize;
200 }
201
202 8215358 pix_op[0][dxy](dest_y, ptr_y, linesize, h);
203
204 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY)) {
205 8215358 pix_op[s->chroma_x_shift][uvdxy]
206 8215358 (dest_cb, ptr_cb, uvlinesize, h >> s->chroma_y_shift);
207 8215358 pix_op[s->chroma_x_shift][uvdxy]
208 8215358 (dest_cr, ptr_cr, uvlinesize, h >> s->chroma_y_shift);
209 }
210
2/2
✓ Branch 0 taken 4029043 times.
✓ Branch 1 taken 4186315 times.
8215358 if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
211
2/2
✓ Branch 0 taken 205957 times.
✓ Branch 1 taken 3823086 times.
4029043 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 7772326 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 3743283 times.
✓ Branch 1 taken 4029043 times.
7772326 if (s->out_format == FMT_MPEG1)
224 3743283 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 4029043 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 7772326 }
233
234 443032 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 443032 times.
✗ Branch 1 not taken.
443032 if (s->out_format == FMT_MPEG1)
243 443032 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 443032 }
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 212545 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 212545 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
348
349 212545 src_x = s->mb_x * 16 + (motion_x >> 2);
350 212545 src_y = s->mb_y * (16 >> field_based) + (motion_y >> 2);
351
352 212545 v_edge_pos = s->v_edge_pos >> field_based;
353 212545 linesize = s->linesize << field_based;
354 212545 uvlinesize = s->uvlinesize << field_based;
355
356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212545 times.
212545 if (field_based) {
357 mx = motion_x / 2;
358 my = motion_y >> 1;
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 212545 times.
212545 } 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 212545 times.
212545 } 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 212545 mx = motion_x / 2;
368 212545 my = motion_y / 2;
369 }
370 212545 mx = (mx >> 1) | (mx & 1);
371 212545 my = (my >> 1) | (my & 1);
372
373 212545 uvdxy = (mx & 1) | ((my & 1) << 1);
374 212545 mx >>= 1;
375 212545 my >>= 1;
376
377 212545 uvsrc_x = s->mb_x * 8 + mx;
378 212545 uvsrc_y = s->mb_y * (8 >> field_based) + my;
379
380 212545 ptr_y = ref_picture[0] + src_y * linesize + src_x;
381 212545 ptr_cb = ref_picture[1] + uvsrc_y * uvlinesize + uvsrc_x;
382 212545 ptr_cr = ref_picture[2] + uvsrc_y * uvlinesize + uvsrc_x;
383
384
3/4
✓ Branch 0 taken 212545 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202996 times.
✓ Branch 3 taken 9549 times.
212545 if ((unsigned)src_x >= FFMAX(s->h_edge_pos - (motion_x & 3) - 15 , 0) ||
385
3/4
✓ Branch 0 taken 202996 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11156 times.
✓ Branch 3 taken 191840 times.
202996 (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 212545 times.
✗ Branch 1 not taken.
212545 if (!field_based)
413 212545 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 212545 pix_op[1][uvdxy](dest_cr, ptr_cr, uvlinesize, h >> 1);
433 212545 pix_op[1][uvdxy](dest_cb, ptr_cb, uvlinesize, h >> 1);
434 }
435 212545 }
436
437 /**
438 * H.263 chroma 4mv motion compensation.
439 */
440 684325 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 684325 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 684325 mx = ff_h263_round_chroma(mx);
453 684325 my = ff_h263_round_chroma(my);
454
455 684325 dxy = ((my & 1) << 1) | (mx & 1);
456 684325 mx >>= 1;
457 684325 my >>= 1;
458
459 684325 src_x = s->mb_x * 8 + mx;
460 684325 src_y = s->mb_y * 8 + my;
461 684325 src_x = av_clip(src_x, -8, (s->width >> 1));
462
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 684323 times.
684325 if (src_x == (s->width >> 1))
463 2 dxy &= ~1;
464 684325 src_y = av_clip(src_y, -8, (s->height >> 1));
465
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 684311 times.
684325 if (src_y == (s->height >> 1))
466 14 dxy &= ~2;
467
468 684325 offset = src_y * s->uvlinesize + src_x;
469 684325 ptr = ref_picture[1] + offset;
470
3/4
✓ Branch 0 taken 684325 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 657379 times.
✓ Branch 3 taken 26946 times.
684325 if ((unsigned)src_x >= FFMAX((s->h_edge_pos >> 1) - (dxy & 1) - 7, 0) ||
471
3/4
✓ Branch 0 taken 657379 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 28746 times.
✓ Branch 3 taken 628633 times.
657379 (unsigned)src_y >= FFMAX((s->v_edge_pos >> 1) - (dxy >> 1) - 7, 0)) {
472 55692 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
473 s->uvlinesize, s->uvlinesize,
474 9, 9, src_x, src_y,
475 55692 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
476 55692 ptr = s->sc.edge_emu_buffer;
477 55692 emu = 1;
478 }
479 684325 pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
480
481 684325 ptr = ref_picture[2] + offset;
482
2/2
✓ Branch 0 taken 55692 times.
✓ Branch 1 taken 628633 times.
684325 if (emu) {
483 55692 s->vdsp.emulated_edge_mc(s->sc.edge_emu_buffer, ptr,
484 s->uvlinesize, s->uvlinesize,
485 9, 9, src_x, src_y,
486 55692 s->h_edge_pos >> 1, s->v_edge_pos >> 1);
487 55692 ptr = s->sc.edge_emu_buffer;
488 }
489 684325 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
490 684325 }
491
492 8805892 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 339076 times.
✓ Branch 1 taken 8466816 times.
8805892 const int shift = s->quarter_sample ? 2 : 1;
497 8805892 const int mx = (s->mv[dir][0][0] >> shift) + 16 * s->mb_x + 8;
498 8805892 const int my = (s->mv[dir][0][1] >> shift) + 16 * s->mb_y;
499 8805892 int off = mx + (my + (s->mb_x & 3) * 4) * s->linesize + 64;
500
501 8805892 s->vdsp.prefetch(pix[0] + off, s->linesize, 4);
502 8805892 off = (mx >> 1) + ((my >> 1) + (s->mb_x & 7)) * s->uvlinesize + 64;
503 8805892 s->vdsp.prefetch(pix[1] + off, pix[2] - pix[1], 2);
504 8805892 }
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 581083 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 581083 int mb_x = s->mb_x;
605 581083 int mb_y = s->mb_y;
606 uint8_t *dest;
607 const uint8_t *ptr;
608
609 581083 mx = 0;
610 581083 my = 0;
611
2/2
✓ Branch 0 taken 126531 times.
✓ Branch 1 taken 454552 times.
581083 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 1818208 times.
✓ Branch 1 taken 454552 times.
2272760 for (i = 0; i < 4; i++) {
647 1818208 hpel_motion(s,
648 1818208 dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
649 ref_picture[0],
650 1818208 mb_x * 16 + (i & 1) * 8,
651 1818208 mb_y * 16 + (i >> 1) * 8,
652 1818208 pix_op[1],
653 s->mv[dir][i][0],
654 s->mv[dir][i][1]);
655
656 1818208 mx += s->mv[dir][i][0];
657 1818208 my += s->mv[dir][i][1];
658 }
659 }
660
661 if (!CONFIG_GRAY || !(s->avctx->flags & AV_CODEC_FLAG_GRAY))
662 581083 chroma_4mv_motion(s, dest_cb, dest_cr,
663 581083 ref_picture, pix_op[1], mx, my);
664 581083 }
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 8805892 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 8805892 int mb_y = s->mb_y;
690
691
5/6
✓ Branch 0 taken 5006406 times.
✓ Branch 1 taken 3799486 times.
✓ Branch 2 taken 103242 times.
✓ Branch 3 taken 4903164 times.
✓ Branch 4 taken 103242 times.
✗ Branch 5 not taken.
8805892 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 7486276 times.
✓ Branch 1 taken 581083 times.
✓ Branch 2 taken 469978 times.
✓ Branch 3 taken 153889 times.
✓ Branch 4 taken 11424 times.
✗ Branch 5 not taken.
8702650 switch (s->mv_type) {
697 7486276 case MV_TYPE_16X16:
698
3/4
✓ Branch 0 taken 4322081 times.
✓ Branch 1 taken 3164195 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4322081 times.
7486276 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 4322081 times.
✓ Branch 1 taken 3164195 times.
✓ Branch 2 taken 212545 times.
✓ Branch 3 taken 4109536 times.
7486276 } else if (!is_mpeg12 && s->quarter_sample) {
701 212545 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 4109536 times.
✓ Branch 1 taken 3164195 times.
7273731 } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
706
3/4
✓ Branch 0 taken 80493 times.
✓ Branch 1 taken 4029043 times.
✓ Branch 2 taken 80493 times.
✗ Branch 3 not taken.
4109536 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 7193238 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 7486276 break;
716 581083 case MV_TYPE_8X8:
717
1/2
✓ Branch 0 taken 581083 times.
✗ Branch 1 not taken.
581083 if (!is_mpeg12)
718 581083 apply_8x8(s, dest_y, dest_cb, dest_cr,
719 dir, ref_picture, qpix_op, pix_op);
720 581083 break;
721 469978 case MV_TYPE_FIELD:
722
2/2
✓ Branch 0 taken 221516 times.
✓ Branch 1 taken 248462 times.
469978 if (s->picture_structure == PICT_FRAME) {
723
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 221516 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
221516 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 221516 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 221516 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 40900 times.
✓ Branch 1 taken 207562 times.
✓ Branch 2 taken 29953 times.
✓ Branch 3 taken 10947 times.
✓ Branch 4 taken 7184 times.
✓ Branch 5 taken 22769 times.
248462 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 225693 times.
225693 || !ref_picture[0]) {
744 22769 ref_picture = s->current_picture_ptr->f->data;
745 }
746
747 248462 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 469978 break;
753 153889 case MV_TYPE_16X8:
754
1/2
✓ Branch 0 taken 153889 times.
✗ Branch 1 not taken.
153889 if (CONFIG_SMALL || is_mpeg12) {
755
2/2
✓ Branch 0 taken 307778 times.
✓ Branch 1 taken 153889 times.
461667 for (i = 0; i < 2; i++) {
756 uint8_t *const *ref2picture;
757
758
2/2
✓ Branch 0 taken 42179 times.
✓ Branch 1 taken 265599 times.
307778 if ((s->picture_structure == s->field_select[dir][i] + 1 ||
759
4/4
✓ Branch 0 taken 40482 times.
✓ Branch 1 taken 1697 times.
✓ Branch 2 taken 4332 times.
✓ Branch 3 taken 36150 times.
42179 s->pict_type == AV_PICTURE_TYPE_B || s->first_field) &&
760
1/2
✓ Branch 0 taken 271628 times.
✗ Branch 1 not taken.
271628 ref_picture[0]) {
761 271628 ref2picture = ref_picture;
762 } else {
763 36150 ref2picture = s->current_picture_ptr->f->data;
764 }
765
766 307778 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 307778 8, 1, (mb_y & ~1) + i);
771
772 307778 dest_y += 16 * s->linesize;
773 307778 dest_cb += (16 >> s->chroma_y_shift) * s->uvlinesize;
774 307778 dest_cr += (16 >> s->chroma_y_shift) * s->uvlinesize;
775 }
776 153889 break;
777 }
778 case MV_TYPE_DMV:
779
1/2
✓ Branch 0 taken 11424 times.
✗ Branch 1 not taken.
11424 if (CONFIG_SMALL || is_mpeg12) {
780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11424 times.
11424 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 11424 times.
11424 if (!ref_picture[0]) {
791 ref_picture = s->current_picture_ptr->f->data;
792 }
793
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 11424 times.
34272 for (i = 0; i < 2; i++) {
794 22848 mpeg_motion(s, dest_y, dest_cb, dest_cr,
795 22848 s->picture_structure != i + 1,
796 ref_picture, pix_op,
797 22848 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 22848 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 19632 times.
✓ Branch 1 taken 3216 times.
22848 if (!s->first_field)
806 19632 ref_picture = s->current_picture_ptr->f->data;
807 }
808 }
809 11424 break;
810 }
811 default: av_assert2(0);
812 }
813 }
814
815 8805892 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 8805892 prefetch_motion(s, ref_picture, dir);
823
824 #if !CONFIG_SMALL
825
2/2
✓ Branch 0 taken 3799486 times.
✓ Branch 1 taken 5006406 times.
8805892 if (s->out_format == FMT_MPEG1)
826 3799486 mpv_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
827 ref_picture, pix_op, qpix_op, 1);
828 else
829 #endif
830 5006406 mpv_motion_internal(s, dest_y, dest_cb, dest_cr, dir,
831 ref_picture, pix_op, qpix_op, 0);
832 8805892 }
833