39 int poc,
int poc1,
int i)
42 int64_t pocdiff = poc1 - (int64_t)poc0;
43 int td = av_clip_int8(pocdiff);
45 if (pocdiff != (
int)pocdiff)
51 int64_t pocdiff0 = poc - (int64_t)poc0;
52 int tb = av_clip_int8(pocdiff0);
55 if (pocdiff0 != (
int)pocdiff0)
58 return av_clip_intp2((
tb * tx + 32) >> 6, 10);
66 :
h->cur_pic_ptr->poc;
72 const int poc =
h->cur_pic_ptr->field_poc[
field];
85 int field,
int colfield,
int mbafi)
88 int j, old_ref, rfield;
89 int start = mbafi ? 16 : 0;
91 int interl = mbafi ||
h->picture_structure !=
PICT_FRAME;
96 for (rfield = 0; rfield < 2; rfield++) {
97 for (old_ref = 0; old_ref < ref1->
ref_count[colfield][
list]; old_ref++) {
103 else if (interl && (poc & 3) == 3)
104 poc = (poc & ~3) + rfield + 1;
106 for (j = start; j <
end; j++) {
109 int cur_ref = mbafi ? (j - 16) ^
field : j;
111 map[
list][2 * old_ref + (rfield ^
field) + 16] = cur_ref;
112 if (rfield ==
field || !interl)
126 int sidx = (
h->picture_structure & 1) ^ 1;
127 int ref1sidx = (ref1->
reference & 1) ^ 1;
141 if (
h->current_slice == 0) {
153 int cur_poc =
h->cur_pic_ptr->poc;
155 if (col_poc[0] == INT_MAX && col_poc[1] == INT_MAX) {
160 FFABS(col_poc[1] - (int64_t)cur_poc));
184 int ref_field =
ref->reference - 1;
185 int ref_field_picture =
ref->parent->field_picture;
186 int ref_height = 16 *
h->mb_height >> ref_field_picture;
195 FFMIN(16 * mb_y >> ref_field_picture,
197 ref_field_picture && ref_field);
204 int b4_stride =
h->b_stride;
207 const int16_t (*l1mv0)[2], (*l1mv1)[2];
208 const int8_t *l1ref0, *l1ref1;
209 const int is_b8x8 =
IS_8X8(*mb_type);
221 #define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16 | MB_TYPE_INTRA4x4 | \
222 MB_TYPE_INTRA16x16 | MB_TYPE_INTRA_PCM)
243 int match_count = (left_ref ==
ref[
list]) +
247 if (match_count > 1) {
251 assert(match_count == 1);
269 if (
ref[0] < 0 &&
ref[1] < 0) {
276 if (!(is_b8x8 |
mv[0] |
mv[1])) {
300 mb_y = sl->
mb_y & ~1;
301 mb_xy = (sl->
mb_y & ~1) *
h->mb_stride + sl->
mb_x;
304 b8_stride = 2 + 4 *
h->mb_stride;
328 }
else if (!is_b8x8 &&
333 if (!
h->ps.sps->direct_8x8_inference_flag) {
353 l1mv0 += 2 * b4_stride;
354 l1mv1 += 2 * b4_stride;
360 for (i8 = 0; i8 < 4; i8++) {
363 int xy8 = x8 + y8 * b8_stride;
364 int xy4 = x8 * 3 + y8 * b4_stride;
376 ((l1ref0[xy8] == 0 &&
377 FFABS(l1mv0[xy4][0]) <= 1 &&
378 FFABS(l1mv0[xy4][1]) <= 1) ||
381 FFABS(l1mv1[xy4][0]) <= 1 &&
382 FFABS(l1mv1[xy4][1]) <= 1))) {
397 if (!is_b8x8 && !(n & 3))
408 FFABS(l1mv0[0][0]) <= 1 &&
409 FFABS(l1mv0[0][1]) <= 1) ||
410 (l1ref0[0] < 0 && !l1ref1[0] &&
411 FFABS(l1mv1[0][0]) <= 1 &&
412 FFABS(l1mv1[0][1]) <= 1 &&
413 h->x264_build > 33
U))) {
427 for (i8 = 0; i8 < 4; i8++) {
428 const int x8 = i8 & 1;
429 const int y8 = i8 >> 1;
442 assert(b8_stride == 2);
448 h->x264_build > 33
U))) {
449 const int16_t (*l1mv)[2] = l1ref0[i8] == 0 ? l1mv0 : l1mv1;
451 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
452 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
463 for (i4 = 0; i4 < 4; i4++) {
464 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
465 (y8 * 2 + (i4 >> 1)) * b4_stride];
466 if (
FFABS(mv_col[0]) <= 1 &&
FFABS(mv_col[1]) <= 1) {
480 if (!is_b8x8 && !(n & 15))
491 int b4_stride =
h->b_stride;
494 const int16_t (*l1mv0)[2], (*l1mv1)[2];
495 const int8_t *l1ref0, *l1ref1;
496 const int is_b8x8 =
IS_8X8(*mb_type);
497 unsigned int sub_mb_type;
518 mb_y = sl->
mb_y & ~1;
519 mb_xy = sl->
mb_x + (sl->
mb_y & ~1) *
h->mb_stride;
522 b8_stride = 2 + 4 *
h->mb_stride;
551 }
else if (!is_b8x8 &&
556 if (!
h->ps.sps->direct_8x8_inference_flag) {
577 l1mv0 += 2 * b4_stride;
578 l1mv1 += 2 * b4_stride;
597 assert(
h->ps.sps->direct_8x8_inference_flag);
599 for (i8 = 0; i8 < 4; i8++) {
600 const int x8 = i8 & 1;
601 const int y8 = i8 >> 1;
603 const int16_t (*l1mv)[2] = l1mv0;
617 ref0 = l1ref0[x8 + y8 * b8_stride];
619 ref0 = map_col_to_list0[0][ref0 + ref_offset];
621 ref0 = map_col_to_list0[1][l1ref1[x8 + y8 * b8_stride] +
625 scale = dist_scale_factor[ref0];
630 const int16_t *mv_col = l1mv[x8 * 3 + y8 * b4_stride];
631 int my_col = (mv_col[1] * (1 << y_shift)) / 2;
632 int mx = (scale * mv_col[0] + 128) >> 8;
633 int my = (scale * my_col + 128) >> 8;
652 const int ref0 = l1ref0[0] >= 0 ? map_col_to_list0[0][l1ref0[0] + ref_offset]
653 : map_col_to_list0[1][l1ref1[0] + ref_offset];
654 const int scale = dist_scale_factor[ref0];
655 const int16_t *mv_col = l1ref0[0] >= 0 ? l1mv0[0] : l1mv1[0];
657 mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
658 mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
661 mv1 =
pack16to32(mv_l0[0] - mv_col[0], mv_l0[1] - mv_col[1]);
667 for (i8 = 0; i8 < 4; i8++) {
668 const int x8 = i8 & 1;
669 const int y8 = i8 >> 1;
671 const int16_t (*l1mv)[2] = l1mv0;
684 assert(b8_stride == 2);
687 ref0 = map_col_to_list0[0][ref0 + ref_offset];
689 ref0 = map_col_to_list0[1][l1ref1[i8] + ref_offset];
692 scale = dist_scale_factor[ref0];
697 const int16_t *mv_col = l1mv[x8 * 3 + y8 * 3 * b4_stride];
698 int mx = (scale * mv_col[0] + 128) >> 8;
699 int my = (scale * mv_col[1] + 128) >> 8;
703 pack16to32(mx - mv_col[0], my - mv_col[1]), 4);
705 for (i4 = 0; i4 < 4; i4++) {
706 const int16_t *mv_col = l1mv[x8 * 2 + (i4 & 1) +
707 (y8 * 2 + (i4 >> 1)) * b4_stride];
709 mv_l0[0] = (scale * mv_col[0] + 128) >> 8;
710 mv_l0[1] = (scale * mv_col[1] + 128) >> 8;
713 mv_l0[1] - mv_col[1]));