1 /*
2 * Common mpeg video decoding code
3 * Copyright (c) 2000,2001 Fabrice Bellard
4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5 *
6 * This file is part of FFmpeg.
7 *
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * FFmpeg is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
24
25 #include "config_components.h"
26
31
41
43 {
45
51
52 /* convert fourcc to upper case */
54
56 }
57
60 {
64
66 return 0;
67
69
70 // FIXME can parameters change on I-frames?
71 // in that case dst may need a reinit
72 if (!
s->context_initialized) {
74 int err;
75 memcpy(
s,
s1,
sizeof(*
s));
76
79 s->bitstream_buffer =
NULL;
80 s->bitstream_buffer_size =
s->allocated_bitstream_buffer_size = 0;
81
82 if (
s1->context_initialized) {
85 memset(
s, 0,
sizeof(*
s));
88 memcpy(&
s->h264chroma, &
s1->h264chroma,
sizeof(
s->h264chroma));
89 return err;
90 }
91 }
92 }
93
94 if (
s->height !=
s1->height ||
s->width !=
s1->width ||
s->context_reinit) {
95 s->height =
s1->height;
99 }
100
101 s->quarter_sample =
s1->quarter_sample;
102
103 s->coded_picture_number =
s1->coded_picture_number;
104 s->picture_number =
s1->picture_number;
105
110 if (
s1->picture &&
s1->picture[
i].f->buf[0] &&
113 }
114
115 #define UPDATE_PICTURE(pic)\
116 do {\
117 ff_mpeg_unref_picture(s->avctx, &s->pic);\
118 if (s1->pic.f && s1->pic.f->buf[0])\
119 ret = ff_mpeg_ref_picture(s->avctx, &s->pic, &s1->pic);\
120 else\
121 ret = ff_update_picture_tables(&s->pic, &s1->pic);\
122 if (ret < 0)\
123 return ret;\
124 } while (0)
125
129
130 #define REBASE_PICTURE(pic, new_ctx, old_ctx) \
131 ((pic && pic >= old_ctx->picture && \
132 pic < old_ctx->picture + MAX_PICTURE_COUNT) ? \
133 &new_ctx->picture[pic - old_ctx->picture] : NULL)
134
138
139 // Error/bug resilience
140 s->workaround_bugs =
s1->workaround_bugs;
141 s->padding_bug_score =
s1->padding_bug_score;
142
143 // MPEG-4 timing info
144 memcpy(&
s->last_time_base, &
s1->last_time_base,
145 (
char *) &
s1->pb_field_time +
sizeof(
s1->pb_field_time) -
146 (
char *) &
s1->last_time_base);
147
148 // B-frame info
149 s->max_b_frames =
s1->max_b_frames;
150 s->low_delay =
s1->low_delay;
151 s->droppable =
s1->droppable;
152
153 // DivX handling (doesn't work)
154 s->divx_packed =
s1->divx_packed;
155
156 if (
s1->bitstream_buffer) {
157 if (
s1->bitstream_buffer_size +
160 &
s->allocated_bitstream_buffer_size,
161 s1->allocated_bitstream_buffer_size);
162 if (!
s->bitstream_buffer) {
163 s->bitstream_buffer_size = 0;
165 }
166 }
167 s->bitstream_buffer_size =
s1->bitstream_buffer_size;
168 memcpy(
s->bitstream_buffer,
s1->bitstream_buffer,
169 s1->bitstream_buffer_size);
170 memset(
s->bitstream_buffer +
s->bitstream_buffer_size, 0,
172 }
173
174 // linesize-dependent scratch buffer allocation
175 if (!
s->sc.edge_emu_buffer)
178 &
s->sc,
s1->linesize) < 0) {
180 "scratch buffers.\n");
182 }
183 } else {
185 "be allocated due to unknown size.\n");
186 }
187
188 // MPEG-2/interlacing info
189 memcpy(&
s->progressive_sequence, &
s1->progressive_sequence,
190 (
char *) &
s1->rtp_mode - (
char *) &
s1->progressive_sequence);
191
192 return 0;
193 }
194
196 {
197 int err = 0;
198
199 if (!
s->context_initialized)
201
203
206 s->picture[
i].needs_realloc = 1;
207
208 s->last_picture_ptr =
209 s->next_picture_ptr =
210 s->current_picture_ptr =
NULL;
211
212 if ((
s->width ||
s->height) &&
215
216 /* set chroma shifts */
220 if (err < 0)
222
225
226 memset(
s->thread_context, 0,
sizeof(
s->thread_context));
227 s->thread_context[0] =
s;
228
229 if (
s->width &&
s->height) {
231 if (err < 0)
233 }
234 s->context_reinit = 0;
235
236 return 0;
239 s->context_reinit = 1;
240 return err;
241 }
242
244 {
246 s->chroma_x_shift,
s->chroma_y_shift,
s->out_format,
247 s->mb_stride,
s->mb_width,
s->mb_height,
s->b8_stride,
248 &
s->linesize, &
s->uvlinesize);
249 }
250
252 {
253 int h_chroma_shift, v_chroma_shift;
254
256
257 for (
int i = 0;
i <
frame->height;
i++)
264 }
265 }
266
267 /**
268 * generic function called after decoding
269 * the header and before a frame is decoded.
270 */
272 {
275
277
280 return -1;
281 }
282
283 /* mark & release old frames */
285 s->last_picture_ptr !=
s->next_picture_ptr &&
286 s->last_picture_ptr->f->buf[0]) {
288 }
289
290 /* release non reference/forgotten frames */
292 if (!
s->picture[
i].reference ||
293 (&
s->picture[
i] !=
s->last_picture_ptr &&
294 &
s->picture[
i] !=
s->next_picture_ptr &&
295 !
s->picture[
i].needs_realloc)) {
297 }
298 }
299
303
304 if (
s->current_picture_ptr && !
s->current_picture_ptr->f->buf[0]) {
305 // we already have an unused image
306 // (maybe it was set before reading the header)
307 pic =
s->current_picture_ptr;
308 } else {
310 if (idx < 0) {
312 return idx;
313 }
314 pic = &
s->picture[idx];
315 }
316
321 }
322
323 #if FF_API_FRAME_PICTURE_NUMBER
327 #endif
328
330 return -1;
331
332 s->current_picture_ptr = pic;
333 // FIXME use only the vars from current_pic
334 s->current_picture_ptr->f->top_field_first =
s->top_field_first;
338 s->current_picture_ptr->f->top_field_first =
340 }
341 s->current_picture_ptr->f->interlaced_frame = !
s->progressive_frame &&
342 !
s->progressive_sequence;
343 s->current_picture_ptr->field_picture =
s->picture_structure !=
PICT_FRAME;
344
345 s->current_picture_ptr->f->pict_type =
s->pict_type;
347
349 s->current_picture_ptr)) < 0)
351
353 s->last_picture_ptr =
s->next_picture_ptr;
355 s->next_picture_ptr =
s->current_picture_ptr;
356 }
357 ff_dlog(
s->avctx,
"L%p N%p C%p L%p N%p C%p type:%d drop:%d\n",
358 s->last_picture_ptr,
s->next_picture_ptr,
s->current_picture_ptr,
359 s->last_picture_ptr ?
s->last_picture_ptr->f->data[0] :
NULL,
360 s->next_picture_ptr ?
s->next_picture_ptr->f->data[0] :
NULL,
361 s->current_picture_ptr ?
s->current_picture_ptr->f->data[0] :
NULL,
362 s->pict_type,
s->droppable);
363
364 if ((!
s->last_picture_ptr || !
s->last_picture_ptr->f->buf[0]) &&
366 int h_chroma_shift, v_chroma_shift;
368 &h_chroma_shift, &v_chroma_shift);
371 "allocating dummy last picture for B frame\n");
374 "warning: first frame is no keyframe\n");
375
376 /* Allocate a dummy frame */
378 if (idx < 0) {
380 return idx;
381 }
382 s->last_picture_ptr = &
s->picture[idx];
383
384 s->last_picture_ptr->reference = 3;
385 s->last_picture_ptr->f->key_frame = 0;
387
389 s->last_picture_ptr =
NULL;
390 return -1;
391 }
392
395 memset(
s->last_picture_ptr->f->data[0] +
s->last_picture_ptr->f->linesize[0]*
i,
397 if (
s->last_picture_ptr->f->data[2]) {
399 memset(
s->last_picture_ptr->f->data[1] +
s->last_picture_ptr->f->linesize[1]*
i,
401 memset(
s->last_picture_ptr->f->data[2] +
s->last_picture_ptr->f->linesize[2]*
i,
403 }
404 }
405
408 memset(
s->last_picture_ptr->f->data[0] +
s->last_picture_ptr->f->linesize[0] *
i,
410 }
411 }
412
415 }
416 if ((!
s->next_picture_ptr || !
s->next_picture_ptr->f->buf[0]) &&
418 /* Allocate a dummy frame */
420 if (idx < 0) {
422 return idx;
423 }
424 s->next_picture_ptr = &
s->picture[idx];
425
426 s->next_picture_ptr->reference = 3;
427 s->next_picture_ptr->f->key_frame = 0;
429
431 s->next_picture_ptr =
NULL;
432 return -1;
433 }
436 }
437
438 #if 0 // BUFREF-FIXME
439 memset(
s->last_picture.f->data, 0,
sizeof(
s->last_picture.f->data));
440 memset(
s->next_picture.f->data, 0,
sizeof(
s->next_picture.f->data));
441 #endif
442 if (
s->last_picture_ptr) {
443 if (
s->last_picture_ptr->f->buf[0] &&
445 s->last_picture_ptr)) < 0)
447 }
448 if (
s->next_picture_ptr) {
449 if (
s->next_picture_ptr->f->buf[0] &&
451 s->next_picture_ptr)) < 0)
453 }
454
456 s->last_picture_ptr->f->buf[0]));
457
459 for (
int i = 0;
i < 4;
i++) {
461 s->current_picture.f->data[
i] =
FF_PTR_ADD(
s->current_picture.f->data[
i],
462 s->current_picture.f->linesize[
i]);
463 }
464 s->current_picture.f->linesize[
i] *= 2;
465 s->last_picture.f->linesize[
i] *= 2;
466 s->next_picture.f->linesize[
i] *= 2;
467 }
468 }
469
470 /* set dequantizer, we can't do it during init as
471 * it might change for MPEG-4 and we can't do it in the header
472 * decode as init is not called for MPEG-4 there yet */
474 s->dct_unquantize_intra =
s->dct_unquantize_mpeg2_intra;
475 s->dct_unquantize_inter =
s->dct_unquantize_mpeg2_inter;
477 s->dct_unquantize_intra =
s->dct_unquantize_h263_intra;
478 s->dct_unquantize_inter =
s->dct_unquantize_h263_inter;
479 } else {
480 s->dct_unquantize_intra =
s->dct_unquantize_mpeg1_intra;
481 s->dct_unquantize_inter =
s->dct_unquantize_mpeg1_inter;
482 }
483
486
487 return 0;
488 }
489
490 /* called after a frame has been decoded. */
492 {
493 emms_c();
494
495 if (
s->current_picture.reference)
497 }
498
500 {
503 s->mb_width,
s->mb_height,
s->mb_stride,
s->quarter_sample);
504 }
505
507 {
511
513 return 0;
514
516 if (!par)
518
524
529
531 }
532
533 return 0;
534 }
535
537 {
539 s->last_picture_ptr ?
s->last_picture_ptr->f :
NULL,
540 y,
h,
s->picture_structure,
541 s->first_field,
s->low_delay);
542 }
543
545 {
547
549 return;
550
553 s->current_picture_ptr =
s->last_picture_ptr =
s->next_picture_ptr =
NULL;
554
558
559 s->mb_x =
s->mb_y = 0;
560
561 s->bitstream_buffer_size = 0;
563 }
564
566 {
569 }
570
571
573 uint8_t *
dest,
const uint8_t *
src,
575 int src_x, int src_y,
579 int motion_x, int motion_y)
580 {
581 const int lowres =
s->avctx->lowres;
583 const int s_mask = (2 <<
lowres) - 1;
584 int emu = 0;
585 int sx, sy;
586
587 if (
s->quarter_sample) {
588 motion_x /= 2;
589 motion_y /= 2;
590 }
591
592 sx = motion_x & s_mask;
593 sy = motion_y & s_mask;
594 src_x += motion_x >>
lowres + 1;
595 src_y += motion_y >>
lowres + 1;
596
598
601 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer,
src,
602 s->linesize,
s->linesize,
603 w + 1, (
h + 1) << field_based,
604 src_x, src_y * (1 << field_based),
606 src =
s->sc.edge_emu_buffer;
607 emu = 1;
608 }
609
615 return emu;
616 }
617
618 /* apply one mpeg motion vector to the three components */
620 uint8_t *dest_y,
621 uint8_t *dest_cb,
622 uint8_t *dest_cr,
623 int field_based,
624 int bottom_field,
626 uint8_t *const *ref_picture,
628 int motion_x, int motion_y,
630 {
631 const uint8_t *ptr_y, *ptr_cb, *ptr_cr;
632 int mx, my, src_x, src_y, uvsrc_x, uvsrc_y, sx, sy, uvsx, uvsy;
634 const int lowres =
s->avctx->lowres;
635 const int op_index =
FFMIN(
lowres - 1 +
s->chroma_x_shift, 3);
636 const int block_s = 8 >>
lowres;
637 const int s_mask = (2 <<
lowres) - 1;
640 linesize =
s->current_picture.f->linesize[0] << field_based;
641 uvlinesize =
s->current_picture.f->linesize[1] << field_based;
642
643 // FIXME obviously not perfect but qpel will not work in lowres anyway
644 if (
s->quarter_sample) {
645 motion_x /= 2;
646 motion_y /= 2;
647 }
648
649 if (field_based) {
651 }
652
653 sx = motion_x & s_mask;
654 sy = motion_y & s_mask;
655 src_x =
s->mb_x * 2 * block_s + (motion_x >>
lowres + 1);
656 src_y = (
mb_y * 2 * block_s >> field_based) + (motion_y >>
lowres + 1);
657
659 uvsx = ((motion_x >> 1) & s_mask) | (sx & 1);
660 uvsy = ((motion_y >> 1) & s_mask) | (sy & 1);
661 uvsrc_x = src_x >> 1;
662 uvsrc_y = src_y >> 1;
664 // even chroma mv's are full pel in H261
665 mx = motion_x / 4;
666 my = motion_y / 4;
667 uvsx = (2 * mx) & s_mask;
668 uvsy = (2 * my) & s_mask;
669 uvsrc_x =
s->mb_x * block_s + (mx >>
lowres);
671 } else {
672 if (
s->chroma_y_shift) {
673 mx = motion_x / 2;
674 my = motion_y / 2;
675 uvsx = mx & s_mask;
676 uvsy = my & s_mask;
677 uvsrc_x =
s->mb_x * block_s + (mx >>
lowres + 1);
678 uvsrc_y = (
mb_y * block_s >> field_based) + (my >>
lowres + 1);
679 } else {
680 if (
s->chroma_x_shift) {
681 //Chroma422
682 mx = motion_x / 2;
683 uvsx = mx & s_mask;
684 uvsy = motion_y & s_mask;
685 uvsrc_y = src_y;
686 uvsrc_x =
s->mb_x*block_s + (mx >> (
lowres+1));
687 } else {
688 //Chroma444
689 uvsx = motion_x & s_mask;
690 uvsy = motion_y & s_mask;
691 uvsrc_x = src_x;
692 uvsrc_y = src_y;
693 }
694 }
695 }
696
697 ptr_y = ref_picture[0] + src_y *
linesize + src_x;
698 ptr_cb = ref_picture[1] + uvsrc_y *
uvlinesize + uvsrc_x;
699 ptr_cr = ref_picture[2] + uvsrc_y *
uvlinesize + uvsrc_x;
700
701 if ((
unsigned) src_x >
FFMAX(
h_edge_pos - (!!sx) - 2 * block_s, 0) || uvsrc_y<0 ||
703 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr_y,
705 17, 17 + field_based,
706 src_x, src_y * (1 << field_based),
h_edge_pos,
708 ptr_y =
s->sc.edge_emu_buffer;
710 uint8_t *ubuf =
s->sc.edge_emu_buffer + 18 *
s->linesize;
711 uint8_t *vbuf =ubuf + 10 *
s->uvlinesize;
713 vbuf -=
s->uvlinesize;
714 s->vdsp.emulated_edge_mc(ubuf, ptr_cb,
716 9, 9 + field_based,
717 uvsrc_x, uvsrc_y * (1 << field_based),
719 s->vdsp.emulated_edge_mc(vbuf, ptr_cr,
721 9, 9 + field_based,
722 uvsrc_x, uvsrc_y * (1 << field_based),
724 ptr_cb = ubuf;
725 ptr_cr = vbuf;
726 }
727 }
728
729 // FIXME use this for field pix too instead of the obnoxious hack which changes picture.f->data
730 if (bottom_field) {
731 dest_y +=
s->linesize;
732 dest_cb +=
s->uvlinesize;
733 dest_cr +=
s->uvlinesize;
734 }
735
737 ptr_y +=
s->linesize;
738 ptr_cb +=
s->uvlinesize;
739 ptr_cr +=
s->uvlinesize;
740 }
741
745
747 int hc =
s->chroma_y_shift ? (
h+1-bottom_field)>>1 :
h;
748 uvsx = (uvsx << 2) >>
lowres;
749 uvsy = (uvsy << 2) >>
lowres;
750 if (hc) {
751 pix_op[op_index](dest_cb, ptr_cb,
uvlinesize, hc, uvsx, uvsy);
752 pix_op[op_index](dest_cr, ptr_cr,
uvlinesize, hc, uvsx, uvsy);
753 }
754 }
755 // FIXME h261 lowres loop filter
756 }
757
759 uint8_t *dest_cb, uint8_t *dest_cr,
760 uint8_t *const *ref_picture,
762 int mx, int my)
763 {
764 const int lowres =
s->avctx->lowres;
766 const int block_s = 8 >>
lowres;
767 const int s_mask = (2 <<
lowres) - 1;
770 int emu = 0, src_x, src_y, sx, sy;
772 const uint8_t *ptr;
773
774 if (
s->quarter_sample) {
775 mx /= 2;
776 my /= 2;
777 }
778
779 /* In case of 8X8, we construct a single chroma motion vector
780 with a special rounding */
783
784 sx = mx & s_mask;
785 sy = my & s_mask;
786 src_x =
s->mb_x * block_s + (mx >>
lowres + 1);
787 src_y =
s->mb_y * block_s + (my >>
lowres + 1);
788
789 offset = src_y *
s->uvlinesize + src_x;
790 ptr = ref_picture[1] +
offset;
793 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
794 s->uvlinesize,
s->uvlinesize,
795 9, 9,
797 ptr =
s->sc.edge_emu_buffer;
798 emu = 1;
799 }
802 pix_op[op_index](dest_cb, ptr,
s->uvlinesize, block_s, sx, sy);
803
804 ptr = ref_picture[2] +
offset;
805 if (emu) {
806 s->vdsp.emulated_edge_mc(
s->sc.edge_emu_buffer, ptr,
807 s->uvlinesize,
s->uvlinesize,
808 9, 9,
810 ptr =
s->sc.edge_emu_buffer;
811 }
812 pix_op[op_index](dest_cr, ptr,
s->uvlinesize, block_s, sx, sy);
813 }
814
815 /**
816 * motion compensation of a single macroblock
817 * @param s context
818 * @param dest_y luma destination pointer
819 * @param dest_cb chroma cb/u destination pointer
820 * @param dest_cr chroma cr/v destination pointer
821 * @param dir direction (0->forward, 1->backward)
822 * @param ref_picture array[3] of pointers to the 3 planes of the reference picture
823 * @param pix_op halfpel motion compensation function (average or put normally)
824 * the motion vectors are taken from s->mv and the MV type from s->mv_type
825 */
827 uint8_t *dest_y, uint8_t *dest_cb,
828 uint8_t *dest_cr,
829 int dir, uint8_t *const *ref_picture,
831 {
832 int mx, my;
834 const int lowres =
s->avctx->lowres;
835 const int block_s = 8 >>
lowres;
836
839
840 switch (
s->mv_type) {
843 0, 0, 0,
844 ref_picture, pix_op,
845 s->mv[dir][0][0],
s->mv[dir][0][1],
847 break;
849 mx = 0;
850 my = 0;
851 for (
int i = 0;
i < 4;
i++) {
853 s->linesize) * block_s,
854 ref_picture[0], 0, 0,
855 (2 *
mb_x + (
i & 1)) * block_s,
856 (2 *
mb_y + (
i >> 1)) * block_s,
857 s->width,
s->height,
s->linesize,
859 block_s, block_s, pix_op,
860 s->mv[dir][
i][0],
s->mv[dir][
i][1]);
861
862 mx +=
s->mv[dir][
i][0];
863 my +=
s->mv[dir][
i][1];
864 }
865
868 pix_op, mx, my);
869 break;
872 /* top field */
874 1, 0,
s->field_select[dir][0],
875 ref_picture, pix_op,
876 s->mv[dir][0][0],
s->mv[dir][0][1],
878 /* bottom field */
880 1, 1,
s->field_select[dir][1],
881 ref_picture, pix_op,
882 s->mv[dir][1][0],
s->mv[dir][1][1],
884 } else {
885 if (
s->picture_structure !=
s->field_select[dir][0] + 1 &&
887 ref_picture =
s->current_picture_ptr->f->data;
888
889 }
891 0, 0,
s->field_select[dir][0],
892 ref_picture, pix_op,
894 s->mv[dir][0][1], 2 * block_s,
mb_y >> 1);
895 }
896 break;
898 for (
int i = 0;
i < 2;
i++) {
899 uint8_t *const *ref2picture;
900
901 if (
s->picture_structure ==
s->field_select[dir][
i] + 1 ||
903 ref2picture = ref_picture;
904 } else {
905 ref2picture =
s->current_picture_ptr->f->data;
906 }
907
909 0, 0,
s->field_select[dir][
i],
910 ref2picture, pix_op,
911 s->mv[dir][
i][0],
s->mv[dir][
i][1] +
912 2 * block_s *
i, block_s,
mb_y >> 1);
913
914 dest_y += 2 * block_s *
s->linesize;
915 dest_cb += (2 * block_s >>
s->chroma_y_shift) *
s->uvlinesize;
916 dest_cr += (2 * block_s >>
s->chroma_y_shift) *
s->uvlinesize;
917 }
918 break;
921 for (
int i = 0;
i < 2;
i++) {
922 for (int j = 0; j < 2; j++) {
925 ref_picture, pix_op,
926 s->mv[dir][2 *
i + j][0],
927 s->mv[dir][2 *
i + j][1],
929 }
930 pix_op =
s->h264chroma.avg_h264_chroma_pixels_tab;
931 }
932 } else {
933 for (
int i = 0;
i < 2;
i++) {
935 0, 0,
s->picture_structure !=
i + 1,
936 ref_picture, pix_op,
937 s->mv[dir][2 *
i][0],
s->mv[dir][2 *
i][1],
938 2 * block_s,
mb_y >> 1);
939
940 // after put we make avg of the same block
941 pix_op =
s->h264chroma.avg_h264_chroma_pixels_tab;
942
943 // opposite parity is always in the same
944 // frame if this is second field
945 if (!
s->first_field) {
946 ref_picture =
s->current_picture_ptr->f->data;
947 }
948 }
949 }
950 break;
951 default:
953 }
954 }
955
956 /**
957 * find the lowest MB row referenced in the MVs
958 */
960 {
961 int my_max = INT_MIN, my_min = INT_MAX, qpel_shift = !
s->quarter_sample;
962 int off, mvs;
963
965 goto unhandled;
966
967 switch (
s->mv_type) {
969 mvs = 1;
970 break;
972 mvs = 2;
973 break;
975 mvs = 4;
976 break;
977 default:
978 goto unhandled;
979 }
980
981 for (
int i = 0;
i < mvs;
i++) {
982 int my =
s->mv[dir][
i][1];
983 my_max =
FFMAX(my_max, my);
984 my_min =
FFMIN(my_min, my);
985 }
986
987 off = ((
FFMAX(-my_min, my_max) << qpel_shift) + 63) >> 6;
988
989 return av_clip(
s->mb_y + off, 0,
s->mb_height - 1);
990 unhandled:
991 return s->mb_height - 1;
992 }
993
994 /* add block[] to dest[] */
996 int16_t *
block,
int i, uint8_t *
dest,
int line_size)
997 {
998 if (
s->block_last_index[
i] >= 0) {
1000 }
1001 }
1002
1003 #define IS_ENCODER 0
1005
1007 {
1009 /* print DCT coefficients */
1011 for (
int i = 0;
i < 6;
i++) {
1012 for (int j = 0; j < 64; j++) {
1014 block[
i][
s->idsp.idct_permutation[j]]);
1015 }
1017 }
1018 }
1019
1020 if (!
s->avctx->lowres) {
1021 #if !CONFIG_SMALL
1024 else
1026 #else
1028 #endif
1029 } else
1031 }