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 },
87 for (i = 0; i < block_count; i++) {
90 dest = s->
dest[0] + ((i & 2) - 4) * 4 * s->
linesize + ((i & 1) - 2) * 8;
103 for (i = 0; i < block_count; i++) {
106 dest = s->
dest[0] + ((i & 2) - 4) * 4 * s->
linesize + (i & 1) * 8;
123 for (i = 0; i < block_count; i++) {
127 dest = s->
dest[0] + ((i & 2) >> 1) * s->
linesize + ((i & 1) - 2) * 8;
129 dest = s->
dest[0] + (i & 2) * 4 * s->
linesize + ((i & 1) - 2) * 8;
132 i > 3 ? s->
dest[i - 3] - 8 : dest,
136 i > 3 ? s->
dest[i - 3] - 8 : dest,
144 for (i = 0; i < block_count; i++) {
147 dest = s->
dest[0] + ((i & 2) >> 1) * s->
linesize + (i & 1) * 8;
149 dest = s->
dest[0] + (i & 2) * 4 * s->
linesize + (i & 1) * 8;
152 i > 3 ? s->
dest[i - 3] : dest,
156 i > 3 ? s->
dest[i - 3] : dest,
164 #define inc_blk_idx(idx) do { \
166 if (idx >= v->n_allocated_blks) \
181 #define GET_MQUANT() \
182 if (v->dquantfrm) { \
184 if (v->dqprofile == DQPROFILE_ALL_MBS) { \
185 if (v->dqbilevel) { \
186 mquant = (get_bits1(gb)) ? -v->altpq : v->pq; \
188 mqdiff = get_bits(gb, 3); \
190 mquant = -v->pq - mqdiff; \
192 mquant = -get_bits(gb, 5); \
195 if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \
196 edges = 1 << v->dqsbedge; \
197 else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
198 edges = (3 << v->dqsbedge) % 15; \
199 else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \
201 if ((edges&1) && !s->mb_x) \
202 mquant = -v->altpq; \
203 if ((edges&2) && !s->mb_y) \
204 mquant = -v->altpq; \
205 if ((edges&4) && s->mb_x == (s->mb_width - 1)) \
206 mquant = -v->altpq; \
208 s->mb_y == ((s->mb_height >> v->field_mode) - 1)) \
209 mquant = -v->altpq; \
210 if (!mquant || mquant > 31 || mquant < -31) { \
211 av_log(v->s.avctx, AV_LOG_ERROR, \
212 "Overriding invalid mquant %d\n", mquant); \
224 #define GET_MVDATA(_dmv_x, _dmv_y) \
225 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \
226 VC1_MV_DIFF_VLC_BITS, 2); \
234 _dmv_x = _dmv_y = 0; \
235 } else if (index == 35) { \
236 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \
237 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \
238 } else if (index == 36) { \
243 index1 = index % 6; \
244 _dmv_x = offset_table[1][index1]; \
245 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \
247 val = get_bits(gb, val); \
248 sign = 0 - (val & 1); \
249 _dmv_x = (sign ^ ((val >> 1) + _dmv_x)) - sign; \
252 index1 = index / 6; \
253 _dmv_y = offset_table[1][index1]; \
254 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \
256 val = get_bits(gb, val); \
257 sign = 0 - (val & 1); \
258 _dmv_y = (sign ^ ((val >> 1) + _dmv_y)) - sign; \
263 int *dmv_y,
int *pred_flag)
266 int extend_x, extend_y;
286 *pred_flag = *dmv_y & 1;
287 *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
292 index1 = (index + 1) % 9;
294 val =
get_bits(gb, index1 + extend_x);
295 sign = 0 - (val & 1);
296 *dmv_x = (sign ^ ((val >> 1) +
offset_table[extend_x][index1])) - sign;
299 index1 = (index + 1) / 9;
302 sign = 0 - (val & 1);
306 if (v->
numref && pred_flag)
307 *pred_flag = index1 & 1;
314 int direct,
int mode)
340 int16_t **dc_val_ptr,
int *dir_ptr)
344 static const uint16_t dcpred[32] = {
345 -1, 1024, 512, 341, 256, 205, 171, 146, 128,
346 114, 102, 93, 85, 79, 73, 68, 64,
347 60, 57, 54, 51, 49, 47, 45, 43,
348 41, 39, 38, 37, 35, 34, 33
362 b = dc_val[ - 1 -
wrap];
365 if (pq < 9 || !overlap) {
368 b = a = dcpred[scale];
369 if (s->
mb_x == 0 && (n != 1 && n != 3))
370 b = c = dcpred[scale];
375 if (s->
mb_x == 0 && (n != 1 && n != 3))
379 if (abs(a - b) <= abs(b - c)) {
388 *dc_val_ptr = &dc_val[0];
405 int a_avail,
int c_avail,
406 int16_t **dc_val_ptr,
int *dir_ptr)
417 if (dqscale_index < 0)
427 b = dc_val[ - 1 -
wrap];
430 if (c_avail && (n != 1 && n != 3)) {
435 if (a_avail && (n != 2 && n != 3)) {
440 if (a_avail && c_avail && (n != 3)) {
451 if (c_avail && (!a_avail || abs(a - b) <= abs(b - c))) {
454 }
else if (a_avail) {
463 *dc_val_ptr = &dc_val[0];
512 int *
value,
int codingset)
562 *value = (level ^ -sign) + sign;
573 int coded,
int codingset)
580 int16_t *ac_val, *ac_val2;
594 const int m = (v->
pq == 1 || v->
pq == 2) ? 3 - v->
pq : 0;
595 if (dcdiff == 119 ) {
599 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
614 block[0] = dcdiff * scale;
629 int last = 0, skip,
value;
646 block[zz_table[i++]] =
value;
658 for (k = 1; k < 8; k++)
659 block[k << sh] += ac_val[k];
662 for (k = 1; k < 8; k++) {
668 for (k = 1; k < 64; k++)
672 block[k] += (block[k] < 0) ? -v->
pq : v->
pq;
678 memset(ac_val2, 0, 16 * 2);
690 memcpy(ac_val2, ac_val, 8 * 2);
691 for (k = 1; k < 8; k++) {
692 block[k << sh] = ac_val[k] * scale;
694 block[k << sh] += (block[k << sh] < 0) ? -v->
pq : v->
pq;
713 int coded,
int codingset,
int mquant)
719 int16_t *dc_val =
NULL;
720 int16_t *ac_val, *ac_val2;
740 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
741 if (dcdiff == 119 ) {
745 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
760 block[0] = dcdiff * scale;
763 if (!a_avail && !c_avail)
766 scale = quant * 2 + ((mquant < 0) ? 0 : v->
halfpq);
778 else if (dc_pred_dir) {
781 else if (c_avail && mb_pos)
786 else if (a_avail && mb_pos >= s->
mb_stride)
794 int last = 0, skip,
value;
819 block[zz_table[i++]] =
value;
832 q1 =
FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->
halfpq) - 1;
836 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
837 if (q2 && q1 != q2) {
838 for (k = 1; k < 8; k++)
839 block[k << sh] += (ac_val[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
841 for (k = 1; k < 8; k++)
842 block[k << sh] += ac_val[k];
846 for (k = 1; k < 8; k++) {
852 for (k = 1; k < 64; k++)
856 block[k] += (block[k] < 0) ? -quant : quant;
862 memset(ac_val2, 0, 16 * 2);
874 memcpy(ac_val2, ac_val, 8 * 2);
875 q1 =
FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->
halfpq) - 1;
879 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
880 if (q2 && q1 != q2) {
881 for (k = 1; k < 8; k++)
882 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
884 for (k = 1; k < 8; k++) {
885 block[k << sh] = ac_val2[k] * scale;
887 block[k << sh] += (block[k << sh] < 0) ? -quant : quant;
891 if (use_pred) i = 63;
906 int coded,
int mquant,
int codingset)
912 int16_t *dc_val =
NULL;
913 int16_t *ac_val, *ac_val2;
925 quant = av_clip_uintp2(quant, 5);
942 const int m = (quant == 1 || quant == 2) ? 3 - quant : 0;
943 if (dcdiff == 119 ) {
947 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
969 if (!a_avail) dc_pred_dir = 1;
970 if (!c_avail) dc_pred_dir = 0;
971 if (!a_avail && !c_avail) use_pred = 0;
975 scale = quant * 2 + ((mquant < 0) ? 0 : v->
halfpq);
983 if (dc_pred_dir && c_avail && mb_pos)
985 if (!dc_pred_dir && a_avail && mb_pos >= s->
mb_stride)
987 if (dc_pred_dir && n == 1)
989 if (!dc_pred_dir && n == 2)
994 int last = 0, skip,
value;
1019 q1 =
FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->
halfpq) - 1;
1023 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1024 if (q2 && q1 != q2) {
1026 for (k = 1; k < 8; k++)
1029 for (k = 1; k < 8; k++)
1034 for (k = 1; k < 8; k++)
1037 for (k = 1; k < 8; k++)
1043 for (k = 1; k < 8; k++) {
1049 for (k = 1; k < 64; k++)
1053 block[k] += (block[k] < 0) ? -quant : quant;
1056 if (use_pred) i = 63;
1060 memset(ac_val2, 0, 16 * 2);
1063 memcpy(ac_val2, ac_val, 8 * 2);
1064 q1 =
FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->
halfpq) - 1;
1068 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1069 if (q2 && q1 != q2) {
1070 for (k = 1; k < 8; k++)
1071 ac_val2[k] = (ac_val2[k] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1076 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
1077 q1 =
FFABS(q1) * 2 + ((q1 < 0) ? 0 : v->
halfpq) - 1;
1081 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1082 if (q2 && q1 != q2) {
1083 for (k = 1; k < 8; k++)
1084 ac_val2[k + 8] = (ac_val2[k + 8] * q2 *
ff_vc1_dqscale[q1 - 1] + 0x20000) >> 18;
1092 for (k = 1; k < 8; k++) {
1098 for (k = 1; k < 8; k++) {
1099 block[k << v->
top_blk_sh] = ac_val2[k + 8] * scale;
1115 int mquant,
int ttmb,
int first_block,
1116 uint8_t *dst,
int linesize,
int skip_block,
1123 int scale, off, idx, last, skip,
value;
1124 int ttblk = ttmb & 7;
1137 && ((v->
ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
1147 scale = quant * 2 + ((mquant < 0) ? 0 : v->
halfpq);
1172 block[idx] = value * scale;
1174 block[idx] += (block[idx] < 0) ? -quant : quant;
1186 pat = ~subblkpat & 0xF;
1187 for (j = 0; j < 4; j++) {
1188 last = subblkpat & (1 << (3 - j));
1190 off = (j & 1) * 4 + (j & 2) * 16;
1200 block[idx + off] = value * scale;
1202 block[idx + off] += (block[idx + off] < 0) ? -quant : quant;
1204 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
1213 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
1214 for (j = 0; j < 2; j++) {
1215 last = subblkpat & (1 << (1 - j));
1224 idx = v->
zz_8x4[i++] + off;
1227 block[idx] = value * scale;
1229 block[idx] += (block[idx] < 0) ? -quant : quant;
1231 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1240 pat = ~(subblkpat * 5) & 0xF;
1241 for (j = 0; j < 2; j++) {
1242 last = subblkpat & (1 << (1 - j));
1251 idx = v->
zz_4x8[i++] + off;
1254 block[idx] = value * scale;
1256 block[idx] += (block[idx] < 0) ? -quant : quant;
1258 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1268 *ttmb_out |= ttblk << (n * 4);
1286 int ttmb = v->
ttfrm;
1288 int mb_has_coeffs = 1;
1292 int first_block = 1;
1294 int skipped, fourmv;
1295 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
1320 if (s->
mb_intra && !mb_has_coeffs) {
1324 }
else if (mb_has_coeffs) {
1340 for (i = 0; i < 6; i++) {
1343 val = ((cbp >> (5 - i)) & 1);
1344 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1351 if (i == 1 || i == 3 || s->
mb_x)
1360 for (j = 0; j < 64; j++)
1362 block_cbp |= 0xF << (i << 2);
1363 block_intra |= 1 << i;
1368 block_cbp |= pat << (i << 2);
1369 if (!v->
ttmbf && ttmb < 8)
1376 for (i = 0; i < 6; i++) {
1387 int intra_count = 0, coded_inter = 0;
1388 int is_intra[6], is_coded[6];
1391 for (i = 0; i < 6; i++) {
1392 val = ((cbp >> (5 - i)) & 1);
1407 is_coded[i] = mb_has_coeffs;
1410 is_intra[i] = (intra_count >= 3);
1417 coded_inter = !is_intra[i] & is_coded[i];
1421 if (!intra_count && !coded_inter)
1428 for (i = 0; i < 6; i++)
1441 if (!v->
ttmbf && coded_inter)
1443 for (i = 0; i < 6; i++) {
1445 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1452 if (i == 1 || i == 3 || s->
mb_x)
1461 for (j = 0; j < 64; j++)
1463 block_cbp |= 0xF << (i << 2);
1464 block_intra |= 1 << i;
1465 }
else if (is_coded[i]) {
1467 first_block, s->
dest[dst_idx] + off,
1471 block_cbp |= pat << (i << 2);
1472 if (!v->
ttmbf && ttmb < 8)
1480 for (i = 0; i < 6; i++) {
1484 for (i = 0; i < 4; i++) {
1514 int ttmb = v->
ttfrm;
1516 int mb_has_coeffs = 1;
1519 int first_block = 1;
1521 int skipped, fourmv = 0, twomv = 0;
1522 int block_cbp = 0, pat, block_tt = 0;
1523 int idx_mbmode = 0, mvbp;
1568 for (i = 0; i < 4; i++) {
1586 for (i = 0; i < 6; i++) {
1591 val = ((cbp >> (5 - i)) & 1);
1594 if (i == 1 || i == 3 || s->
mb_x)
1603 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->
linesize : (i & 1) * 8 + 4 * (i & 2) * s->
linesize;
1606 block_cbp |= 0
xf << (i << 2);
1622 for (i = 0; i < 6; i++)
1629 for (i = 0; i < 4; i++) {
1631 if (mvbp & (8 >> i))
1666 if (!v->
ttmbf && cbp)
1668 for (i = 0; i < 6; i++) {
1671 val = ((cbp >> (5 - i)) & 1);
1673 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1675 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->
linesize));
1678 first_block, s->
dest[dst_idx] + off,
1681 block_cbp |= pat << (i << 2);
1682 if (!v->
ttmbf && ttmb < 8)
1690 for (i = 0; i < 6; i++) {
1722 int ttmb = v->
ttfrm;
1724 int mb_has_coeffs = 1;
1727 int first_block = 1;
1730 int block_cbp = 0, pat, block_tt = 0;
1736 if (idx_mbmode <= 1) {
1748 mb_has_coeffs = idx_mbmode & 1;
1752 for (i = 0; i < 6; i++) {
1757 val = ((cbp >> (5 - i)) & 1);
1760 if (i == 1 || i == 3 || s->
mb_x)
1768 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1769 block_cbp |= 0xf << (i << 2);
1774 for (i = 0; i < 6; i++)
1776 if (idx_mbmode <= 5) {
1777 dmv_x = dmv_y = pred_flag = 0;
1778 if (idx_mbmode & 1) {
1783 mb_has_coeffs = !(idx_mbmode & 2);
1786 for (i = 0; i < 4; i++) {
1787 dmv_x = dmv_y = pred_flag = 0;
1794 mb_has_coeffs = idx_mbmode & 1;
1802 if (!v->
ttmbf && cbp) {
1806 for (i = 0; i < 6; i++) {
1809 val = ((cbp >> (5 - i)) & 1);
1810 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
1813 first_block, s->
dest[dst_idx] + off,
1817 block_cbp |= pat << (i << 2);
1818 if (!v->
ttmbf && ttmb < 8)
1844 int ttmb = v->
ttfrm;
1845 int mb_has_coeffs = 0;
1848 int first_block = 1;
1850 int skipped, direct;
1851 int dmv_x[2], dmv_y[2];
1866 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1867 for (i = 0; i < 6; i++) {
1876 dmv_x[1] = dmv_x[0];
1877 dmv_y[1] = dmv_y[0];
1890 dmv_x[0] = dmv_y[0] = 0;
1894 for (i = 0; i < 6; i++)
1901 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1911 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1913 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1915 if (!mb_has_coeffs && !s->
mb_intra) {
1918 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1921 if (s->
mb_intra && !mb_has_coeffs) {
1930 if (!mb_has_coeffs) {
1933 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1939 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1951 for (i = 0; i < 6; i++) {
1954 val = ((cbp >> (5 - i)) & 1);
1955 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
1962 if (i == 1 || i == 3 || s->
mb_x)
1971 for (j = 0; j < 64; j++)
1972 s->
block[i][j] <<= 1;
1974 s->
dest[dst_idx] + off,
1979 first_block, s->
dest[dst_idx] + off,
1982 if (!v->
ttmbf && ttmb < 8)
1999 int ttmb = v->
ttfrm;
2000 int mb_has_coeffs = 0;
2002 int first_block = 1;
2005 int dmv_x[2], dmv_y[2], pred_flag[2];
2007 int block_cbp = 0, pat, block_tt = 0;
2014 if (idx_mbmode <= 1) {
2026 mb_has_coeffs = idx_mbmode & 1;
2030 for (i = 0; i < 6; i++) {
2035 val = ((cbp >> (5 - i)) & 1);
2038 if (i == 1 || i == 3 || s->
mb_x)
2047 for (j = 0; j < 64; j++)
2048 s->
block[i][j] <<= 1;
2049 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
2051 s->
dest[dst_idx] + off,
2058 for (i = 0; i < 6; i++)
2064 if (idx_mbmode <= 5) {
2066 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2067 pred_flag[0] = pred_flag[1] = 0;
2092 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2093 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2101 mb_has_coeffs = !(idx_mbmode & 2);
2107 for (i = 0; i < 4; i++) {
2108 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2109 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2119 mb_has_coeffs = idx_mbmode & 1;
2127 if (!v->
ttmbf && cbp) {
2131 for (i = 0; i < 6; i++) {
2134 val = ((cbp >> (5 - i)) & 1);
2135 off = (i & 4) ? 0 : (i & 1) * 8 + (i & 2) * 4 * s->
linesize;
2138 first_block, s->
dest[dst_idx] + off,
2141 block_cbp |= pat << (i << 2);
2142 if (!v->
ttmbf && ttmb < 8)
2162 int ttmb = v->
ttfrm;
2164 int mb_has_coeffs = 1;
2167 int first_block = 1;
2169 int skipped, direct, twomv = 0;
2170 int block_cbp = 0, pat, block_tt = 0;
2171 int idx_mbmode = 0, mvbp;
2172 int stride_y, fieldtx;
2200 for (i = 0; i < 4; i++) {
2220 for (i = 0; i < 6; i++) {
2225 val = ((cbp >> (5 - i)) & 1);
2228 if (i == 1 || i == 3 || s->
mb_x)
2238 off = (fieldtx) ? ((i & 1) * 8) + ((i & 2) >> 1) * s->
linesize : (i & 1) * 8 + 4 * (i & 2) * s->
linesize;
2244 s->
dest[dst_idx] + off,
2269 for (i = 1; i < 4; i += 2) {
2276 for (i = 1; i < 4; i++) {
2316 for (i = 0; i < 6; i++)
2323 for (i = 0; i < 4; i++) {
2335 for (i = 0; i < 4; i++) {
2338 val = ((mvbp >> (3 - i)) & 1);
2381 for (i = 0; i < 2; i++) {
2411 for (i = 0; i < 2; i++) {
2421 if (!v->
ttmbf && cbp)
2423 for (i = 0; i < 6; i++) {
2426 val = ((cbp >> (5 - i)) & 1);
2428 off = (i & 4) ? 0 : ((i & 1) * 8 + (i & 2) * 4 * s->
linesize);
2430 off = (i & 4) ? 0 : ((i & 1) * 8 + ((i > 1) * s->
linesize));
2433 first_block, s->
dest[dst_idx] + off,
2436 block_cbp |= pat << (i << 2);
2437 if (!v->
ttmbf && ttmb < 8)
2445 for (i = 0; i < 6; i++) {
2467 for (i = 0; i < 2; i++) {
2479 for (i = 0; i < 2; i++) {
2552 for (
int i = 0; i < 4; i++) {
2561 for (k = 0; k < 6; k++) {
2564 val = ((cbp >> (5 - k)) & 1);
2571 cbp |= val << (5 - k);
2583 for (k = 0; k < 6; k++)
2584 for (j = 0; j < 64; j++)
2589 for (k = 0; k < 6; k++)
2590 for (j = 0; j < 64; j++)
2683 for (
int i = 0; i < 4; i++) {
2707 for (k = 0; k < 6; k++) {
2710 val = ((cbp >> (5 - k)) & 1);
2717 cbp |= val << (5 - k);
2802 if (apply_loop_filter)
2806 if (apply_loop_filter)
2810 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
void(* clear_block)(int16_t *block)
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.
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
static const int vc1_last_decode_table[AC_MODES]
int tt_index
Index for Transform Type tables (to decode TTMB)
#define VC1_2REF_MVDATA_VLC_BITS
void(* clear_blocks)(int16_t *blocks)
uint8_t rangeredfrm
Frame decoding info for S/M profiles only.
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 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_8x8)(int16_t *b)
void(* add_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
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]
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)
static const uint16_t table[]
uint8_t ttmbf
Transform type flag.
void(* put_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
int k_y
Number of bits for MVs (depends on MV range)
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_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(* vc1_inv_trans_8x8_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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 void vc1_put_blocks_clamped(VC1Context *v, int put_signed)
void(* vc1_inv_trans_8x4)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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.
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]
void ff_vc1_i_loop_filter(VC1Context *v)
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...
int16_t(*[2] motion_val)[2]
GLsizei GLboolean const GLfloat * value
Picture * current_picture_ptr
pointer to the current picture
void ff_vc1_b_intfi_loop_filter(VC1Context *v)
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.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
static av_always_inline int get_vlc2(GetBitContext *s, VLC_TYPE(*table)[2], int bits, int max_depth)
Parse a vlc code.
void(* vc1_inv_trans_4x4)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
int block_last_index[12]
last non zero coefficient in block
static const int block_map[6]
void ff_vc1_p_loop_filter(VC1Context *v)
void(* vc1_inv_trans_8x4_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(* vc1_inv_trans_4x8)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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)
void(* vc1_inv_trans_4x8_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
int top_blk_sh
Either 3 or 0, positions of l/t in blk[].
Libavcodec external API header.
void(* vc1_inv_trans_4x4_dc)(uint8_t *dest, ptrdiff_t stride, int16_t *block)
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 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
#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)
void ff_vc1_p_overlap_filter(VC1Context *v)
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)
int numref
number of past field pictures used as reference
const int32_t ff_vc1_dqscale[63]
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)
void ff_vc1_i_overlap_filter(VC1Context *v)
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 ...
void(* put_signed_pixels_clamped)(const int16_t *block, uint8_t *av_restrict pixels, ptrdiff_t line_size)
#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.
#define xf(width, name, var, range_min, range_max, subs,...)
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_p_intfr_loop_filter(VC1Context *v)
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]