42 { 0, 1, 2, 4, 8, 16, 32, 64, 128 },
43 { 0, 1, 3, 7, 15, 31, 63, 127, 255 },
62 s->dest[0] +=
s->current_picture_ptr->f->linesize[0];
63 s->dest[1] +=
s->current_picture_ptr->f->linesize[1];
64 s->dest[2] +=
s->current_picture_ptr->f->linesize[2];
92 for (
i = 0;
i < block_count;
i++) {
93 if (
i > 3 ? v->
mb_type[0][
s->block_index[
i] -
s->block_wrap[
i] - 1] :
94 v->
mb_type[0][
s->block_index[
i] - 2 *
s->block_wrap[
i] - 2]) {
95 dest =
s->dest[0] + ((
i & 2) - 4) * 4 *
s->linesize + ((
i & 1) - 2) * 8;
98 i > 3 ?
s->dest[
i - 3] - 8 *
s->uvlinesize - 8 : dest,
99 i > 3 ?
s->uvlinesize :
s->linesize);
102 i > 3 ?
s->dest[
i - 3] - 8 *
s->uvlinesize - 8 : dest,
103 i > 3 ?
s->uvlinesize :
s->linesize);
108 for (
i = 0;
i < block_count;
i++) {
109 if (
i > 3 ? v->
mb_type[0][
s->block_index[
i] -
s->block_wrap[
i]] :
110 v->
mb_type[0][
s->block_index[
i] - 2 *
s->block_wrap[
i]]) {
111 dest =
s->dest[0] + ((
i & 2) - 4) * 4 *
s->linesize + (
i & 1) * 8;
114 i > 3 ?
s->dest[
i - 3] - 8 *
s->uvlinesize : dest,
115 i > 3 ?
s->uvlinesize :
s->linesize);
118 i > 3 ?
s->dest[
i - 3] - 8 *
s->uvlinesize : dest,
119 i > 3 ?
s->uvlinesize :
s->linesize);
128 for (
i = 0;
i < block_count;
i++) {
129 if (
i > 3 ? v->
mb_type[0][
s->block_index[
i] - 1] :
132 dest =
s->dest[0] + ((
i & 2) >> 1) *
s->linesize + ((
i & 1) - 2) * 8;
134 dest =
s->dest[0] + (
i & 2) * 4 *
s->linesize + ((
i & 1) - 2) * 8;
137 i > 3 ?
s->dest[
i - 3] - 8 : dest,
138 i > 3 ?
s->uvlinesize :
s->linesize << fieldtx);
141 i > 3 ?
s->dest[
i - 3] - 8 : dest,
142 i > 3 ?
s->uvlinesize :
s->linesize << fieldtx);
149 for (
i = 0;
i < block_count;
i++) {
152 dest =
s->dest[0] + ((
i & 2) >> 1) *
s->linesize + (
i & 1) * 8;
154 dest =
s->dest[0] + (
i & 2) * 4 *
s->linesize + (
i & 1) * 8;
157 i > 3 ?
s->dest[
i - 3] : dest,
158 i > 3 ?
s->uvlinesize :
s->linesize << fieldtx);
161 i > 3 ?
s->dest[
i - 3] : dest,
162 i > 3 ?
s->uvlinesize :
s->linesize << fieldtx);
169 #define inc_blk_idx(idx) do { \
171 if (idx >= v->n_allocated_blks) \
186 #define GET_MQUANT() \
187 if (v->dquantfrm) { \
189 if (v->dqprofile == DQPROFILE_ALL_MBS) { \
190 if (v->dqbilevel) { \
191 mquant = (get_bits1(gb)) ? -v->altpq : v->pq; \
193 mqdiff = get_bits(gb, 3); \
195 mquant = -v->pq - mqdiff; \
197 mquant = -get_bits(gb, 5); \
200 if (v->dqprofile == DQPROFILE_SINGLE_EDGE) \
201 edges = 1 << v->dqsbedge; \
202 else if (v->dqprofile == DQPROFILE_DOUBLE_EDGES) \
203 edges = (3 << v->dqsbedge) % 15; \
204 else if (v->dqprofile == DQPROFILE_FOUR_EDGES) \
206 if ((edges&1) && !s->mb_x) \
207 mquant = -v->altpq; \
208 if ((edges&2) && !s->mb_y) \
209 mquant = -v->altpq; \
210 if ((edges&4) && s->mb_x == (s->mb_width - 1)) \
211 mquant = -v->altpq; \
213 s->mb_y == ((s->mb_height >> v->field_mode) - 1)) \
214 mquant = -v->altpq; \
215 if (!mquant || mquant > 31 || mquant < -31) { \
216 av_log(v->s.avctx, AV_LOG_ERROR, \
217 "Overriding invalid mquant %d\n", mquant); \
229 #define GET_MVDATA(_dmv_x, _dmv_y) \
230 index = 1 + get_vlc2(gb, ff_vc1_mv_diff_vlc[s->mv_table_index].table, \
231 VC1_MV_DIFF_VLC_BITS, 2); \
239 _dmv_x = _dmv_y = 0; \
240 } else if (index == 35) { \
241 _dmv_x = get_bits(gb, v->k_x - 1 + s->quarter_sample); \
242 _dmv_y = get_bits(gb, v->k_y - 1 + s->quarter_sample); \
243 } else if (index == 36) { \
248 index1 = index % 6; \
249 _dmv_x = offset_table[1][index1]; \
250 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \
252 val = get_bits(gb, val); \
253 sign = 0 - (val & 1); \
254 _dmv_x = (sign ^ ((val >> 1) + _dmv_x)) - sign; \
257 index1 = index / 6; \
258 _dmv_y = offset_table[1][index1]; \
259 val = size_table[index1] - (!s->quarter_sample && index1 == 5); \
261 val = get_bits(gb, val); \
262 sign = 0 - (val & 1); \
263 _dmv_y = (sign ^ ((val >> 1) + _dmv_y)) - sign; \
268 int *dmv_y,
int *pred_flag)
271 int extend_x, extend_y;
291 *pred_flag = *dmv_y & 1;
292 *dmv_y = (*dmv_y + (*dmv_y & 1)) >> 1;
297 index1 = (
index + 1) % 9;
300 sign = 0 - (
val & 1);
301 *dmv_x = (sign ^ ((
val >> 1) +
offset_table[extend_x][index1])) - sign;
304 index1 = (
index + 1) / 9;
307 sign = 0 - (
val & 1);
311 if (v->
numref && pred_flag)
312 *pred_flag = index1 & 1;
319 int direct,
int mode)
345 int16_t **dc_val_ptr,
int *dir_ptr)
349 static const uint16_t dcpred[32] = {
350 -1, 1024, 512, 341, 256, 205, 171, 146, 128,
351 114, 102, 93, 85, 79, 73, 68, 64,
352 60, 57, 54, 51, 49, 47, 45, 43,
353 41, 39, 38, 37, 35, 34, 33
357 if (n < 4)
scale =
s->y_dc_scale;
358 else scale =
s->c_dc_scale;
360 wrap =
s->block_wrap[n];
361 dc_val =
s->dc_val[0] +
s->block_index[n];
367 b = dc_val[ - 1 -
wrap];
370 if (pq < 9 || !overlap) {
372 if (
s->first_slice_line && (n != 2 && n != 3))
374 if (
s->mb_x == 0 && (n != 1 && n != 3))
378 if (
s->first_slice_line && (n != 2 && n != 3))
380 if (
s->mb_x == 0 && (n != 1 && n != 3))
393 *dc_val_ptr = &dc_val[0];
410 int a_avail,
int c_avail,
411 int16_t **dc_val_ptr,
int *dir_ptr)
415 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
420 q1 =
FFABS(
s->current_picture.qscale_table[mb_pos]);
421 dqscale_index =
s->y_dc_scale_table[
q1] - 1;
422 if (dqscale_index < 0)
425 wrap =
s->block_wrap[n];
426 dc_val =
s->dc_val[0] +
s->block_index[n];
432 b = dc_val[ - 1 -
wrap];
435 if (c_avail && (n != 1 && n != 3)) {
436 q2 =
FFABS(
s->current_picture.qscale_table[mb_pos - 1]);
438 c = (
int)((
unsigned)
c *
s->y_dc_scale_table[q2] *
ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
440 if (a_avail && (n != 2 && n != 3)) {
441 q2 =
FFABS(
s->current_picture.qscale_table[mb_pos -
s->mb_stride]);
443 a = (
int)((
unsigned)
a *
s->y_dc_scale_table[q2] *
ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
445 if (a_avail && c_avail && (n != 3)) {
451 q2 =
FFABS(
s->current_picture.qscale_table[off]);
453 b = (
int)((
unsigned)
b *
s->y_dc_scale_table[q2] *
ff_vc1_dqscale[dqscale_index] + 0x20000) >> 18;
456 if (c_avail && (!a_avail ||
abs(
a -
b) <=
abs(
b -
c))) {
459 }
else if (a_avail) {
468 *dc_val_ptr = &dc_val[0];
481 uint8_t **coded_block_ptr)
485 xy =
s->block_index[n];
491 a =
s->coded_block[xy - 1 ];
492 b =
s->coded_block[xy - 1 -
wrap];
493 c =
s->coded_block[xy -
wrap];
502 *coded_block_ptr = &
s->coded_block[xy];
517 int *
value,
int codingset)
584 int coded,
int codingset)
591 int16_t *ac_val, *ac_val2;
603 const int m = (v->
pq == 1 || v->
pq == 2) ? 3 - v->
pq : 0;
604 if (dcdiff == 119 ) {
608 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
625 ac_val =
s->ac_val[0][
s->block_index[n]];
630 ac_val -= 16 *
s->block_wrap[n];
639 const uint8_t *zz_table;
669 for (k = 1; k < 8; k++)
670 block[k << sh] += ac_val[k];
673 for (k = 1; k < 8; k++) {
679 for (k = 1; k < 64; k++)
689 memset(ac_val2, 0, 16 * 2);
701 memcpy(ac_val2, ac_val, 8 * 2);
702 for (k = 1; k < 8; k++) {
709 if (
s->ac_pred)
i = 63;
710 s->block_last_index[n] =
i;
724 int coded,
int codingset,
int mquant)
730 int16_t *dc_val =
NULL;
731 int16_t *ac_val, *ac_val2;
734 int use_pred =
s->ac_pred;
737 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
750 if (dcdiff == 119 ) {
754 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
772 if (!a_avail && !c_avail)
777 ac_val =
s->ac_val[0][
s->block_index[n]];
782 ac_val -= 16 *
s->block_wrap[n];
784 q1 =
s->current_picture.qscale_table[mb_pos];
787 else if (dc_pred_dir) {
790 else if (c_avail && mb_pos)
791 q2 =
s->current_picture.qscale_table[mb_pos - 1];
795 else if (a_avail && mb_pos >=
s->mb_stride)
796 q2 =
s->current_picture.qscale_table[mb_pos -
s->mb_stride];
804 const uint8_t *zz_table;
847 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
848 if (q2 &&
q1 != q2) {
849 for (k = 1; k < 8; k++)
852 for (k = 1; k < 8; k++)
853 block[k << sh] += ac_val[k];
857 for (k = 1; k < 8; k++) {
863 for (k = 1; k < 64; k++)
873 memset(ac_val2, 0, 16 * 2);
885 memcpy(ac_val2, ac_val, 8 * 2);
890 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
891 if (q2 &&
q1 != q2) {
892 for (k = 1; k < 8; k++)
893 ac_val2[k] = (
int)(ac_val2[k] * q2 * (unsigned)
ff_vc1_dqscale[
q1 - 1] + 0x20000) >> 18;
895 for (k = 1; k < 8; k++) {
902 if (use_pred)
i = 63;
903 s->block_last_index[n] =
i;
917 int coded,
int mquant,
int codingset)
923 int16_t *dc_val =
NULL;
924 int16_t *ac_val, *ac_val2;
926 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
928 int use_pred =
s->ac_pred;
933 s->bdsp.clear_block(
block);
939 s->y_dc_scale =
s->y_dc_scale_table[
quant];
940 s->c_dc_scale =
s->c_dc_scale_table[
quant];
952 if (dcdiff == 119 ) {
956 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
969 block[0] = dcdiff *
s->y_dc_scale;
971 block[0] = dcdiff *
s->c_dc_scale;
978 if (!a_avail) dc_pred_dir = 1;
979 if (!c_avail) dc_pred_dir = 0;
980 if (!a_avail && !c_avail) use_pred = 0;
981 ac_val =
s->ac_val[0][
s->block_index[n]];
989 ac_val -= 16 *
s->block_wrap[n];
991 q1 =
s->current_picture.qscale_table[mb_pos];
992 if (dc_pred_dir && c_avail && mb_pos)
993 q2 =
s->current_picture.qscale_table[mb_pos - 1];
994 if (!dc_pred_dir && a_avail && mb_pos >=
s->mb_stride)
995 q2 =
s->current_picture.qscale_table[mb_pos -
s->mb_stride];
996 if (dc_pred_dir && n == 1)
998 if (!dc_pred_dir && n == 2)
1000 if (n == 3) q2 =
q1;
1034 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1035 if (q2 &&
q1 != q2) {
1037 for (k = 1; k < 8; k++)
1040 for (k = 1; k < 8; k++)
1045 for (k = 1; k < 8; k++)
1048 for (k = 1; k < 8; k++)
1054 for (k = 1; k < 8; k++) {
1060 for (k = 1; k < 64; k++)
1067 if (use_pred)
i = 63;
1071 memset(ac_val2, 0, 16 * 2);
1074 memcpy(ac_val2, ac_val, 8 * 2);
1079 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1080 if (q2 &&
q1 != q2) {
1081 for (k = 1; k < 8; k++)
1082 ac_val2[k] = (
int)(ac_val2[k] * (unsigned)q2 *
ff_vc1_dqscale[
q1 - 1] + 0x20000) >> 18;
1087 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
1092 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1093 if (q2 &&
q1 != q2) {
1094 for (k = 1; k < 8; k++)
1095 ac_val2[k + 8] = (
int)(ac_val2[k + 8] * (unsigned)q2 *
ff_vc1_dqscale[
q1 - 1] + 0x20000) >> 18;
1103 for (k = 1; k < 8; k++) {
1109 for (k = 1; k < 8; k++) {
1118 s->block_last_index[n] =
i;
1126 int mquant,
int ttmb,
int first_block,
1127 uint8_t *dst,
int linesize,
int skip_block,
1135 int ttblk = ttmb & 7;
1139 s->bdsp.clear_block(
block);
1148 && ((v->
ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
1194 s->idsp.add_pixels_clamped(
block, dst, linesize);
1199 pat = ~subblkpat & 0xF;
1200 for (j = 0; j < 4; j++) {
1201 last = subblkpat & (1 << (3 - j));
1203 off = (j & 1) * 4 + (j & 2) * 16;
1219 if (!(subblkpat & (1 << (3 - j))) && !skip_block) {
1228 pat = ~((subblkpat & 2) * 6 + (subblkpat & 1) * 3) & 0xF;
1229 for (j = 0; j < 2; j++) {
1230 last = subblkpat & (1 << (1 - j));
1248 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1257 pat = ~(subblkpat * 5) & 0xF;
1258 for (j = 0; j < 2; j++) {
1259 last = subblkpat & (1 << (1 - j));
1277 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1287 *ttmb_out |= ttblk << (n * 4);
1302 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1305 int ttmb = v->
ttfrm;
1307 int mb_has_coeffs = 1;
1311 int first_block = 1;
1313 int skipped, fourmv;
1314 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
1332 s->current_picture.motion_val[1][
s->block_index[0]][0] = 0;
1333 s->current_picture.motion_val[1][
s->block_index[0]][1] = 0;
1339 if (
s->mb_intra && !mb_has_coeffs) {
1343 }
else if (mb_has_coeffs) {
1352 s->current_picture.qscale_table[mb_pos] = mquant;
1354 if (!v->
ttmbf && !
s->mb_intra && mb_has_coeffs)
1359 for (
i = 0;
i < 6;
i++) {
1360 s->dc_val[0][
s->block_index[
i]] = 0;
1362 val = ((cbp >> (5 -
i)) & 1);
1363 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1364 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1368 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1370 if (
i == 1 ||
i == 3 ||
s->mb_x)
1379 for (j = 0; j < 64; j++)
1381 block_cbp |= 0xF << (
i << 2);
1382 block_intra |= 1 <<
i;
1385 s->dest[dst_idx] + off, (
i & 4) ?
s->uvlinesize :
s->linesize,
1389 block_cbp |= pat << (
i << 2);
1390 if (!v->
ttmbf && ttmb < 8)
1397 for (
i = 0;
i < 6;
i++) {
1399 s->dc_val[0][
s->block_index[
i]] = 0;
1402 s->current_picture.qscale_table[mb_pos] = 0;
1408 int intra_count = 0, coded_inter = 0;
1409 int is_intra[6], is_coded[6];
1412 for (
i = 0;
i < 6;
i++) {
1413 val = ((cbp >> (5 -
i)) & 1);
1414 s->dc_val[0][
s->block_index[
i]] = 0;
1426 intra_count +=
s->mb_intra;
1427 is_intra[
i] =
s->mb_intra;
1428 is_coded[
i] = mb_has_coeffs;
1431 is_intra[
i] = (intra_count >= 3);
1436 v->
mb_type[0][
s->block_index[
i]] = is_intra[
i];
1438 coded_inter = !is_intra[
i] & is_coded[
i];
1442 if (!intra_count && !coded_inter)
1445 s->current_picture.qscale_table[mb_pos] = mquant;
1449 for (
i = 0;
i < 6;
i++)
1451 if (((!
s->first_slice_line || (
i == 2 ||
i == 3)) && v->
mb_type[0][
s->block_index[
i] -
s->block_wrap[
i]])
1452 || ((
s->mb_x || (
i == 1 ||
i == 3)) && v->
mb_type[0][
s->block_index[
i] - 1])) {
1462 if (!v->
ttmbf && coded_inter)
1464 for (
i = 0;
i < 6;
i++) {
1466 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1467 s->mb_intra = is_intra[
i];
1471 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1473 if (
i == 1 ||
i == 3 ||
s->mb_x)
1482 for (j = 0; j < 64; j++)
1484 block_cbp |= 0xF << (
i << 2);
1485 block_intra |= 1 <<
i;
1486 }
else if (is_coded[
i]) {
1488 first_block,
s->dest[dst_idx] + off,
1489 (
i & 4) ?
s->uvlinesize :
s->linesize,
1494 block_cbp |= pat << (
i << 2);
1495 if (!v->
ttmbf && ttmb < 8)
1502 s->current_picture.qscale_table[mb_pos] = 0;
1503 for (
i = 0;
i < 6;
i++) {
1505 s->dc_val[0][
s->block_index[
i]] = 0;
1507 for (
i = 0;
i < 4;
i++) {
1512 s->current_picture.qscale_table[mb_pos] = 0;
1520 v->
cbp[
s->mb_x] = block_cbp;
1521 v->
ttblk[
s->mb_x] = block_tt;
1534 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1537 int ttmb = v->
ttfrm;
1539 int mb_has_coeffs = 1;
1542 int first_block = 1;
1544 int skipped, fourmv = 0, twomv = 0;
1545 int block_cbp = 0, pat, block_tt = 0;
1546 int idx_mbmode = 0, mvbp;
1591 for (
i = 0;
i < 4;
i++) {
1592 s->current_picture.motion_val[1][
s->block_index[
i]][0] = 0;
1593 s->current_picture.motion_val[1][
s->block_index[
i]][1] = 0;
1604 s->current_picture.qscale_table[mb_pos] = mquant;
1606 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
1607 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
1609 for (
i = 0;
i < 6;
i++) {
1612 s->dc_val[0][
s->block_index[
i]] = 0;
1614 val = ((cbp >> (5 -
i)) & 1);
1615 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1617 if (
i == 1 ||
i == 3 ||
s->mb_x)
1626 off = (fieldtx) ? ((
i & 1) * 8) + ((
i & 2) >> 1) *
s->linesize : (
i & 1) * 8 + 4 * (
i & 2) *
s->linesize;
1629 block_cbp |= 0
xf << (
i << 2);
1645 for (
i = 0;
i < 6;
i++)
1652 for (
i = 0;
i < 4;
i++) {
1654 if (mvbp & (8 >>
i))
1688 s->current_picture.qscale_table[mb_pos] = mquant;
1689 if (!v->
ttmbf && cbp)
1691 for (
i = 0;
i < 6;
i++) {
1692 s->dc_val[0][
s->block_index[
i]] = 0;
1694 val = ((cbp >> (5 -
i)) & 1);
1696 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1698 off = (
i & 4) ? 0 : ((
i & 1) * 8 + ((
i > 1) *
s->linesize));
1701 first_block,
s->dest[dst_idx] + off,
1702 (
i & 4) ?
s->uvlinesize : (
s->linesize << fieldtx),
1706 block_cbp |= pat << (
i << 2);
1707 if (!v->
ttmbf && ttmb < 8)
1715 for (
i = 0;
i < 6;
i++) {
1717 s->dc_val[0][
s->block_index[
i]] = 0;
1720 s->current_picture.qscale_table[mb_pos] = 0;
1733 v->
cbp[
s->mb_x] = block_cbp;
1734 v->
ttblk[
s->mb_x] = block_tt;
1744 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1747 int ttmb = v->
ttfrm;
1749 int mb_has_coeffs = 1;
1752 int first_block = 1;
1755 int block_cbp = 0, pat, block_tt = 0;
1761 if (idx_mbmode <= 1) {
1764 s->current_picture.motion_val[1][
s->block_index[0] + v->
blocks_off][0] = 0;
1765 s->current_picture.motion_val[1][
s->block_index[0] + v->
blocks_off][1] = 0;
1768 s->current_picture.qscale_table[mb_pos] = mquant;
1770 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
1771 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
1773 mb_has_coeffs = idx_mbmode & 1;
1777 for (
i = 0;
i < 6;
i++) {
1780 s->dc_val[0][
s->block_index[
i]] = 0;
1782 val = ((cbp >> (5 -
i)) & 1);
1783 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1785 if (
i == 1 ||
i == 3 ||
s->mb_x)
1793 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1794 block_cbp |= 0xf << (
i << 2);
1799 for (
i = 0;
i < 6;
i++)
1801 if (idx_mbmode <= 5) {
1802 dmv_x = dmv_y = pred_flag = 0;
1803 if (idx_mbmode & 1) {
1808 mb_has_coeffs = !(idx_mbmode & 2);
1811 for (
i = 0;
i < 4;
i++) {
1812 dmv_x = dmv_y = pred_flag = 0;
1819 mb_has_coeffs = idx_mbmode & 1;
1826 s->current_picture.qscale_table[mb_pos] = mquant;
1827 if (!v->
ttmbf && cbp) {
1831 for (
i = 0;
i < 6;
i++) {
1832 s->dc_val[0][
s->block_index[
i]] = 0;
1834 val = ((cbp >> (5 -
i)) & 1);
1835 off = (
i & 4) ? 0 : (
i & 1) * 8 + (
i & 2) * 4 *
s->linesize;
1838 first_block,
s->dest[dst_idx] + off,
1839 (
i & 4) ?
s->uvlinesize :
s->linesize,
1844 block_cbp |= pat << (
i << 2);
1845 if (!v->
ttmbf && ttmb < 8)
1855 v->
cbp[
s->mb_x] = block_cbp;
1856 v->
ttblk[
s->mb_x] = block_tt;
1868 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1871 int ttmb = v->
ttfrm;
1872 int mb_has_coeffs = 0;
1875 int first_block = 1;
1877 int skipped, direct;
1878 int dmv_x[2], dmv_y[2];
1893 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1894 for (
i = 0;
i < 6;
i++) {
1896 s->dc_val[0][
s->block_index[
i]] = 0;
1898 s->current_picture.qscale_table[mb_pos] = 0;
1903 dmv_x[1] = dmv_x[0];
1904 dmv_y[1] = dmv_y[0];
1906 if (skipped || !
s->mb_intra) {
1917 dmv_x[0] = dmv_y[0] = 0;
1921 for (
i = 0;
i < 6;
i++)
1922 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1928 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1935 s->current_picture.qscale_table[mb_pos] = mquant;
1938 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1940 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1942 if (!mb_has_coeffs && !
s->mb_intra) {
1945 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1948 if (
s->mb_intra && !mb_has_coeffs) {
1950 s->current_picture.qscale_table[mb_pos] = mquant;
1957 if (!mb_has_coeffs) {
1960 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1966 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1972 s->current_picture.qscale_table[mb_pos] = mquant;
1973 if (!v->
ttmbf && !
s->mb_intra && mb_has_coeffs)
1978 for (
i = 0;
i < 6;
i++) {
1979 s->dc_val[0][
s->block_index[
i]] = 0;
1981 val = ((cbp >> (5 -
i)) & 1);
1982 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1983 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1987 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1989 if (
i == 1 ||
i == 3 ||
s->mb_x)
1998 for (j = 0; j < 64; j++)
1999 s->block[
i][j] *= 2;
2000 s->idsp.put_signed_pixels_clamped(
s->block[
i],
2001 s->dest[dst_idx] + off,
2002 i & 4 ?
s->uvlinesize
2006 first_block,
s->dest[dst_idx] + off,
2007 (
i & 4) ?
s->uvlinesize :
s->linesize,
2011 if (!v->
ttmbf && ttmb < 8)
2026 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2029 int ttmb = v->
ttfrm;
2030 int mb_has_coeffs = 0;
2032 int first_block = 1;
2035 int dmv_x[2], dmv_y[2], pred_flag[2];
2037 int block_cbp = 0, pat, block_tt = 0;
2044 if (idx_mbmode <= 1) {
2047 s->current_picture.motion_val[1][
s->block_index[0]][0] = 0;
2048 s->current_picture.motion_val[1][
s->block_index[0]][1] = 0;
2051 s->current_picture.qscale_table[mb_pos] = mquant;
2053 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2054 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2056 mb_has_coeffs = idx_mbmode & 1;
2060 for (
i = 0;
i < 6;
i++) {
2063 s->dc_val[0][
s->block_index[
i]] = 0;
2065 val = ((cbp >> (5 -
i)) & 1);
2066 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
2068 if (
i == 1 ||
i == 3 ||
s->mb_x)
2077 for (j = 0; j < 64; j++)
2078 s->block[
i][j] <<= 1;
2079 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
2080 s->idsp.put_signed_pixels_clamped(
s->block[
i],
2081 s->dest[dst_idx] + off,
2082 (
i & 4) ?
s->uvlinesize
2088 for (
i = 0;
i < 6;
i++)
2094 if (idx_mbmode <= 5) {
2096 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2097 pred_flag[0] = pred_flag[1] = 0;
2122 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2123 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2124 if (!
s->next_picture_ptr->field_picture) {
2131 mb_has_coeffs = !(idx_mbmode & 2);
2137 for (
i = 0;
i < 4;
i++) {
2138 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2139 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2149 mb_has_coeffs = idx_mbmode & 1;
2156 s->current_picture.qscale_table[mb_pos] = mquant;
2157 if (!v->
ttmbf && cbp) {
2161 for (
i = 0;
i < 6;
i++) {
2162 s->dc_val[0][
s->block_index[
i]] = 0;
2164 val = ((cbp >> (5 -
i)) & 1);
2165 off = (
i & 4) ? 0 : (
i & 1) * 8 + (
i & 2) * 4 *
s->linesize;
2168 first_block,
s->dest[dst_idx] + off,
2169 (
i & 4) ?
s->uvlinesize :
s->linesize,
2173 block_cbp |= pat << (
i << 2);
2174 if (!v->
ttmbf && ttmb < 8)
2180 v->
cbp[
s->mb_x] = block_cbp;
2181 v->
ttblk[
s->mb_x] = block_tt;
2193 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2196 int ttmb = v->
ttfrm;
2198 int mb_has_coeffs = 1;
2201 int first_block = 1;
2203 int skipped, direct, twomv = 0;
2204 int block_cbp = 0, pat, block_tt = 0;
2205 int idx_mbmode = 0, mvbp;
2206 int stride_y, fieldtx;
2234 for (
i = 0;
i < 4;
i++) {
2235 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0] = 0;
2236 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1] = 0;
2237 s->mv[1][
i][0] =
s->current_picture.motion_val[1][
s->block_index[
i]][0] = 0;
2238 s->mv[1][
i][1] =
s->current_picture.motion_val[1][
s->block_index[
i]][1] = 0;
2249 s->current_picture.qscale_table[mb_pos] = mquant;
2251 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2252 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2254 for (
i = 0;
i < 6;
i++) {
2257 s->dc_val[0][
s->block_index[
i]] = 0;
2259 val = ((cbp >> (5 -
i)) & 1);
2260 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
2262 if (
i == 1 ||
i == 3 ||
s->mb_x)
2271 stride_y =
s->linesize << fieldtx;
2272 off = (fieldtx) ? ((
i & 1) * 8) + ((
i & 2) >> 1) *
s->linesize : (
i & 1) * 8 + 4 * (
i & 2) *
s->linesize;
2274 stride_y =
s->uvlinesize;
2277 s->idsp.put_signed_pixels_clamped(
s->block[
i],
2278 s->dest[dst_idx] + off,
2290 if (
s->next_picture_ptr->field_picture)
2292 s->mv[0][0][0] =
s->current_picture.motion_val[0][
s->block_index[0]][0] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[0]][0], v->
bfraction, 0,
s->quarter_sample);
2293 s->mv[0][0][1] =
s->current_picture.motion_val[0][
s->block_index[0]][1] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[0]][1], v->
bfraction, 0,
s->quarter_sample);
2294 s->mv[1][0][0] =
s->current_picture.motion_val[1][
s->block_index[0]][0] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[0]][0], v->
bfraction, 1,
s->quarter_sample);
2295 s->mv[1][0][1] =
s->current_picture.motion_val[1][
s->block_index[0]][1] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[0]][1], v->
bfraction, 1,
s->quarter_sample);
2298 s->mv[0][2][0] =
s->current_picture.motion_val[0][
s->block_index[2]][0] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[2]][0], v->
bfraction, 0,
s->quarter_sample);
2299 s->mv[0][2][1] =
s->current_picture.motion_val[0][
s->block_index[2]][1] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[2]][1], v->
bfraction, 0,
s->quarter_sample);
2300 s->mv[1][2][0] =
s->current_picture.motion_val[1][
s->block_index[2]][0] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[2]][0], v->
bfraction, 1,
s->quarter_sample);
2301 s->mv[1][2][1] =
s->current_picture.motion_val[1][
s->block_index[2]][1] =
scale_mv(
s->next_picture.motion_val[1][
s->block_index[2]][1], v->
bfraction, 1,
s->quarter_sample);
2303 for (
i = 1;
i < 4;
i += 2) {
2304 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0] =
s->mv[0][
i-1][0];
2305 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1] =
s->mv[0][
i-1][1];
2306 s->mv[1][
i][0] =
s->current_picture.motion_val[1][
s->block_index[
i]][0] =
s->mv[1][
i-1][0];
2307 s->mv[1][
i][1] =
s->current_picture.motion_val[1][
s->block_index[
i]][1] =
s->mv[1][
i-1][1];
2310 for (
i = 1;
i < 4;
i++) {
2311 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0] =
s->mv[0][0][0];
2312 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1] =
s->mv[0][0][1];
2313 s->mv[1][
i][0] =
s->current_picture.motion_val[1][
s->block_index[
i]][0] =
s->mv[1][0][0];
2314 s->mv[1][
i][1] =
s->current_picture.motion_val[1][
s->block_index[
i]][1] =
s->mv[1][0][1];
2320 if (skipped || !
s->mb_intra) {
2350 for (
i = 0;
i < 6;
i++)
2357 for (
i = 0;
i < 4;
i++) {
2369 for (
i = 0;
i < 4;
i++) {
2372 val = ((mvbp >> (3 -
i)) & 1);
2415 for (
i = 0;
i < 2;
i++) {
2416 s->mv[dir][
i+2][0] =
s->mv[dir][
i][0] =
s->current_picture.motion_val[dir][
s->block_index[
i+2]][0] =
s->current_picture.motion_val[dir][
s->block_index[
i]][0];
2417 s->mv[dir][
i+2][1] =
s->mv[dir][
i][1] =
s->current_picture.motion_val[dir][
s->block_index[
i+2]][1] =
s->current_picture.motion_val[dir][
s->block_index[
i]][1];
2418 s->mv[dir2][
i+2][0] =
s->mv[dir2][
i][0] =
s->current_picture.motion_val[dir2][
s->block_index[
i]][0] =
s->current_picture.motion_val[dir2][
s->block_index[
i+2]][0];
2419 s->mv[dir2][
i+2][1] =
s->mv[dir2][
i][1] =
s->current_picture.motion_val[dir2][
s->block_index[
i]][1] =
s->current_picture.motion_val[dir2][
s->block_index[
i+2]][1];
2445 for (
i = 0;
i < 2;
i++) {
2446 s->mv[!dir][
i+2][0] =
s->mv[!dir][
i][0] =
s->current_picture.motion_val[!dir][
s->block_index[
i+2]][0] =
s->current_picture.motion_val[!dir][
s->block_index[
i]][0];
2447 s->mv[!dir][
i+2][1] =
s->mv[!dir][
i][1] =
s->current_picture.motion_val[!dir][
s->block_index[
i+2]][1] =
s->current_picture.motion_val[!dir][
s->block_index[
i]][1];
2454 s->current_picture.qscale_table[mb_pos] = mquant;
2455 if (!v->
ttmbf && cbp)
2457 for (
i = 0;
i < 6;
i++) {
2458 s->dc_val[0][
s->block_index[
i]] = 0;
2460 val = ((cbp >> (5 -
i)) & 1);
2462 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
2464 off = (
i & 4) ? 0 : ((
i & 1) * 8 + ((
i > 1) *
s->linesize));
2467 first_block,
s->dest[dst_idx] + off,
2468 (
i & 4) ?
s->uvlinesize : (
s->linesize << fieldtx),
2472 block_cbp |= pat << (
i << 2);
2473 if (!v->
ttmbf && ttmb < 8)
2481 for (
i = 0;
i < 6;
i++) {
2483 s->dc_val[0][
s->block_index[
i]] = 0;
2486 s->current_picture.qscale_table[mb_pos] = 0;
2503 for (
i = 0;
i < 2;
i++) {
2504 s->mv[dir][
i+2][0] =
s->mv[dir][
i][0] =
s->current_picture.motion_val[dir][
s->block_index[
i+2]][0] =
s->current_picture.motion_val[dir][
s->block_index[
i]][0];
2505 s->mv[dir][
i+2][1] =
s->mv[dir][
i][1] =
s->current_picture.motion_val[dir][
s->block_index[
i+2]][1] =
s->current_picture.motion_val[dir][
s->block_index[
i]][1];
2506 s->mv[dir2][
i+2][0] =
s->mv[dir2][
i][0] =
s->current_picture.motion_val[dir2][
s->block_index[
i]][0] =
s->current_picture.motion_val[dir2][
s->block_index[
i+2]][0];
2507 s->mv[dir2][
i+2][1] =
s->mv[dir2][
i][1] =
s->current_picture.motion_val[dir2][
s->block_index[
i]][1] =
s->current_picture.motion_val[dir2][
s->block_index[
i+2]][1];
2515 for (
i = 0;
i < 2;
i++) {
2516 s->mv[!dir][
i+2][0] =
s->mv[!dir][
i][0] =
s->current_picture.motion_val[!dir][
s->block_index[
i+2]][0] =
s->current_picture.motion_val[!dir][
s->block_index[
i]][0];
2517 s->mv[!dir][
i+2][1] =
s->mv[!dir][
i][1] =
s->current_picture.motion_val[!dir][
s->block_index[
i+2]][1] =
s->current_picture.motion_val[!dir][
s->block_index[
i]][1];
2530 v->
cbp[
s->mb_x] = block_cbp;
2531 v->
ttblk[
s->mb_x] = block_tt;
2572 s->y_dc_scale =
s->y_dc_scale_table[v->
pq];
2573 s->c_dc_scale =
s->c_dc_scale_table[v->
pq];
2576 s->mb_x =
s->mb_y = 0;
2578 s->first_slice_line = 1;
2579 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2585 mb_pos =
s->mb_x +
s->mb_y *
s->mb_width;
2587 s->current_picture.qscale_table[mb_pos] = v->
pq;
2588 for (
int i = 0;
i < 4;
i++) {
2589 s->current_picture.motion_val[1][
s->block_index[
i]][0] = 0;
2590 s->current_picture.motion_val[1][
s->block_index[
i]][1] = 0;
2598 for (k = 0; k < 6; k++) {
2599 v->
mb_type[0][
s->block_index[k]] = 1;
2601 val = ((cbp >> (5 - k)) & 1);
2608 cbp |=
val << (5 - k);
2620 for (k = 0; k < 6; k++)
2621 for (j = 0; j < 64; j++)
2626 for (k = 0; k < 6; k++)
2627 for (j = 0; j < 64; j++)
2648 s->first_slice_line = 0;
2698 s->mb_x =
s->mb_y = 0;
2700 s->first_slice_line = 1;
2701 s->mb_y =
s->start_mb_y;
2702 if (
s->start_mb_y) {
2705 memset(&
s->coded_block[
s->block_index[0] -
s->b8_stride], 0,
2706 (1 +
s->b8_stride) *
sizeof(*
s->coded_block));
2708 for (;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2711 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2715 mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2717 for (
int i = 0;
i < 4;
i++) {
2718 s->current_picture.motion_val[1][
s->block_index[
i] + v->
blocks_off][0] = 0;
2719 s->current_picture.motion_val[1][
s->block_index[
i] + v->
blocks_off][1] = 0;
2742 s->current_picture.qscale_table[mb_pos] = mquant;
2744 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2745 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2747 for (k = 0; k < 6; k++) {
2748 v->
mb_type[0][
s->block_index[k]] = 1;
2750 val = ((cbp >> (5 - k)) & 1);
2757 cbp |=
val << (5 - k);
2759 v->
a_avail = !
s->first_slice_line || (k == 2 || k == 3);
2760 v->
c_avail = !!
s->mb_x || (k == 1 || k == 3);
2788 s->first_slice_line = 0;
2827 s->first_slice_line = 1;
2829 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2832 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2867 v->
cbp -
s->mb_stride,
2868 sizeof(v->
cbp_base[0]) * 2 *
s->mb_stride);
2878 s->first_slice_line = 0;
2913 s->first_slice_line = 1;
2914 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2917 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2948 v->
cbp -
s->mb_stride,
2949 sizeof(v->
cbp_base[0]) * 2 *
s->mb_stride);
2956 s->first_slice_line = 0;
2970 s->first_slice_line = 1;
2971 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2975 memcpy(
s->dest[0],
s->last_picture.f->data[0] +
s->mb_y * 16 *
s->linesize,
s->linesize * 16);
2976 memcpy(
s->dest[1],
s->last_picture.f->data[1] +
s->mb_y * 8 *
s->uvlinesize,
s->uvlinesize * 8);
2977 memcpy(
s->dest[2],
s->last_picture.f->data[2] +
s->mb_y * 8 *
s->uvlinesize,
s->uvlinesize * 8);
2978 s->first_slice_line = 0;