39 #define MB_INTRA_VLC_BITS 9 44 { 0, 1, 2, 4, 8, 16, 32, 64, 128 },
45 { 0, 1, 3, 7, 15, 31, 63, 127, 255 },
72 int topleft_mb_pos, top_mb_pos;
73 int stride_y, fieldtx = 0;
89 v_dist = (16 - fieldtx) >> (fieldtx == 0);
116 v_dist = fieldtx ? 15 : 8;
140 #define inc_blk_idx(idx) do { \ 142 if (idx >= v->n_allocated_blks) \ 163 #define GET_MQUANT() \ 164 if (v->dquantfrm) { \ 166 if (v->dqprofile == DQPROFILE_ALL_MBS) { \ 167 if (v->dqbilevel) { \ 168 mquant = (get_bits1(gb)) ? v->altpq : v->pq; \ 170 mqdiff = get_bits(gb, 3); \ 172 mquant = v->pq + mqdiff; \ 174 mquant = get_bits(gb, 5); \ 177 if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \ 178 edges = 1 << v->dqsbedge; \ 179 else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \ 180 edges = (3 << v->dqsbedge) % 15; \ 181 else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \ 183 if ((edges&1) && !s->mb_x) \ 185 if ((edges&2) && s->first_slice_line) \ 187 if ((edges&4) && s->mb_x == (s->mb_width - 1)) \ 189 if ((edges&8) && s->mb_y == (s->mb_height - 1)) \ 191 if (!mquant || mquant > 31) { \ 192 av_log(v->s.avctx, AV_LOG_ERROR, \ 193 "Overriding invalid mquant %d\n", mquant); \ 205 #define GET_MVDATA(_dmv_x, _dmv_y) \ 206 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \ 207 VC1_MV_DIFF_VLC_BITS, 2); \ 215 _dmv_x = _dmv_y = 0; \ 216 } else if (index == 35) { \ 217 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \ 218 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \ 219 } else if (index == 36) { \ 224 index1 = index % 6; \ 225 _dmv_x = offset_table[1][index1]; \ 226 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \ 228 val = get_bits(gb, val); \ 229 sign = 0 - (val & 1); \ 230 _dmv_x = (sign ^ ((val >> 1) + _dmv_x)) - sign; \ 233 index1 = index / 6; \ 234 _dmv_y = offset_table[1][index1]; \ 235 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \ 237 val = get_bits(gb, val); \ 238 sign = 0 - (val & 1); \ 239 _dmv_y = (sign ^ ((val >> 1) + _dmv_y)) - sign; \ 244 int *dmv_y,
int *pred_flag)
247 int extend_x, extend_y;
267 *pred_flag = *dmv_y & 1;
268 *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
273 index1 = (index + 1) % 9;
275 val =
get_bits(gb, index1 + extend_x);
276 sign = 0 - (val & 1);
277 *dmv_x = (sign ^ ((val >> 1) +
offset_table[extend_x][index1])) - sign;
280 index1 = (index + 1) / 9;
283 sign = 0 - (val & 1);
287 if (v->
numref && pred_flag)
288 *pred_flag = index1 & 1;
295 int direct,
int mode)
321 int16_t **dc_val_ptr,
int *dir_ptr)
325 static const uint16_t dcpred[32] = {
326 -1, 1024, 512, 341, 256, 205, 171, 146, 128,
327 114, 102, 93, 85, 79, 73, 68, 64,
328 60, 57, 54, 51, 49, 47, 45, 43,
329 41, 39, 38, 37, 35, 34, 33
343 b = dc_val[ - 1 -
wrap];
346 if (pq < 9 || !overlap) {
349 b = a = dcpred[scale];
350 if (s->
mb_x == 0 && (n != 1 && n != 3))
351 b = c = dcpred[scale];
356 if (s->
mb_x == 0 && (n != 1 && n != 3))
360 if (abs(a - b) <= abs(b - c)) {
369 *dc_val_ptr = &dc_val[0];
386 int a_avail,
int c_avail,
387 int16_t **dc_val_ptr,
int *dir_ptr)
398 if (dqscale_index < 0)
408 b = dc_val[ - 1 -
wrap];
411 if (c_avail && (n != 1 && n != 3)) {
416 if (a_avail && (n != 2 && n != 3)) {
421 if (a_avail && c_avail && (n != 3)) {
432 if (c_avail && (!a_avail || abs(a - b) <= abs(b - c))) {
435 }
else if (a_avail) {
444 *dc_val_ptr = &dc_val[0];
493 int *
value,
int codingset)
543 *value = (level ^ -sign) + sign;
554 int coded,
int codingset)
561 int16_t *ac_val, *ac_val2;
575 const int m = (v->
pq == 1 || v->
pq == 2) ? 3 - v->
pq : 0;
576 if (dcdiff == 119 ) {
580 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
595 block[0] = dcdiff * scale;
610 int last = 0, skip,
value;
627 block[zz_table[i++]] =
value;
639 for (k = 1; k < 8; k++)
640 block[k << sh] += ac_val[k];
643 for (k = 1; k < 8; k++) {
649 for (k = 1; k < 64; k++)
653 block[k] += (block[k] < 0) ? -v->
pq : v->
pq;
659 memset(ac_val2, 0, 16 * 2);
671 memcpy(ac_val2, ac_val, 8 * 2);
672 for (k = 1; k < 8; k++) {
673 block[k << sh] = ac_val[k] * scale;
675 block[k << sh] += (block[k << sh] < 0) ? -v->
pq : v->
pq;
694 int coded,
int codingset,
int mquant)
700 int16_t *dc_val =
NULL;
701 int16_t *ac_val, *ac_val2;
720 const int m = (mquant == 1 || mquant == 2) ? 3 - mquant : 0;
721 if (dcdiff == 119 ) {
725 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
740 block[0] = dcdiff * scale;
743 if (!a_avail && !c_avail)
746 scale = mquant * 2 + ((mquant == v->
pq) ? v->
halfpq : 0);
758 else if (dc_pred_dir) {
761 else if (c_avail && mb_pos)
766 else if (a_avail && mb_pos >= s->
mb_stride)
774 int last = 0, skip,
value;
799 block[zz_table[i++]] =
value;
812 if (q2 && q1 != q2) {
813 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
816 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
817 for (k = 1; k < 8; k++)
818 block[k << sh] += (ac_val[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
820 for (k = 1; k < 8; k++)
821 block[k << sh] += ac_val[k];
825 for (k = 1; k < 8; k++) {
831 for (k = 1; k < 64; k++)
835 block[k] += (block[k] < 0) ? -mquant : mquant;
841 memset(ac_val2, 0, 16 * 2);
853 memcpy(ac_val2, ac_val, 8 * 2);
854 if (q2 && q1 != q2) {
855 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
856 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
859 for (k = 1; k < 8; k++)
860 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
862 for (k = 1; k < 8; k++) {
863 block[k << sh] = ac_val2[k] * scale;
865 block[k << sh] += (block[k << sh] < 0) ? -mquant : mquant;
869 if (use_pred) i = 63;
884 int coded,
int mquant,
int codingset)
890 int16_t *dc_val =
NULL;
891 int16_t *ac_val, *ac_val2;
902 mquant = av_clip_uintp2(mquant, 5);
919 const int m = (mquant == 1 || mquant == 2) ? 3 - mquant : 0;
920 if (dcdiff == 119 ) {
924 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
946 if (!a_avail) dc_pred_dir = 1;
947 if (!c_avail) dc_pred_dir = 0;
948 if (!a_avail && !c_avail) use_pred = 0;
952 scale = mquant * 2 + v->
halfpq;
960 if (dc_pred_dir && c_avail && mb_pos)
962 if (!dc_pred_dir && a_avail && mb_pos >= s->
mb_stride)
964 if (dc_pred_dir && n == 1)
966 if (!dc_pred_dir && n == 2)
971 int last = 0, skip,
value;
996 if (q2 && q1 != q2) {
997 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
998 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
1003 for (k = 1; k < 8; k++)
1006 for (k = 1; k < 8; k++)
1011 for (k = 1; k < 8; k++)
1014 for (k = 1; k < 8; k++)
1020 for (k = 1; k < 8; k++) {
1026 for (k = 1; k < 64; k++)
1030 block[k] += (block[k] < 0) ? -mquant : mquant;
1033 if (use_pred) i = 63;
1037 memset(ac_val2, 0, 16 * 2);
1040 memcpy(ac_val2, ac_val, 8 * 2);
1041 if (q2 && q1 != q2) {
1042 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
1043 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
1046 for (k = 1; k < 8; k++)
1047 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1052 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
1053 if (q2 && q1 != q2) {
1054 q1 = q1 * 2 + ((q1 == v->
pq) ? v->
halfpq : 0) - 1;
1055 q2 = q2 * 2 + ((q2 == v->
pq) ? v->
halfpq : 0) - 1;
1058 for (k = 1; k < 8; k++)
1059 ac_val2[k + 8] = (ac_val2[k + 8] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1067 for (k = 1; k < 8; k++) {
1073 for (k = 1; k < 8; k++) {
1074 block[k << v->
top_blk_sh] = ac_val2[k + 8] * scale;
1090 int mquant,
int ttmb,
int first_block,
1091 uint8_t *dst,
int linesize,
int skip_block,
1098 int scale, off, idx, last, skip,
value;
1099 int ttblk = ttmb & 7;
1111 && ((v->
ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
1121 scale = 2 * mquant + ((v->
pq == mquant) ? v->
halfpq : 0);
1146 block[idx] = value * scale;
1148 block[idx] += (block[idx] < 0) ? -mquant : mquant;
1160 pat = ~subblkpat & 0xF;
1161 for (j = 0; j < 4; j++) {
1162 last = subblkpat & (1 << (3 - j));
1164 off = (j & 1) * 4 + (j & 2) * 16;
1174 block[idx + off] = value * scale;
1176 block[idx + off] += (block[idx + off] < 0) ? -mquant : mquant;
1178 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
1187 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
1188 for (j = 0; j < 2; j++) {
1189 last = subblkpat & (1 << (1 - j));
1198 idx = v->
zz_8x4[i++] + off;
1201 block[idx] = value * scale;
1203 block[idx] += (block[idx] < 0) ? -mquant : mquant;
1205 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1214 pat = ~(subblkpat * 5) & 0xF;
1215 for (j = 0; j < 2; j++) {
1216 last = subblkpat & (1 << (1 - j));
1225 idx = v->
zz_4x8[i++] + off;
1228 block[idx] = value * scale;
1230 block[idx] += (block[idx] < 0) ? -mquant : mquant;
1232 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1242 *ttmb_out |= ttblk << (n * 4);
1260 int ttmb = v->
ttfrm;
1262 int mb_has_coeffs = 1;
1266 int first_block = 1;
1268 int skipped, fourmv;
1269 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
1294 if (s->
mb_intra && !mb_has_coeffs) {
1298 }
else if (mb_has_coeffs) {
1314 for (i = 0; i < 6; i++) {
1317 val = ((cbp >> (5 - i)) & 1);
1318 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1325 if (i == 1 || i == 3 || s->
mb_x)
1334 for (j = 0; j < 64; j++)
1335 s->
block[i][j] <<= 1;
1337 s->
dest[dst_idx] + off,
1346 block_cbp |= 0xF << (i << 2);
1347 block_intra |= 1 << i;
1352 block_cbp |= pat << (i << 2);
1353 if (!v->
ttmbf && ttmb < 8)
1360 for (i = 0; i < 6; i++) {
1371 int intra_count = 0, coded_inter = 0;
1372 int is_intra[6], is_coded[6];
1375 for (i = 0; i < 6; i++) {
1376 val = ((cbp >> (5 - i)) & 1);
1391 is_coded[i] = mb_has_coeffs;
1394 is_intra[i] = (intra_count >= 3);
1401 coded_inter = !is_intra[i] & is_coded[i];
1405 if (!intra_count && !coded_inter)
1412 for (i = 0; i < 6; i++)
1425 if (!v->
ttmbf && coded_inter)
1427 for (i = 0; i < 6; i++) {
1429 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1436 if (i == 1 || i == 3 || s->
mb_x)
1445 for (j = 0; j < 64; j++)
1446 s->
block[i][j] <<= 1;
1448 s->
dest[dst_idx] + off,
1457 block_cbp |= 0xF << (i << 2);
1458 block_intra |= 1 << i;
1459 }
else if (is_coded[i]) {
1461 first_block, s->
dest[dst_idx] + off,
1465 block_cbp |= pat << (i << 2);
1466 if (!v->
ttmbf && ttmb < 8)
1474 for (i = 0; i < 6; i++) {
1478 for (i = 0; i < 4; i++) {
1504 int ttmb = v->
ttfrm;
1506 int mb_has_coeffs = 1;
1509 int first_block = 1;
1511 int skipped, fourmv = 0, twomv = 0;
1512 int block_cbp = 0, pat, block_tt = 0;
1513 int idx_mbmode = 0, mvbp;
1514 int stride_y, fieldtx;
1558 for (i = 0; i < 4; i++) {
1576 for (i = 0; i < 6; i++) {
1581 val = ((cbp >> (5 - i)) & 1);
1584 if (i == 1 || i == 3 || s->
mb_x)
1594 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->
linesize : (i & 1) * 8 + 4 * (i & 2) * s->
linesize;
1600 s->
dest[dst_idx] + off,
1618 for (i = 0; i < 6; i++)
1625 for (i = 0; i < 4; i++) {
1627 if (mvbp & (8 >> i))
1662 if (!v->
ttmbf && cbp)
1664 for (i = 0; i < 6; i++) {
1667 val = ((cbp >> (5 - i)) & 1);
1669 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1671 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->
linesize));
1674 first_block, s->
dest[dst_idx] + off,
1677 block_cbp |= pat << (i << 2);
1678 if (!v->
ttmbf && ttmb < 8)
1686 for (i = 0; i < 6; i++) {
1712 int ttmb = v->
ttfrm;
1714 int mb_has_coeffs = 1;
1717 int first_block = 1;
1720 int block_cbp = 0, pat, block_tt = 0;
1726 if (idx_mbmode <= 1) {
1738 mb_has_coeffs = idx_mbmode & 1;
1742 for (i = 0; i < 6; i++) {
1747 val = ((cbp >> (5 - i)) & 1);
1750 if (i == 1 || i == 3 || s->
mb_x)
1758 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1760 s->
dest[dst_idx] + off,
1768 for (i = 0; i < 6; i++)
1770 if (idx_mbmode <= 5) {
1771 dmv_x = dmv_y = pred_flag = 0;
1772 if (idx_mbmode & 1) {
1777 mb_has_coeffs = !(idx_mbmode & 2);
1780 for (i = 0; i < 4; i++) {
1781 dmv_x = dmv_y = pred_flag = 0;
1788 mb_has_coeffs = idx_mbmode & 1;
1796 if (!v->
ttmbf && cbp) {
1800 for (i = 0; i < 6; i++) {
1803 val = ((cbp >> (5 - i)) & 1);
1804 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
1807 first_block, s->
dest[dst_idx] + off,
1811 block_cbp |= pat << (i << 2);
1812 if (!v->
ttmbf && ttmb < 8)
1833 int ttmb = v->
ttfrm;
1834 int mb_has_coeffs = 0;
1837 int first_block = 1;
1839 int skipped, direct;
1840 int dmv_x[2], dmv_y[2];
1855 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1856 for (i = 0; i < 6; i++) {
1865 dmv_x[1] = dmv_x[0];
1866 dmv_y[1] = dmv_y[0];
1879 dmv_x[0] = dmv_y[0] = 0;
1883 for (i = 0; i < 6; i++)
1890 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1900 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1902 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1904 if (!mb_has_coeffs && !s->
mb_intra) {
1907 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1910 if (s->
mb_intra && !mb_has_coeffs) {
1919 if (!mb_has_coeffs) {
1922 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1928 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1940 for (i = 0; i < 6; i++) {
1943 val = ((cbp >> (5 - i)) & 1);
1944 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1951 if (i == 1 || i == 3 || s->
mb_x)
1960 for (j = 0; j < 64; j++)
1961 s->
block[i][j] <<= 1;
1963 s->
dest[dst_idx] + off,
1968 first_block, s->
dest[dst_idx] + off,
1971 if (!v->
ttmbf && ttmb < 8)
1988 int ttmb = v->
ttfrm;
1989 int mb_has_coeffs = 0;
1991 int first_block = 1;
1994 int dmv_x[2], dmv_y[2], pred_flag[2];
2002 if (idx_mbmode <= 1) {
2014 mb_has_coeffs = idx_mbmode & 1;
2018 for (i = 0; i < 6; i++) {
2023 val = ((cbp >> (5 - i)) & 1);
2026 if (i == 1 || i == 3 || s->
mb_x)
2035 for (j = 0; j < 64; j++)
2036 s->
block[i][j] <<= 1;
2037 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
2039 s->
dest[dst_idx] + off,
2047 for (i = 0; i < 6; i++)
2053 if (idx_mbmode <= 5) {
2055 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2056 pred_flag[0] = pred_flag[1] = 0;
2081 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2082 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2090 mb_has_coeffs = !(idx_mbmode & 2);
2096 for (i = 0; i < 4; i++) {
2097 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2098 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2108 mb_has_coeffs = idx_mbmode & 1;
2116 if (!v->
ttmbf && cbp) {
2120 for (i = 0; i < 6; i++) {
2123 val = ((cbp >> (5 - i)) & 1);
2124 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
2127 first_block, s->
dest[dst_idx] + off,
2130 if (!v->
ttmbf && ttmb < 8)
2148 int ttmb = v->
ttfrm;
2150 int mb_has_coeffs = 1;
2153 int first_block = 1;
2155 int skipped, direct, twomv = 0;
2156 int block_cbp = 0, pat, block_tt = 0;
2157 int idx_mbmode = 0, mvbp;
2158 int stride_y, fieldtx;
2204 for (i = 1; i < 4; i += 2) {
2211 for (i = 1; i < 4; i++) {
2221 for (i = 0; i < 4; i++) {
2241 for (i = 0; i < 6; i++) {
2246 val = ((cbp >> (5 - i)) & 1);
2249 if (i == 1 || i == 3 || s->
mb_x)
2259 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->
linesize : (i & 1) * 8 + 4 * (i & 2) * s->
linesize;
2265 s->
dest[dst_idx] + off,
2301 for (i = 0; i < 6; i++)
2308 for (i = 0; i < 4; i++) {
2320 for (i = 0; i < 4; i++) {
2323 val = ((mvbp >> (3 - i)) & 1);
2366 for (i = 0; i < 2; i++) {
2396 for (i = 0; i < 2; i++) {
2406 if (!v->
ttmbf && cbp)
2408 for (i = 0; i < 6; i++) {
2411 val = ((cbp >> (5 - i)) & 1);
2413 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
2415 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->
linesize));
2418 first_block, s->
dest[dst_idx] + off,
2421 block_cbp |= pat << (i << 2);
2422 if (!v->
ttmbf && ttmb < 8)
2430 for (i = 0; i < 6; i++) {
2452 for (i = 0; i < 2; i++) {
2464 for (i = 0; i < 2; i++) {
2534 dst[0] = s->
dest[0];
2535 dst[1] = dst[0] + 8;
2537 dst[3] = dst[2] + 8;
2538 dst[4] = s->
dest[1];
2539 dst[5] = s->
dest[2];
2551 for (k = 0; k < 6; k++) {
2552 val = ((cbp >> (5 - k)) & 1);
2559 cbp |= val << (5 - k);
2568 for (j = 0; j < 64; j++)
2569 s->
block[k][j] <<= 1;
2575 for (j = 0; j < 64; j++)
2710 for (k = 0; k < 6; k++) {
2711 val = ((cbp >> (5 - k)) & 1);
2718 cbp |= val << (5 - k);
2829 if (apply_loop_filter) {
in the bitstream is reported as 00b
const int ff_vc1_ttblk_to_tt[3][8]
Table for conversion between TTBLK and TTMB.
#define VC1_TTBLK_VLC_BITS
void ff_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.
const char const char void * val
discard all frames except keyframes
void ff_init_block_index(MpegEncContext *s)
#define VC1_IF_MBMODE_VLC_BITS
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define VC1_ICBPCY_VLC_BITS
int k_x
Number of bits for MVs (depends on MV range)
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 mv_type_is_raw
mv type mb plane is not coded
uint8_t dmvrange
Frame decoding info for interlaced picture.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
#define AV_LOG_WARNING
Something somehow does not look correct.
void(* vc1_inv_trans_8x4)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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) ...
int16_t(*[3] ac_val)[16]
used for MPEG-4 AC prediction, all 3 arrays must be continuous
void(* put_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
static const int vc1_last_decode_table[AC_MODES]
void(* clear_block)(int16_t *block)
int tt_index
Index for Transform Type tables (to decode TTMB)
#define VC1_2REF_MVDATA_VLC_BITS
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
void(* vc1_v_overlap)(uint8_t *src, int stride)
int field_picture
whether or not the picture was encoded in separate fields
static int ff_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.
uint8_t zz_8x8[4][64]
Zigzag table for TT_8x8, permuted for IDCT.
static void vc1_put_signed_blocks_clamped(VC1Context *v)
static int vc1_decode_p_block(VC1Context *v, int16_t 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.
static const uint8_t q1[256]
int end_mb_x
Horizontal macroblock limit (used only by mss2)
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.
static int vc1_decode_p_mb(VC1Context *v)
Decode one P-frame MB.
const uint8_t ff_vc1_adv_interlaced_4x8_zz[32]
#define VC1_4MV_BLOCK_PATTERN_VLC_BITS
#define av_assert0(cond)
assert() equivalent, that is always enabled.
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h)
uint8_t * acpred_plane
AC prediction flags bitplane.
void ff_vc1_pred_b_mv_intfi(VC1Context *v, int n, int *dmv_x, int *dmv_y, int mv1, int *pred_flag)
void(* vc1_inv_trans_4x8_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
static av_cold int end(AVCodecContext *avctx)
int y_ac_table_index
Luma index from AC2FRM element.
int c_ac_table_index
AC coding set indexes.
const int ff_vc1_ac_sizes[AC_MODES]
void(* vc1_inv_trans_8x8)(int16_t *b)
int ttfrm
Transform type info present at frame level.
static void vc1_decode_b_mb_intfi(VC1Context *v)
Decode one B-frame MB (in interlaced field B picture)
Picture current_picture
copy of the current picture structure.
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.
int profile
Sequence header data for all Profiles TODO: choose between ints, uint8_ts and monobit flags...
static const uint8_t offset_table[2][9]
int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict, GetBitContext *gb, int *mb_x, int *mb_y, int dquant, int quant_offset, int loopfilter, int lowdelay)
Decode single IntraX8 frame.
static int get_bits_count(const GetBitContext *s)
uint8_t * forward_mb_plane
bitplane for "forward" MBs
int mb_height
number of MBs horizontally & vertically
static void vc1_decode_skip_blocks(VC1Context *v)
static const uint8_t size_table[6]
uint8_t * over_flags_plane
Overflags bitplane.
#define AV_CODEC_FLAG_GRAY
Only decode/encode grayscale.
static void ff_update_block_index(MpegEncContext *s)
uint8_t ttmbf
Transform type flag.
int k_y
Number of bits for MVs (depends on MV range)
void(* vc1_inv_trans_4x4)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
static int get_bits_left(GetBitContext *gb)
int16_t * dc_val[3]
used for MPEG-4 DC prediction, all 3 arrays must be continuous
int dmb_is_raw
direct mb plane is raw
const uint8_t ff_vc1_simple_progressive_4x4_zz[16]
#define VC1_CBPCY_P_VLC_BITS
static void vc1_decode_b_mb(VC1Context *v)
Decode one B-frame MB (in Main profile)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int overlap
overlapped transforms in use
in the bitstream is reported as 11b
static int vc1_decode_b_mb_intfr(VC1Context *v)
Decode one B-frame MB (in interlaced frame B picture)
void ff_vc1_smooth_overlap_filter_iblk(VC1Context *v)
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy, int status)
Add a slice.
static int vc1_decode_i_block_adv(VC1Context *v, int16_t block[64], int n, int coded, int codingset, int mquant)
Decode intra block in intra frames - should be faster than decode_intra_block.
void(* clear_blocks)(int16_t *blocks)
void ff_vc1_mc_4mv_chroma4(VC1Context *v, int dir, int dir2, int avg)
Do motion compensation for 4-MV interlaced frame chroma macroblock (both U and V) ...
static const struct endianess table[]
int flags
AV_CODEC_FLAG_*.
int quarter_sample
1->qpel, 0->half pel ME/MC
int low_delay
no reordering needed / has no B-frames
void ff_vc1_mc_4mv_chroma(VC1Context *v, int dir)
Do motion compensation for 4-MV macroblock - both chroma blocks.
void(* put_signed_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
const uint8_t * zz_8x4
Zigzag scan table for TT_8x4 coding mode.
int res_rtm_flag
reserved, set to 1
uint8_t * blk_mv_type
0: frame MV, 1: field MV (interlaced frame)
const uint8_t ff_vc1_adv_interlaced_8x4_zz[32]
static void vc1_decode_b_blocks(VC1Context *v)
const uint8_t * zz_4x8
Zigzag scan table for TT_4x8 coding mode.
void ff_vc1_decode_blocks(VC1Context *v)
static int vc1_decode_p_mb_intfr(VC1Context *v)
#define MB_INTRA_VLC_BITS
int field_mode
1 for interlaced field pictures
#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...
void(* vc1_h_overlap)(uint8_t *src, int stride)
int16_t(*[2] motion_val)[2]
Picture * current_picture_ptr
pointer to the current picture
void ff_vc1_loop_filter_iblk_delayed(VC1Context *v, int pq)
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.
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
void(* vc1_inv_trans_8x8_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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]
void ff_vc1_loop_filter_iblk(VC1Context *v, int pq)
int first_slice_line
used in MPEG-4 too to handle resync markers
static void apply_loop_filter(Vp3DecodeContext *s, int plane, int ystart, int yend)
int top_blk_sh
Either 3 or 0, positions of l/t in blk[].
Libavcodec external API header.
void ff_vc1_mc_1mv(VC1Context *v, int dir)
Do motion compensation over 1 macroblock Mostly adapted hpel_motion and qpel_motion from mpegvideo...
ptrdiff_t linesize
line size, in bytes, may be different from width
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
static const uint8_t vc1_delta_run_table[AC_MODES][57]
#define GET_MVDATA(_dmv_x, _dmv_y)
Get MV differentials.
uint8_t * coded_block
used for coded block pattern prediction (msmpeg4v3, wmv1)
void(* vc1_inv_trans_4x8)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
void ff_vc1_pred_b_mv(VC1Context *v, int dmv_x[2], int dmv_y[2], int direct, int mvtype)
const uint8_t ff_vc1_mbmode_intfrp[2][15][4]
static unsigned int get_bits1(GetBitContext *s)
static void vc1_decode_i_blocks_adv(VC1Context *v)
Decode blocks of I-frame for advanced profile.
int fmb_is_raw
forward mb plane is raw
void(* vc1_inv_trans_8x4_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
#define VC1_2MV_BLOCK_PATTERN_VLC_BITS
static int vc1_coded_block_pred(MpegEncContext *s, int n, uint8_t **coded_block_ptr)
ptrdiff_t uvlinesize
line size, for chroma in bytes, may be different from width
int skip_is_raw
skip mb plane is not coded
static av_always_inline void get_mvdata_interlaced(VC1Context *v, int *dmv_x, int *dmv_y, int *pred_flag)
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, ...
uint8_t * mv_type_mb_plane
bitplane for mv_type == (4MV)
void ff_vc1_apply_p_loop_filter(VC1Context *v)
int numref
number of past field pictures used as reference
const int32_t ff_vc1_dqscale[63]
void(* vc1_inv_trans_4x4_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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
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
in the bitstream is reported as 10b
Picture * next_picture_ptr
pointer to the next picture (for bidir pred)
struct AVCodecContext * avctx
void ff_vc1_mc_4mv_luma(VC1Context *v, int n, int dir, int avg)
Do motion compensation for 4-MV macroblock - luminance block.
static int vc1_decode_p_mb_intfi(VC1Context *v)
#define GET_MQUANT()
Get macroblock-level quantizer scale.
int pqindex
raw pqindex used in coding set selection
static const uint8_t vc1_last_delta_level_table[AC_MODES][44]
#define VC1_1REF_MVDATA_VLC_BITS
static void vc1_decode_ac_coeff(VC1Context *v, int *last, int *skip, int *value, int codingset)
Decode one AC coefficient.
int mb_stride
mb_width+1 used for some arrays to allow simple addressing of left & top MBs without sig11 ...
#define VC1_TTMB_VLC_BITS
static int get_unary(GetBitContext *gb, int stop, int len)
Get unary code of limited length.
static int vc1_decode_intra_block(VC1Context *v, int16_t block[64], int n, int coded, int mquant, int codingset)
Decode intra block in inter frames - more generic version than vc1_decode_i_block.
enum FrameCodingMode fcm
Frame decoding info for Advanced profile.
Picture last_picture
copy of the previous picture structure.
uint8_t dquantfrm
pquant parameters
const uint8_t ff_vc1_adv_interlaced_4x4_zz[16]
enum AVDiscard skip_loop_filter
Skip loop filtering for selected frames.
int * ttblk
Transform type at the block level.
VLC ff_vc1_ac_coeff_table[8]
void ff_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, int dir)
Predict and set motion vector for interlaced frame picture MBs.
#define VC1_INTFR_4MV_MBMODE_VLC_BITS
static void vc1_decode_p_blocks(VC1Context *v)
uint8_t pquantizer
Uniform (over sequence) quantizer in use.
static int vc1_decode_i_block(VC1Context *v, int16_t block[64], int n, int coded, int codingset)
Decode intra block in intra frames - should be faster than decode_intra_block.
void ff_vc1_interp_mc(VC1Context *v)
Motion compensation for direct or interpolated blocks in B-frames.
int16_t(* block)[64]
points to one of the following blocks
static int decode012(GetBitContext *gb)
VLC_TYPE(* table)[2]
code, bits
Picture next_picture
copy of the next picture structure.
uint32_t * mb_type
types and macros are defined in mpegutils.h
static void vc1_decode_i_blocks(VC1Context *v)
Decode blocks of I-frame.
int codingset
index of current table set from 11.8 to use for luma block decoding
#define VC1_INTFR_NON4MV_MBMODE_VLC_BITS
mode
Use these values in ebur128_init (or'ed).
VLC ff_msmp4_dc_luma_vlc[2]
VLC ff_vc1_subblkpat_vlc[3]
uint8_t halfpq
Uniform quant over image and qp+.5.
static const uint8_t vc1_delta_level_table[AC_MODES][31]
static void init_block_index(VC1Context *v)
VLC ff_msmp4_dc_chroma_vlc[2]
void(* add_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)