38 int poc,
int poc1,
int i)
41 int64_t pocdiff = poc1 - (int64_t)poc0;
44 if (pocdiff != (
int)pocdiff)
50 int64_t pocdiff0 = poc - (int64_t)poc0;
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;
140 if (
h->current_slice == 0) {
152 int cur_poc =
h->cur_pic_ptr->poc;
154 if (col_poc[0] == INT_MAX && col_poc[1] == INT_MAX) {
159 FFABS(col_poc[1] - (int64_t)cur_poc));
183 int ref_field =
ref->reference - 1;
184 int ref_field_picture =
ref->parent->field_picture;
185 int ref_height = 16 *
h->mb_height >> ref_field_picture;
194 FFMIN(16 * mb_y >> ref_field_picture,
196 ref_field_picture && ref_field);
203 int b4_stride =
h->b_stride;
206 const int16_t (*l1mv0)[2], (*l1mv1)[2];
207 const int8_t *l1ref0, *l1ref1;
208 const int is_b8x8 =
IS_8X8(*mb_type);
220 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
221 MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
242 int match_count = (left_ref ==
ref[
list]) +
246 if (match_count > 1) {
250 assert(match_count == 1);
268 if (
ref[0] < 0 &&
ref[1] < 0) {
275 if (!(is_b8x8 |
mv[0] |
mv[1])) {
299 mb_y = sl->
mb_y & ~1;
300 mb_xy = (sl->
mb_y & ~1) *
h->mb_stride + sl->
mb_x;
303 b8_stride = 2 + 4 *
h->mb_stride;
327 }
else if (!is_b8x8 &&
332 if (!
h->ps.sps->direct_8x8_inference_flag) {
352 l1mv0 += 2 * b4_stride;
353 l1mv1 += 2 * b4_stride;
359 for (i8 = 0; i8 < 4; i8++) {
362 int xy8 = x8 + y8 * b8_stride;
363 int xy4 = x8 * 3 + y8 * b4_stride;
375 ((l1ref0[xy8] == 0 &&
376 FFABS(l1mv0[xy4][0]) <= 1 &&
377 FFABS(l1mv0[xy4][1]) <= 1) ||
380 FFABS(l1mv1[xy4][0]) <= 1 &&
381 FFABS(l1mv1[xy4][1]) <= 1))) {
396 if (!is_b8x8 && !(n & 3))
407 FFABS(l1mv0[0][0]) <= 1 &&
408 FFABS(l1mv0[0][1]) <= 1) ||
409 (l1ref0[0] < 0 && !l1ref1[0] &&
410 FFABS(l1mv1[0][0]) <= 1 &&
411 FFABS(l1mv1[0][1]) <= 1 &&
412 h->x264_build > 33
U))) {
426 for (i8 = 0; i8 < 4; i8++) {
427 const int x8 = i8 & 1;
428 const int y8 = i8 >> 1;
441 assert(b8_stride == 2);
447 h->x264_build > 33
U))) {
448 const int16_t (*l1mv)[2] = l1ref0[i8] == 0 ? l1mv0 : l1mv1;
450 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
451 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
462 for (i4 = 0; i4 < 4; i4++) {
463 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
464 (y8 * 2 + (i4 >> 1)) * b4_stride];
465 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
479 if (!is_b8x8 && !(n & 15))
490 int b4_stride =
h->b_stride;
493 const int16_t (*l1mv0)[2], (*l1mv1)[2];
494 const int8_t *l1ref0, *l1ref1;
495 const int is_b8x8 =
IS_8X8(*mb_type);
496 unsigned int sub_mb_type;
517 mb_y = sl->
mb_y & ~1;
518 mb_xy = sl->
mb_x + (sl->
mb_y & ~1) *
h->mb_stride;
521 b8_stride = 2 + 4 *
h->mb_stride;
550 }
else if (!is_b8x8 &&
555 if (!
h->ps.sps->direct_8x8_inference_flag) {
576 l1mv0 += 2 * b4_stride;
577 l1mv1 += 2 * b4_stride;
596 assert(
h->ps.sps->direct_8x8_inference_flag);
598 for (i8 = 0; i8 < 4; i8++) {
599 const int x8 = i8 & 1;
600 const int y8 = i8 >> 1;
602 const int16_t (*l1mv)[2] = l1mv0;
616 ref0 = l1ref0[x8 + y8 * b8_stride];
618 ref0 = map_col_to_list0[0][ref0 + ref_offset];
620 ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
624 scale = dist_scale_factor[ref0];
629 const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
630 int my_col = (mv_col[1] * (1 << y_shift)) / 2;
631 int mx = (
scale * mv_col[0] + 128) >> 8;
632 int my = (
scale * my_col + 128) >> 8;
651 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
652 : map_col_to_list0[1][l1ref1[0] + ref_offset];
653 const int scale = dist_scale_factor[ref0];
654 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
656 mv_l0[0] = (
scale * mv_col[0] + 128) >> 8;
657 mv_l0[1] = (
scale * mv_col[1] + 128) >> 8;
660 mv1 =
pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
666 for (i8 = 0; i8 < 4; i8++) {
667 const int x8 = i8 & 1;
668 const int y8 = i8 >> 1;
670 const int16_t (*l1mv)[2] = l1mv0;
683 assert(b8_stride == 2);
686 ref0 = map_col_to_list0[0][ref0 + ref_offset];
688 ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
691 scale = dist_scale_factor[ref0];
696 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
697 int mx = (
scale * mv_col[0] + 128) >> 8;
698 int my = (
scale * mv_col[1] + 128) >> 8;
702 pack16to32(mx - mv_col[0], my - mv_col[1]), 4);
704 for (i4 = 0; i4 < 4; i4++) {
705 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
706 (y8 * 2 + (i4 >> 1)) * b4_stride];
708 mv_l0[0] = (
scale * mv_col[0] + 128) >> 8;
709 mv_l0[1] = (
scale * mv_col[1] + 128) >> 8;
712 mv_l0[1] - mv_col[1]));