38 int poc,
int poc1,
int i)
44 if (pocdiff != (
int)pocdiff)
52 int tx = (16384 + (
FFABS(td) >> 1)) / td;
54 if (pocdiff0 != (
int)pocdiff0)
65 :
h->cur_pic_ptr->poc;
71 const int poc =
h->cur_pic_ptr->field_poc[
field];
84 int field,
int colfield,
int mbafi)
87 int j, old_ref, rfield;
88 int start = mbafi ? 16 : 0;
90 int interl = mbafi ||
h->picture_structure !=
PICT_FRAME;
95 for (rfield = 0; rfield < 2; rfield++) {
96 for (old_ref = 0; old_ref < ref1->
ref_count[colfield][
list]; old_ref++) {
102 else if (interl && (poc & 3) == 3)
103 poc = (poc & ~3) + rfield + 1;
105 for (j = start; j < end; j++) {
108 int cur_ref = mbafi ? (j - 16) ^
field : j;
110 map[
list][2 * old_ref + (rfield ^
field) + 16] = cur_ref;
111 if (rfield ==
field || !interl)
125 int sidx = (
h->picture_structure & 1) ^ 1;
126 int ref1sidx = (ref1->
reference & 1) ^ 1;
130 if (!
h->setup_finished) {
143 if (
h->current_slice == 0) {
156 int cur_poc =
h->cur_pic_ptr->poc;
158 if (col_poc[0] == INT_MAX && col_poc[1] == INT_MAX) {
190 int ref_field =
ref->reference - 1;
191 int ref_field_picture =
ref->parent->field_picture;
192 int ref_height = 16 *
h->mb_height >> ref_field_picture;
193 int row =
FFMIN(16 * mb_y >> ref_field_picture, ref_height - 1);
199 ref_field_picture && ref_field);
212 int b4_stride =
h->b_stride;
215 const int16_t (*l1mv0)[2], (*l1mv1)[2];
216 const int8_t *l1ref0, *l1ref1;
217 const int is_b8x8 =
IS_8X8(*mb_type);
229 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
230 MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
251 int match_count = (left_ref ==
ref[
list]) +
255 if (match_count > 1) {
259 assert(match_count == 1);
277 if (
ref[0] < 0 &&
ref[1] < 0) {
284 if (!(is_b8x8 |
mv[0] |
mv[1])) {
308 mb_y = sl->
mb_y & ~1;
309 mb_xy = (sl->
mb_y & ~1) *
h->mb_stride + sl->
mb_x;
312 b8_stride = 2 + 4 *
h->mb_stride;
336 }
else if (!is_b8x8 &&
341 if (!
h->ps.sps->direct_8x8_inference_flag) {
361 l1mv0 += 2 * b4_stride;
362 l1mv1 += 2 * b4_stride;
368 for (i8 = 0; i8 < 4; i8++) {
371 int xy8 = x8 + y8 * b8_stride;
372 int xy4 = x8 * 3 + y8 * b4_stride;
384 ((l1ref0[xy8] == 0 &&
385 FFABS(l1mv0[xy4][0]) <= 1 &&
386 FFABS(l1mv0[xy4][1]) <= 1) ||
389 FFABS(l1mv1[xy4][0]) <= 1 &&
390 FFABS(l1mv1[xy4][1]) <= 1))) {
405 if (!is_b8x8 && !(n & 3))
416 FFABS(l1mv0[0][0]) <= 1 &&
417 FFABS(l1mv0[0][1]) <= 1) ||
418 (l1ref0[0] < 0 && !l1ref1[0] &&
419 FFABS(l1mv1[0][0]) <= 1 &&
420 FFABS(l1mv1[0][1]) <= 1 &&
421 h->x264_build > 33
U))) {
435 for (i8 = 0; i8 < 4; i8++) {
436 const int x8 = i8 & 1;
437 const int y8 = i8 >> 1;
450 assert(b8_stride == 2);
456 h->x264_build > 33
U))) {
457 const int16_t (*l1mv)[2] = l1ref0[i8] == 0 ? l1mv0 : l1mv1;
459 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
460 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
471 for (i4 = 0; i4 < 4; i4++) {
472 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
473 (y8 * 2 + (i4 >> 1)) * b4_stride];
474 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
488 if (!is_b8x8 && !(n & 15))
499 int b4_stride =
h->b_stride;
502 const int16_t (*l1mv0)[2], (*l1mv1)[2];
503 const int8_t *l1ref0, *l1ref1;
504 const int is_b8x8 =
IS_8X8(*mb_type);
505 unsigned int sub_mb_type;
526 mb_y = sl->
mb_y & ~1;
527 mb_xy = sl->
mb_x + (sl->
mb_y & ~1) *
h->mb_stride;
530 b8_stride = 2 + 4 *
h->mb_stride;
559 }
else if (!is_b8x8 &&
564 if (!
h->ps.sps->direct_8x8_inference_flag) {
585 l1mv0 += 2 * b4_stride;
586 l1mv1 += 2 * b4_stride;
605 assert(
h->ps.sps->direct_8x8_inference_flag);
607 for (i8 = 0; i8 < 4; i8++) {
608 const int x8 = i8 & 1;
609 const int y8 = i8 >> 1;
611 const int16_t (*l1mv)[2] = l1mv0;
625 ref0 = l1ref0[x8 + y8 * b8_stride];
627 ref0 = map_col_to_list0[0][ref0 + ref_offset];
629 ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
633 scale = dist_scale_factor[ref0];
638 const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
639 int my_col = (mv_col[1] * (1 << y_shift)) / 2;
640 int mx = (
scale * mv_col[0] + 128) >> 8;
641 int my = (
scale * my_col + 128) >> 8;
660 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
661 : map_col_to_list0[1][l1ref1[0] + ref_offset];
662 const int scale = dist_scale_factor[ref0];
663 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
665 mv_l0[0] = (
scale * mv_col[0] + 128) >> 8;
666 mv_l0[1] = (
scale * mv_col[1] + 128) >> 8;
669 mv1 =
pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
675 for (i8 = 0; i8 < 4; i8++) {
676 const int x8 = i8 & 1;
677 const int y8 = i8 >> 1;
679 const int16_t (*l1mv)[2] = l1mv0;
692 assert(b8_stride == 2);
695 ref0 = map_col_to_list0[0][ref0 + ref_offset];
697 ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
700 scale = dist_scale_factor[ref0];
705 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
706 int mx = (
scale * mv_col[0] + 128) >> 8;
707 int my = (
scale * mv_col[1] + 128) >> 8;
713 for (i4 = 0; i4 < 4; i4++) {
714 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
715 (y8 * 2 + (i4 >> 1)) * b4_stride];
717 mv_l0[0] = (
scale * mv_col[0] + 128) >> 8;
718 mv_l0[1] = (
scale * mv_col[1] + 128) >> 8;
721 mv_l0[1] - mv_col[1]));