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
29
37
40 int src_x, int src_y,
42 int motion_x, int motion_y)
43 {
44 int dxy = 0;
45 int emu = 0;
46
47 src_x += motion_x >> 1;
48 src_y += motion_y >> 1;
49
50 /* WARNING: do no forget half pels */
51 src_x =
av_clip(src_x, -16,
s->width);
// FIXME unneeded for emu?
52 if (src_x !=
s->width)
53 dxy |= motion_x & 1;
54 src_y =
av_clip(src_y, -16,
s->height);
55 if (src_y !=
s->height)
56 dxy |= (motion_y & 1) << 1;
57 src += src_y *
s->linesize + src_x;
58
59 if ((
unsigned)src_x >=
FFMAX(
s->h_edge_pos - (motion_x & 1) - 7, 0) ||
60 (unsigned)src_y >=
FFMAX(
s->v_edge_pos - (motion_y & 1) - 7, 0)) {
61 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 src =
s->sc.edge_emu_buffer;
67 emu = 1;
68 }
69 pix_op[dxy](
dest,
src,
s->linesize, 8);
70 return emu;
71 }
72
75 uint8_t *dest_y,
76 uint8_t *dest_cb,
77 uint8_t *dest_cr,
78 int field_based,
79 int bottom_field,
81 uint8_t *const *ref_picture,
83 int motion_x,
84 int motion_y,
86 int is_mpeg12,
87 int is_16x8,
89 {
90 const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
91 int dxy, uvdxy, mx, my, src_x, src_y,
94
96 linesize =
s->current_picture.f->linesize[0] << field_based;
97 uvlinesize =
s->current_picture.f->linesize[1] << field_based;
98 block_y_half = (field_based | is_16x8);
99
100 dxy = ((motion_y & 1) << 1) | (motion_x & 1);
101 src_x =
s->mb_x * 16 + (motion_x >> 1);
102 src_y = (
mb_y << (4 - block_y_half)) + (motion_y >> 1);
103
104 if (!is_mpeg12 &&
s->out_format ==
FMT_H263) {
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 uvdxy = dxy | (motion_y & 2) | ((motion_x & 2) >> 1);
113 uvsrc_x = src_x >> 1;
114 uvsrc_y = src_y >> 1;
115 }
116 // Even chroma mv's are full pel in H261
117 }
else if (!is_mpeg12 &&
s->out_format ==
FMT_H261) {
118 mx = motion_x / 4;
119 my = motion_y / 4;
120 uvdxy = 0;
121 uvsrc_x =
s->mb_x * 8 + mx;
122 uvsrc_y =
mb_y * 8 + my;
123 } else {
124 if (
s->chroma_y_shift) {
125 mx = motion_x / 2;
126 my = motion_y / 2;
127 uvdxy = ((my & 1) << 1) | (mx & 1);
128 uvsrc_x =
s->mb_x * 8 + (mx >> 1);
129 uvsrc_y = (
mb_y << (3 - block_y_half)) + (my >> 1);
130 } else {
131 if (
s->chroma_x_shift) {
132 // Chroma422
133 mx = motion_x / 2;
134 uvdxy = ((motion_y & 1) << 1) | (mx & 1);
135 uvsrc_x =
s->mb_x * 8 + (mx >> 1);
136 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 ptr_y = ref_picture[0] + src_y *
linesize + src_x;
147 ptr_cb = ref_picture[1] + uvsrc_y *
uvlinesize + uvsrc_x;
148 ptr_cr = ref_picture[2] + uvsrc_y *
uvlinesize + uvsrc_x;
149
150 if ((
unsigned)src_x >=
FFMAX(
s->h_edge_pos - (motion_x & 1) - 15 , 0) ||
152 if (is_mpeg12 || (CONFIG_SMALL &&
156 "MPEG motion vector out of boundary (%d %d)\n", src_x,
157 src_y);
158 return;
159 }
160 src_y = (unsigned)src_y << field_based;
161 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 ptr_y =
s->sc.edge_emu_buffer;
168 uint8_t *ubuf =
s->sc.edge_emu_buffer + 18 *
s->linesize;
169 uint8_t *vbuf = ubuf + 10 *
s->uvlinesize;
171 vbuf -=
s->uvlinesize;
172 uvsrc_y = (unsigned)uvsrc_y << field_based;
173 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
174 s->uvlinesize,
s->uvlinesize,
175 9, 9 + field_based,
176 uvsrc_x, uvsrc_y,
177 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
178 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
179 s->uvlinesize,
s->uvlinesize,
180 9, 9 + field_based,
181 uvsrc_x, uvsrc_y,
182 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
183 ptr_cb = ubuf;
184 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 if (bottom_field) {
191 dest_y +=
s->linesize;
192 dest_cb +=
s->uvlinesize;
193 dest_cr +=
s->uvlinesize;
194 }
195
197 ptr_y +=
s->linesize;
198 ptr_cb +=
s->uvlinesize;
199 ptr_cr +=
s->uvlinesize;
200 }
201
202 pix_op[0][dxy](dest_y, ptr_y,
linesize,
h);
203
205 pix_op[
s->chroma_x_shift][uvdxy]
207 pix_op[
s->chroma_x_shift][uvdxy]
209 }
210 if (!is_mpeg12 && (CONFIG_H261_ENCODER || CONFIG_H261_DECODER) &&
213 }
214 }
215 /* apply one mpeg motion vector to the three components */
217 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
220 int motion_x,
int motion_y,
int h,
int is_16x8,
int mb_y)
221 {
222 #if !CONFIG_SMALL
226 motion_x, motion_y,
h, 1, is_16x8,
mb_y);
227 else
228 #endif
231 motion_x, motion_y,
h, 0, is_16x8,
mb_y);
232 }
233
235 uint8_t *dest_cb, uint8_t *dest_cr,
237 uint8_t *const *ref_picture,
239 int motion_x,
int motion_y,
int h,
int mb_y)
240 {
241 #if !CONFIG_SMALL
245 motion_x, motion_y,
h, 1, 0,
mb_y);
246 else
247 #endif
250 motion_x, motion_y,
h, 0, 0,
mb_y);
251 }
252
253 // FIXME: SIMDify, avg variant, 16x16 version
255 {
256 int x;
257 uint8_t *
const top =
src[1];
259 uint8_t *
const mid =
src[0];
260 uint8_t *
const right =
src[3];
261 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 x = 0;
304 }
305
306 /* obmc for 1 8x8 luma block */
309 int src_x, int src_y,
311 int16_t
mv[5][2]
/* mid top left right bottom */)
312 #define MID 0
313 {
315 uint8_t *ptr[5];
316
318
319 for (
i = 0;
i < 5;
i++) {
322 } else {
323 ptr[
i] =
s->sc.obmc_scratchpad + 8 * (
i & 1) +
324 s->linesize * 8 * (
i >> 1);
327 }
328 }
329
331 }
332
334 uint8_t *dest_y,
335 uint8_t *dest_cb,
336 uint8_t *dest_cr,
337 int field_based, int bottom_field,
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;
346
347 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
348
349 src_x =
s->mb_x * 16 + (motion_x >> 2);
350 src_y =
s->mb_y * (16 >> field_based) + (motion_y >> 2);
351
355
356 if (field_based) {
357 mx = motion_x / 2;
358 my = motion_y >> 1;
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];
364 mx = (motion_x >> 1) | (motion_x & 1);
365 my = (motion_y >> 1) | (motion_y & 1);
366 } else {
367 mx = motion_x / 2;
368 my = motion_y / 2;
369 }
370 mx = (mx >> 1) | (mx & 1);
371 my = (my >> 1) | (my & 1);
372
373 uvdxy = (mx & 1) | ((my & 1) << 1);
374 mx >>= 1;
375 my >>= 1;
376
377 uvsrc_x =
s->mb_x * 8 + mx;
378 uvsrc_y =
s->mb_y * (8 >> field_based) + my;
379
380 ptr_y = ref_picture[0] + src_y *
linesize + src_x;
381 ptr_cb = ref_picture[1] + uvsrc_y *
uvlinesize + uvsrc_x;
382 ptr_cr = ref_picture[2] + uvsrc_y *
uvlinesize + uvsrc_x;
383
384 if ((
unsigned)src_x >=
FFMAX(
s->h_edge_pos - (motion_x & 3) - 15 , 0) ||
386 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 ptr_y =
s->sc.edge_emu_buffer;
393 uint8_t *ubuf =
s->sc.edge_emu_buffer + 18 *
s->linesize;
394 uint8_t *vbuf = ubuf + 10 *
s->uvlinesize;
396 vbuf -=
s->uvlinesize;
397 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 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
402 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 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
407 ptr_cb = ubuf;
408 ptr_cr = vbuf;
409 }
410 }
411
412 if (!field_based)
413 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
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 }
432 pix_op[1][uvdxy](dest_cr, ptr_cr,
uvlinesize,
h >> 1);
433 pix_op[1][uvdxy](dest_cb, ptr_cb,
uvlinesize,
h >> 1);
434 }
435 }
436
437 /**
438 * H.263 chroma 4mv motion compensation.
439 */
441 uint8_t *dest_cb, uint8_t *dest_cr,
442 uint8_t *const *ref_picture,
444 int mx, int my)
445 {
446 const uint8_t *ptr;
447 int src_x, src_y, dxy, emu = 0;
449
450 /* In case of 8X8, we construct a single chroma motion vector
451 * with a special rounding */
454
455 dxy = ((my & 1) << 1) | (mx & 1);
456 mx >>= 1;
457 my >>= 1;
458
459 src_x =
s->mb_x * 8 + mx;
460 src_y =
s->mb_y * 8 + my;
461 src_x =
av_clip(src_x, -8, (
s->width >> 1));
462 if (src_x == (
s->width >> 1))
463 dxy &= ~1;
464 src_y =
av_clip(src_y, -8, (
s->height >> 1));
465 if (src_y == (
s->height >> 1))
466 dxy &= ~2;
467
468 offset = src_y *
s->uvlinesize + src_x;
469 ptr = ref_picture[1] +
offset;
470 if ((
unsigned)src_x >=
FFMAX((
s->h_edge_pos >> 1) - (dxy & 1) - 7, 0) ||
471 (
unsigned)src_y >=
FFMAX((
s->v_edge_pos >> 1) - (dxy >> 1) - 7, 0)) {
472 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
473 s->uvlinesize,
s->uvlinesize,
474 9, 9, src_x, src_y,
475 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
476 ptr =
s->sc.edge_emu_buffer;
477 emu = 1;
478 }
479 pix_op[dxy](dest_cb, ptr,
s->uvlinesize, 8);
480
481 ptr = ref_picture[2] +
offset;
482 if (emu) {
483 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
484 s->uvlinesize,
s->uvlinesize,
485 9, 9, src_x, src_y,
486 s->h_edge_pos >> 1,
s->v_edge_pos >> 1);
487 ptr =
s->sc.edge_emu_buffer;
488 }
489 pix_op[dxy](dest_cr, ptr,
s->uvlinesize, 8);
490 }
491
493 {
494 /* fetch pixels for estimated mv 4 macroblocks ahead
495 * optimized for 64byte cache lines */
496 const int shift =
s->quarter_sample ? 2 : 1;
497 const int mx = (
s->mv[dir][0][0] >>
shift) + 16 *
s->mb_x + 8;
498 const int my = (
s->mv[dir][0][1] >>
shift) + 16 *
s->mb_y;
499 int off = mx + (my + (
s->mb_x & 3) * 4) *
s->linesize + 64;
500
501 s->vdsp.prefetch(pix[0] + off,
s->linesize, 4);
502 off = (mx >> 1) + ((my >> 1) + (
s->mb_x & 7)) *
s->uvlinesize + 64;
503 s->vdsp.prefetch(pix[1] + off, pix[2] - pix[1], 2);
504 }
505
507 uint8_t *dest_y,
508 uint8_t *dest_cb,
509 uint8_t *dest_cr,
510 uint8_t *const *ref_picture,
512 {
514 const Picture *cur_frame = &
s->current_picture;
517 const int xy =
mb_x +
mb_y *
s->mb_stride;
518 const int mot_stride =
s->b8_stride;
519 const int mot_xy =
mb_x * 2 +
mb_y * 2 * mot_stride;
521
523
526
528 cur_frame->
motion_val[0][mot_xy + mot_stride]);
530 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
531
533 cur_frame->
motion_val[0][mot_xy + mot_stride]);
535 cur_frame->
motion_val[0][mot_xy + mot_stride + 1]);
536
538 AV_COPY32(mv_cache[0][1], mv_cache[1][1]);
539 AV_COPY32(mv_cache[0][2], mv_cache[1][2]);
540 } else {
542 cur_frame->
motion_val[0][mot_xy - mot_stride]);
544 cur_frame->
motion_val[0][mot_xy - mot_stride + 1]);
545 }
546
548 AV_COPY32(mv_cache[1][0], mv_cache[1][1]);
549 AV_COPY32(mv_cache[2][0], mv_cache[2][1]);
550 } else {
553 cur_frame->
motion_val[0][mot_xy - 1 + mot_stride]);
554 }
555
557 AV_COPY32(mv_cache[1][3], mv_cache[1][2]);
558 AV_COPY32(mv_cache[2][3], mv_cache[2][2]);
559 } else {
562 cur_frame->
motion_val[0][mot_xy + 2 + mot_stride]);
563 }
564
565 mx = 0;
566 my = 0;
567 for (
i = 0;
i < 4;
i++) {
568 const int x = (
i & 1) + 1;
569 const int y = (
i >> 1) + 1;
571 { mv_cache[y][x][0], mv_cache[y][x][1] },
572 { mv_cache[y - 1][x][0], mv_cache[y - 1][x][1] },
573 { mv_cache[y][x - 1][0], mv_cache[y][x - 1][1] },
574 { mv_cache[y][x + 1][0], mv_cache[y][x + 1][1] },
575 { mv_cache[y + 1][x][0], mv_cache[y + 1][x][1] }
576 };
577 // FIXME cleanup
579 ref_picture[0],
580 mb_x * 16 + (
i & 1) * 8,
mb_y * 16 + (
i >> 1) * 8,
581 pix_op[1],
583
586 }
589 ref_picture, pix_op[1],
590 mx, my);
591 }
592
594 uint8_t *dest_y,
595 uint8_t *dest_cb,
596 uint8_t *dest_cr,
597 int dir,
598 uint8_t *const *ref_picture,
601 {
602 int dxy, mx, my, src_x, src_y;
607 const uint8_t *ptr;
608
609 mx = 0;
610 my = 0;
611 if (
s->quarter_sample) {
612 for (
i = 0;
i < 4;
i++) {
613 int motion_x =
s->mv[dir][
i][0];
614 int motion_y =
s->mv[dir][
i][1];
615
616 dxy = ((motion_y & 3) << 2) | (motion_x & 3);
617 src_x =
mb_x * 16 + (motion_x >> 2) + (
i & 1) * 8;
618 src_y =
mb_y * 16 + (motion_y >> 2) + (
i >> 1) * 8;
619
620 /* WARNING: do no forget half pels */
621 src_x =
av_clip(src_x, -16,
s->width);
622 if (src_x ==
s->width)
623 dxy &= ~3;
624 src_y =
av_clip(src_y, -16,
s->height);
625 if (src_y ==
s->height)
626 dxy &= ~12;
627
628 ptr = ref_picture[0] + (src_y *
s->linesize) + (src_x);
629 if ((
unsigned)src_x >=
FFMAX(
s->h_edge_pos - (motion_x & 3) - 7, 0) ||
630 (
unsigned)src_y >=
FFMAX(
s->v_edge_pos - (motion_y & 3) - 7, 0)) {
631 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
632 s->linesize,
s->linesize,
633 9, 9,
634 src_x, src_y,
637 ptr =
s->sc.edge_emu_buffer;
638 }
639 dest = dest_y + ((
i & 1) * 8) + (
i >> 1) * 8 *
s->linesize;
640 qpix_op[1][dxy](
dest, ptr,
s->linesize);
641
642 mx +=
s->mv[dir][
i][0] / 2;
643 my +=
s->mv[dir][
i][1] / 2;
644 }
645 } else {
646 for (
i = 0;
i < 4;
i++) {
648 dest_y + ((
i & 1) * 8) + (
i >> 1) * 8 *
s->linesize,
649 ref_picture[0],
650 mb_x * 16 + (
i & 1) * 8,
651 mb_y * 16 + (
i >> 1) * 8,
652 pix_op[1],
655
656 mx +=
s->mv[dir][
i][0];
657 my +=
s->mv[dir][
i][1];
658 }
659 }
660
663 ref_picture, pix_op[1], mx, my);
664 }
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 */
679 uint8_t *dest_y,
680 uint8_t *dest_cb,
681 uint8_t *dest_cr,
682 int dir,
683 uint8_t *const *ref_picture,
686 int is_mpeg12)
687 {
690
692 apply_obmc(
s, dest_y, dest_cb, dest_cr, ref_picture, pix_op);
693 return;
694 }
695
696 switch (
s->mv_type) {
698 if (CONFIG_MPEG4_DECODER && !is_mpeg12 &&
s->mcsel) {
700 }
else if (!is_mpeg12 &&
s->quarter_sample) {
702 0, 0, 0,
703 ref_picture, pix_op, qpix_op,
704 s->mv[dir][0][0],
s->mv[dir][0][1], 16);
705 } else if (!is_mpeg12 && (CONFIG_WMV2_DECODER || CONFIG_WMV2_ENCODER) &&
708 ref_picture, pix_op,
709 s->mv[dir][0][0],
s->mv[dir][0][1], 16);
710 } else {
712 ref_picture, pix_op,
713 s->mv[dir][0][0],
s->mv[dir][0][1], 16, 0,
mb_y);
714 }
715 break;
717 if (!is_mpeg12)
719 dir, ref_picture, qpix_op, pix_op);
720 break;
723 if (!is_mpeg12 &&
s->quarter_sample) {
724 for (
i = 0;
i < 2;
i++)
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 */
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 */
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 if (
s->picture_structure !=
s->field_select[dir][0] + 1 &&
s->pict_type !=
AV_PICTURE_TYPE_B && !
s->first_field
743 || !ref_picture[0]) {
744 ref_picture =
s->current_picture_ptr->f->data;
745 }
746
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 break;
754 if (CONFIG_SMALL || is_mpeg12) {
755 for (
i = 0;
i < 2;
i++) {
756 uint8_t *const *ref2picture;
757
758 if ((
s->picture_structure ==
s->field_select[dir][
i] + 1 ||
760 ref_picture[0]) {
761 ref2picture = ref_picture;
762 } else {
763 ref2picture =
s->current_picture_ptr->f->data;
764 }
765
767 s->field_select[dir][
i],
768 ref2picture, pix_op,
769 s->mv[dir][
i][0],
s->mv[dir][
i][1],
770 8, 1, (
mb_y & ~1) +
i);
771
772 dest_y += 16 *
s->linesize;
773 dest_cb += (16 >>
s->chroma_y_shift) *
s->uvlinesize;
774 dest_cr += (16 >>
s->chroma_y_shift) *
s->uvlinesize;
775 }
776 break;
777 }
779 if (CONFIG_SMALL || is_mpeg12) {
781 for (
i = 0;
i < 2;
i++) {
782 for (int j = 0; j < 2; j++)
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 if (!ref_picture[0]) {
791 ref_picture =
s->current_picture_ptr->f->data;
792 }
793 for (
i = 0;
i < 2;
i++) {
795 s->picture_structure !=
i + 1,
796 ref_picture, pix_op,
797 s->mv[dir][2 *
i][0],
s->mv[dir][2 *
i][1],
799
800 // after put we make avg of the same block
801 pix_op =
s->hdsp.avg_pixels_tab;
802
803 /* opposite parity is always in the same frame if this is
804 * second field */
806 ref_picture =
s->current_picture_ptr->f->data;
807 }
808 }
809 break;
810 }
812 }
813 }
814
816 uint8_t *dest_y, uint8_t *dest_cb,
817 uint8_t *dest_cr, int dir,
818 uint8_t *const *ref_picture,
821 {
823
824 #if !CONFIG_SMALL
827 ref_picture, pix_op, qpix_op, 1);
828 else
829 #endif
831 ref_picture, pix_op, qpix_op, 0);
832 }