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], \
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;
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->current_picture.qscale_table[mb_pos];
777 else if (dc_pred_dir) {
780 else if (c_avail && mb_pos)
781 q2 =
s->current_picture.qscale_table[mb_pos - 1];
785 else if (a_avail && mb_pos >=
s->mb_stride)
786 q2 =
s->current_picture.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->current_picture.qscale_table[mb_pos];
977 if (dc_pred_dir && c_avail && mb_pos)
978 q2 =
s->current_picture.qscale_table[mb_pos - 1];
979 if (!dc_pred_dir && a_avail && mb_pos >=
s->mb_stride)
980 q2 =
s->current_picture.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;
1317 s->current_picture.motion_val[1][
s->block_index[0]][0] = 0;
1318 s->current_picture.motion_val[1][
s->block_index[0]][1] = 0;
1324 if (
s->mb_intra && !mb_has_coeffs) {
1328 }
else if (mb_has_coeffs) {
1337 s->current_picture.qscale_table[mb_pos] = mquant;
1339 if (!v->
ttmbf && !
s->mb_intra && mb_has_coeffs)
1344 for (
i = 0;
i < 6;
i++) {
1345 s->dc_val[0][
s->block_index[
i]] = 0;
1347 val = ((cbp >> (5 -
i)) & 1);
1348 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1349 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1353 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1355 if (
i == 1 ||
i == 3 ||
s->mb_x)
1364 for (j = 0; j < 64; j++)
1366 block_cbp |= 0xF << (
i << 2);
1367 block_intra |= 1 <<
i;
1370 s->dest[dst_idx] + off, (
i & 4) ?
s->uvlinesize :
s->linesize,
1374 block_cbp |= pat << (
i << 2);
1375 if (!v->
ttmbf && ttmb < 8)
1382 for (
i = 0;
i < 6;
i++) {
1384 s->dc_val[0][
s->block_index[
i]] = 0;
1387 s->current_picture.qscale_table[mb_pos] = 0;
1393 int intra_count = 0, coded_inter = 0;
1394 int is_intra[6], is_coded[6];
1397 for (
i = 0;
i < 6;
i++) {
1398 val = ((cbp >> (5 -
i)) & 1);
1399 s->dc_val[0][
s->block_index[
i]] = 0;
1411 intra_count +=
s->mb_intra;
1412 is_intra[
i] =
s->mb_intra;
1413 is_coded[
i] = mb_has_coeffs;
1416 is_intra[
i] = (intra_count >= 3);
1421 v->
mb_type[0][
s->block_index[
i]] = is_intra[
i];
1423 coded_inter = !is_intra[
i] & is_coded[
i];
1427 if (!intra_count && !coded_inter)
1430 s->current_picture.qscale_table[mb_pos] = mquant;
1434 for (
i = 0;
i < 6;
i++)
1436 if (((!
s->first_slice_line || (
i == 2 ||
i == 3)) && v->
mb_type[0][
s->block_index[
i] -
s->block_wrap[
i]])
1437 || ((
s->mb_x || (
i == 1 ||
i == 3)) && v->
mb_type[0][
s->block_index[
i] - 1])) {
1447 if (!v->
ttmbf && coded_inter)
1449 for (
i = 0;
i < 6;
i++) {
1451 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1452 s->mb_intra = is_intra[
i];
1456 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1458 if (
i == 1 ||
i == 3 ||
s->mb_x)
1467 for (j = 0; j < 64; j++)
1469 block_cbp |= 0xF << (
i << 2);
1470 block_intra |= 1 <<
i;
1471 }
else if (is_coded[
i]) {
1473 first_block,
s->dest[dst_idx] + off,
1474 (
i & 4) ?
s->uvlinesize :
s->linesize,
1479 block_cbp |= pat << (
i << 2);
1480 if (!v->
ttmbf && ttmb < 8)
1487 s->current_picture.qscale_table[mb_pos] = 0;
1488 for (
i = 0;
i < 6;
i++) {
1490 s->dc_val[0][
s->block_index[
i]] = 0;
1492 for (
i = 0;
i < 4;
i++) {
1497 s->current_picture.qscale_table[mb_pos] = 0;
1505 v->
cbp[
s->mb_x] = block_cbp;
1506 v->
ttblk[
s->mb_x] = block_tt;
1519 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1522 int ttmb = v->
ttfrm;
1524 int mb_has_coeffs = 1;
1527 int first_block = 1;
1529 int skipped, fourmv = 0, twomv = 0;
1530 int block_cbp = 0, pat, block_tt = 0;
1531 int idx_mbmode = 0, mvbp;
1576 for (
i = 0;
i < 4;
i++) {
1577 s->current_picture.motion_val[1][
s->block_index[
i]][0] = 0;
1578 s->current_picture.motion_val[1][
s->block_index[
i]][1] = 0;
1589 s->current_picture.qscale_table[mb_pos] = mquant;
1591 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
1592 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
1594 for (
i = 0;
i < 6;
i++) {
1597 s->dc_val[0][
s->block_index[
i]] = 0;
1599 val = ((cbp >> (5 -
i)) & 1);
1600 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1602 if (
i == 1 ||
i == 3 ||
s->mb_x)
1611 off = (fieldtx) ? ((
i & 1) * 8) + ((
i & 2) >> 1) *
s->linesize : (
i & 1) * 8 + 4 * (
i & 2) *
s->linesize;
1614 block_cbp |= 0
xf << (
i << 2);
1630 for (
i = 0;
i < 6;
i++)
1637 for (
i = 0;
i < 4;
i++) {
1639 if (mvbp & (8 >>
i))
1673 s->current_picture.qscale_table[mb_pos] = mquant;
1674 if (!v->
ttmbf && cbp)
1676 for (
i = 0;
i < 6;
i++) {
1677 s->dc_val[0][
s->block_index[
i]] = 0;
1679 val = ((cbp >> (5 -
i)) & 1);
1681 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1683 off = (
i & 4) ? 0 : ((
i & 1) * 8 + ((
i > 1) *
s->linesize));
1686 first_block,
s->dest[dst_idx] + off,
1687 (
i & 4) ?
s->uvlinesize : (
s->linesize << fieldtx),
1691 block_cbp |= pat << (
i << 2);
1692 if (!v->
ttmbf && ttmb < 8)
1700 for (
i = 0;
i < 6;
i++) {
1702 s->dc_val[0][
s->block_index[
i]] = 0;
1705 s->current_picture.qscale_table[mb_pos] = 0;
1718 v->
cbp[
s->mb_x] = block_cbp;
1719 v->
ttblk[
s->mb_x] = block_tt;
1729 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1732 int ttmb = v->
ttfrm;
1734 int mb_has_coeffs = 1;
1737 int first_block = 1;
1740 int block_cbp = 0, pat, block_tt = 0;
1746 if (idx_mbmode <= 1) {
1749 s->current_picture.motion_val[1][
s->block_index[0] + v->
blocks_off][0] = 0;
1750 s->current_picture.motion_val[1][
s->block_index[0] + v->
blocks_off][1] = 0;
1753 s->current_picture.qscale_table[mb_pos] = mquant;
1755 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
1756 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
1758 mb_has_coeffs = idx_mbmode & 1;
1762 for (
i = 0;
i < 6;
i++) {
1765 s->dc_val[0][
s->block_index[
i]] = 0;
1767 val = ((cbp >> (5 -
i)) & 1);
1768 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1770 if (
i == 1 ||
i == 3 ||
s->mb_x)
1778 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1779 block_cbp |= 0xf << (
i << 2);
1784 for (
i = 0;
i < 6;
i++)
1786 if (idx_mbmode <= 5) {
1787 dmv_x = dmv_y = pred_flag = 0;
1788 if (idx_mbmode & 1) {
1793 mb_has_coeffs = !(idx_mbmode & 2);
1796 for (
i = 0;
i < 4;
i++) {
1797 dmv_x = dmv_y = pred_flag = 0;
1804 mb_has_coeffs = idx_mbmode & 1;
1811 s->current_picture.qscale_table[mb_pos] = mquant;
1812 if (!v->
ttmbf && cbp) {
1816 for (
i = 0;
i < 6;
i++) {
1817 s->dc_val[0][
s->block_index[
i]] = 0;
1819 val = ((cbp >> (5 -
i)) & 1);
1820 off = (
i & 4) ? 0 : (
i & 1) * 8 + (
i & 2) * 4 *
s->linesize;
1823 first_block,
s->dest[dst_idx] + off,
1824 (
i & 4) ?
s->uvlinesize :
s->linesize,
1829 block_cbp |= pat << (
i << 2);
1830 if (!v->
ttmbf && ttmb < 8)
1840 v->
cbp[
s->mb_x] = block_cbp;
1841 v->
ttblk[
s->mb_x] = block_tt;
1853 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
1856 int ttmb = v->
ttfrm;
1857 int mb_has_coeffs = 0;
1860 int first_block = 1;
1862 int skipped, direct;
1863 int dmv_x[2], dmv_y[2];
1878 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
1879 for (
i = 0;
i < 6;
i++) {
1881 s->dc_val[0][
s->block_index[
i]] = 0;
1883 s->current_picture.qscale_table[mb_pos] = 0;
1888 dmv_x[1] = dmv_x[0];
1889 dmv_y[1] = dmv_y[0];
1891 if (skipped || !
s->mb_intra) {
1902 dmv_x[0] = dmv_y[0] = 0;
1906 for (
i = 0;
i < 6;
i++)
1907 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1913 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1920 s->current_picture.qscale_table[mb_pos] = mquant;
1923 dmv_x[0] = dmv_y[0] = dmv_x[1] = dmv_y[1] = 0;
1925 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1927 if (!mb_has_coeffs && !
s->mb_intra) {
1930 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1933 if (
s->mb_intra && !mb_has_coeffs) {
1935 s->current_picture.qscale_table[mb_pos] = mquant;
1942 if (!mb_has_coeffs) {
1945 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1951 vc1_b_mc(v, dmv_x, dmv_y, direct, bmvtype);
1957 s->current_picture.qscale_table[mb_pos] = mquant;
1958 if (!v->
ttmbf && !
s->mb_intra && mb_has_coeffs)
1963 for (
i = 0;
i < 6;
i++) {
1964 s->dc_val[0][
s->block_index[
i]] = 0;
1966 val = ((cbp >> (5 -
i)) & 1);
1967 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
1968 v->
mb_type[0][
s->block_index[
i]] =
s->mb_intra;
1972 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
1974 if (
i == 1 ||
i == 3 ||
s->mb_x)
1983 for (j = 0; j < 64; j++)
1984 s->block[
i][j] *= 2;
1985 s->idsp.put_signed_pixels_clamped(
s->block[
i],
1986 s->dest[dst_idx] + off,
1987 i & 4 ?
s->uvlinesize
1991 first_block,
s->dest[dst_idx] + off,
1992 (
i & 4) ?
s->uvlinesize :
s->linesize,
1996 if (!v->
ttmbf && ttmb < 8)
2011 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2014 int ttmb = v->
ttfrm;
2015 int mb_has_coeffs = 0;
2017 int first_block = 1;
2020 int dmv_x[2], dmv_y[2], pred_flag[2];
2022 int block_cbp = 0, pat, block_tt = 0;
2029 if (idx_mbmode <= 1) {
2032 s->current_picture.motion_val[1][
s->block_index[0]][0] = 0;
2033 s->current_picture.motion_val[1][
s->block_index[0]][1] = 0;
2036 s->current_picture.qscale_table[mb_pos] = mquant;
2038 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2039 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2041 mb_has_coeffs = idx_mbmode & 1;
2045 for (
i = 0;
i < 6;
i++) {
2048 s->dc_val[0][
s->block_index[
i]] = 0;
2050 val = ((cbp >> (5 -
i)) & 1);
2051 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
2053 if (
i == 1 ||
i == 3 ||
s->mb_x)
2062 for (j = 0; j < 64; j++)
2063 s->block[
i][j] <<= 1;
2064 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
2065 s->idsp.put_signed_pixels_clamped(
s->block[
i],
2066 s->dest[dst_idx] + off,
2067 (
i & 4) ?
s->uvlinesize
2073 for (
i = 0;
i < 6;
i++)
2079 if (idx_mbmode <= 5) {
2081 dmv_x[0] = dmv_x[1] = dmv_y[0] = dmv_y[1] = 0;
2082 pred_flag[0] = pred_flag[1] = 0;
2107 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2108 dmv_x[1] = dmv_y[1] = pred_flag[0] = 0;
2109 if (!
s->next_picture_ptr->field_picture) {
2116 mb_has_coeffs = !(idx_mbmode & 2);
2122 for (
i = 0;
i < 4;
i++) {
2123 dmv_x[0] = dmv_y[0] = pred_flag[0] = 0;
2124 dmv_x[1] = dmv_y[1] = pred_flag[1] = 0;
2134 mb_has_coeffs = idx_mbmode & 1;
2141 s->current_picture.qscale_table[mb_pos] = mquant;
2142 if (!v->
ttmbf && cbp) {
2146 for (
i = 0;
i < 6;
i++) {
2147 s->dc_val[0][
s->block_index[
i]] = 0;
2149 val = ((cbp >> (5 -
i)) & 1);
2150 off = (
i & 4) ? 0 : (
i & 1) * 8 + (
i & 2) * 4 *
s->linesize;
2153 first_block,
s->dest[dst_idx] + off,
2154 (
i & 4) ?
s->uvlinesize :
s->linesize,
2158 block_cbp |= pat << (
i << 2);
2159 if (!v->
ttmbf && ttmb < 8)
2165 v->
cbp[
s->mb_x] = block_cbp;
2166 v->
ttblk[
s->mb_x] = block_tt;
2178 int mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2181 int ttmb = v->
ttfrm;
2183 int mb_has_coeffs = 1;
2186 int first_block = 1;
2188 int skipped, direct, twomv = 0;
2189 int block_cbp = 0, pat, block_tt = 0;
2190 int idx_mbmode = 0, mvbp;
2191 int stride_y, fieldtx;
2219 for (
i = 0;
i < 4;
i++) {
2220 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0] = 0;
2221 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1] = 0;
2222 s->mv[1][
i][0] =
s->current_picture.motion_val[1][
s->block_index[
i]][0] = 0;
2223 s->mv[1][
i][1] =
s->current_picture.motion_val[1][
s->block_index[
i]][1] = 0;
2234 s->current_picture.qscale_table[mb_pos] = mquant;
2236 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2237 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2239 for (
i = 0;
i < 6;
i++) {
2242 s->dc_val[0][
s->block_index[
i]] = 0;
2244 val = ((cbp >> (5 -
i)) & 1);
2245 if (
i == 2 ||
i == 3 || !
s->first_slice_line)
2247 if (
i == 1 ||
i == 3 ||
s->mb_x)
2256 stride_y =
s->linesize << fieldtx;
2257 off = (fieldtx) ? ((
i & 1) * 8) + ((
i & 2) >> 1) *
s->linesize : (
i & 1) * 8 + 4 * (
i & 2) *
s->linesize;
2259 stride_y =
s->uvlinesize;
2262 s->idsp.put_signed_pixels_clamped(
s->block[
i],
2263 s->dest[dst_idx] + off,
2275 if (
s->next_picture_ptr->field_picture)
2277 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);
2278 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);
2279 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);
2280 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);
2283 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);
2284 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);
2285 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);
2286 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);
2288 for (
i = 1;
i < 4;
i += 2) {
2289 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0] =
s->mv[0][
i-1][0];
2290 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1] =
s->mv[0][
i-1][1];
2291 s->mv[1][
i][0] =
s->current_picture.motion_val[1][
s->block_index[
i]][0] =
s->mv[1][
i-1][0];
2292 s->mv[1][
i][1] =
s->current_picture.motion_val[1][
s->block_index[
i]][1] =
s->mv[1][
i-1][1];
2295 for (
i = 1;
i < 4;
i++) {
2296 s->mv[0][
i][0] =
s->current_picture.motion_val[0][
s->block_index[
i]][0] =
s->mv[0][0][0];
2297 s->mv[0][
i][1] =
s->current_picture.motion_val[0][
s->block_index[
i]][1] =
s->mv[0][0][1];
2298 s->mv[1][
i][0] =
s->current_picture.motion_val[1][
s->block_index[
i]][0] =
s->mv[1][0][0];
2299 s->mv[1][
i][1] =
s->current_picture.motion_val[1][
s->block_index[
i]][1] =
s->mv[1][0][1];
2305 if (skipped || !
s->mb_intra) {
2335 for (
i = 0;
i < 6;
i++)
2342 for (
i = 0;
i < 4;
i++) {
2354 for (
i = 0;
i < 4;
i++) {
2357 val = ((mvbp >> (3 -
i)) & 1);
2400 for (
i = 0;
i < 2;
i++) {
2401 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];
2402 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];
2403 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];
2404 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];
2430 for (
i = 0;
i < 2;
i++) {
2431 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];
2432 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];
2439 s->current_picture.qscale_table[mb_pos] = mquant;
2440 if (!v->
ttmbf && cbp)
2442 for (
i = 0;
i < 6;
i++) {
2443 s->dc_val[0][
s->block_index[
i]] = 0;
2445 val = ((cbp >> (5 -
i)) & 1);
2447 off = (
i & 4) ? 0 : ((
i & 1) * 8 + (
i & 2) * 4 *
s->linesize);
2449 off = (
i & 4) ? 0 : ((
i & 1) * 8 + ((
i > 1) *
s->linesize));
2452 first_block,
s->dest[dst_idx] + off,
2453 (
i & 4) ?
s->uvlinesize : (
s->linesize << fieldtx),
2457 block_cbp |= pat << (
i << 2);
2458 if (!v->
ttmbf && ttmb < 8)
2466 for (
i = 0;
i < 6;
i++) {
2468 s->dc_val[0][
s->block_index[
i]] = 0;
2471 s->current_picture.qscale_table[mb_pos] = 0;
2488 for (
i = 0;
i < 2;
i++) {
2489 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];
2490 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];
2491 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];
2492 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];
2500 for (
i = 0;
i < 2;
i++) {
2501 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];
2502 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];
2515 v->
cbp[
s->mb_x] = block_cbp;
2516 v->
ttblk[
s->mb_x] = block_tt;
2557 s->y_dc_scale =
s->y_dc_scale_table[v->
pq];
2558 s->c_dc_scale =
s->c_dc_scale_table[v->
pq];
2561 s->mb_x =
s->mb_y = 0;
2563 s->first_slice_line = 1;
2564 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2570 mb_pos =
s->mb_x +
s->mb_y *
s->mb_width;
2572 s->current_picture.qscale_table[mb_pos] = v->
pq;
2573 for (
int i = 0;
i < 4;
i++) {
2574 s->current_picture.motion_val[1][
s->block_index[
i]][0] = 0;
2575 s->current_picture.motion_val[1][
s->block_index[
i]][1] = 0;
2583 for (k = 0; k < 6; k++) {
2584 v->
mb_type[0][
s->block_index[k]] = 1;
2586 val = ((cbp >> (5 - k)) & 1);
2593 cbp |=
val << (5 - k);
2605 for (k = 0; k < 6; k++)
2606 for (j = 0; j < 64; j++)
2611 for (k = 0; k < 6; k++)
2612 for (j = 0; j < 64; j++)
2633 s->first_slice_line = 0;
2683 s->mb_x =
s->mb_y = 0;
2685 s->first_slice_line = 1;
2686 s->mb_y =
s->start_mb_y;
2687 if (
s->start_mb_y) {
2690 memset(&
s->coded_block[
s->block_index[0] -
s->b8_stride], 0,
2691 (1 +
s->b8_stride) *
sizeof(*
s->coded_block));
2693 for (;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2696 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2700 mb_pos =
s->mb_x +
s->mb_y *
s->mb_stride;
2702 for (
int i = 0;
i < 4;
i++) {
2703 s->current_picture.motion_val[1][
s->block_index[
i] + v->
blocks_off][0] = 0;
2704 s->current_picture.motion_val[1][
s->block_index[
i] + v->
blocks_off][1] = 0;
2727 s->current_picture.qscale_table[mb_pos] = mquant;
2729 s->y_dc_scale =
s->y_dc_scale_table[
FFABS(mquant)];
2730 s->c_dc_scale =
s->c_dc_scale_table[
FFABS(mquant)];
2732 for (k = 0; k < 6; k++) {
2733 v->
mb_type[0][
s->block_index[k]] = 1;
2735 val = ((cbp >> (5 - k)) & 1);
2742 cbp |=
val << (5 - k);
2744 v->
a_avail = !
s->first_slice_line || (k == 2 || k == 3);
2745 v->
c_avail = !!
s->mb_x || (k == 1 || k == 3);
2773 s->first_slice_line = 0;
2812 s->first_slice_line = 1;
2814 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2817 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2852 v->
cbp -
s->mb_stride,
2853 sizeof(v->
cbp_base[0]) * 2 *
s->mb_stride);
2863 s->first_slice_line = 0;
2898 s->first_slice_line = 1;
2899 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2902 for (;
s->mb_x <
s->mb_width;
s->mb_x++) {
2933 v->
cbp -
s->mb_stride,
2934 sizeof(v->
cbp_base[0]) * 2 *
s->mb_stride);
2941 s->first_slice_line = 0;
2955 s->first_slice_line = 1;
2956 for (
s->mb_y =
s->start_mb_y;
s->mb_y <
s->end_mb_y;
s->mb_y++) {
2960 memcpy(
s->dest[0],
s->last_picture.f->data[0] +
s->mb_y * 16 *
s->linesize,
s->linesize * 16);
2961 memcpy(
s->dest[1],
s->last_picture.f->data[1] +
s->mb_y * 8 *
s->uvlinesize,
s->uvlinesize * 8);
2962 memcpy(
s->dest[2],
s->last_picture.f->data[2] +
s->mb_y * 8 *
s->uvlinesize,
s->uvlinesize * 8);
2963 s->first_slice_line = 0;