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->cur_pic.ptr->f->linesize[0];
63 s->dest[1] +=
s->cur_pic.ptr->f->linesize[1];
64 s->dest[2] +=
s->cur_pic.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], \
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->cur_pic.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->cur_pic.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->cur_pic.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->cur_pic.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;
598 const int m = (v->
pq == 1 || v->
pq == 2) ? 3 - v->
pq : 0;
599 if (dcdiff == 119 ) {
603 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
620 ac_val =
s->ac_val[0][
s->block_index[n]];
625 ac_val -= 16 *
s->block_wrap[n];
634 const uint8_t *zz_table;
664 for (k = 1; k < 8; k++)
665 block[k << sh] += ac_val[k];
668 for (k = 1; k < 8; k++) {
674 for (k = 1; k < 64; k++)
684 memset(ac_val2, 0, 16 * 2);
696 memcpy(ac_val2, ac_val, 8 * 2);
697 for (k = 1; k < 8; k++) {
704 if (
s->ac_pred)
i = 63;
705 s->block_last_index[n] =
i;
719 int coded,
int codingset,
int mquant)
725 int16_t *dc_val =
NULL;
726 int16_t *ac_val, *ac_val2;
729 int use_pred =
s->ac_pred;
732 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
740 if (dcdiff == 119 ) {
744 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
762 if (!a_avail && !c_avail)
767 ac_val =
s->ac_val[0][
s->block_index[n]];
772 ac_val -= 16 *
s->block_wrap[n];
774 q1 =
s->cur_pic.qscale_table[mb_pos];
777 else if (dc_pred_dir) {
780 else if (c_avail && mb_pos)
781 q2 =
s->cur_pic.qscale_table[mb_pos - 1];
785 else if (a_avail && mb_pos >=
s->mb_stride)
786 q2 =
s->cur_pic.qscale_table[mb_pos -
s->mb_stride];
794 const uint8_t *zz_table;
837 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
838 if (q2 &&
q1 != q2) {
839 for (k = 1; k < 8; k++)
842 for (k = 1; k < 8; k++)
843 block[k << sh] += ac_val[k];
847 for (k = 1; k < 8; k++) {
853 for (k = 1; k < 64; k++)
863 memset(ac_val2, 0, 16 * 2);
875 memcpy(ac_val2, ac_val, 8 * 2);
880 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
881 if (q2 &&
q1 != q2) {
882 for (k = 1; k < 8; k++)
883 ac_val2[k] = (
int)(ac_val2[k] * q2 * (unsigned)
ff_vc1_dqscale[
q1 - 1] + 0x20000) >> 18;
885 for (k = 1; k < 8; k++) {
892 if (use_pred)
i = 63;
893 s->block_last_index[n] =
i;
907 int coded,
int mquant,
int codingset)
913 int16_t *dc_val =
NULL;
914 int16_t *ac_val, *ac_val2;
916 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
918 int use_pred =
s->ac_pred;
923 s->bdsp.clear_block(
block);
929 s->y_dc_scale =
s->y_dc_scale_table[
quant];
930 s->c_dc_scale =
s->c_dc_scale_table[
quant];
937 if (dcdiff == 119 ) {
941 dcdiff = (dcdiff << m) +
get_bits(gb, m) - ((1 << m) - 1);
954 block[0] = dcdiff *
s->y_dc_scale;
956 block[0] = dcdiff *
s->c_dc_scale;
963 if (!a_avail) dc_pred_dir = 1;
964 if (!c_avail) dc_pred_dir = 0;
965 if (!a_avail && !c_avail) use_pred = 0;
966 ac_val =
s->ac_val[0][
s->block_index[n]];
974 ac_val -= 16 *
s->block_wrap[n];
976 q1 =
s->cur_pic.qscale_table[mb_pos];
977 if (dc_pred_dir && c_avail && mb_pos)
978 q2 =
s->cur_pic.qscale_table[mb_pos - 1];
979 if (!dc_pred_dir && a_avail && mb_pos >=
s->mb_stride)
980 q2 =
s->cur_pic.qscale_table[mb_pos -
s->mb_stride];
981 if (dc_pred_dir && n == 1)
983 if (!dc_pred_dir && n == 2)
1019 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1020 if (q2 &&
q1 != q2) {
1022 for (k = 1; k < 8; k++)
1025 for (k = 1; k < 8; k++)
1030 for (k = 1; k < 8; k++)
1033 for (k = 1; k < 8; k++)
1039 for (k = 1; k < 8; k++) {
1045 for (k = 1; k < 64; k++)
1052 if (use_pred)
i = 63;
1056 memset(ac_val2, 0, 16 * 2);
1059 memcpy(ac_val2, ac_val, 8 * 2);
1064 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1065 if (q2 &&
q1 != q2) {
1066 for (k = 1; k < 8; k++)
1067 ac_val2[k] = (
int)(ac_val2[k] * (unsigned)q2 *
ff_vc1_dqscale[
q1 - 1] + 0x20000) >> 18;
1072 memcpy(ac_val2 + 8, ac_val + 8, 8 * 2);
1077 q2 =
FFABS(q2) * 2 + ((q2 < 0) ? 0 : v->
halfpq) - 1;
1078 if (q2 &&
q1 != q2) {
1079 for (k = 1; k < 8; k++)
1080 ac_val2[k + 8] = (
int)(ac_val2[k + 8] * (unsigned)q2 *
ff_vc1_dqscale[
q1 - 1] + 0x20000) >> 18;
1088 for (k = 1; k < 8; k++) {
1094 for (k = 1; k < 8; k++) {
1103 s->block_last_index[n] =
i;
1111 int mquant,
int ttmb,
int first_block,
1112 uint8_t *
dst,
int linesize,
int skip_block,
1120 int ttblk = ttmb & 7;
1124 s->bdsp.clear_block(
block);
1133 && ((v->
ttmbf || (ttmb != -1 && (ttmb & 8) && !first_block))
1179 s->idsp.add_pixels_clamped(
block,
dst, linesize);
1184 pat = ~subblkpat & 0xF;
1185 for (j = 0; j < 4; j++) {
1186 last = subblkpat & (1 << (3 - j));
1188 off = (j & 1) * 4 + (j & 2) * 16;
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));
1233 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1242 pat = ~(subblkpat * 5) & 0xF;
1243 for (j = 0; j < 2; j++) {
1244 last = subblkpat & (1 << (1 - j));
1262 if (!(subblkpat & (1 << (1 - j))) && !skip_block) {
1272 *ttmb_out |= ttblk << (n * 4);
1287 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1290 int ttmb = v->
ttfrm;
1292 int mb_has_coeffs = 1;
1296 int first_block = 1;
1298 int skipped, fourmv;
1299 int block_cbp = 0, pat, block_tt = 0, block_intra = 0;
1318 s->cur_pic.motion_val[1][
s->block_index[0]][0] = 0;
1319 s->cur_pic.motion_val[1][
s->block_index[0]][1] = 0;
1325 if (
s->mb_intra && !mb_has_coeffs) {
1329 }
else if (mb_has_coeffs) {
1338 s->cur_pic.qscale_table[mb_pos] = mquant;
1340 if (!v->
ttmbf && !
s->mb_intra && mb_has_coeffs)
1345 for (
i = 0;
i < 6;
i++) {
1346 s->dc_val[0][
s->block_index[
i]] = 0;
1348 val = ((cbp >> (5 -
i)) & 1);
1349 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1350 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1354 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1356 if (
i == 1 ||
i == 3 ||
s->mb_x)
1367 for (j = 0; j < 64; j++)
1369 block_cbp |= 0xF << (
i << 2);
1370 block_intra |= 1 <<
i;
1373 s->dest[dst_idx] + off, (
i & 4) ?
s->uvlinesize :
s->linesize,
1377 block_cbp |= pat << (
i << 2);
1378 if (!v->
ttmbf && ttmb < 8)
1385 for (
i = 0;
i < 6;
i++) {
1387 s->dc_val[0][
s->block_index[
i]] = 0;
1390 s->cur_pic.qscale_table[mb_pos] = 0;
1396 int intra_count = 0, coded_inter = 0;
1397 int is_intra[6], is_coded[6];
1400 for (
i = 0;
i < 6;
i++) {
1401 val = ((cbp >> (5 -
i)) & 1);
1402 s->dc_val[0][
s->block_index[
i]] = 0;
1414 intra_count +=
s->mb_intra;
1415 is_intra[
i] =
s->mb_intra;
1416 is_coded[
i] = mb_has_coeffs;
1419 is_intra[
i] = (intra_count >= 3);
1424 v->
mb_type[0][
s->block_index[
i]] = is_intra[
i];
1426 coded_inter = !is_intra[
i] & is_coded[
i];
1430 if (!intra_count && !coded_inter)
1433 s->cur_pic.qscale_table[mb_pos] = mquant;
1437 for (
i = 0;
i < 6;
i++)
1439 if (((!
s->first_slice_line || (
i == 2 ||
i == 3)) && v->
mb_type[0][
s->block_index[
i] -
s->block_wrap[
i]])
1440 || ((
s->mb_x || (
i == 1 ||
i == 3)) && v->
mb_type[0][
s->block_index[
i] - 1])) {
1450 if (!v->
ttmbf && coded_inter)
1452 for (
i = 0;
i < 6;
i++) {
1454 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1455 s->mb_intra = is_intra[
i];
1459 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1461 if (
i == 1 ||
i == 3 ||
s->mb_x)
1472 for (j = 0; j < 64; j++)
1474 block_cbp |= 0xF << (
i << 2);
1475 block_intra |= 1 <<
i;
1476 }
else if (is_coded[
i]) {
1478 first_block,
s->dest[dst_idx] + off,
1479 (
i & 4) ?
s->uvlinesize :
s->linesize,
1484 block_cbp |= pat << (
i << 2);
1485 if (!v->
ttmbf && ttmb < 8)
1492 s->cur_pic.qscale_table[mb_pos] = 0;
1493 for (
i = 0;
i < 6;
i++) {
1495 s->dc_val[0][
s->block_index[
i]] = 0;
1497 for (
i = 0;
i < 4;
i++) {
1502 s->cur_pic.qscale_table[mb_pos] = 0;
1510 v->
cbp[
s->mb_x] = block_cbp;
1511 v->
ttblk[
s->mb_x] = block_tt;
1524 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1527 int ttmb = v->
ttfrm;
1529 int mb_has_coeffs = 1;
1532 int first_block = 1;
1534 int skipped, fourmv = 0, twomv = 0;
1535 int block_cbp = 0, pat, block_tt = 0;
1536 int idx_mbmode = 0, mvbp;
1582 for (
i = 0;
i < 4;
i++) {
1583 s->cur_pic.motion_val[1][
s->block_index[
i]][0] = 0;
1584 s->cur_pic.motion_val[1][
s->block_index[
i]][1] = 0;
1595 s->cur_pic.qscale_table[mb_pos] = mquant;
1597 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
1598 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
1600 for (
i = 0;
i < 6;
i++) {
1603 s->dc_val[0][
s->block_index[
i]] = 0;
1605 val = ((cbp >> (5 -
i)) & 1);
1606 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1608 if (
i == 1 ||
i == 3 ||
s->mb_x)
1618 block_cbp |= 0xf << (
i << 2);
1634 for (
i = 0;
i < 6;
i++)
1641 for (
i = 0;
i < 4;
i++) {
1643 if (mvbp & (8 >>
i))
1677 s->cur_pic.qscale_table[mb_pos] = mquant;
1678 if (!v->
ttmbf && cbp)
1680 for (
i = 0;
i < 6;
i++) {
1681 s->dc_val[0][
s->block_index[
i]] = 0;
1683 val = ((cbp >> (5 -
i)) & 1);
1685 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1687 off = (
i & 4) ? 0 : ((
i & 1) * 8 + ((
i > 1) *
s->linesize));
1690 first_block,
s->dest[dst_idx] + off,
1691 (
i & 4) ?
s->uvlinesize : (
s->linesize << fieldtx),
1695 block_cbp |= pat << (
i << 2);
1696 if (!v->
ttmbf && ttmb < 8)
1704 for (
i = 0;
i < 6;
i++) {
1706 s->dc_val[0][
s->block_index[
i]] = 0;
1709 s->cur_pic.qscale_table[mb_pos] = 0;
1722 v->
cbp[
s->mb_x] = block_cbp;
1723 v->
ttblk[
s->mb_x] = block_tt;
1733 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1736 int ttmb = v->
ttfrm;
1738 int mb_has_coeffs = 1;
1741 int first_block = 1;
1744 int block_cbp = 0, pat, block_tt = 0;
1751 if (idx_mbmode <= 1) {
1754 s->cur_pic.motion_val[1][
s->block_index[0] + v->
blocks_off][0] = 0;
1755 s->cur_pic.motion_val[1][
s->block_index[0] + v->
blocks_off][1] = 0;
1758 s->cur_pic.qscale_table[mb_pos] = mquant;
1760 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
1761 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
1763 mb_has_coeffs = idx_mbmode & 1;
1767 for (
i = 0;
i < 6;
i++) {
1770 s->dc_val[0][
s->block_index[
i]] = 0;
1772 val = ((cbp >> (5 -
i)) & 1);
1773 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1775 if (
i == 1 ||
i == 3 ||
s->mb_x)
1785 block_cbp |= 0xf << (
i << 2);
1790 for (
i = 0;
i < 6;
i++)
1792 if (idx_mbmode <= 5) {
1793 dmv_x = dmv_y = pred_flag = 0;
1794 if (idx_mbmode & 1) {
1799 mb_has_coeffs = !(idx_mbmode & 2);
1802 for (
i = 0;
i < 4;
i++) {
1803 dmv_x = dmv_y = pred_flag = 0;
1810 mb_has_coeffs = idx_mbmode & 1;
1817 s->cur_pic.qscale_table[mb_pos] = mquant;
1818 if (!v->
ttmbf && cbp) {
1822 for (
i = 0;
i < 6;
i++) {
1823 s->dc_val[0][
s->block_index[
i]] = 0;
1825 val = ((cbp >> (5 -
i)) & 1);
1826 off = (
i & 4) ? 0 : (
i & 1) * 8 + (
i & 2) * 4 *
s->linesize;
1829 first_block,
s->dest[dst_idx] + off,
1830 (
i & 4) ?
s->uvlinesize :
s->linesize,
1835 block_cbp |= pat << (
i << 2);
1836 if (!v->
ttmbf && ttmb < 8)
1846 v->
cbp[
s->mb_x] = block_cbp;
1847 v->
ttblk[
s->mb_x] = block_tt;
1859 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1862 int ttmb = v->
ttfrm;
1863 int mb_has_coeffs = 0;
1866 int first_block = 1;
1868 int skipped, direct;
1869 int dmv_x[2], dmv_y[2];
1885 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1886 for (
i = 0;
i < 6;
i++) {
1888 s->dc_val[0][
s->block_index[
i]] = 0;
1890 s->cur_pic.qscale_table[mb_pos] = 0;
1895 dmv_x[1] = dmv_x[0];
1896 dmv_y[1] = dmv_y[0];
1898 if (skipped || !
s->mb_intra) {
1909 dmv_x[0] = dmv_y[0] = 0;
1913 for (
i = 0;
i < 6;
i++)
1914 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1920 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1927 s->cur_pic.qscale_table[mb_pos] = mquant;
1930 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1932 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1934 if (!mb_has_coeffs && !
s->mb_intra) {
1937 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1940 if (
s->mb_intra && !mb_has_coeffs) {
1942 s->cur_pic.qscale_table[mb_pos] = mquant;
1949 if (!mb_has_coeffs) {
1952 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1958 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1964 s->cur_pic.qscale_table[mb_pos] = mquant;
1965 if (!v->
ttmbf && !
s->mb_intra && mb_has_coeffs)
1970 for (
i = 0;
i < 6;
i++) {
1971 s->dc_val[0][
s->block_index[
i]] = 0;
1973 val = ((cbp >> (5 -
i)) & 1);
1974 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1975 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1979 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1981 if (
i == 1 ||
i == 3 ||
s->mb_x)
1992 for (j = 0; j < 64; j++)
1993 s->block[
i][j] *= 2;
1994 s->idsp.put_signed_pixels_clamped(
s->block[
i],
1995 s->dest[dst_idx] + off,
1996 i & 4 ?
s->uvlinesize
2000 first_block,
s->dest[dst_idx] + off,
2001 (
i & 4) ?
s->uvlinesize :
s->linesize,
2005 if (!v->
ttmbf && ttmb < 8)
2020 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2023 int ttmb = v->
ttfrm;
2024 int mb_has_coeffs = 0;
2026 int first_block = 1;
2029 int dmv_x[2], dmv_y[2], pred_flag[2];
2031 int block_cbp = 0, pat, block_tt = 0;
2039 if (idx_mbmode <= 1) {
2042 s->cur_pic.motion_val[1][
s->block_index[0]][0] = 0;
2043 s->cur_pic.motion_val[1][
s->block_index[0]][1] = 0;
2046 s->cur_pic.qscale_table[mb_pos] = mquant;
2048 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2049 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2051 mb_has_coeffs = idx_mbmode & 1;
2055 for (
i = 0;
i < 6;
i++) {
2058 s->dc_val[0][
s->block_index[
i]] = 0;
2060 val = ((cbp >> (5 -
i)) & 1);
2061 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
2063 if (
i == 1 ||
i == 3 ||
s->mb_x)
2074 for (j = 0; j < 64; j++)
2075 s->block[
i][j] <<= 1;
2076 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
2077 s->idsp.put_signed_pixels_clamped(
s->block[
i],
2078 s->dest[dst_idx] + off,
2079 (
i & 4) ?
s->uvlinesize
2085 for (
i = 0;
i < 6;
i++)
2091 if (idx_mbmode <= 5) {
2093 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2094 pred_flag[0] = pred_flag[1] = 0;
2119 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2120 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2121 if (!
s->next_pic.ptr->field_picture) {
2128 mb_has_coeffs = !(idx_mbmode & 2);
2134 for (
i = 0;
i < 4;
i++) {
2135 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2136 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2146 mb_has_coeffs = idx_mbmode & 1;
2153 s->cur_pic.qscale_table[mb_pos] = mquant;
2154 if (!v->
ttmbf && cbp) {
2158 for (
i = 0;
i < 6;
i++) {
2159 s->dc_val[0][
s->block_index[
i]] = 0;
2161 val = ((cbp >> (5 -
i)) & 1);
2162 off = (
i & 4) ? 0 : (
i & 1) * 8 + (
i & 2) * 4 *
s->linesize;
2165 first_block,
s->dest[dst_idx] + off,
2166 (
i & 4) ?
s->uvlinesize :
s->linesize,
2170 block_cbp |= pat << (
i << 2);
2171 if (!v->
ttmbf && ttmb < 8)
2177 v->
cbp[
s->mb_x] = block_cbp;
2178 v->
ttblk[
s->mb_x] = block_tt;
2190 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2193 int ttmb = v->
ttfrm;
2195 int mb_has_coeffs = 1;
2198 int first_block = 1;
2200 int skipped, direct, twomv = 0;
2201 int block_cbp = 0, pat, block_tt = 0;
2202 int idx_mbmode = 0, mvbp;
2203 int stride_y, fieldtx;
2232 for (
i = 0;
i < 4;
i++) {
2233 s->mv[0][
i][0] =
s->cur_pic.motion_val[0][
s->block_index[
i]][0] = 0;
2234 s->mv[0][
i][1] =
s->cur_pic.motion_val[0][
s->block_index[
i]][1] = 0;
2235 s->mv[1][
i][0] =
s->cur_pic.motion_val[1][
s->block_index[
i]][0] = 0;
2236 s->mv[1][
i][1] =
s->cur_pic.motion_val[1][
s->block_index[
i]][1] = 0;
2247 s->cur_pic.qscale_table[mb_pos] = mquant;
2249 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2250 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2252 for (
i = 0;
i < 6;
i++) {
2255 s->dc_val[0][
s->block_index[
i]] = 0;
2257 val = ((cbp >> (5 -
i)) & 1);
2258 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
2260 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_pic.ptr->field_picture)
2292 s->mv[0][0][0] =
s->cur_pic.motion_val[0][
s->block_index[0]][0] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[0]][0], v->
bfraction, 0,
s->quarter_sample);
2293 s->mv[0][0][1] =
s->cur_pic.motion_val[0][
s->block_index[0]][1] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[0]][1], v->
bfraction, 0,
s->quarter_sample);
2294 s->mv[1][0][0] =
s->cur_pic.motion_val[1][
s->block_index[0]][0] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[0]][0], v->
bfraction, 1,
s->quarter_sample);
2295 s->mv[1][0][1] =
s->cur_pic.motion_val[1][
s->block_index[0]][1] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[0]][1], v->
bfraction, 1,
s->quarter_sample);
2298 s->mv[0][2][0] =
s->cur_pic.motion_val[0][
s->block_index[2]][0] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[2]][0], v->
bfraction, 0,
s->quarter_sample);
2299 s->mv[0][2][1] =
s->cur_pic.motion_val[0][
s->block_index[2]][1] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[2]][1], v->
bfraction, 0,
s->quarter_sample);
2300 s->mv[1][2][0] =
s->cur_pic.motion_val[1][
s->block_index[2]][0] =
scale_mv(
s->next_pic.motion_val[1][
s->block_index[2]][0], v->
bfraction, 1,
s->quarter_sample);
2301 s->mv[1][2][1] =
s->cur_pic.motion_val[1][
s->block_index[2]][1] =
scale_mv(
s->next_pic.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->cur_pic.motion_val[0][
s->block_index[
i]][0] =
s->mv[0][
i-1][0];
2305 s->mv[0][
i][1] =
s->cur_pic.motion_val[0][
s->block_index[
i]][1] =
s->mv[0][
i-1][1];
2306 s->mv[1][
i][0] =
s->cur_pic.motion_val[1][
s->block_index[
i]][0] =
s->mv[1][
i-1][0];
2307 s->mv[1][
i][1] =
s->cur_pic.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->cur_pic.motion_val[0][
s->block_index[
i]][0] =
s->mv[0][0][0];
2312 s->mv[0][
i][1] =
s->cur_pic.motion_val[0][
s->block_index[
i]][1] =
s->mv[0][0][1];
2313 s->mv[1][
i][0] =
s->cur_pic.motion_val[1][
s->block_index[
i]][0] =
s->mv[1][0][0];
2314 s->mv[1][
i][1] =
s->cur_pic.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->cur_pic.motion_val[dir][
s->block_index[
i+2]][0] =
s->cur_pic.motion_val[dir][
s->block_index[
i]][0];
2417 s->mv[dir][
i+2][1] =
s->mv[dir][
i][1] =
s->cur_pic.motion_val[dir][
s->block_index[
i+2]][1] =
s->cur_pic.motion_val[dir][
s->block_index[
i]][1];
2418 s->mv[dir2][
i+2][0] =
s->mv[dir2][
i][0] =
s->cur_pic.motion_val[dir2][
s->block_index[
i]][0] =
s->cur_pic.motion_val[dir2][
s->block_index[
i+2]][0];
2419 s->mv[dir2][
i+2][1] =
s->mv[dir2][
i][1] =
s->cur_pic.motion_val[dir2][
s->block_index[
i]][1] =
s->cur_pic.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->cur_pic.motion_val[!dir][
s->block_index[
i+2]][0] =
s->cur_pic.motion_val[!dir][
s->block_index[
i]][0];
2447 s->mv[!dir][
i+2][1] =
s->mv[!dir][
i][1] =
s->cur_pic.motion_val[!dir][
s->block_index[
i+2]][1] =
s->cur_pic.motion_val[!dir][
s->block_index[
i]][1];
2454 s->cur_pic.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->cur_pic.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->cur_pic.motion_val[dir][
s->block_index[
i+2]][0] =
s->cur_pic.motion_val[dir][
s->block_index[
i]][0];
2505 s->mv[dir][
i+2][1] =
s->mv[dir][
i][1] =
s->cur_pic.motion_val[dir][
s->block_index[
i+2]][1] =
s->cur_pic.motion_val[dir][
s->block_index[
i]][1];
2506 s->mv[dir2][
i+2][0] =
s->mv[dir2][
i][0] =
s->cur_pic.motion_val[dir2][
s->block_index[
i]][0] =
s->cur_pic.motion_val[dir2][
s->block_index[
i+2]][0];
2507 s->mv[dir2][
i+2][1] =
s->mv[dir2][
i][1] =
s->cur_pic.motion_val[dir2][
s->block_index[
i]][1] =
s->cur_pic.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->cur_pic.motion_val[!dir][
s->block_index[
i+2]][0] =
s->cur_pic.motion_val[!dir][
s->block_index[
i]][0];
2517 s->mv[!dir][
i+2][1] =
s->mv[!dir][
i][1] =
s->cur_pic.motion_val[!dir][
s->block_index[
i+2]][1] =
s->cur_pic.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->cur_pic.qscale_table[mb_pos] = v->
pq;
2588 for (
int i = 0;
i < 4;
i++) {
2589 s->cur_pic.motion_val[1][
s->block_index[
i]][0] = 0;
2590 s->cur_pic.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;
2699 s->first_slice_line = 1;
2701 s->mb_y =
s->start_mb_y;
2702 if (
s->start_mb_y) {
2703 memset(&
s->coded_block[(2 *
s->mb_y - 1) *
s->b8_stride - 2], 0,
2704 (1 +
s->b8_stride) *
sizeof(*
s->coded_block));
2706 for (;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2709 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2713 mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2715 for (
int i = 0;
i < 4;
i++) {
2716 s->cur_pic.motion_val[1][
s->block_index[
i] + v->
blocks_off][0] = 0;
2717 s->cur_pic.motion_val[1][
s->block_index[
i] + v->
blocks_off][1] = 0;
2740 s->cur_pic.qscale_table[mb_pos] = mquant;
2742 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2743 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2745 for (k = 0; k < 6; k++) {
2746 v->
mb_type[0][
s->block_index[k]] = 1;
2748 val = ((cbp >> (5 - k)) & 1);
2755 cbp |=
val << (5 - k);
2757 v->
a_avail = !
s->first_slice_line || (k == 2 || k == 3);
2758 v->
c_avail = !!
s->mb_x || (k == 1 || k == 3);
2786 s->first_slice_line = 0;
2826 s->first_slice_line = 1;
2828 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2831 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2866 v->
cbp -
s->mb_stride,
2867 sizeof(v->
cbp_base[0]) * 2 *
s->mb_stride);
2877 s->first_slice_line = 0;
2912 s->first_slice_line = 1;
2913 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2916 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2947 v->
cbp -
s->mb_stride,
2948 sizeof(v->
cbp_base[0]) * 2 *
s->mb_stride);
2955 s->first_slice_line = 0;
2969 s->first_slice_line = 1;
2970 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2974 memcpy(
s->dest[0],
s->last_pic.data[0] +
s->mb_y * 16 *
s->linesize,
s->linesize * 16);
2975 memcpy(
s->dest[1],
s->last_pic.data[1] +
s->mb_y * 8 *
s->uvlinesize,
s->uvlinesize * 8);
2976 memcpy(
s->dest[2],
s->last_pic.data[2] +
s->mb_y * 8 *
s->uvlinesize,
s->uvlinesize * 8);
2977 s->first_slice_line = 0;