47 #define MB_INTRA_VLC_BITS 9
53 static const int offset_table2[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
93 int topleft_mb_pos, top_mb_pos;
94 int stride_y, fieldtx = 0;
110 v_dist = (16 - fieldtx) >> (fieldtx == 0);
135 v_dist = fieldtx ? 15 : 8;
157 #define inc_blk_idx(idx) do { \
159 if (idx >= v->n_allocated_blks) \
178 for (j = 0; j < 2; j++) {
211 for (j = 0; j < 2; j++) {
228 for (j = 0; j < 2; j++) {
244 for (j = 0; j < 2; j++) {
255 for (j = 0; j < 2; j++) {
349 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
352 uint8_t (*luty)[256], (*lutuv)[256];
360 mx = s->
mv[dir][0][0];
361 my = s->
mv[dir][0][1];
365 for (i = 0; i < 4; i++) {
371 uvmx = (mx + ((mx & 3) == 3)) >> 1;
372 uvmy = (my + ((my & 3) == 3)) >> 1;
384 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
385 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
415 src_x = s->
mb_x * 16 + (mx >> 2);
416 src_y = s->
mb_y * 16 + (my >> 2);
417 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
418 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
421 src_x = av_clip( src_x, -16, s->
mb_width * 16);
422 src_y = av_clip( src_y, -16, s->
mb_height * 16);
423 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
424 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
432 srcY += src_y * s->
linesize + src_x;
451 || (
unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
461 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
463 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
472 for (j = 0; j < 17 + s->
mspel * 2; j++) {
473 for (i = 0; i < 17 + s->
mspel * 2; i++)
474 src[i] = ((src[i] - 128) >> 1) + 128;
479 for (j = 0; j < 9; j++) {
480 for (i = 0; i < 9; i++) {
481 src[i] = ((src[i] - 128) >> 1) + 128;
482 src2[i] = ((src2[i] - 128) >> 1) + 128;
494 for (j = 0; j < 17 + s->
mspel * 2; j++) {
496 for (i = 0; i < 17 + s->
mspel * 2; i++)
497 src[i] = luty[f][src[i]];
502 for (j = 0; j < 9; j++) {
504 for (i = 0; i < 9; i++) {
505 src[i] = lutuv[f][src[i]];
506 src2[i] = lutuv[f][src2[i]];
516 dxy = ((my & 3) << 2) | (mx & 3);
523 dxy = (my & 2) | ((mx & 2) >> 1);
532 uvmx = (uvmx & 3) << 1;
533 uvmy = (uvmy & 3) << 1;
546 if (c < d)
return (
FFMIN(b, d) +
FFMAX(a, c)) / 2;
549 if (c < d)
return (
FFMIN(a, d) +
FFMAX(b, c)) / 2;
560 int dxy, mx, my, src_x, src_y;
572 mx = s->
mv[dir][
n][0];
573 my = s->
mv[dir][
n][1];
600 int same_count = 0, opp_count = 0, k;
601 int chosen_mv[2][4][2], f;
603 for (k = 0; k < 4; k++) {
605 chosen_mv[f][f ? opp_count : same_count][0] = s->
mv[0][k][0];
606 chosen_mv[f][f ? opp_count : same_count][1] = s->
mv[0][k][1];
610 f = opp_count > same_count;
611 switch (f ? opp_count : same_count) {
613 tx =
median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
614 chosen_mv[f][2][0], chosen_mv[f][3][0]);
615 ty =
median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
616 chosen_mv[f][2][1], chosen_mv[f][3][1]);
619 tx =
mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
620 ty =
mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
623 tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
624 ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
631 for (k = 0; k < 4; k++)
643 qx = (s->
mb_x * 16) + (mx >> 2);
644 qy = (s->
mb_y * 8) + (my >> 3);
649 mx -= 4 * (qx -
width);
652 else if (qy > height + 1)
653 my -= 8 * (qy - height - 1);
657 off = ((n > 1) ? s->
linesize : 0) + (n & 1) * 8;
659 off = s->
linesize * 4 * (n & 2) + (n & 1) * 8;
661 src_x = s->
mb_x * 16 + (n & 1) * 8 + (mx >> 2);
663 src_y = s->
mb_y * 16 + (n & 2) * 4 + (my >> 2);
665 src_y = s->
mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
668 src_x = av_clip(src_x, -16, s->
mb_width * 16);
669 src_y = av_clip(src_y, -16, s->
mb_height * 16);
682 srcY += src_y * s->
linesize + src_x;
686 if (fieldmv && !(src_y & 1))
688 if (fieldmv && (src_y & 1) && src_y < 4)
693 || (
unsigned)(src_y - (s->
mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->
mspel * 2) << fieldmv)) {
697 9 + s->
mspel * 2, (9 + s->
mspel * 2) << fieldmv,
698 src_x - s->
mspel, src_y - (s->
mspel << fieldmv),
707 for (j = 0; j < 9 + s->
mspel * 2; j++) {
708 for (i = 0; i < 9 + s->
mspel * 2; i++)
709 src[i] = ((src[i] - 128) >> 1) + 128;
719 for (j = 0; j < 9 + s->
mspel * 2; j++) {
721 for (i = 0; i < 9 + s->
mspel * 2; i++)
722 src[i] = luty[f][src[i]];
730 dxy = ((my & 3) << 2) | (mx & 3);
736 dxy = (my & 2) | ((mx & 2) >> 1);
747 static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
749 idx = ((a[3] != flag) << 3)
750 | ((a[2] != flag) << 2)
751 | ((a[1] != flag) << 1)
754 *tx =
median4(mvx[0], mvx[1], mvx[2], mvx[3]);
755 *ty =
median4(mvy[0], mvy[1], mvy[2], mvy[3]);
757 }
else if (count[idx] == 1) {
760 *tx =
mid_pred(mvx[1], mvx[2], mvx[3]);
761 *ty =
mid_pred(mvy[1], mvy[2], mvy[3]);
764 *tx =
mid_pred(mvx[0], mvx[2], mvx[3]);
765 *ty =
mid_pred(mvy[0], mvy[2], mvy[3]);
768 *tx =
mid_pred(mvx[0], mvx[1], mvx[3]);
769 *ty =
mid_pred(mvy[0], mvy[1], mvy[3]);
772 *tx =
mid_pred(mvx[0], mvx[1], mvx[2]);
773 *ty =
mid_pred(mvy[0], mvy[1], mvy[2]);
776 }
else if (count[idx] == 2) {
778 for (i = 0; i < 3; i++)
783 for (i = t1 + 1; i < 4; i++)
788 *tx = (mvx[
t1] + mvx[
t2]) / 2;
789 *ty = (mvy[
t1] + mvy[
t2]) / 2;
804 int uvmx, uvmy, uvsrc_x, uvsrc_y;
805 int k, tx = 0, ty = 0;
806 int mvx[4], mvy[4], intra[4], mv_f[4];
818 for (k = 0; k < 4; k++) {
819 mvx[k] = s->
mv[dir][k][0];
820 mvy[k] = s->
mv[dir][k][1];
838 if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
840 valid_count =
get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
848 uvmx = (tx + ((tx & 3) == 3)) >> 1;
849 uvmy = (ty + ((ty & 3) == 3)) >> 1;
855 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
856 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
860 uvmy += 2 - 4 * chroma_ref_type;
862 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
863 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
866 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
867 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
899 if (chroma_ref_type) {
907 || (
unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 9
908 || (
unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
910 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
913 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
925 for (j = 0; j < 9; j++) {
926 for (i = 0; i < 9; i++) {
927 src[i] = ((src[i] - 128) >> 1) + 128;
928 src2[i] = ((src2[i] - 128) >> 1) + 128;
941 for (j = 0; j < 9; j++) {
942 int f = v->
field_mode ? chroma_ref_type : ((j + uvsrc_y) & 1);
943 for (i = 0; i < 9; i++) {
944 src[i] = lutuv[f][src[i]];
945 src2[i] = lutuv[f][src2[i]];
954 uvmx = (uvmx & 3) << 1;
955 uvmy = (uvmy & 3) << 1;
972 int uvsrc_x, uvsrc_y;
973 int uvmx_field[4], uvmy_field[4];
976 static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
977 int v_dist = fieldmv ? 1 : 4;
985 for (i = 0; i < 4; i++) {
986 int d = i < 2 ? dir: dir2;
988 uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
991 uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
993 uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
996 for (i = 0; i < 4; i++) {
997 off = (i & 1) * 4 + ((i & 2) ? v_dist * s->
uvlinesize : 0);
998 uvsrc_x = s->
mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
999 uvsrc_y = s->
mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
1003 if (i < 2 ? dir : dir2) {
1018 uvmx_field[i] = (uvmx_field[i] & 3) << 1;
1019 uvmy_field[i] = (uvmy_field[i] & 3) << 1;
1021 if (fieldmv && !(uvsrc_y & 1))
1024 if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2)
1027 || s->
h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
1028 || (unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 5
1029 || (unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
1031 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
1034 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
1046 for (j = 0; j < 5; j++) {
1047 int f = (uvsrc_y + (j << fieldmv)) & 1;
1048 for (i = 0; i < 5; i++) {
1049 src[i] = lutuv[f][src[i]];
1050 src2[i] = lutuv[f][src2[i]];
1088 #define GET_MQUANT() \
1089 if (v->dquantfrm) { \
1091 if (v->dqprofile == DQPROFILE_ALL_MBS) { \
1092 if (v->dqbilevel) { \
1093 mquant = (get_bits1(gb)) ? v->altpq : v->pq; \
1095 mqdiff = get_bits(gb, 3); \
1097 mquant = v->pq + mqdiff; \
1099 mquant = get_bits(gb, 5); \
1102 if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \
1103 edges = 1 << v->dqsbedge; \
1104 else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
1105 edges = (3 << v->dqsbedge) % 15; \
1106 else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \
1108 if ((edges&1) && !s->mb_x) \
1109 mquant = v->altpq; \
1110 if ((edges&2) && s->first_slice_line) \
1111 mquant = v->altpq; \
1112 if ((edges&4) && s->mb_x == (s->mb_width - 1)) \
1113 mquant = v->altpq; \
1114 if ((edges&8) && s->mb_y == (s->mb_height - 1)) \
1115 mquant = v->altpq; \
1116 if (!mquant || mquant > 31) { \
1117 av_log(v->s.avctx, AV_LOG_ERROR, \
1118 "Overriding invalid mquant %d\n", mquant); \
1130 #define GET_MVDATA(_dmv_x, _dmv_y) \
1131 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \
1132 VC1_MV_DIFF_VLC_BITS, 2); \
1134 mb_has_coeffs = 1; \
1137 mb_has_coeffs = 0; \
1140 _dmv_x = _dmv_y = 0; \
1141 } else if (index == 35) { \
1142 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \
1143 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \
1144 } else if (index == 36) { \
1149 index1 = index % 6; \
1150 if (!s->quarter_sample && index1 == 5) val = 1; \
1152 if (size_table[index1] - val > 0) \
1153 val = get_bits(gb, size_table[index1] - val); \
1155 sign = 0 - (val&1); \
1156 _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \
1158 index1 = index / 6; \
1159 if (!s->quarter_sample && index1 == 5) val = 1; \
1161 if (size_table[index1] - val > 0) \
1162 val = get_bits(gb, size_table[index1] - val); \
1164 sign = 0 - (val & 1); \
1165 _dmv_y = (sign ^ ((val >> 1) + offset_table[index1])) - sign; \
1169 int *dmv_y,
int *pred_flag)
1172 int extend_x = 0, extend_y = 0;
1176 const int* offs_tab;
1193 extend_x = extend_y = 1;
1202 *pred_flag = *dmv_y & 1;
1203 *dmv_y = (*dmv_y + *pred_flag) >> 1;
1205 *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
1215 index1 = (index + 1) % 9;
1217 val =
get_bits(gb, index1 + extend_x);
1218 sign = 0 -(val & 1);
1219 *dmv_x = (sign ^ ((val >> 1) + offs_tab[index1])) - sign;
1226 index1 = (index + 1) / 9;
1227 if (index1 > v->
numref) {
1229 sign = 0 - (val & 1);
1230 *dmv_y = (sign ^ ((val >> 1) + offs_tab[index1 >> v->
numref])) - sign;
1233 if (v->
numref && pred_flag)
1234 *pred_flag = index1 & 1;
1240 int scaledvalue, refdist;
1241 int scalesame1, scalesame2;
1242 int scalezone1_x, zone1offset_x;
1259 if (
FFABS(n) < scalezone1_x)
1260 scaledvalue = (n * scalesame1) >> 8;
1263 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x;
1265 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x;
1273 int scaledvalue, refdist;
1274 int scalesame1, scalesame2;
1275 int scalezone1_y, zone1offset_y;
1292 if (
FFABS(n) < scalezone1_y)
1293 scaledvalue = (n * scalesame1) >> 8;
1296 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y;
1298 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y;
1303 return av_clip(scaledvalue, -v->
range_y / 2 + 1, v->
range_y / 2);
1305 return av_clip(scaledvalue, -v->
range_y / 2, v->
range_y / 2 - 1);
1310 int scalezone1_x, zone1offset_x;
1311 int scaleopp1, scaleopp2, brfd;
1323 if (
FFABS(n) < scalezone1_x)
1324 scaledvalue = (n * scaleopp1) >> 8;
1327 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x;
1329 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x;
1337 int scalezone1_y, zone1offset_y;
1338 int scaleopp1, scaleopp2, brfd;
1350 if (
FFABS(n) < scalezone1_y)
1351 scaledvalue = (n * scaleopp1) >> 8;
1354 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y;
1356 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y;
1360 return av_clip(scaledvalue, -v->
range_y / 2 + 1, v->
range_y / 2);
1362 return av_clip(scaledvalue, -v->
range_y / 2, v->
range_y / 2 - 1);
1369 int brfd, scalesame;
1383 n = (n * scalesame >> 8) << hpel;
1390 int refdist, scaleopp;
1407 n = (n * scaleopp >> 8) << hpel;
1414 int mv1,
int r_x,
int r_y,
uint8_t* is_intra,
1415 int pred_flag,
int dir)
1422 int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
1423 int opposite, a_f, b_f, c_f;
1424 int16_t field_predA[2];
1425 int16_t field_predB[2];
1426 int16_t field_predC[2];
1427 int a_valid, b_valid, c_valid;
1428 int hybridmv_thresh, y_bias = 0;
1476 off = (s->
mb_x > 0) ? -1 : 1;
1491 b_valid = a_valid && (s->
mb_width > 1);
1492 c_valid = s->
mb_x || (n == 1 || n == 3);
1494 a_valid = a_valid && !is_intra[xy -
wrap];
1495 b_valid = b_valid && !is_intra[xy - wrap +
off];
1496 c_valid = c_valid && !is_intra[xy - 1];
1501 num_oppfield += a_f;
1502 num_samefield += 1 - a_f;
1503 field_predA[0] = A[0];
1504 field_predA[1] = A[1];
1506 field_predA[0] = field_predA[1] = 0;
1511 num_oppfield += b_f;
1512 num_samefield += 1 - b_f;
1513 field_predB[0] = B[0];
1514 field_predB[1] = B[1];
1516 field_predB[0] = field_predB[1] = 0;
1521 num_oppfield += c_f;
1522 num_samefield += 1 - c_f;
1523 field_predC[0] = C[0];
1524 field_predC[1] = C[1];
1526 field_predC[0] = field_predC[1] = 0;
1536 if (num_samefield <= num_oppfield)
1537 opposite = 1 - pred_flag;
1539 opposite = pred_flag;
1544 if (a_valid && !a_f) {
1545 field_predA[0] =
scaleforopp(v, field_predA[0], 0, dir);
1546 field_predA[1] =
scaleforopp(v, field_predA[1], 1, dir);
1548 if (b_valid && !b_f) {
1549 field_predB[0] =
scaleforopp(v, field_predB[0], 0, dir);
1550 field_predB[1] =
scaleforopp(v, field_predB[1], 1, dir);
1552 if (c_valid && !c_f) {
1553 field_predC[0] =
scaleforopp(v, field_predC[0], 0, dir);
1554 field_predC[1] =
scaleforopp(v, field_predC[1], 1, dir);
1559 if (a_valid && a_f) {
1560 field_predA[0] =
scaleforsame(v, n, field_predA[0], 0, dir);
1561 field_predA[1] =
scaleforsame(v, n, field_predA[1], 1, dir);
1563 if (b_valid && b_f) {
1564 field_predB[0] =
scaleforsame(v, n, field_predB[0], 0, dir);
1565 field_predB[1] =
scaleforsame(v, n, field_predB[1], 1, dir);
1567 if (c_valid && c_f) {
1568 field_predC[0] =
scaleforsame(v, n, field_predC[0], 0, dir);
1569 field_predC[1] =
scaleforsame(v, n, field_predC[1], 1, dir);
1576 px = field_predA[0];
1577 py = field_predA[1];
1578 }
else if (c_valid) {
1579 px = field_predC[0];
1580 py = field_predC[1];
1581 }
else if (b_valid) {
1582 px = field_predB[0];
1583 py = field_predB[1];
1589 if (num_samefield + num_oppfield > 1) {
1590 px =
mid_pred(field_predA[0], field_predB[0], field_predC[0]);
1591 py =
mid_pred(field_predA[1], field_predB[1], field_predC[1]);
1597 qx = (s->
mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0);
1598 qy = (s->
mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0);
1602 if (qx + px < -60) px = -60 - qx;
1603 if (qy + py < -60) py = -60 - qy;
1605 if (qx + px < -28) px = -28 - qx;
1606 if (qy + py < -28) py = -28 - qy;
1608 if (qx + px > X) px = X - qx;
1609 if (qy + py > Y) py = Y - qy;
1614 hybridmv_thresh = 32;
1615 if (a_valid && c_valid) {
1616 if (is_intra[xy - wrap])
1619 sum =
FFABS(px - field_predA[0]) +
FFABS(py - field_predA[1]);
1620 if (sum > hybridmv_thresh) {
1622 px = field_predA[0];
1623 py = field_predA[1];
1625 px = field_predC[0];
1626 py = field_predC[1];
1629 if (is_intra[xy - 1])
1632 sum =
FFABS(px - field_predC[0]) +
FFABS(py - field_predC[1]);
1633 if (sum > hybridmv_thresh) {
1635 px = field_predA[0];
1636 py = field_predA[1];
1638 px = field_predC[0];
1639 py = field_predC[1];
1668 int mvn,
int r_x,
int r_y,
uint8_t* is_intra,
int dir)
1672 int A[2],
B[2],
C[2];
1674 int a_valid = 0, b_valid = 0, c_valid = 0;
1675 int field_a, field_b, field_c;
1676 int total_valid, num_samefield, num_oppfield;
1677 int pos_c, pos_b, n_adj;
1705 off = ((n == 0) || (n == 1)) ? 1 : -1;
1707 if (s->
mb_x || (n == 1) || (n == 3)) {
1727 B[0] = B[1] = C[0] = C[1] = 0;
1735 n_adj = (n & 2) | (n & 1);
1789 total_valid = a_valid + b_valid + c_valid;
1791 if (!s->
mb_x && !(n == 1 || n == 3)) {
1796 B[0] = B[1] = C[0] = C[1] = 0;
1803 if (total_valid >= 2) {
1806 }
else if (total_valid) {
1807 if (a_valid) { px = A[0]; py = A[1]; }
1808 else if (b_valid) { px = B[0]; py = B[1]; }
1809 else if (c_valid) { px = C[0]; py = C[1]; }
1815 field_a = (A[1] & 4) ? 1 : 0;
1819 field_b = (B[1] & 4) ? 1 : 0;
1823 field_c = (C[1] & 4) ? 1 : 0;
1827 num_oppfield = field_a + field_b + field_c;
1828 num_samefield = total_valid - num_oppfield;
1829 if (total_valid == 3) {
1830 if ((num_samefield == 3) || (num_oppfield == 3)) {
1833 }
else if (num_samefield >= num_oppfield) {
1836 px = !field_a ? A[0] : B[0];
1837 py = !field_a ? A[1] : B[1];
1839 px = field_a ? A[0] : B[0];
1840 py = field_a ? A[1] : B[1];
1842 }
else if (total_valid == 2) {
1843 if (num_samefield >= num_oppfield) {
1844 if (!field_a && a_valid) {
1847 }
else if (!field_b && b_valid) {
1856 if (field_a && a_valid) {
1868 }
else if (total_valid == 1) {
1869 px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
1870 py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
1884 }
else if (mvn == 2) {
1887 s->
mv[dir][n + 1][0] = s->
mv[dir][
n][0];
1888 s->
mv[dir][n + 1][1] = s->
mv[dir][
n][1];
1899 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
1907 mx = s->
mv[1][0][0];
1908 my = s->
mv[1][0][1];
1909 uvmx = (mx + ((mx & 3) == 3)) >> 1;
1910 uvmy = (my + ((my & 3) == 3)) >> 1;
1917 uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
1918 uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
1924 src_x = s->
mb_x * 16 + (mx >> 2);
1925 src_y = s->
mb_y * 16 + (my >> 2);
1926 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
1927 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
1930 src_x = av_clip( src_x, -16, s->
mb_width * 16);
1931 src_y = av_clip( src_y, -16, s->
mb_height * 16);
1932 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
1933 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
1941 srcY += src_y * s->
linesize + src_x;
1958 || (
unsigned)(src_x - 1) > s->
h_edge_pos - (mx & 3) - 16 - 3
1959 || (
unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
1969 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
1971 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
1980 for (j = 0; j < 17 + s->
mspel * 2; j++) {
1981 for (i = 0; i < 17 + s->
mspel * 2; i++)
1982 src[i] = ((src[i] - 128) >> 1) + 128;
1987 for (j = 0; j < 9; j++) {
1988 for (i = 0; i < 9; i++) {
1989 src[i] = ((src[i] - 128) >> 1) + 128;
1990 src2[i] = ((src2[i] - 128) >> 1) + 128;
2004 for (j = 0; j < 17 + s->
mspel * 2; j++) {
2006 for (i = 0; i < 17 + s->
mspel * 2; i++)
2007 src[i] = luty[f][src[i]];
2012 for (j = 0; j < 9; j++) {
2014 for (i = 0; i < 9; i++) {
2015 src[i] = lutuv[f][src[i]];
2016 src2[i] = lutuv[f][src2[i]];
2029 dxy = ((my & 3) << 2) | (mx & 3);
2036 dxy = (my & 2) | ((mx & 2) >> 1);
2046 uvmx = (uvmx & 3) << 1;
2047 uvmy = (uvmy & 3) << 1;
2061 #if B_FRACTION_DEN==256
2065 return 2 * ((value * n + 255) >> 9);
2066 return (value * n + 128) >> 8;
2079 int direct,
int mode)
2096 int direct,
int mvtype)
2131 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));
2132 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));
2133 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));
2134 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));
2150 if (!s->
mb_x) C[0] = C[1] = 0;
2159 }
else if (s->
mb_x) {
2169 qx = (s->
mb_x << 5);
2170 qy = (s->
mb_y << 5);
2173 if (qx + px < -28) px = -28 - qx;
2174 if (qy + py < -28) py = -28 - qy;
2175 if (qx + px > X) px = X - qx;
2176 if (qy + py > Y) py = Y - qy;
2178 qx = (s->
mb_x << 6);
2179 qy = (s->
mb_y << 6);
2182 if (qx + px < -60) px = -60 - qx;
2183 if (qy + py < -60) py = -60 - qy;
2184 if (qx + px > X) px = X - qx;
2185 if (qy + py > Y) py = Y - qy;
2190 if (is_intra[xy - wrap])
2203 if (is_intra[xy - 2])
2219 s->
mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x;
2220 s->
mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
2238 }
else if (s->
mb_x) {
2248 qx = (s->
mb_x << 5);
2249 qy = (s->
mb_y << 5);
2252 if (qx + px < -28) px = -28 - qx;
2253 if (qy + py < -28) py = -28 - qy;
2254 if (qx + px > X) px = X - qx;
2255 if (qy + py > Y) py = Y - qy;
2257 qx = (s->
mb_x << 6);
2258 qy = (s->
mb_y << 6);
2261 if (qx + px < -60) px = -60 - qx;
2262 if (qy + py < -60) py = -60 - qy;
2263 if (qx + px > X) px = X - qx;
2264 if (qy + py > Y) py = Y - qy;
2269 if (is_intra[xy - wrap])
2282 if (is_intra[xy - 2])
2299 s->
mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
2300 s->
mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
2315 int total_opp, k, f;
2330 f = (total_opp > 2) ? 1 : 0;
2332 s->
mv[0][0][0] = s->
mv[0][0][1] = 0;
2333 s->
mv[1][0][0] = s->
mv[1][0][1] = 0;
2337 for (k = 0; k < 4; k++) {
2354 if (n == 3 || mv1) {
2359 if (n == 3 || mv1) {
2375 int16_t **dc_val_ptr,
int *dir_ptr)
2379 static const uint16_t dcpred[32] = {
2380 -1, 1024, 512, 341, 256, 205, 171, 146, 128,
2381 114, 102, 93, 85, 79, 73, 68, 64,
2382 60, 57, 54, 51, 49, 47, 45, 43,
2383 41, 39, 38, 37, 35, 34, 33
2397 b = dc_val[ - 1 -
wrap];
2398 a = dc_val[ -
wrap];
2400 if (pq < 9 || !overlap) {
2403 b = a = dcpred[
scale];
2404 if (s->
mb_x == 0 && (n != 1 && n != 3))
2405 b = c = dcpred[
scale];
2410 if (s->
mb_x == 0 && (n != 1 && n != 3))
2414 if (abs(a - b) <= abs(b - c)) {
2423 *dc_val_ptr = &dc_val[0];
2440 int a_avail,
int c_avail,
2441 int16_t **dc_val_ptr,
int *dir_ptr)
2456 b = dc_val[ - 1 -
wrap];
2457 a = dc_val[ -
wrap];
2461 if (dqscale_index < 0)
2463 if (c_avail && (n != 1 && n != 3)) {
2468 if (a_avail && (n != 2 && n != 3)) {
2473 if (a_avail && c_avail && (n != 3)) {
2484 if (a_avail && c_avail) {
2485 if (abs(a - b) <= abs(b - c)) {
2492 }
else if (a_avail) {
2495 }
else if (c_avail) {
2504 *dc_val_ptr = &dc_val[0];
2553 int *
value,
int codingset)
2619 int coded,
int codingset)
2623 int dc_pred_dir = 0;
2626 int16_t *ac_val, *ac_val2;
2640 if (dcdiff == 119 ) {
2643 else if (v->
pq == 2) dcdiff =
get_bits(gb, 9);
2647 dcdiff = (dcdiff << 2) +
get_bits(gb, 2) - 3;
2648 else if (v->
pq == 2)
2649 dcdiff = (dcdiff << 1) +
get_bits1(gb) - 1;
2674 int last = 0, skip,
value;
2701 block[zz_table[i++]] =
value;
2707 for (k = 1; k < 8; k++)
2710 for (k = 1; k < 8; k++)
2715 for (k = 1; k < 8; k++) {
2721 for (k = 1; k < 64; k++)
2725 block[k] += (block[k] < 0) ? -v->
pq : v->
pq;
2739 memset(ac_val2, 0, 16 * 2);
2743 memcpy(ac_val2, ac_val, 8 * 2);
2747 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
2753 for (k = 1; k < 8; k++) {
2759 for (k = 1; k < 8; k++) {
2782 int coded,
int codingset,
int mquant)
2786 int dc_pred_dir = 0;
2788 int16_t *dc_val = NULL;
2789 int16_t *ac_val, *ac_val2;
2808 if (dcdiff == 119 ) {
2810 if (mquant == 1) dcdiff =
get_bits(gb, 10);
2811 else if (mquant == 2) dcdiff =
get_bits(gb, 9);
2815 dcdiff = (dcdiff << 2) +
get_bits(gb, 2) - 3;
2816 else if (mquant == 2)
2817 dcdiff = (dcdiff << 1) +
get_bits1(gb) - 1;
2838 if (!a_avail && !c_avail)
2843 scale = mquant * 2 + ((mquant == v->
pq) ? v->
halfpq : 0);
2851 if ( dc_pred_dir && c_avail && mb_pos)
2853 if (!dc_pred_dir && a_avail && mb_pos >= s->
mb_stride)
2855 if ( dc_pred_dir && n == 1)
2857 if (!dc_pred_dir && n == 2)
2863 int last = 0, skip,
value;
2888 block[zz_table[i++]] =
value;
2894 if (q2 && q1 != q2) {
2895 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
2896 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
2901 for (k = 1; k < 8; k++)
2904 for (k = 1; k < 8; k++)
2909 for (k = 1; k < 8; k++)
2912 for (k = 1; k < 8; k++)
2918 for (k = 1; k < 8; k++) {
2924 for (k = 1; k < 64; k++)
2928 block[k] += (block[k] < 0) ? -mquant : mquant;
2931 if (use_pred) i = 63;
2935 memset(ac_val2, 0, 16 * 2);
2938 memcpy(ac_val2, ac_val, 8 * 2);
2939 if (q2 && q1 != q2) {
2940 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
2941 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
2944 for (k = 1; k < 8; k++)
2945 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
2950 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
2951 if (q2 && q1 != q2) {
2952 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
2953 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
2956 for (k = 1; k < 8; k++)
2957 ac_val2[k + 8] = (ac_val2[k + 8] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
2965 for (k = 1; k < 8; k++) {
2971 for (k = 1; k < 8; k++) {
2994 int coded,
int mquant,
int codingset)
2998 int dc_pred_dir = 0;
3000 int16_t *dc_val = NULL;
3001 int16_t *ac_val, *ac_val2;
3012 mquant = (mquant < 1) ? 0 : ((mquant > 31) ? 31 : mquant);
3029 if (dcdiff == 119 ) {
3031 if (mquant == 1) dcdiff =
get_bits(gb, 10);
3032 else if (mquant == 2) dcdiff =
get_bits(gb, 9);
3036 dcdiff = (dcdiff << 2) +
get_bits(gb, 2) - 3;
3037 else if (mquant == 2)
3038 dcdiff = (dcdiff << 1) +
get_bits1(gb) - 1;
3045 dcdiff +=
vc1_pred_dc(&v->
s, v->
overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
3060 if (!a_avail) dc_pred_dir = 1;
3061 if (!c_avail) dc_pred_dir = 0;
3062 if (!a_avail && !c_avail) use_pred = 0;
3066 scale = mquant * 2 + v->
halfpq;
3074 if (dc_pred_dir && c_avail && mb_pos)
3076 if (!dc_pred_dir && a_avail && mb_pos >= s->
mb_stride)
3078 if ( dc_pred_dir && n == 1)
3080 if (!dc_pred_dir && n == 2)
3082 if (n == 3) q2 = q1;
3085 int last = 0, skip,
value;
3110 if (q2 && q1 != q2) {
3111 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
3112 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
3117 for (k = 1; k < 8; k++)
3120 for (k = 1; k < 8; k++)
3125 for (k = 1; k < 8; k++)
3128 for (k = 1; k < 8; k++)
3134 for (k = 1; k < 8; k++) {
3140 for (k = 1; k < 64; k++)
3144 block[k] += (block[k] < 0) ? -mquant : mquant;
3147 if (use_pred) i = 63;
3151 memset(ac_val2, 0, 16 * 2);
3154 memcpy(ac_val2, ac_val, 8 * 2);
3155 if (q2 && q1 != q2) {
3156 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
3157 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
3160 for (k = 1; k < 8; k++)
3161 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
3166 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
3167 if (q2 && q1 != q2) {
3168 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
3169 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
3172 for (k = 1; k < 8; k++)
3173 ac_val2[k + 8] = (ac_val2[k + 8] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
3181 for (k = 1; k < 8; k++) {
3187 for (k = 1; k < 8; k++) {
3204 int mquant,
int ttmb,
int first_block,
3205 uint8_t *dst,
int linesize,
int skip_block,
3213 int ttblk = ttmb & 7;
3225 && ((v->
ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
3235 scale = 2 * mquant + ((v->
pq == mquant) ? v->
halfpq : 0);
3260 block[idx] = value *
scale;
3262 block[idx] += (block[idx] < 0) ? -mquant : mquant;
3274 pat = ~subblkpat & 0xF;
3275 for (j = 0; j < 4; j++) {
3276 last = subblkpat & (1 << (3 - j));
3278 off = (j & 1) * 4 + (j & 2) * 16;
3290 block[idx +
off] += (block[idx +
off] < 0) ? -mquant : mquant;
3292 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
3301 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
3302 for (j = 0; j < 2; j++) {
3303 last = subblkpat & (1 << (1 - j));
3315 block[idx] = value *
scale;
3317 block[idx] += (block[idx] < 0) ? -mquant : mquant;
3319 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
3328 pat = ~(subblkpat * 5) & 0xF;
3329 for (j = 0; j < 2; j++) {
3330 last = subblkpat & (1 << (1 - j));
3342 block[idx] = value *
scale;
3344 block[idx] += (block[idx] < 0) ? -mquant : mquant;
3346 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
3356 *ttmb_out |= ttblk << (n * 4);
3369 block_cbp = mb_cbp >> (block_num * 4), bottom_cbp,
3371 block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;
3375 if (block_num > 3) {
3376 dst = s->
dest[block_num - 3];
3378 dst = s->
dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize;
3384 if (block_num > 3) {
3385 bottom_cbp = v->
cbp[s->
mb_x] >> (block_num * 4);
3386 bottom_is_intra = v->
is_intra[s->
mb_x] >> (block_num * 4);
3390 bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4))
3391 : (v->
cbp[s->
mb_x] >> ((block_num - 2) * 4));
3392 bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4))
3398 if (bottom_is_intra & 1 || block_is_intra & 1 ||
3399 mv[0][0] !=
mv[mv_stride][0] ||
mv[0][1] !=
mv[mv_stride][1]) {
3402 idx = ((bottom_cbp >> 2) | block_cbp) & 3;
3414 dst -= 4 * linesize;
3417 idx = (block_cbp | (block_cbp >> 2)) & 3;
3433 block_cbp = mb_cbp >> (block_num * 4), right_cbp,
3435 block_is_intra = mb_is_intra >> (block_num * 4), right_is_intra;
3439 if (block_num > 3) {
3440 dst = s->
dest[block_num - 3] - 8 * linesize;
3442 dst = s->
dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 16) * linesize - 8;
3448 if (block_num > 3) {
3453 right_cbp = (block_num & 1) ? (v->
cbp[s->
mb_x - s->
mb_stride] >> ((block_num - 1) * 4))
3454 : (mb_cbp >> ((block_num + 1) * 4));
3456 : (mb_is_intra >> ((block_num + 1) * 4));
3459 if (block_is_intra & 1 || right_is_intra & 1 ||
mv[0][0] !=
mv[1][0] ||
mv[0][1] !=
mv[1][1]) {
3462 idx = ((right_cbp >> 1) | block_cbp) & 5;
3477 idx = (block_cbp | (block_cbp >> 1)) & 5;
3494 for (i = 0; i < 6; i++) {
3501 for (i = 0; i < 6; i++) {
3507 for (i = 0; i < 6; i++) {
3524 int ttmb = v->
ttfrm;
3526 int mb_has_coeffs = 1;
3530 int first_block = 1;
3532 int skipped, fourmv;
3533 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
3558 if (s->
mb_intra && !mb_has_coeffs) {
3562 }
else if (mb_has_coeffs) {
3578 for (i = 0; i < 6; i++) {
3581 val = ((cbp >> (5 - i)) & 1);
3582 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3589 if (i == 1 || i == 3 || s->
mb_x)
3598 for (j = 0; j < 64; j++)
3599 s->
block[i][j] <<= 1;
3607 block_cbp |= 0xF << (i << 2);
3608 block_intra |= 1 << i;
3613 block_cbp |= pat << (i << 2);
3614 if (!v->
ttmbf && ttmb < 8)
3621 for (i = 0; i < 6; i++) {
3632 int intra_count = 0, coded_inter = 0;
3633 int is_intra[6], is_coded[6];
3636 for (i = 0; i < 6; i++) {
3637 val = ((cbp >> (5 - i)) & 1);
3652 is_coded[i] = mb_has_coeffs;
3655 is_intra[i] = (intra_count >= 3);
3662 coded_inter = !is_intra[i] & is_coded[i];
3666 if (!intra_count && !coded_inter)
3673 for (i = 0; i < 6; i++)
3686 if (!v->
ttmbf && coded_inter)
3688 for (i = 0; i < 6; i++) {
3690 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3697 if (i == 1 || i == 3 || s->
mb_x)
3706 for (j = 0; j < 64; j++)
3707 s->
block[i][j] <<= 1;
3716 block_cbp |= 0xF << (i << 2);
3717 block_intra |= 1 << i;
3718 }
else if (is_coded[i]) {
3720 first_block, s->
dest[dst_idx] + off,
3724 block_cbp |= pat << (i << 2);
3725 if (!v->
ttmbf && ttmb < 8)
3733 for (i = 0; i < 6; i++) {
3737 for (i = 0; i < 4; i++) {
3763 int ttmb = v->
ttfrm;
3765 int mb_has_coeffs = 1;
3768 int first_block = 1;
3770 int skipped, fourmv = 0, twomv = 0;
3771 int block_cbp = 0, pat, block_tt = 0;
3772 int idx_mbmode = 0, mvbp;
3773 int stride_y, fieldtx;
3817 for (i = 0; i < 4; i++) {
3823 for (i = 0; i < 6; i++)
3836 for (i = 0; i < 6; i++) {
3839 val = ((cbp >> (5 - i)) & 1);
3844 if (i == 1 || i == 3 || s->
mb_x)
3853 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->
linesize : (i & 1) * 8 + 4 * (i & 2) * s->
linesize;
3875 for (i = 0; i < 6; i++)
3882 for (i = 0; i < 6; i++) {
3885 val = ((mvbp >> (3 - i)) & 1);
3891 }
else if (i == 4) {
3924 if (!v->
ttmbf && cbp)
3926 for (i = 0; i < 6; i++) {
3929 val = ((cbp >> (5 - i)) & 1);
3931 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3933 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->
linesize));
3936 first_block, s->
dest[dst_idx] + off,
3939 block_cbp |= pat << (i << 2);
3940 if (!v->
ttmbf && ttmb < 8)
3948 for (i = 0; i < 6; i++) {
3974 int ttmb = v->
ttfrm;
3976 int mb_has_coeffs = 1;
3979 int first_block = 1;
3982 int block_cbp = 0, pat, block_tt = 0;
3988 if (idx_mbmode <= 1) {
3999 mb_has_coeffs = idx_mbmode & 1;
4003 for (i = 0; i < 6; i++) {
4007 val = ((cbp >> (5 - i)) & 1);
4011 if (i == 1 || i == 3 || s->
mb_x)
4019 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
4027 if (idx_mbmode <= 5) {
4028 dmv_x = dmv_y = pred_flag = 0;
4029 if (idx_mbmode & 1) {
4034 mb_has_coeffs = !(idx_mbmode & 2);
4037 for (i = 0; i < 6; i++) {
4039 dmv_x = dmv_y = pred_flag = 0;
4040 val = ((v->
fourmvbp >> (3 - i)) & 1);
4049 mb_has_coeffs = idx_mbmode & 1;
4057 if (!v->
ttmbf && cbp) {
4061 for (i = 0; i < 6; i++) {
4064 val = ((cbp >> (5 - i)) & 1);
4065 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
4068 first_block, s->
dest[dst_idx] + off,
4072 block_cbp |= pat << (i << 2);
4073 if (!v->
ttmbf && ttmb < 8) ttmb = -1;
4093 int ttmb = v->
ttfrm;
4094 int mb_has_coeffs = 0;
4097 int first_block = 1;
4099 int skipped, direct;
4100 int dmv_x[2], dmv_y[2];
4115 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
4116 for (i = 0; i < 6; i++) {
4125 dmv_x[1] = dmv_x[0];
4126 dmv_y[1] = dmv_y[0];
4139 dmv_x[0] = dmv_y[0] = 0;
4143 for (i = 0; i < 6; i++)
4150 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4160 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
4162 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4164 if (!mb_has_coeffs && !s->
mb_intra) {
4167 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4170 if (s->
mb_intra && !mb_has_coeffs) {
4179 if (!mb_has_coeffs) {
4182 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4188 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4200 for (i = 0; i < 6; i++) {
4203 val = ((cbp >> (5 - i)) & 1);
4204 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
4211 if (i == 1 || i == 3 || s->
mb_x)
4220 for (j = 0; j < 64; j++)
4221 s->
block[i][j] <<= 1;
4225 first_block, s->
dest[dst_idx] + off,
4228 if (!v->
ttmbf && ttmb < 8)
4245 int ttmb = v->
ttfrm;
4246 int mb_has_coeffs = 0;
4248 int first_block = 1;
4251 int dmv_x[2], dmv_y[2], pred_flag[2];
4259 if (idx_mbmode <= 1) {
4270 mb_has_coeffs = idx_mbmode & 1;
4274 for (i = 0; i < 6; i++) {
4277 val = ((cbp >> (5 - i)) & 1);
4282 if (i == 1 || i == 3 || s->
mb_x)
4291 for (j = 0; j < 64; j++)
4292 s->
block[i][j] <<= 1;
4293 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
4305 if (idx_mbmode <= 5) {
4307 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
4308 pred_flag[0] = pred_flag[1] = 0;
4333 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
4334 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
4338 mb_has_coeffs = !(idx_mbmode & 2);
4344 for (i = 0; i < 6; i++) {