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) {
187 int ref_field =
ref->reference - 1;
188 int ref_field_picture =
ref->parent->field_picture;
189 int ref_height = 16 *
h->mb_height >> ref_field_picture;
198 FFMIN(16 * mb_y >> ref_field_picture,
200 ref_field_picture && ref_field);
207 int b4_stride =
h->b_stride;
210 const int16_t (*l1mv0)[2], (*l1mv1)[2];
211 const int8_t *l1ref0, *l1ref1;
212 const int is_b8x8 =
IS_8X8(*mb_type);
224 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
225 MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
246 int match_count = (left_ref ==
ref[
list]) +
250 if (match_count > 1) {
254 assert(match_count == 1);
272 if (
ref[0] < 0 &&
ref[1] < 0) {
279 if (!(is_b8x8 |
mv[0] |
mv[1])) {
303 mb_y = sl->
mb_y & ~1;
304 mb_xy = (sl->
mb_y & ~1) *
h->mb_stride + sl->
mb_x;
307 b8_stride = 2 + 4 *
h->mb_stride;
331 }
else if (!is_b8x8 &&
336 if (!
h->ps.sps->direct_8x8_inference_flag) {
356 l1mv0 += 2 * b4_stride;
357 l1mv1 += 2 * b4_stride;
363 for (i8 = 0; i8 < 4; i8++) {
366 int xy8 = x8 + y8 * b8_stride;
367 int xy4 = x8 * 3 + y8 * b4_stride;
379 ((l1ref0[xy8] == 0 &&
380 FFABS(l1mv0[xy4][0]) <= 1 &&
381 FFABS(l1mv0[xy4][1]) <= 1) ||
384 FFABS(l1mv1[xy4][0]) <= 1 &&
385 FFABS(l1mv1[xy4][1]) <= 1))) {
400 if (!is_b8x8 && !(n & 3))
411 FFABS(l1mv0[0][0]) <= 1 &&
412 FFABS(l1mv0[0][1]) <= 1) ||
413 (l1ref0[0] < 0 && !l1ref1[0] &&
414 FFABS(l1mv1[0][0]) <= 1 &&
415 FFABS(l1mv1[0][1]) <= 1 &&
416 h->x264_build > 33
U))) {
430 for (i8 = 0; i8 < 4; i8++) {
431 const int x8 = i8 & 1;
432 const int y8 = i8 >> 1;
445 assert(b8_stride == 2);
451 h->x264_build > 33
U))) {
452 const int16_t (*l1mv)[2] = l1ref0[i8] == 0 ? l1mv0 : l1mv1;
454 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
455 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
466 for (i4 = 0; i4 < 4; i4++) {
467 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
468 (y8 * 2 + (i4 >> 1)) * b4_stride];
469 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
483 if (!is_b8x8 && !(n & 15))
494 int b4_stride =
h->b_stride;
497 const int16_t (*l1mv0)[2], (*l1mv1)[2];
498 const int8_t *l1ref0, *l1ref1;
499 const int is_b8x8 =
IS_8X8(*mb_type);
500 unsigned int sub_mb_type;
521 mb_y = sl->
mb_y & ~1;
522 mb_xy = sl->
mb_x + (sl->
mb_y & ~1) *
h->mb_stride;
525 b8_stride = 2 + 4 *
h->mb_stride;
554 }
else if (!is_b8x8 &&
559 if (!
h->ps.sps->direct_8x8_inference_flag) {
580 l1mv0 += 2 * b4_stride;
581 l1mv1 += 2 * b4_stride;
600 assert(
h->ps.sps->direct_8x8_inference_flag);
602 for (i8 = 0; i8 < 4; i8++) {
603 const int x8 = i8 & 1;
604 const int y8 = i8 >> 1;
606 const int16_t (*l1mv)[2] = l1mv0;
620 ref0 = l1ref0[x8 + y8 * b8_stride];
622 ref0 = map_col_to_list0[0][ref0 + ref_offset];
624 ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
628 scale = dist_scale_factor[ref0];
633 const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
634 int my_col = (mv_col[1] * (1 << y_shift)) / 2;
635 int mx = (
scale * mv_col[0] + 128) >> 8;
636 int my = (
scale * my_col + 128) >> 8;
655 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
656 : map_col_to_list0[1][l1ref1[0] + ref_offset];
657 const int scale = dist_scale_factor[ref0];
658 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
660 mv_l0[0] = (
scale * mv_col[0] + 128) >> 8;
661 mv_l0[1] = (
scale * mv_col[1] + 128) >> 8;
664 mv1 =
pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
670 for (i8 = 0; i8 < 4; i8++) {
671 const int x8 = i8 & 1;
672 const int y8 = i8 >> 1;
674 const int16_t (*l1mv)[2] = l1mv0;
687 assert(b8_stride == 2);
690 ref0 = map_col_to_list0[0][ref0 + ref_offset];
692 ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
695 scale = dist_scale_factor[ref0];
700 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
701 int mx = (
scale * mv_col[0] + 128) >> 8;
702 int my = (
scale * mv_col[1] + 128) >> 8;
708 for (i4 = 0; i4 < 4; i4++) {
709 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
710 (y8 * 2 + (i4 >> 1)) * b4_stride];
712 mv_l0[0] = (
scale * mv_col[0] + 128) >> 8;
713 mv_l0[1] = (
scale * mv_col[1] + 128) >> 8;
716 mv_l0[1] - mv_col[1]));