38 int scaledvalue, refdist;
39 int scalesame1, scalesame2;
40 int scalezone1_x, zone1offset_x;
57 if (
FFABS(n) < scalezone1_x)
58 scaledvalue = (n * scalesame1) >> 8;
61 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x;
63 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x;
71 int scaledvalue, refdist;
72 int scalesame1, scalesame2;
73 int scalezone1_y, zone1offset_y;
90 if (
FFABS(n) < scalezone1_y)
91 scaledvalue = (n * scalesame1) >> 8;
94 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y;
96 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y;
108 int scalezone1_x, zone1offset_x;
109 int scaleopp1, scaleopp2, brfd;
121 if (
FFABS(n) < scalezone1_x)
122 scaledvalue = (n * scaleopp1) >> 8;
125 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x;
127 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x;
135 int scalezone1_y, zone1offset_y;
136 int scaleopp1, scaleopp2, brfd;
148 if (
FFABS(n) < scalezone1_y)
149 scaledvalue = (n * scaleopp1) >> 8;
152 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y;
154 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y;
181 n = (n * scalesame >> 8) << hpel;
188 int refdist, scaleopp;
205 n = (n * scaleopp >> 8) << hpel;
212 int mv1,
int r_x,
int r_y,
uint8_t* is_intra,
213 int pred_flag,
int dir)
216 int xy,
wrap, off = 0;
220 int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
221 int opposite, a_f, b_f, c_f;
222 int16_t field_predA[2];
223 int16_t field_predB[2];
224 int16_t field_predC[2];
225 int a_valid, b_valid, c_valid;
226 int hybridmv_thresh, y_bias = 0;
274 off = (s->
mb_x > 0) ? -1 : 1;
289 b_valid = a_valid && (s->
mb_width > 1);
290 c_valid = s->
mb_x || (n == 1 || n == 3);
292 a_valid = a_valid && !is_intra[xy -
wrap];
293 b_valid = b_valid && !is_intra[xy - wrap + off];
294 c_valid = c_valid && !is_intra[xy - 1];
300 num_samefield += 1 - a_f;
301 field_predA[0] = A[0];
302 field_predA[1] = A[1];
304 field_predA[0] = field_predA[1] = 0;
310 num_samefield += 1 - b_f;
311 field_predB[0] = B[0];
312 field_predB[1] = B[1];
314 field_predB[0] = field_predB[1] = 0;
320 num_samefield += 1 - c_f;
321 field_predC[0] = C[0];
322 field_predC[1] = C[1];
324 field_predC[0] = field_predC[1] = 0;
334 if (num_samefield <= num_oppfield)
335 opposite = 1 - pred_flag;
337 opposite = pred_flag;
342 if (a_valid && !a_f) {
343 field_predA[0] =
scaleforopp(v, field_predA[0], 0, dir);
344 field_predA[1] =
scaleforopp(v, field_predA[1], 1, dir);
346 if (b_valid && !b_f) {
347 field_predB[0] =
scaleforopp(v, field_predB[0], 0, dir);
348 field_predB[1] =
scaleforopp(v, field_predB[1], 1, dir);
350 if (c_valid && !c_f) {
351 field_predC[0] =
scaleforopp(v, field_predC[0], 0, dir);
352 field_predC[1] =
scaleforopp(v, field_predC[1], 1, dir);
357 if (a_valid && a_f) {
358 field_predA[0] =
scaleforsame(v, n, field_predA[0], 0, dir);
359 field_predA[1] =
scaleforsame(v, n, field_predA[1], 1, dir);
361 if (b_valid && b_f) {
362 field_predB[0] =
scaleforsame(v, n, field_predB[0], 0, dir);
363 field_predB[1] =
scaleforsame(v, n, field_predB[1], 1, dir);
365 if (c_valid && c_f) {
366 field_predC[0] =
scaleforsame(v, n, field_predC[0], 0, dir);
367 field_predC[1] =
scaleforsame(v, n, field_predC[1], 1, dir);
376 }
else if (c_valid) {
379 }
else if (b_valid) {
387 if (num_samefield + num_oppfield > 1) {
388 px =
mid_pred(field_predA[0], field_predB[0], field_predC[0]);
389 py =
mid_pred(field_predA[1], field_predB[1], field_predC[1]);
395 qx = (s->
mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0);
396 qy = (s->
mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0);
400 if (qx + px < -60) px = -60 - qx;
401 if (qy + py < -60) py = -60 - qy;
403 if (qx + px < -28) px = -28 - qx;
404 if (qy + py < -28) py = -28 - qy;
406 if (qx + px > X) px = X - qx;
407 if (qy + py > Y) py = Y - qy;
412 hybridmv_thresh = 32;
413 if (a_valid && c_valid) {
414 if (is_intra[xy - wrap])
417 sum =
FFABS(px - field_predA[0]) +
FFABS(py - field_predA[1]);
418 if (sum > hybridmv_thresh) {
427 if (is_intra[xy - 1])
430 sum =
FFABS(px - field_predC[0]) +
FFABS(py - field_predC[1]);
431 if (sum > hybridmv_thresh) {
466 int mvn,
int r_x,
int r_y,
uint8_t* is_intra,
int dir)
469 int xy,
wrap, off = 0;
470 int A[2],
B[2],
C[2];
472 int a_valid = 0, b_valid = 0, c_valid = 0;
473 int field_a, field_b, field_c;
474 int total_valid, num_samefield, num_oppfield;
475 int pos_c, pos_b, n_adj;
503 off = ((n == 0) || (n == 1)) ? 1 : -1;
505 if (s->
mb_x || (n == 1) || (n == 3)) {
525 B[0] = B[1] = C[0] = C[1] = 0;
533 n_adj = (n & 2) | (n & 1);
587 total_valid = a_valid + b_valid + c_valid;
589 if (!s->
mb_x && !(n == 1 || n == 3)) {
594 B[0] = B[1] = C[0] = C[1] = 0;
601 if (total_valid >= 2) {
604 }
else if (total_valid) {
605 if (a_valid) { px = A[0]; py = A[1]; }
606 else if (b_valid) { px = B[0]; py = B[1]; }
607 else { px = C[0]; py = C[1]; }
612 field_a = (A[1] & 4) ? 1 : 0;
616 field_b = (B[1] & 4) ? 1 : 0;
620 field_c = (C[1] & 4) ? 1 : 0;
624 num_oppfield = field_a + field_b + field_c;
625 num_samefield = total_valid - num_oppfield;
626 if (total_valid == 3) {
627 if ((num_samefield == 3) || (num_oppfield == 3)) {
630 }
else if (num_samefield >= num_oppfield) {
633 px = !field_a ? A[0] : B[0];
634 py = !field_a ? A[1] : B[1];
636 px = field_a ? A[0] : B[0];
637 py = field_a ? A[1] : B[1];
639 }
else if (total_valid == 2) {
640 if (num_samefield >= num_oppfield) {
641 if (!field_a && a_valid) {
644 }
else if (!field_b && b_valid) {
653 if (field_a && a_valid) {
662 }
else if (total_valid == 1) {
663 px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
664 py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
678 }
else if (mvn == 2) {
681 s->
mv[dir][n + 1][0] = s->
mv[dir][
n][0];
682 s->
mv[dir][n + 1][1] = s->
mv[dir][
n][1];
687 int direct,
int mvtype)
690 int xy,
wrap, off = 0;
726 s->
mv[0][0][0] = av_clip(s->
mv[0][0][0], -60 - (s->
mb_x << 6), (s->
mb_width << 6) - 4 - (s->
mb_x << 6));
727 s->
mv[0][0][1] = av_clip(s->
mv[0][0][1], -60 - (s->
mb_y << 6), (s->
mb_height << 6) - 4 - (s->
mb_y << 6));
728 s->
mv[1][0][0] = av_clip(s->
mv[1][0][0], -60 - (s->
mb_x << 6), (s->
mb_width << 6) - 4 - (s->
mb_x << 6));
729 s->
mv[1][0][1] = av_clip(s->
mv[1][0][1], -60 - (s->
mb_y << 6), (s->
mb_height << 6) - 4 - (s->
mb_y << 6));
744 if (!s->
mb_x) C[0] = C[1] = 0;
753 }
else if (s->
mb_x) {
767 if (qx + px < -28) px = -28 - qx;
768 if (qy + py < -28) py = -28 - qy;
769 if (qx + px > X) px = X - qx;
770 if (qy + py > Y) py = Y - qy;
776 if (qx + px < -60) px = -60 - qx;
777 if (qy + py < -60) py = -60 - qy;
778 if (qx + px > X) px = X - qx;
779 if (qy + py > Y) py = Y - qy;
784 if (is_intra[xy - wrap])
797 if (is_intra[xy - 2])
813 s->
mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x;
814 s->
mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
832 }
else if (s->
mb_x) {
846 if (qx + px < -28) px = -28 - qx;
847 if (qy + py < -28) py = -28 - qy;
848 if (qx + px > X) px = X - qx;
849 if (qy + py > Y) py = Y - qy;
855 if (qx + px < -60) px = -60 - qx;
856 if (qy + py < -60) py = -60 - qy;
857 if (qx + px > X) px = X - qx;
858 if (qy + py > Y) py = Y - qy;
863 if (is_intra[xy - wrap])
876 if (is_intra[xy - 2])
893 s->
mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
894 s->
mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
903 int mv1,
int *pred_flag)
925 f = (total_opp > 2) ? 1 : 0;
927 s->
mv[0][0][0] = s->
mv[0][0][1] = 0;
928 s->
mv[1][0][0] = s->
mv[1][0][1] = 0;
932 for (k = 0; k < 4; k++) {