45 #define MB_INTRA_VLC_BITS 9
51 static const int offset_table2[9] = { 0, 1, 3, 7, 15, 31, 63, 127, 255 };
81 int topleft_mb_pos, top_mb_pos;
82 int stride_y, fieldtx;
97 v_dist = (16 - fieldtx) >> (fieldtx == 0);
121 v_dist = fieldtx ? 15 : 8;
143 #define inc_blk_idx(idx) do { \
145 if (idx >= v->n_allocated_blks) \
164 for (j = 0; j < 2; j++) {
197 for (j = 0; j < 2; j++) {
214 for (j = 0; j < 2; j++) {
230 for (j = 0; j < 2; j++) {
241 for (j = 0; j < 2; j++) {
335 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
344 mx = s->
mv[dir][0][0];
345 my = s->
mv[dir][0][1];
353 uvmx = (mx + ((mx & 3) == 3)) >> 1;
354 uvmy = (my + ((my & 3) == 3)) >> 1;
366 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
367 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
397 if (!srcY || !srcU) {
402 src_x = s->
mb_x * 16 + (mx >> 2);
403 src_y = s->
mb_y * 16 + (my >> 2);
404 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
405 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
408 src_x = av_clip( src_x, -16, s->
mb_width * 16);
409 src_y = av_clip( src_y, -16, s->
mb_height * 16);
410 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
411 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
419 srcY += src_y * s->
linesize + src_x;
438 || (
unsigned)(src_y - 1) > v_edge_pos - (my&3) - 16 - 3) {
448 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
450 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
459 for (j = 0; j < 17 + s->
mspel * 2; j++) {
460 for (i = 0; i < 17 + s->
mspel * 2; i++)
461 src[i] = ((src[i] - 128) >> 1) + 128;
466 for (j = 0; j < 9; j++) {
467 for (i = 0; i < 9; i++) {
468 src[i] = ((src[i] - 128) >> 1) + 128;
469 src2[i] = ((src2[i] - 128) >> 1) + 128;
481 for (j = 0; j < 17 + s->
mspel * 2; j++) {
482 for (i = 0; i < 17 + s->
mspel * 2; i++)
483 src[i] = v->
luty[src[i]];
488 for (j = 0; j < 9; j++) {
489 for (i = 0; i < 9; i++) {
490 src[i] = v->
lutuv[src[i]];
491 src2[i] = v->
lutuv[src2[i]];
508 dxy = ((my & 3) << 2) | (mx & 3);
515 dxy = (my & 2) | ((mx & 2) >> 1);
524 uvmx = (uvmx & 3) << 1;
525 uvmy = (uvmy & 3) << 1;
538 if (c < d)
return (
FFMIN(b, d) +
FFMAX(a, c)) / 2;
541 if (c < d)
return (
FFMIN(a, d) +
FFMAX(b, c)) / 2;
553 int dxy, mx, my, src_x, src_y;
563 mx = s->
mv[dir][n][0];
564 my = s->
mv[dir][n][1];
588 int same_count = 0, opp_count = 0, k;
589 int chosen_mv[2][4][2], f;
591 for (k = 0; k < 4; k++) {
593 chosen_mv[f][f ? opp_count : same_count][0] = s->
mv[0][k][0];
594 chosen_mv[f][f ? opp_count : same_count][1] = s->
mv[0][k][1];
598 f = opp_count > same_count;
599 switch (f ? opp_count : same_count) {
601 tx =
median4(chosen_mv[f][0][0], chosen_mv[f][1][0],
602 chosen_mv[f][2][0], chosen_mv[f][3][0]);
603 ty =
median4(chosen_mv[f][0][1], chosen_mv[f][1][1],
604 chosen_mv[f][2][1], chosen_mv[f][3][1]);
607 tx =
mid_pred(chosen_mv[f][0][0], chosen_mv[f][1][0], chosen_mv[f][2][0]);
608 ty =
mid_pred(chosen_mv[f][0][1], chosen_mv[f][1][1], chosen_mv[f][2][1]);
611 tx = (chosen_mv[f][0][0] + chosen_mv[f][1][0]) / 2;
612 ty = (chosen_mv[f][0][1] + chosen_mv[f][1][1]) / 2;
617 for (k = 0; k < 4; k++)
625 qx = (s->
mb_x * 16) + (mx >> 2);
626 qy = (s->
mb_y * 8) + (my >> 3);
631 mx -= 4 * (qx -
width);
634 else if (qy > height + 1)
635 my -= 8 * (qy - height - 1);
639 off = ((n > 1) ? s->
linesize : 0) + (n & 1) * 8;
641 off = s->
linesize * 4 * (n & 2) + (n & 1) * 8;
645 src_x = s->
mb_x * 16 + (n & 1) * 8 + (mx >> 2);
647 src_y = s->
mb_y * 16 + (n & 2) * 4 + (my >> 2);
649 src_y = s->
mb_y * 16 + ((n > 1) ? 1 : 0) + (my >> 2);
652 src_x = av_clip(src_x, -16, s->
mb_width * 16);
653 src_y = av_clip(src_y, -16, s->
mb_height * 16);
666 srcY += src_y * s->
linesize + src_x;
670 if (fieldmv && !(src_y & 1))
672 if (fieldmv && (src_y & 1) && src_y < 4)
677 || (
unsigned)(src_y - (s->
mspel << fieldmv)) > v_edge_pos - (my & 3) - ((8 + s->
mspel * 2) << fieldmv)) {
681 9 + s->
mspel * 2, (9 + s->
mspel * 2) << fieldmv,
682 src_x - s->
mspel, src_y - (s->
mspel << fieldmv),
691 for (j = 0; j < 9 + s->
mspel * 2; j++) {
692 for (i = 0; i < 9 + s->
mspel * 2; i++)
693 src[i] = ((src[i] - 128) >> 1) + 128;
703 for (j = 0; j < 9 + s->
mspel * 2; j++) {
704 for (i = 0; i < 9 + s->
mspel * 2; i++)
705 src[i] = v->
luty[src[i]];
713 dxy = ((my & 3) << 2) | (mx & 3);
716 dxy = (my & 2) | ((mx & 2) >> 1);
727 static const int count[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4};
729 idx = ((a[3] != flag) << 3)
730 | ((a[2] != flag) << 2)
731 | ((a[1] != flag) << 1)
734 *tx =
median4(mvx[0], mvx[1], mvx[2], mvx[3]);
735 *ty =
median4(mvy[0], mvy[1], mvy[2], mvy[3]);
737 }
else if (count[idx] == 1) {
740 *tx =
mid_pred(mvx[1], mvx[2], mvx[3]);
741 *ty =
mid_pred(mvy[1], mvy[2], mvy[3]);
744 *tx =
mid_pred(mvx[0], mvx[2], mvx[3]);
745 *ty =
mid_pred(mvy[0], mvy[2], mvy[3]);
748 *tx =
mid_pred(mvx[0], mvx[1], mvx[3]);
749 *ty =
mid_pred(mvy[0], mvy[1], mvy[3]);
752 *tx =
mid_pred(mvx[0], mvx[1], mvx[2]);
753 *ty =
mid_pred(mvy[0], mvy[1], mvy[2]);
756 }
else if (count[idx] == 2) {
758 for (i = 0; i < 3; i++)
763 for (i = t1 + 1; i < 4; i++)
768 *tx = (mvx[
t1] + mvx[
t2]) / 2;
769 *ty = (mvy[
t1] + mvy[
t2]) / 2;
784 int uvmx, uvmy, uvsrc_x, uvsrc_y;
785 int k, tx = 0, ty = 0;
786 int mvx[4], mvy[4], intra[4], mv_f[4];
796 for (k = 0; k < 4; k++) {
797 mvx[k] = s->
mv[dir][k][0];
798 mvy[k] = s->
mv[dir][k][1];
816 if (mv_f[0] + mv_f[1] + mv_f[2] + mv_f[3] > 2)
818 valid_count =
get_chroma_mv(mvx, mvy, mv_f, dominant, &tx, &ty);
826 uvmx = (tx + ((tx & 3) == 3)) >> 1;
827 uvmy = (ty + ((ty & 3) == 3)) >> 1;
833 uvmx = uvmx + ((uvmx < 0) ? (uvmx & 1) : -(uvmx & 1));
834 uvmy = uvmy + ((uvmy < 0) ? (uvmy & 1) : -(uvmy & 1));
838 uvmy += 2 - 4 * chroma_ref_type;
840 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
841 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
844 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
845 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
875 if (chroma_ref_type) {
884 || (
unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 9
885 || (
unsigned)uvsrc_y > (v_edge_pos >> 1) - 9) {
887 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
890 8 + 1, 8 + 1, uvsrc_x, uvsrc_y,
902 for (j = 0; j < 9; j++) {
903 for (i = 0; i < 9; i++) {
904 src[i] = ((src[i] - 128) >> 1) + 128;
905 src2[i] = ((src2[i] - 128) >> 1) + 128;
918 for (j = 0; j < 9; j++) {
919 for (i = 0; i < 9; i++) {
920 src[i] = v->
lutuv[src[i]];
921 src2[i] = v->
lutuv[src2[i]];
930 uvmx = (uvmx & 3) << 1;
931 uvmy = (uvmy & 3) << 1;
948 int uvsrc_x, uvsrc_y;
949 int uvmx_field[4], uvmy_field[4];
952 static const int s_rndtblfield[16] = { 0, 0, 1, 2, 4, 4, 5, 6, 2, 2, 3, 8, 6, 6, 7, 12 };
953 int v_dist = fieldmv ? 1 : 4;
961 for (i = 0; i < 4; i++) {
963 uvmx_field[i] = (tx + ((tx & 3) == 3)) >> 1;
966 uvmy_field[i] = (ty >> 4) * 8 + s_rndtblfield[ty & 0xF];
968 uvmy_field[i] = (ty + ((ty & 3) == 3)) >> 1;
971 for (i = 0; i < 4; i++) {
972 off = (i & 1) * 4 + ((i & 2) ? v_dist * s->
uvlinesize : 0);
973 uvsrc_x = s->
mb_x * 8 + (i & 1) * 4 + (uvmx_field[i] >> 2);
974 uvsrc_y = s->
mb_y * 8 + ((i & 2) ? v_dist : 0) + (uvmy_field[i] >> 2);
980 uvmx_field[i] = (uvmx_field[i] & 3) << 1;
981 uvmy_field[i] = (uvmy_field[i] & 3) << 1;
983 if (fieldmv && !(uvsrc_y & 1))
985 if (fieldmv && (uvsrc_y & 1) && uvsrc_y < 2)
988 || s->
h_edge_pos < 10 || v_edge_pos < (5 << fieldmv)
989 || (
unsigned)uvsrc_x > (s->
h_edge_pos >> 1) - 5
990 || (
unsigned)uvsrc_y > v_edge_pos - (5 << fieldmv)) {
992 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
995 5, (5 << fieldmv), uvsrc_x, uvsrc_y,
1007 for (j = 0; j < 5; j++) {
1008 for (i = 0; i < 5; i++) {
1009 src[i] = v->
lutuv[src[i]];
1010 src2[i] = v->
lutuv[src2[i]];
1038 #define GET_MQUANT() \
1039 if (v->dquantfrm) { \
1041 if (v->dqprofile == DQPROFILE_ALL_MBS) { \
1042 if (v->dqbilevel) { \
1043 mquant = (get_bits1(gb)) ? v->altpq : v->pq; \
1045 mqdiff = get_bits(gb, 3); \
1047 mquant = v->pq + mqdiff; \
1049 mquant = get_bits(gb, 5); \
1052 if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \
1053 edges = 1 << v->dqsbedge; \
1054 else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
1055 edges = (3 << v->dqsbedge) % 15; \
1056 else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \
1058 if ((edges&1) && !s->mb_x) \
1059 mquant = v->altpq; \
1060 if ((edges&2) && s->first_slice_line) \
1061 mquant = v->altpq; \
1062 if ((edges&4) && s->mb_x == (s->mb_width - 1)) \
1063 mquant = v->altpq; \
1064 if ((edges&8) && s->mb_y == (s->mb_height - 1)) \
1065 mquant = v->altpq; \
1066 if (!mquant || mquant > 31) { \
1067 av_log(v->s.avctx, AV_LOG_ERROR, \
1068 "Overriding invalid mquant %d\n", mquant); \
1080 #define GET_MVDATA(_dmv_x, _dmv_y) \
1081 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \
1082 VC1_MV_DIFF_VLC_BITS, 2); \
1084 mb_has_coeffs = 1; \
1087 mb_has_coeffs = 0; \
1090 _dmv_x = _dmv_y = 0; \
1091 } else if (index == 35) { \
1092 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \
1093 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \
1094 } else if (index == 36) { \
1099 index1 = index % 6; \
1100 if (!s->quarter_sample && index1 == 5) val = 1; \
1102 if (size_table[index1] - val > 0) \
1103 val = get_bits(gb, size_table[index1] - val); \
1105 sign = 0 - (val&1); \
1106 _dmv_x = (sign ^ ((val>>1) + offset_table[index1])) - sign; \
1108 index1 = index / 6; \
1109 if (!s->quarter_sample && index1 == 5) val = 1; \
1111 if (size_table[index1] - val > 0) \
1112 val = get_bits(gb, size_table[index1] - val); \
1114 sign = 0 - (val & 1); \
1115 _dmv_y = (sign ^ ((val >> 1) + offset_table[index1])) - sign; \
1119 int *dmv_y,
int *pred_flag)
1122 int extend_x = 0, extend_y = 0;
1126 const int* offs_tab;
1143 extend_x = extend_y = 1;
1152 *pred_flag = *dmv_y & 1;
1153 *dmv_y = (*dmv_y + *pred_flag) >> 1;
1155 *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
1164 index1 = (index + 1) % 9;
1166 val =
get_bits(gb, index1 + extend_x);
1167 sign = 0 -(val & 1);
1168 *dmv_x = (sign ^ ((val >> 1) + offs_tab[index1])) - sign;
1175 index1 = (index + 1) / 9;
1176 if (index1 > v->
numref) {
1178 sign = 0 - (val & 1);
1179 *dmv_y = (sign ^ ((val >> 1) + offs_tab[index1 >> v->
numref])) - sign;
1182 if (v->
numref && pred_flag)
1183 *pred_flag = index1 & 1;
1189 int scaledvalue, refdist;
1190 int scalesame1, scalesame2;
1191 int scalezone1_x, zone1offset_x;
1208 if (
FFABS(n) < scalezone1_x)
1209 scaledvalue = (n * scalesame1) >> 8;
1212 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_x;
1214 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_x;
1222 int scaledvalue, refdist;
1223 int scalesame1, scalesame2;
1224 int scalezone1_y, zone1offset_y;
1241 if (
FFABS(n) < scalezone1_y)
1242 scaledvalue = (n * scalesame1) >> 8;
1245 scaledvalue = ((n * scalesame2) >> 8) - zone1offset_y;
1247 scaledvalue = ((n * scalesame2) >> 8) + zone1offset_y;
1252 return av_clip(scaledvalue, -v->
range_y / 2 + 1, v->
range_y / 2);
1254 return av_clip(scaledvalue, -v->
range_y / 2, v->
range_y / 2 - 1);
1259 int scalezone1_x, zone1offset_x;
1260 int scaleopp1, scaleopp2, brfd;
1272 if (
FFABS(n) < scalezone1_x)
1273 scaledvalue = (n * scaleopp1) >> 8;
1276 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_x;
1278 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_x;
1286 int scalezone1_y, zone1offset_y;
1287 int scaleopp1, scaleopp2, brfd;
1299 if (
FFABS(n) < scalezone1_y)
1300 scaledvalue = (n * scaleopp1) >> 8;
1303 scaledvalue = ((n * scaleopp2) >> 8) - zone1offset_y;
1305 scaledvalue = ((n * scaleopp2) >> 8) + zone1offset_y;
1309 return av_clip(scaledvalue, -v->
range_y / 2 + 1, v->
range_y / 2);
1311 return av_clip(scaledvalue, -v->
range_y / 2, v->
range_y / 2 - 1);
1318 int brfd, scalesame;
1332 n = (n * scalesame >> 8) << hpel;
1339 int refdist, scaleopp;
1356 n = (n * scaleopp >> 8) << hpel;
1363 int mv1,
int r_x,
int r_y,
uint8_t* is_intra,
1364 int pred_flag,
int dir)
1371 int mixedmv_pic, num_samefield = 0, num_oppfield = 0;
1372 int opposite, a_f, b_f, c_f;
1373 int16_t field_predA[2];
1374 int16_t field_predB[2];
1375 int16_t field_predC[2];
1376 int a_valid, b_valid, c_valid;
1377 int hybridmv_thresh, y_bias = 0;
1425 off = (s->
mb_x > 0) ? -1 : 1;
1440 b_valid = a_valid && (s->
mb_width > 1);
1441 c_valid = s->
mb_x || (n == 1 || n == 3);
1443 a_valid = a_valid && !is_intra[xy -
wrap];
1444 b_valid = b_valid && !is_intra[xy - wrap +
off];
1445 c_valid = c_valid && !is_intra[xy - 1];
1450 num_oppfield += a_f;
1451 num_samefield += 1 - a_f;
1452 field_predA[0] = A[0];
1453 field_predA[1] = A[1];
1455 field_predA[0] = field_predA[1] = 0;
1460 num_oppfield += b_f;
1461 num_samefield += 1 - b_f;
1462 field_predB[0] = B[0];
1463 field_predB[1] = B[1];
1465 field_predB[0] = field_predB[1] = 0;
1470 num_oppfield += c_f;
1471 num_samefield += 1 - c_f;
1472 field_predC[0] = C[0];
1473 field_predC[1] = C[1];
1475 field_predC[0] = field_predC[1] = 0;
1485 if (num_samefield <= num_oppfield)
1486 opposite = 1 - pred_flag;
1488 opposite = pred_flag;
1493 if (a_valid && !a_f) {
1494 field_predA[0] =
scaleforopp(v, field_predA[0], 0, dir);
1495 field_predA[1] =
scaleforopp(v, field_predA[1], 1, dir);
1497 if (b_valid && !b_f) {
1498 field_predB[0] =
scaleforopp(v, field_predB[0], 0, dir);
1499 field_predB[1] =
scaleforopp(v, field_predB[1], 1, dir);
1501 if (c_valid && !c_f) {
1502 field_predC[0] =
scaleforopp(v, field_predC[0], 0, dir);
1503 field_predC[1] =
scaleforopp(v, field_predC[1], 1, dir);
1508 if (a_valid && a_f) {
1509 field_predA[0] =
scaleforsame(v, n, field_predA[0], 0, dir);
1510 field_predA[1] =
scaleforsame(v, n, field_predA[1], 1, dir);
1512 if (b_valid && b_f) {
1513 field_predB[0] =
scaleforsame(v, n, field_predB[0], 0, dir);
1514 field_predB[1] =
scaleforsame(v, n, field_predB[1], 1, dir);
1516 if (c_valid && c_f) {
1517 field_predC[0] =
scaleforsame(v, n, field_predC[0], 0, dir);
1518 field_predC[1] =
scaleforsame(v, n, field_predC[1], 1, dir);
1525 px = field_predA[0];
1526 py = field_predA[1];
1527 }
else if (c_valid) {
1528 px = field_predC[0];
1529 py = field_predC[1];
1530 }
else if (b_valid) {
1531 px = field_predB[0];
1532 py = field_predB[1];
1538 if (num_samefield + num_oppfield > 1) {
1539 px =
mid_pred(field_predA[0], field_predB[0], field_predC[0]);
1540 py =
mid_pred(field_predA[1], field_predB[1], field_predC[1]);
1546 qx = (s->
mb_x << 6) + ((n == 1 || n == 3) ? 32 : 0);
1547 qy = (s->
mb_y << 6) + ((n == 2 || n == 3) ? 32 : 0);
1551 if (qx + px < -60) px = -60 - qx;
1552 if (qy + py < -60) py = -60 - qy;
1554 if (qx + px < -28) px = -28 - qx;
1555 if (qy + py < -28) py = -28 - qy;
1557 if (qx + px > X) px = X - qx;
1558 if (qy + py > Y) py = Y - qy;
1563 hybridmv_thresh = 32;
1564 if (a_valid && c_valid) {
1565 if (is_intra[xy - wrap])
1568 sum =
FFABS(px - field_predA[0]) +
FFABS(py - field_predA[1]);
1569 if (sum > hybridmv_thresh) {
1571 px = field_predA[0];
1572 py = field_predA[1];
1574 px = field_predC[0];
1575 py = field_predC[1];
1578 if (is_intra[xy - 1])
1581 sum =
FFABS(px - field_predC[0]) +
FFABS(py - field_predC[1]);
1582 if (sum > hybridmv_thresh) {
1584 px = field_predA[0];
1585 py = field_predA[1];
1587 px = field_predC[0];
1588 py = field_predC[1];
1617 int mvn,
int r_x,
int r_y,
uint8_t* is_intra)
1621 int A[2],
B[2], C[2];
1623 int a_valid = 0, b_valid = 0, c_valid = 0;
1624 int field_a, field_b, field_c;
1625 int total_valid, num_samefield, num_oppfield;
1626 int pos_c, pos_b, n_adj;
1654 off = ((n == 0) || (n == 1)) ? 1 : -1;
1656 if (s->
mb_x || (n == 1) || (n == 3)) {
1676 B[0] = B[1] = C[0] = C[1] = 0;
1684 n_adj = (n & 2) | (n & 1);
1738 total_valid = a_valid + b_valid + c_valid;
1740 if (!s->
mb_x && !(n == 1 || n == 3)) {
1745 B[0] = B[1] = C[0] = C[1] = 0;
1752 if (total_valid >= 2) {
1755 }
else if (total_valid) {
1756 if (a_valid) { px = A[0]; py = A[1]; }
1757 if (b_valid) { px = B[0]; py = B[1]; }
1758 if (c_valid) { px = C[0]; py = C[1]; }
1764 field_a = (A[1] & 4) ? 1 : 0;
1768 field_b = (B[1] & 4) ? 1 : 0;
1772 field_c = (C[1] & 4) ? 1 : 0;
1776 num_oppfield = field_a + field_b + field_c;
1777 num_samefield = total_valid - num_oppfield;
1778 if (total_valid == 3) {
1779 if ((num_samefield == 3) || (num_oppfield == 3)) {
1782 }
else if (num_samefield >= num_oppfield) {
1785 px = !field_a ? A[0] : B[0];
1786 py = !field_a ? A[1] : B[1];
1788 px = field_a ? A[0] : B[0];
1789 py = field_a ? A[1] : B[1];
1791 }
else if (total_valid == 2) {
1792 if (num_samefield >= num_oppfield) {
1793 if (!field_a && a_valid) {
1796 }
else if (!field_b && b_valid) {
1799 }
else if (c_valid) {
1804 if (field_a && a_valid) {
1807 }
else if (field_b && b_valid) {
1810 }
else if (c_valid) {
1815 }
else if (total_valid == 1) {
1816 px = (a_valid) ? A[0] : ((b_valid) ? B[0] : C[0]);
1817 py = (a_valid) ? A[1] : ((b_valid) ? B[1] : C[1]);
1832 }
else if (mvn == 2) {
1835 s->
mv[0][n + 1][0] = s->
mv[0][n][0];
1836 s->
mv[0][n + 1][1] = s->
mv[0][n][1];
1847 int dxy, mx, my, uvmx, uvmy, src_x, src_y, uvsrc_x, uvsrc_y;
1854 mx = s->
mv[1][0][0];
1855 my = s->
mv[1][0][1];
1856 uvmx = (mx + ((mx & 3) == 3)) >> 1;
1857 uvmy = (my + ((my & 3) == 3)) >> 1;
1864 uvmx = uvmx + ((uvmx < 0) ? -(uvmx & 1) : (uvmx & 1));
1865 uvmy = uvmy + ((uvmy < 0) ? -(uvmy & 1) : (uvmy & 1));
1871 src_x = s->
mb_x * 16 + (mx >> 2);
1872 src_y = s->
mb_y * 16 + (my >> 2);
1873 uvsrc_x = s->
mb_x * 8 + (uvmx >> 2);
1874 uvsrc_y = s->
mb_y * 8 + (uvmy >> 2);
1877 src_x = av_clip( src_x, -16, s->
mb_width * 16);
1878 src_y = av_clip( src_y, -16, s->
mb_height * 16);
1879 uvsrc_x = av_clip(uvsrc_x, -8, s->
mb_width * 8);
1880 uvsrc_y = av_clip(uvsrc_y, -8, s->
mb_height * 8);
1888 srcY += src_y * s->
linesize + src_x;
1905 || (
unsigned)(src_x - 1) > s->
h_edge_pos - (mx & 3) - 16 - 3
1906 || (
unsigned)(src_y - 1) > v_edge_pos - (my & 3) - 16 - 3) {
1916 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
1918 uvsrc_x, uvsrc_y, s->
h_edge_pos >> 1, v_edge_pos >> 1);
1927 for (j = 0; j < 17 + s->
mspel * 2; j++) {
1928 for (i = 0; i < 17 + s->
mspel * 2; i++)
1929 src[i] = ((src[i] - 128) >> 1) + 128;
1934 for (j = 0; j < 9; j++) {
1935 for (i = 0; i < 9; i++) {
1936 src[i] = ((src[i] - 128) >> 1) + 128;
1937 src2[i] = ((src2[i] - 128) >> 1) + 128;
1955 dxy = ((my & 3) << 2) | (mx & 3);
1962 dxy = (my & 2) | ((mx & 2) >> 1);
1972 uvmx = (uvmx & 3) << 1;
1973 uvmy = (uvmy & 3) << 1;
1987 #if B_FRACTION_DEN==256
1991 return 2 * ((value * n + 255) >> 9);
1992 return (value * n + 128) >> 8;
2005 int direct,
int mode)
2034 int direct,
int mvtype)
2069 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));
2070 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));
2071 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));
2072 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));
2088 if (!s->
mb_x) C[0] = C[1] = 0;
2097 }
else if (s->
mb_x) {
2107 qx = (s->
mb_x << 5);
2108 qy = (s->
mb_y << 5);
2111 if (qx + px < -28) px = -28 - qx;
2112 if (qy + py < -28) py = -28 - qy;
2113 if (qx + px > X) px = X - qx;
2114 if (qy + py > Y) py = Y - qy;
2116 qx = (s->
mb_x << 6);
2117 qy = (s->
mb_y << 6);
2120 if (qx + px < -60) px = -60 - qx;
2121 if (qy + py < -60) py = -60 - qy;
2122 if (qx + px > X) px = X - qx;
2123 if (qy + py > Y) py = Y - qy;
2128 if (is_intra[xy - wrap])
2141 if (is_intra[xy - 2])
2157 s->
mv[0][0][0] = ((px + dmv_x[0] + r_x) & ((r_x << 1) - 1)) - r_x;
2158 s->
mv[0][0][1] = ((py + dmv_y[0] + r_y) & ((r_y << 1) - 1)) - r_y;
2176 }
else if (s->
mb_x) {
2186 qx = (s->
mb_x << 5);
2187 qy = (s->
mb_y << 5);
2190 if (qx + px < -28) px = -28 - qx;
2191 if (qy + py < -28) py = -28 - qy;
2192 if (qx + px > X) px = X - qx;
2193 if (qy + py > Y) py = Y - qy;
2195 qx = (s->
mb_x << 6);
2196 qy = (s->
mb_y << 6);
2199 if (qx + px < -60) px = -60 - qx;
2200 if (qy + py < -60) py = -60 - qy;
2201 if (qx + px > X) px = X - qx;
2202 if (qy + py > Y) py = Y - qy;
2207 if (is_intra[xy - wrap])
2220 if (is_intra[xy - 2])
2237 s->
mv[1][0][0] = ((px + dmv_x[1] + r_x) & ((r_x << 1) - 1)) - r_x;
2238 s->
mv[1][0][1] = ((py + dmv_y[1] + r_y) & ((r_y << 1) - 1)) - r_y;
2253 int total_opp, k, f;
2268 f = (total_opp > 2) ? 1 : 0;
2270 s->
mv[0][0][0] = s->
mv[0][0][1] = 0;
2271 s->
mv[1][0][0] = s->
mv[1][0][1] = 0;
2275 for (k = 0; k < 4; k++) {
2292 if (n == 3 || mv1) {
2297 if (n == 3 || mv1) {
2313 int16_t **dc_val_ptr,
int *dir_ptr)
2317 static const uint16_t dcpred[32] = {
2318 -1, 1024, 512, 341, 256, 205, 171, 146, 128,
2319 114, 102, 93, 85, 79, 73, 68, 64,
2320 60, 57, 54, 51, 49, 47, 45, 43,
2321 41, 39, 38, 37, 35, 34, 33
2335 b = dc_val[ - 1 -
wrap];
2336 a = dc_val[ -
wrap];
2338 if (pq < 9 || !overlap) {
2341 b = a = dcpred[
scale];
2342 if (s->
mb_x == 0 && (n != 1 && n != 3))
2343 b = c = dcpred[
scale];
2348 if (s->
mb_x == 0 && (n != 1 && n != 3))
2352 if (abs(a - b) <= abs(b - c)) {
2361 *dc_val_ptr = &dc_val[0];
2378 int a_avail,
int c_avail,
2379 int16_t **dc_val_ptr,
int *dir_ptr)
2394 b = dc_val[ - 1 -
wrap];
2395 a = dc_val[ -
wrap];
2399 if (dqscale_index < 0)
2401 if (c_avail && (n != 1 && n != 3)) {
2406 if (a_avail && (n != 2 && n != 3)) {
2411 if (a_avail && c_avail && (n != 3)) {
2422 if (a_avail && c_avail) {
2423 if (abs(a - b) <= abs(b - c)) {
2430 }
else if (a_avail) {
2433 }
else if (c_avail) {
2442 *dc_val_ptr = &dc_val[0];
2491 int *value,
int codingset)
2557 int coded,
int codingset)
2561 int dc_pred_dir = 0;
2564 int16_t *ac_val, *ac_val2;
2578 if (dcdiff == 119 ) {
2581 else if (v->
pq == 2) dcdiff =
get_bits(gb, 9);
2585 dcdiff = (dcdiff << 2) +
get_bits(gb, 2) - 3;
2586 else if (v->
pq == 2)
2587 dcdiff = (dcdiff << 1) +
get_bits1(gb) - 1;
2612 int last = 0, skip, value;
2639 block[zz_table[i++]] = value;
2645 for (k = 1; k < 8; k++)
2648 for (k = 1; k < 8; k++)
2653 for (k = 1; k < 8; k++) {
2659 for (k = 1; k < 64; k++)
2663 block[k] += (block[k] < 0) ? -v->
pq : v->
pq;
2677 memset(ac_val2, 0, 16 * 2);
2681 memcpy(ac_val2, ac_val, 8 * 2);
2685 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
2691 for (k = 1; k < 8; k++) {
2697 for (k = 1; k < 8; k++) {
2720 int coded,
int codingset,
int mquant)
2724 int dc_pred_dir = 0;
2727 int16_t *ac_val, *ac_val2;
2746 if (dcdiff == 119 ) {
2748 if (mquant == 1) dcdiff =
get_bits(gb, 10);
2749 else if (mquant == 2) dcdiff =
get_bits(gb, 9);
2753 dcdiff = (dcdiff << 2) +
get_bits(gb, 2) - 3;
2754 else if (mquant == 2)
2755 dcdiff = (dcdiff << 1) +
get_bits1(gb) - 1;
2776 if (!a_avail && !c_avail)
2781 scale = mquant * 2 + ((mquant == v->
pq) ? v->
halfpq : 0);
2789 if ( dc_pred_dir && c_avail && mb_pos)
2791 if (!dc_pred_dir && a_avail && mb_pos >= s->
mb_stride)
2793 if ( dc_pred_dir && n == 1)
2795 if (!dc_pred_dir && n == 2)
2801 int last = 0, skip, value;
2826 block[zz_table[i++]] = value;
2832 if (q2 && q1 != q2) {
2833 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
2834 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
2839 for (k = 1; k < 8; k++)
2842 for (k = 1; k < 8; k++)
2847 for (k = 1; k < 8; k++)
2850 for (k = 1; k < 8; k++)
2856 for (k = 1; k < 8; k++) {
2862 for (k = 1; k < 64; k++)
2866 block[k] += (block[k] < 0) ? -mquant : mquant;
2869 if (use_pred) i = 63;
2873 memset(ac_val2, 0, 16 * 2);
2876 memcpy(ac_val2, ac_val, 8 * 2);
2877 if (q2 && q1 != q2) {
2878 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
2879 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
2882 for (k = 1; k < 8; k++)
2883 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
2888 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
2889 if (q2 && q1 != q2) {
2890 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
2891 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
2894 for (k = 1; k < 8; k++)
2895 ac_val2[k + 8] = (ac_val2[k + 8] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
2903 for (k = 1; k < 8; k++) {
2909 for (k = 1; k < 8; k++) {
2932 int coded,
int mquant,
int codingset)
2936 int dc_pred_dir = 0;
2939 int16_t *ac_val, *ac_val2;
2950 mquant = (mquant < 1) ? 0 : ((mquant > 31) ? 31 : mquant);
2967 if (dcdiff == 119 ) {
2969 if (mquant == 1) dcdiff =
get_bits(gb, 10);
2970 else if (mquant == 2) dcdiff =
get_bits(gb, 9);
2974 dcdiff = (dcdiff << 2) +
get_bits(gb, 2) - 3;
2975 else if (mquant == 2)
2976 dcdiff = (dcdiff << 1) +
get_bits1(gb) - 1;
2983 dcdiff +=
vc1_pred_dc(&v->
s, v->
overlap, mquant, n, a_avail, c_avail, &dc_val, &dc_pred_dir);
2998 if (!a_avail) dc_pred_dir = 1;
2999 if (!c_avail) dc_pred_dir = 0;
3000 if (!a_avail && !c_avail) use_pred = 0;
3004 scale = mquant * 2 + v->
halfpq;
3012 if (dc_pred_dir && c_avail && mb_pos)
3014 if (!dc_pred_dir && a_avail && mb_pos >= s->
mb_stride)
3016 if ( dc_pred_dir && n == 1)
3018 if (!dc_pred_dir && n == 2)
3020 if (n == 3) q2 = q1;
3023 int last = 0, skip, value;
3032 block[v->
zz_8x8[0][i++]] = value;
3036 block[v->
zz_8x8[2][i++]] = value;
3038 block[v->
zz_8x8[3][i++]] = value;
3040 block[v->
zzi_8x8[i++]] = value;
3048 if (q2 && q1 != q2) {
3049 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
3050 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
3055 for (k = 1; k < 8; k++)
3058 for (k = 1; k < 8; k++)
3063 for (k = 1; k < 8; k++)
3066 for (k = 1; k < 8; k++)
3072 for (k = 1; k < 8; k++) {
3078 for (k = 1; k < 64; k++)
3082 block[k] += (block[k] < 0) ? -mquant : mquant;
3085 if (use_pred) i = 63;
3089 memset(ac_val2, 0, 16 * 2);
3092 memcpy(ac_val2, ac_val, 8 * 2);
3093 if (q2 && q1 != q2) {
3094 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
3095 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
3098 for (k = 1; k < 8; k++)
3099 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
3104 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
3105 if (q2 && q1 != q2) {
3106 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
3107 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
3110 for (k = 1; k < 8; k++)
3111 ac_val2[k + 8] = (ac_val2[k + 8] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
3119 for (k = 1; k < 8; k++) {
3125 for (k = 1; k < 8; k++) {
3142 int mquant,
int ttmb,
int first_block,
3143 uint8_t *dst,
int linesize,
int skip_block,
3150 int scale,
off, idx, last, skip, value;
3151 int ttblk = ttmb & 7;
3163 && ((v->
ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
3173 scale = 2 * mquant + ((v->
pq == mquant) ? v->
halfpq : 0);
3198 block[idx] = value *
scale;
3200 block[idx] += (block[idx] < 0) ? -mquant : mquant;
3212 pat = ~subblkpat & 0xF;
3213 for (j = 0; j < 4; j++) {
3214 last = subblkpat & (1 << (3 - j));
3216 off = (j & 1) * 4 + (j & 2) * 16;
3228 block[idx +
off] += (block[idx +
off] < 0) ? -mquant : mquant;
3230 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
3239 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
3240 for (j = 0; j < 2; j++) {
3241 last = subblkpat & (1 << (1 - j));
3253 block[idx] = value *
scale;
3255 block[idx] += (block[idx] < 0) ? -mquant : mquant;
3257 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
3266 pat = ~(subblkpat * 5) & 0xF;
3267 for (j = 0; j < 2; j++) {
3268 last = subblkpat & (1 << (1 - j));
3280 block[idx] = value *
scale;
3282 block[idx] += (block[idx] < 0) ? -mquant : mquant;
3284 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
3294 *ttmb_out |= ttblk << (n * 4);
3307 block_cbp = mb_cbp >> (block_num * 4), bottom_cbp,
3309 block_is_intra = mb_is_intra >> (block_num * 4), bottom_is_intra;
3313 if (block_num > 3) {
3314 dst = s->
dest[block_num - 3];
3316 dst = s->
dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 8) * linesize;
3322 if (block_num > 3) {
3323 bottom_cbp = v->
cbp[s->
mb_x] >> (block_num * 4);
3324 bottom_is_intra = v->
is_intra[s->
mb_x] >> (block_num * 4);
3328 bottom_cbp = (block_num < 2) ? (mb_cbp >> ((block_num + 2) * 4))
3329 : (v->
cbp[s->
mb_x] >> ((block_num - 2) * 4));
3330 bottom_is_intra = (block_num < 2) ? (mb_is_intra >> ((block_num + 2) * 4))
3336 if (bottom_is_intra & 1 || block_is_intra & 1 ||
3337 mv[0][0] !=
mv[mv_stride][0] ||
mv[0][1] !=
mv[mv_stride][1]) {
3340 idx = ((bottom_cbp >> 2) | block_cbp) & 3;
3352 dst -= 4 * linesize;
3355 idx = (block_cbp | (block_cbp >> 2)) & 3;
3371 block_cbp = mb_cbp >> (block_num * 4), right_cbp,
3373 block_is_intra = mb_is_intra >> (block_num * 4), right_is_intra;
3377 if (block_num > 3) {
3378 dst = s->
dest[block_num - 3] - 8 * linesize;
3380 dst = s->
dest[0] + (block_num & 1) * 8 + ((block_num & 2) * 4 - 16) * linesize - 8;
3386 if (block_num > 3) {
3391 right_cbp = (block_num & 1) ? (v->
cbp[s->
mb_x - s->
mb_stride] >> ((block_num - 1) * 4))
3392 : (mb_cbp >> ((block_num + 1) * 4));
3394 : (mb_is_intra >> ((block_num + 1) * 4));
3397 if (block_is_intra & 1 || right_is_intra & 1 ||
mv[0][0] !=
mv[1][0] ||
mv[0][1] !=
mv[1][1]) {
3400 idx = ((right_cbp >> 1) | block_cbp) & 5;
3415 idx = (block_cbp | (block_cbp >> 1)) & 5;
3432 for (i = 0; i < 6; i++) {
3439 for (i = 0; i < 6; i++) {
3445 for (i = 0; i < 6; i++) {
3462 int ttmb = v->
ttfrm;
3464 int mb_has_coeffs = 1;
3468 int first_block = 1;
3470 int skipped, fourmv;
3471 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
3496 if (s->
mb_intra && !mb_has_coeffs) {
3500 }
else if (mb_has_coeffs) {
3516 for (i = 0; i < 6; i++) {
3519 val = ((cbp >> (5 - i)) & 1);
3520 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3527 if (i == 1 || i == 3 || s->
mb_x)
3536 for (j = 0; j < 64; j++)
3537 s->
block[i][j] <<= 1;
3545 block_cbp |= 0xF << (i << 2);
3546 block_intra |= 1 << i;
3551 block_cbp |= pat << (i << 2);
3552 if (!v->
ttmbf && ttmb < 8)
3559 for (i = 0; i < 6; i++) {
3570 int intra_count = 0, coded_inter = 0;
3571 int is_intra[6], is_coded[6];
3574 for (i = 0; i < 6; i++) {
3575 val = ((cbp >> (5 - i)) & 1);
3590 is_coded[i] = mb_has_coeffs;
3593 is_intra[i] = (intra_count >= 3);
3600 coded_inter = !is_intra[i] & is_coded[i];
3604 if (!intra_count && !coded_inter)
3611 for (i = 0; i < 6; i++)
3624 if (!v->
ttmbf && coded_inter)
3626 for (i = 0; i < 6; i++) {
3628 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3635 if (i == 1 || i == 3 || s->
mb_x)
3644 for (j = 0; j < 64; j++)
3645 s->
block[i][j] <<= 1;
3654 block_cbp |= 0xF << (i << 2);
3655 block_intra |= 1 << i;
3656 }
else if (is_coded[i]) {
3658 first_block, s->
dest[dst_idx] + off,
3662 block_cbp |= pat << (i << 2);
3663 if (!v->
ttmbf && ttmb < 8)
3671 for (i = 0; i < 6; i++) {
3675 for (i = 0; i < 4; i++) {
3701 int ttmb = v->
ttfrm;
3703 int mb_has_coeffs = 1;
3706 int first_block = 1;
3708 int skipped, fourmv = 0, twomv = 0;
3709 int block_cbp = 0, pat, block_tt = 0;
3710 int idx_mbmode = 0, mvbp;
3711 int stride_y, fieldtx;
3759 for (i = 0; i < 6; i++)
3772 for (i = 0; i < 6; i++) {
3775 val = ((cbp >> (5 - i)) & 1);
3780 if (i == 1 || i == 3 || s->
mb_x)
3789 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->
linesize : (i & 1) * 8 + 4 * (i & 2) * s->
linesize;
3811 for (i = 0; i < 6; i++)
3818 for (i = 0; i < 6; i++) {
3821 val = ((mvbp >> (3 - i)) & 1);
3827 }
else if (i == 4) {
3860 if (!v->
ttmbf && cbp)
3862 for (i = 0; i < 6; i++) {
3865 val = ((cbp >> (5 - i)) & 1);
3867 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3869 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->
linesize));
3872 first_block, s->
dest[dst_idx] + off,
3875 block_cbp |= pat << (i << 2);
3876 if (!v->
ttmbf && ttmb < 8)
3884 for (i = 0; i < 6; i++) {
3910 int ttmb = v->
ttfrm;
3912 int mb_has_coeffs = 1;
3915 int first_block = 1;
3918 int block_cbp = 0, pat, block_tt = 0;
3924 if (idx_mbmode <= 1) {
3935 mb_has_coeffs = idx_mbmode & 1;
3939 for (i = 0; i < 6; i++) {
3943 val = ((cbp >> (5 - i)) & 1);
3947 if (i == 1 || i == 3 || s->
mb_x)
3955 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
3964 if (idx_mbmode <= 5) {
3965 dmv_x = dmv_y = pred_flag = 0;
3966 if (idx_mbmode & 1) {
3971 mb_has_coeffs = !(idx_mbmode & 2);
3974 for (i = 0; i < 6; i++) {
3976 dmv_x = dmv_y = pred_flag = 0;
3977 val = ((v->
fourmvbp >> (3 - i)) & 1);
3986 mb_has_coeffs = idx_mbmode & 1;
3994 if (!v->
ttmbf && cbp) {
3998 for (i = 0; i < 6; i++) {
4001 val = ((cbp >> (5 - i)) & 1);
4002 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
4007 first_block, s->
dest[dst_idx] + off,
4011 block_cbp |= pat << (i << 2);
4012 if (!v->
ttmbf && ttmb < 8) ttmb = -1;
4032 int ttmb = v->
ttfrm;
4033 int mb_has_coeffs = 0;
4036 int first_block = 1;
4038 int skipped, direct;
4039 int dmv_x[2], dmv_y[2];
4054 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
4055 for (i = 0; i < 6; i++) {
4064 dmv_x[1] = dmv_x[0];
4065 dmv_y[1] = dmv_y[0];
4078 dmv_x[0] = dmv_y[0] = 0;
4082 for (i = 0; i < 6; i++)
4089 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4099 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
4101 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4103 if (!mb_has_coeffs && !s->
mb_intra) {
4106 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4109 if (s->
mb_intra && !mb_has_coeffs) {
4118 if (!mb_has_coeffs) {
4121 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4127 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
4139 for (i = 0; i < 6; i++) {
4142 val = ((cbp >> (5 - i)) & 1);
4143 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
4150 if (i == 1 || i == 3 || s->
mb_x)
4159 for (j = 0; j < 64; j++)
4160 s->
block[i][j] <<= 1;
4164 first_block, s->
dest[dst_idx] + off,
4167 if (!v->
ttmbf && ttmb < 8)
4184 int ttmb = v->
ttfrm;
4185 int mb_has_coeffs = 0;
4187 int first_block = 1;
4190 int dmv_x[2], dmv_y[2], pred_flag[2];
4192 int idx_mbmode, interpmvp;
4198 if (idx_mbmode <= 1) {
4209 mb_has_coeffs = idx_mbmode & 1;
4213 for (i = 0; i < 6; i++) {
4216 val = ((cbp >> (5 - i)) & 1);
4221 if (i == 1 || i == 3 || s->
mb_x)
4230 for (j = 0; j < 64; j++)
4231 s->
block[i][j] <<= 1;
4232 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
4245 if (idx_mbmode <= 5) {
4246 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
4247 pred_flag[0] = pred_flag[1] = 0;
4272 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
4273 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
4277 mb_has_coeffs = !(idx_mbmode & 2);
4283 for (i = 0; i < 6; i++) {
4285 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
4286 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
4287 val = ((v->
fourmvbp >> (3 - i)) & 1);
4298 mb_has_coeffs = idx_mbmode & 1;
4306 if (!v->
ttmbf && cbp) {
4310 for (i = 0; i < 6; i++) {
4313 val = ((cbp >> (5 - i)) & 1);
4314 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
4319 first_block, s->
dest[dst_idx] + off,
4322 if (!v->
ttmbf && ttmb < 8)
4379 dst[0] = s->
dest[0];
4380 dst[1] = dst[0] + 8;
4382 dst[3] = dst[2] + 8;
4383 dst[4] = s->
dest[1];
4384 dst[5] = s->
dest[2];
4396 for (k = 0; k < 6; k++) {
4397 val = ((cbp >> (5 - k)) & 1);
4404 cbp |= val << (5 - k);
4413 for (j = 0; j < 64; j++)
4414 s->
block[k][j] <<= 1;
4418 for (j = 0; j < 64; j++)
4550 for (k = 0; k < 6; k++) {
4551 val = ((cbp >> (5 - k)) & 1);
4558 cbp |= val << (5 - k);
4666 if (apply_loop_filter) {
4800 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
4816 int effect_type, effect_flag;
4817 int effect_pcount1, effect_pcount2;
4818 int effect_params1[15], effect_params2[10];
4826 static void vc1_sprite_parse_transform(
GetBitContext* gb,
int c[7])
4833 c[2] = get_fp_val(gb);
4837 c[0] = c[4] = get_fp_val(gb);
4838 c[2] = get_fp_val(gb);
4841 c[0] = get_fp_val(gb);
4842 c[2] = get_fp_val(gb);
4843 c[4] = get_fp_val(gb);
4846 c[0] = get_fp_val(gb);
4847 c[1] = get_fp_val(gb);
4848 c[2] = get_fp_val(gb);
4849 c[3] = get_fp_val(gb);
4850 c[4] = get_fp_val(gb);
4853 c[5] = get_fp_val(gb);
4855 c[6] = get_fp_val(gb);
4865 for (sprite = 0; sprite <= v->
two_sprites; sprite++) {
4866 vc1_sprite_parse_transform(gb, sd->coefs[sprite]);
4867 if (sd->coefs[sprite][1] || sd->coefs[sprite][3])
4870 for (i = 0; i < 7; i++)
4872 sd->coefs[sprite][i] / (1<<16),
4873 (abs(sd->coefs[sprite][i]) & 0xFFFF) * 1000 / (1 << 16));
4879 switch (sd->effect_pcount1 =
get_bits(gb, 4)) {
4881 vc1_sprite_parse_transform(gb, sd->effect_params1);
4884 vc1_sprite_parse_transform(gb, sd->effect_params1);
4885 vc1_sprite_parse_transform(gb, sd->effect_params1 + 7);
4888 for (i = 0; i < sd->effect_pcount1; i++)
4889 sd->effect_params1[i] = get_fp_val(gb);
4891 if (sd->effect_type != 13 || sd->effect_params1[0] != sd->coefs[0][6]) {
4894 for (i = 0; i < sd->effect_pcount1; i++)
4896 sd->effect_params1[i] / (1 << 16),
4897 (abs(sd->effect_params1[i]) & 0xFFFF) * 1000 / (1 << 16));
4901 sd->effect_pcount2 =
get_bits(gb, 16);
4902 if (sd->effect_pcount2 > 10) {
4905 }
else if (sd->effect_pcount2) {
4908 while (++i < sd->effect_pcount2) {
4909 sd->effect_params2[i] = get_fp_val(gb);
4911 sd->effect_params2[i] / (1 << 16),
4912 (abs(sd->effect_params2[i]) & 0xFFFF) * 1000 / (1 << 16));
4927 static void vc1_draw_sprites(
VC1Context *v, SpriteData* sd)
4929 int i, plane, row, sprite;
4930 int sr_cache[2][2] = { { -1, -1 }, { -1, -1 } };
4932 int xoff[2], xadv[2], yoff[2], yadv[2], alpha;
4936 for (i = 0; i < 2; i++) {
4937 xoff[i] = av_clip(sd->coefs[i][2], 0, v->
sprite_width-1 << 16);
4938 xadv[i] = sd->coefs[i][0];
4942 yoff[i] = av_clip(sd->coefs[i][5], 0, v->
sprite_height-1 << 16);
4945 alpha = av_clip(sd->coefs[1][6], 0, (1<<16) - 1);
4954 for (sprite = 0; sprite <= v->
two_sprites; sprite++) {
4957 int ycoord = yoff[sprite] + yadv[sprite] * row;
4958 int yline = ycoord >> 16;
4960 ysub[sprite] = ycoord & 0xFFFF;
4966 if (!(xoff[sprite] & 0xFFFF) && xadv[sprite] == 1 << 16) {
4967 src_h[sprite][0] = iplane + (xoff[sprite] >> 16) + yline * iline;
4969 src_h[sprite][1] = iplane + (xoff[sprite] >> 16) + next_line;
4971 if (sr_cache[sprite][0] != yline) {
4972 if (sr_cache[sprite][1] == yline) {
4974 FFSWAP(
int, sr_cache[sprite][0], sr_cache[sprite][1]);
4976 v->
vc1dsp.
sprite_h(v->
sr_rows[sprite][0], iplane + yline * iline, xoff[sprite], xadv[sprite], width);
4977 sr_cache[sprite][0] = yline;
4980 if (ysub[sprite] && sr_cache[sprite][1] != yline + 1) {
4982 iplane + next_line, xoff[sprite],
4983 xadv[sprite], width);
4984 sr_cache[sprite][1] = yline + 1;
4986 src_h[sprite][0] = v->
sr_rows[sprite][0];
4987 src_h[sprite][1] = v->
sr_rows[sprite][1];
4995 memcpy(dst, src_h[0][0], width);
4998 if (ysub[0] && ysub[1]) {
5000 src_h[1][0], src_h[1][1], ysub[1], alpha, width);
5001 }
else if (ysub[0]) {
5003 src_h[1][0], alpha, width);
5004 }
else if (ysub[1]) {
5006 src_h[0][0], (1<<16)-1-alpha, width);
5014 for (i = 0; i < 2; i++) {
5030 vc1_parse_sprites(v, gb, &sd);
5052 vc1_draw_sprites(v, &sd);
5072 plane ? 128 : 0, f->
linesize[plane]);
5131 for (i = 0; i < 4; i++)
5157 for (i = 0; i < 64; i++) {
5158 #define transpose(x) ((x >> 3) | ((x & 7) << 3))
5219 }
else if (count < 0) {
5226 int size, buf2_size;
5228 int seq_initialized = 0, ep_initialized = 0;
5238 for (; next < end; start = next) {
5240 size = next - start - 4;
5251 seq_initialized = 1;
5263 if (!seq_initialized || !ep_initialized) {
5314 for (i = 0; i < 4; i++)
5347 int buf_size = avpkt->
size, n_slices = 0, i;
5352 const uint8_t *buf_start = buf;
5353 int mb_height, n_slices1;
5358 } *slices =
NULL, *tmp;
5386 const uint8_t *start, *end, *next;
5390 for (start = buf, end = buf + buf_size; next < end; start = next) {
5392 size = next - start - 4;
5393 if (size <= 0)
continue;
5403 tmp =
av_realloc(slices,
sizeof(*slices) * (n_slices+1));
5408 if (!slices[n_slices].buf)
5411 slices[n_slices].buf);
5416 slices[n_slices].mby_start = s->
mb_height >> 1;
5417 n_slices1 = n_slices - 1;
5428 tmp =
av_realloc(slices,
sizeof(*slices) * (n_slices+1));
5433 if (!slices[n_slices].buf)
5436 slices[n_slices].buf);
5439 slices[n_slices].mby_start =
get_bits(&slices[n_slices].gb, 9);
5445 }
else if (v->
interlace && ((buf[0] & 0xC0) == 0xC0)) {
5454 tmp =
av_realloc(slices,
sizeof(*slices) * (n_slices+1));
5459 if (!slices[n_slices].buf)
5461 buf_size3 =
vc1_unescape_buffer(divider + 4, buf + buf_size - divider - 4, slices[n_slices].buf);
5464 slices[n_slices].mby_start = s->
mb_height >> 1;
5465 n_slices1 = n_slices - 1;
5598 v->
bits = buf_size * 8;
5613 v->
mv_f[0] = tmp[0];
5614 v->
mv_f[1] = tmp[1];
5623 for (i = 0; i <= n_slices; i++) {
5624 if (i > 0 && slices[i - 1].mby_start >= mb_height) {
5627 "picture boundary (%d >= %d)\n", i,
5628 slices[i - 1].mby_start, mb_height);
5656 s->
start_mb_y = (i == 0) ? 0 :
FFMAX(0, slices[i-1].mby_start % mb_height);
5658 s->
end_mb_y = (i == n_slices ) ? mb_height :
FFMIN(mb_height, slices[i].mby_start % mb_height);
5660 s->
end_mb_y = (i <= n_slices1 + 1) ? mb_height :
FFMIN(mb_height, slices[i].mby_start % mb_height);
5663 s->
gb = slices[i].gb;
5692 #if CONFIG_WMV3IMAGE_DECODER || CONFIG_VC1IMAGE_DECODER
5693 if (vc1_decode_sprites(v, &s->
gb))
5712 for (i = 0; i < n_slices; i++)
5719 for (i = 0; i < n_slices; i++)
5749 #if CONFIG_WMV3_DECODER
5766 #if CONFIG_WMV3_VDPAU_DECODER
5767 AVCodec ff_wmv3_vdpau_decoder = {
5768 .
name =
"wmv3_vdpau",
5782 #if CONFIG_VC1_VDPAU_DECODER
5783 AVCodec ff_vc1_vdpau_decoder = {
5784 .
name =
"vc1_vdpau",
5798 #if CONFIG_WMV3IMAGE_DECODER
5799 AVCodec ff_wmv3image_decoder = {
5800 .
name =
"wmv3image",
5808 .
flush = vc1_sprite_flush,
5814 #if CONFIG_VC1IMAGE_DECODER
5815 AVCodec ff_vc1image_decoder = {
5824 .
flush = vc1_sprite_flush,
static void vc1_smooth_overlap_filter_iblk(VC1Context *v)
in the bitstream is reported as 00b
enum AVPixelFormat ff_hwaccel_pixfmt_list_420[]
const int ff_vc1_ttblk_to_tt[3][8]
Table for conversion between TTBLK and TTMB.
op_pixels_func avg_vc1_mspel_pixels_tab[16]
int use_ic
use intensity compensation in B-frames
#define VC1_TTBLK_VLC_BITS
void(* vc1_h_overlap)(uint8_t *src, int stride)
const struct AVCodec * codec
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
discard all frames except keyframes
void ff_init_block_index(MpegEncContext *s)
op_pixels_func put_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
#define VC1_IF_MBMODE_VLC_BITS
int(* start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Called at the beginning of each frame or field picture.
This structure describes decoded (raw) audio or video data.
#define VC1_ICBPCY_VLC_BITS
void(* vc1_inv_trans_4x8)(uint8_t *dest, int line_size, DCTELEM *block)
static int vc1_decode_p_mb(VC1Context *v)
Decode one P-frame MB.
int k_x
Number of bits for MVs (depends on MV range)
int reffield
if numref = 0 (1 reference) then reffield decides which
int start_mb_y
start mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
const uint8_t * y_dc_scale_table
qscale -> y_dc_scale table
int coded_width
Bitstream width / height, may be different from width/height.
int mv_type_is_raw
mv type mb plane is not coded
int buffer_hints
codec suggestion on buffer type if != 0
void(* release_buffer)(struct AVCodecContext *c, AVFrame *pic)
Called to release buffers which were allocated with get_buffer.
static av_always_inline int scaleforsame(VC1Context *v, int i, int n, int dim, int dir)
uint8_t dmvrange
Frame decoding info for interlaced picture.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define FF_PROFILE_VC1_SIMPLE
static av_always_inline int scaleforopp_y(VC1Context *v, int n, int dir)
static const uint8_t vc1_index_decode_table[AC_MODES][185][2]
int end_mb_y
end mb_y of this thread (so current thread should process start_mb_y <= row < end_mb_y) ...
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int16_t(*[3] ac_val)[16]
used for for mpeg4 AC prediction, all 3 arrays must be continuous
static const int vc1_last_decode_table[AC_MODES]
#define FF_PROFILE_VC1_MAIN
int tt_index
Index for Transform Type tables (to decode TTMB)
static void vc1_decode_p_blocks(VC1Context *v)
static void vc1_put_signed_blocks_clamped(VC1Context *v)
int v_edge_pos
horizontal / vertical position of the right/bottom edge (pixel replication)
#define GET_MVDATA(_dmv_x, _dmv_y)
Get MV differentials.
#define VC1_2REF_MVDATA_VLC_BITS
void ff_er_frame_end(ERContext *s)
void(* sprite_v_double_onescale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1, const uint8_t *src2a, int alpha, int width)
int repeat_pict
When decoding, this signals how much the picture must be delayed.
static int vc1_decode_intra_block(VC1Context *v, DCTELEM block[64], int n, int coded, int mquant, int codingset)
Decode intra block in inter frames - more generic version than vc1_decode_i_block.
#define CODEC_CAP_HWACCEL_VDPAU
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
int ff_msmpeg4_decode_init(AVCodecContext *avctx)
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
uint8_t zz_8x8[4][64]
Zigzag table for TT_8x8, permuted for IDCT.
static void vc1_decode_b_blocks(VC1Context *v)
av_dlog(ac->avr,"%d samples - audio_convert: %s to %s (%s)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt), use_generic?ac->func_descr_generic:ac->func_descr)
uint8_t * mv_f[2]
0: MV obtained from same field, 1: opposite field
int fastuvmc
Rounding of qpel vector to hpel ? (not in Simple)
int end_mb_x
Horizontal macroblock limit (used only by mss2)
struct VC1Context VC1Context
The VC1 Context.
void(* vc1_v_loop_filter8)(uint8_t *src, int stride, int pq)
void ff_vc1_decode_blocks(VC1Context *v)
static void vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, int mv1, int *pred_flag)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int vc1_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
enum AVDiscard skip_frame
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS
static void vc1_apply_p_loop_filter(VC1Context *v)
const uint16_t ff_vc1_b_field_mvpred_scales[7][4]
struct AVHWAccel * hwaccel
Hardware accelerator in use.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
int refdist
distance of the current picture from reference
uint8_t * acpred_plane
AC prediction flags bitplane.
void(* emulated_edge_mc)(uint8_t *buf, const uint8_t *src, ptrdiff_t linesize, int block_w, int block_h, int src_x, int src_y, int w, int h)
Copy a rectangular area of samples to a temporary buffer and replicate the border samples...
static int decode(MimicContext *ctx, int quality, int num_coeffs, int is_iframe)
static const AVProfile profiles[]
#define FFSWAP(type, a, b)
static int vc1_decode_i_block(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset)
Decode intra block in intra frames - should be faster than decode_intra_block.
void(* vc1_v_loop_filter4)(uint8_t *src, int stride, int pq)
void(* sprite_v_double_twoscale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset1, const uint8_t *src2a, const uint8_t *src2b, int offset2, int alpha, int width)
void(* vc1_inv_trans_8x4_dc)(uint8_t *dest, int line_size, DCTELEM *block)
h264_chroma_mc_func avg_h264_chroma_pixels_tab[3]
static void vc1_mc_4mv_chroma4(VC1Context *v)
Do motion compensation for 4-MV field chroma macroblock (both U and V)
void(* vc1_inv_trans_4x8_dc)(uint8_t *dest, int line_size, DCTELEM *block)
int interlace
Progressive/interlaced (RPTFTM syntax element)
int y_ac_table_index
Luma index from AC2FRM element.
qpel_mc_func(* qpel_put)[16]
void ff_mpeg_er_frame_start(MpegEncContext *s)
void(* vc1_inv_trans_8x8)(DCTELEM *b)
int c_ac_table_index
AC coding set indexes.
const int ff_vc1_ac_sizes[AC_MODES]
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
int ttfrm
Transform type info present at frame level.
Picture current_picture
copy of the current picture structure.
uint8_t lutuv[256]
lookup tables used for intensity compensation
int codingset2
index of current table set from 11.8 to use for chroma block decoding
int16_t bfraction
Relative position % anchors=> how to scale MVs.
op_pixels_func avg_pixels_tab[4][4]
Halfpel motion compensation with rounding (a+b+1)>>1.
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags...
static void vc1_loop_filter_iblk_delayed(VC1Context *v, int pq)
static int get_bits_count(const GetBitContext *s)
void(* vc1_h_loop_filter8)(uint8_t *src, int stride, int pq)
static av_always_inline int scaleforsame_x(VC1Context *v, int n, int dir)
void(* vc1_inv_trans_8x8_dc)(uint8_t *dest, int line_size, DCTELEM *block)
uint8_t * forward_mb_plane
bitplane for "forward" MBs
#define MKTAG(a, b, c, d)
WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstrea...
int mb_height
number of MBs horizontally & vertically
enum AVPixelFormat ff_pixfmt_list_420[]
int ff_vc1_decode_sequence_header(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb)
Decode Simple/Main Profiles sequence header.
static void vc1_b_mc(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mode)
Reconstruct motion vector for B-frame and do motion compensation.
void ff_MPV_frame_end(MpegEncContext *s)
static void vc1_mc_4mv_luma(VC1Context *v, int n, int dir)
Do motion compensation for 4-MV macroblock - luminance block.
uint8_t * over_flags_plane
Overflags bitplane.
static void vc1_decode_b_mb(VC1Context *v)
Decode one B-frame MB (in Main profile)
const int8_t ff_vc1_adv_interlaced_4x8_zz[32]
static void ff_update_block_index(MpegEncContext *s)
static int init(AVCodecParserContext *s)
qpel_mc_func put_qpel_pixels_tab[2][16]
uint8_t ttmbf
Transform type flag.
int k_y
Number of bits for MVs (depends on MV range)
void(* add_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size)
static int get_bits_left(GetBitContext *gb)
int16_t * dc_val[3]
used for mpeg4 DC prediction, all 3 arrays must be continuous
void(* put_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size)
int dmb_is_raw
direct mb plane is raw
static int vc1_i_pred_dc(MpegEncContext *s, int overlap, int pq, int n, int16_t **dc_val_ptr, int *dir_ptr)
Get predicted DC value for I-frames only prediction dir: left=0, top=1.
#define VC1_CBPCY_P_VLC_BITS
int has_b_frames
Size of the frame reordering buffer in the decoder.
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
int overlap
overlapped transforms in use
in the bitstream is reported as 11b
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
void av_log_ask_for_sample(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message asking for a sample.
int reference
is this picture used as reference The values for this are the same as the MpegEncContext.picture_structure variable, that is 1->top field, 2->bottom field, 3->frame/both fields.
const int8_t ff_vc1_simple_progressive_4x4_zz[16]
void(* vc1_inv_trans_4x4_dc)(uint8_t *dest, int line_size, DCTELEM *block)
qpel_mc_func avg_qpel_pixels_tab[2][16]
static void vc1_mc_1mv(VC1Context *v, int dir)
Do motion compensation over 1 macroblock Mostly adapted hpel_motion and qpel_motion from mpegvideo...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static av_cold int vc1_decode_init(AVCodecContext *avctx)
Initialize a VC1/WMV3 decoder.
#define GET_MQUANT()
Get macroblock-level quantizer scale.
AVFrame sprite_output_frame
int capabilities
Codec capabilities.
uint8_t * edge_emu_buffer
temporary buffer for if MVs point to out-of-frame data
static int vc1_decode_i_block_adv(VC1Context *v, DCTELEM block[64], int n, int coded, int codingset, int mquant)
Decode intra block in intra frames - should be faster than decode_intra_block.
void(* vc1_v_s_overlap)(DCTELEM *top, DCTELEM *bottom)
static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquant, int ttmb, int first_block, uint8_t *dst, int linesize, int skip_block, int *ttmb_out)
Decode P block.
void av_log(void *avcl, int level, const char *fmt,...)
const char * name
Name of the codec implementation.
#define IS_MARKER(state, i, buf, buf_size)
int quarter_sample
1->qpel, 0->half pel ME/MC
int low_delay
no reordering needed / has no b-frames
op_pixels_func put_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
#define CODEC_FLAG_EMU_EDGE
void(* clear_block)(DCTELEM *block)
void(* vc1_v_loop_filter16)(uint8_t *src, int stride, int pq)
static av_always_inline int scaleforsame_y(VC1Context *v, int i, int n, int dir)
const uint8_t * zz_8x4
Zigzag scan table for TT_8x4 coding mode.
int res_rtm_flag
reserved, set to 1
h264_chroma_mc_func put_h264_chroma_pixels_tab[3]
h264 Chroma MC
uint8_t * blk_mv_type
0: frame MV, 1: field MV (interlaced frame)
static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset)
Decode one AC coefficient.
void ff_mpeg_flush(AVCodecContext *avctx)
const int8_t ff_vc1_adv_interlaced_4x4_zz[16]
int ff_vc1_parse_frame_header_adv(VC1Context *v, GetBitContext *gb)
static av_always_inline int scaleforopp(VC1Context *v, int n, int dim, int dir)
int cur_field_type
0: top, 1: bottom
const uint8_t ff_wmv1_scantable[WMV1_SCANTABLE_COUNT][64]
const uint8_t * zz_4x8
Zigzag scan table for TT_4x8 coding mode.
enum AVPixelFormat * pix_fmts
array of supported pixel formats, or NULL if unknown, array is terminated by -1
static av_always_inline int scaleforopp_x(VC1Context *v, int n)
enum AVPictureType pict_type
Picture type of the frame, see ?_TYPE below.
av_cold int ff_vc1_decode_end(AVCodecContext *avctx)
Close a VC1/WMV3 decoder.
av_cold void ff_vc1_init_transposed_scantables(VC1Context *v)
int next_p_frame_damaged
set if the next p frame is damaged, to avoid showing trashed b frames
uint8_t * blk_mv_type_base
av_cold void ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s)
Initialize IntraX8 frame decoder.
int field_mode
1 for interlaced field pictures
av_cold void ff_intrax8_common_end(IntraX8Context *w)
Destroy IntraX8 frame structure.
int width
picture width / height.
#define VC1_SUBBLKPAT_VLC_BITS
uint8_t * mbskip_table
used to avoid copy if macroblock skipped (for black regions for example) and used for b-frame encodin...
int idct_algo
IDCT algorithm, see FF_IDCT_* below.
uint8_t mv_mode
Frame decoding info for all profiles.
Picture * current_picture_ptr
pointer to the current picture
static void vc1_decode_skip_blocks(VC1Context *v)
static av_always_inline void vc1_apply_p_v_loop_filter(VC1Context *v, int block_num)
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame)
Get a buffer for a frame.
av_cold int ff_vc1_decode_init_alloc_tables(VC1Context *v)
int ff_vc1_parse_frame_header(VC1Context *v, GetBitContext *gb)
static const int offset_table[6]
static int median4(int a, int b, int c, int d)
#define CONFIG_VC1_VDPAU_DECODER
static int vc1_decode_p_mb_intfr(VC1Context *v)
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
int block_last_index[12]
last non zero coefficient in block
static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x, int *dmv_y, int *pred_flag)
static av_always_inline void vc1_apply_p_h_loop_filter(VC1Context *v, int block_num)
const uint16_t ff_vc1_field_mvpred_scales[2][7][4]
int ff_MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
generic function for encode/decode called after coding/decoding the header and before a frame is code...
int16_t(* luma_mv_base)[2]
int block_index[6]
index to current MB in block based arrays with edges
VLC * cbpcy_vlc
CBPCY VLC table.
static int decode210(GetBitContext *gb)
static const float pred[4]
uint8_t * sr_rows[2][2]
Sprite resizer line cache.
static const int8_t mv[256][2]
h264_chroma_mc_func avg_no_rnd_vc1_chroma_pixels_tab[3]
uint32_t * mb_type
macroblock type table mb_type_base + mb_width + 2
static void vc1_loop_filter_iblk(VC1Context *v, int pq)
static void vc1_interp_mc(VC1Context *v)
Motion compensation for direct or interpolated blocks in B-frames.
int first_slice_line
used in mpeg4 too to handle resync markers
static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend)
static const int offset_table1[9]
int res_sprite
Simple/Main Profile sequence header.
void(* vc1_h_loop_filter4)(uint8_t *src, int stride, int pq)
int top_blk_sh
Either 3 or 0, positions of l/t in blk[].
op_pixels_func avg_no_rnd_pixels_tab[4][4]
Halfpel motion compensation with no rounding (a+b)>>1.
int linesize[AV_NUM_DATA_POINTERS]
Size, in bytes, of the data for each picture/channel plane.
const int8_t ff_vc1_adv_interlaced_8x8_zz[64]
static const uint8_t vc1_delta_run_table[AC_MODES][57]
int ff_vc1_init_common(VC1Context *v)
Init VC-1 specific tables and VC1Context members.
main external API structure.
static void close(AVCodecParserContext *s)
static int vc1_decode_p_mb_intfi(VC1Context *v)
uint8_t * coded_block
used for coded block pattern prediction (msmpeg4v3, wmv1)
int height
picture size. must be a multiple of 16
static void vc1_decode_b_mb_intfi(VC1Context *v)
Decode one B-frame MB (in interlaced field B picture)
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int16_t(*[2] motion_val)[2]
motion vector table
void(* sprite_v_double_noscale)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src2a, int alpha, int width)
Picture * picture
main picture buffer
const uint8_t ff_vc1_mbmode_intfrp[2][15][4]
static unsigned int get_bits1(GetBitContext *s)
int fmb_is_raw
forward mb plane is raw
void(* vc1_inv_trans_4x4)(uint8_t *dest, int line_size, DCTELEM *block)
static void skip_bits(GetBitContext *s, int n)
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
#define MB_INTRA_VLC_BITS
static av_always_inline int get_chroma_mv(int *mvx, int *mvy, int *a, int flag, int *tx, int *ty)
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define VC1_2MV_BLOCK_PATTERN_VLC_BITS
#define FF_INPUT_BUFFER_PADDING_SIZE
static int vc1_pred_dc(MpegEncContext *s, int overlap, int pq, int n, int a_avail, int c_avail, int16_t **dc_val_ptr, int *dir_ptr)
Get predicted DC value prediction dir: left=0, top=1.
AVHWAccel * ff_find_hwaccel(enum AVCodecID codec_id, enum AVPixelFormat pix_fmt)
Return the hardware accelerated codec for codec codec_id and pixel format pix_fmt.
DSPContext dsp
pointers for accelerated dsp functions
int skip_is_raw
skip mb plane is not coded
int ff_intrax8_decode_picture(IntraX8Context *const w, int dquant, int quant_offset)
Decode single IntraX8 frame.
static unsigned int get_bits_long(GetBitContext *s, int n)
Read 0-32 bits.
int ref_field_type[2]
forward and backward reference field type (top or bottom)
uint8_t * direct_mb_plane
bitplane for "direct" MBs
static const uint8_t vc1_last_delta_run_table[AC_MODES][10]
int pict_type
AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ...
static int vc1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *avpkt)
Decode a VC1/WMV3 frame.
DCTELEM(* block)[64]
points to one of the following blocks
uint8_t * mv_type_mb_plane
bitplane for mv_type == (4MV)
int numref
number of past field pictures used as reference
const int32_t ff_vc1_dqscale[63]
h264_chroma_mc_func put_no_rnd_vc1_chroma_pixels_tab[3]
static const uint16_t scale[4]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const uint8_t * c_dc_scale_table
qscale -> c_dc_scale table
int8_t * qscale_table
QP table.
qpel_mc_func(* qpel_avg)[16]
int mv[2][4][2]
motion vectors for a macroblock first coordinate : 0 = forward 1 = backward second " : depend...
int b8_stride
2*mb_width+1 used for some 8x8 block arrays to allow simple addressing
void(* clear_blocks)(DCTELEM *blocks)
in the bitstream is reported as 10b
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
VC-1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstrea...
static const int offset_table2[9]
discard all non reference
static void vc1_decode_i_blocks(VC1Context *v)
Decode blocks of I-frame.
void(* put_signed_pixels_clamped)(const DCTELEM *block, uint8_t *pixels, int line_size)
int pqindex
raw pqindex used in coding set selection
static const uint8_t vc1_last_delta_level_table[AC_MODES][44]
#define FF_PROFILE_VC1_COMPLEX
#define VC1_1REF_MVDATA_VLC_BITS
common internal api header.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
static av_always_inline int scale_mv(int value, int bfrac, int inv, int qs)
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
#define VC1_TTMB_VLC_BITS
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static av_cold void flush(AVCodecContext *avctx)
Flush (reset) the frame ID after seeking.
static const int size_table[6]
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
#define AVERROR_INVALIDDATA
static void vc1_pred_mv_intfr(VC1Context *v, int n, int dmv_x, int dmv_y, int mvn, int r_x, int r_y, uint8_t *is_intra)
Predict and set motion vector for interlaced frame picture MBs.
Picture last_picture
copy of the previous picture structure.
uint8_t dquantfrm
pquant parameters
Picture * last_picture_ptr
pointer to the previous picture.
#define FF_PROFILE_VC1_ADVANCED
int res_fasttx
reserved, always 1
enum AVDiscard skip_loop_filter
int * ttblk
Transform type at the block level.
VLC ff_vc1_ac_coeff_table[8]
int ff_vc1_decode_entry_point(AVCodecContext *avctx, VC1Context *v, GetBitContext *gb)
#define VC1_INTFR_4MV_MBMODE_VLC_BITS
uint8_t pquantizer
Uniform (over sequence) quantizer in use.
static void vc1_pred_mv(VC1Context *v, int n, int dmv_x, int dmv_y, int mv1, int r_x, int r_y, uint8_t *is_intra, int pred_flag, int dir)
Predict and set motion vector.
void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf, int buf_size)
void ff_MPV_common_end(MpegEncContext *s)
void ff_print_debug_info(MpegEncContext *s, AVFrame *pict)
Print debugging info for the given picture.
void(* sprite_v_single)(uint8_t *dst, const uint8_t *src1a, const uint8_t *src1b, int offset, int width)
const int8_t ff_vc1_adv_interlaced_8x4_zz[32]
static int decode012(GetBitContext *gb)
VLC_TYPE(* table)[2]
code, bits
Picture next_picture
copy of the next picture structure.
int key_frame
1 -> keyframe, 0-> not
static void vc1_mc_4mv_chroma(VC1Context *v, int dir)
Do motion compensation for 4-MV macroblock - both chroma blocks.
int linesize
line size, in bytes, may be different from width
static void vc1_decode_i_blocks_adv(VC1Context *v)
Decode blocks of I-frame for advanced profile.
static av_always_inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)
int level
Advanced Profile.
int flags
AVCodecContext.flags (HQ, MV4, ...)
int brfd
reference frame distance (forward or backward)
#define FF_BUFFER_HINTS_VALID
uint8_t mv_mode2
Secondary MV coding mode (B frames)
int new_sprite
Frame decoding info for sprite modes.
int codingset
index of current table set from 11.8 to use for luma block decoding
int(* decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size)
Callback for each slice.
int ff_find_unused_picture(MpegEncContext *s, int shared)
int(* end_frame)(AVCodecContext *avctx)
Called at the end of each frame or field picture.
int uvlinesize
line size, for chroma in bytes, may be different from width
#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS
AVPixelFormat
Pixel format.
This structure stores compressed data.
void(* vc1_inv_trans_8x4)(uint8_t *dest, int line_size, DCTELEM *block)
void(* vc1_v_overlap)(uint8_t *src, int stride)
av_cold void ff_vc1dsp_init(VC1DSPContext *dsp)
void(* vc1_h_s_overlap)(DCTELEM *left, DCTELEM *right)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
VLC ff_msmp4_dc_luma_vlc[2]
VLC ff_vc1_subblkpat_vlc[3]
uint8_t halfpq
Uniform quant over image and qp+.5.
static void vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype)
static const uint8_t vc1_delta_level_table[AC_MODES][31]
static av_always_inline const uint8_t * find_next_marker(const uint8_t *src, const uint8_t *end)
Find VC-1 marker in buffer.
VLC ff_msmp4_dc_chroma_vlc[2]
#define FF_PROFILE_UNKNOWN
op_pixels_func put_vc1_mspel_pixels_tab[16]
void(* sprite_h)(uint8_t *dst, const uint8_t *src, int offset, int advance, int count)
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)
void(* vc1_h_loop_filter16)(uint8_t *src, int stride, int pq)