68 32768, 16705, 16705, 17734, 17032, 17734, 18205, 18081,
69 18081, 18205, 18725, 18562, 19195, 18562, 18725, 19266,
70 19091, 19705, 19705, 19091, 19266, 21407, 19643, 20267,
71 20228, 20267, 19643, 21407, 22725, 21826, 20853, 20806,
72 20806, 20853, 21826, 22725, 23170, 23170, 21407, 21400,
73 21407, 23170, 23170, 24598, 23786, 22018, 22018, 23786,
74 24598, 25251, 24465, 22654, 24465, 25251, 25972, 25172,
75 25172, 25972, 26722, 27969, 26722, 29692, 29692, 31521,
78 32768, 16384, 16705, 16705, 17734, 17734, 17734, 17734,
79 18081, 18081, 18725, 18725, 21407, 21407, 19091, 19091,
80 19195, 19195, 18205, 18205, 18725, 18725, 19705, 19705,
81 20267, 20267, 21826, 21826, 23170, 23170, 20806, 20806,
82 20267, 20267, 19266, 19266, 21407, 21407, 20853, 20853,
83 21400, 21400, 23786, 23786, 24465, 24465, 22018, 22018,
84 23170, 23170, 22725, 22725, 24598, 24598, 24465, 24465,
85 25172, 25172, 27969, 27969, 25972, 25972, 29692, 29692
92 128, 16, 16, 17, 17, 17, 18, 18,
93 18, 18, 18, 18, 19, 18, 18, 19,
94 19, 19, 19, 19, 19, 42, 38, 40,
95 40, 40, 38, 42, 44, 43, 41, 41,
96 41, 41, 43, 44, 45, 45, 42, 42,
97 42, 45, 45, 48, 46, 43, 43, 46,
98 48, 49, 48, 44, 48, 49, 101, 98,
99 98, 101, 104, 109, 104, 116, 116, 123,
102 128, 16, 16, 17, 17, 17, 25, 25,
103 25, 25, 26, 25, 26, 25, 26, 26,
104 26, 27, 27, 26, 26, 42, 38, 40,
105 40, 40, 38, 42, 44, 43, 41, 41,
106 41, 41, 43, 44, 91, 91, 84, 84,
107 84, 91, 91, 96, 93, 86, 86, 93,
108 96, 197, 191, 177, 191, 197, 203, 197,
109 197, 203, 209, 219, 209, 232, 232, 246,
112 128, 16, 16, 17, 17, 17, 18, 18,
113 18, 18, 18, 18, 19, 18, 18, 19,
114 19, 19, 19, 19, 19, 42, 38, 40,
115 40, 40, 38, 42, 44, 43, 41, 41,
116 41, 41, 43, 44, 68, 68, 63, 63,
117 63, 68, 68, 96, 92, 86, 86, 92,
118 96, 98, 96, 88, 96, 98, 202, 196,
119 196, 202, 208, 218, 208, 232, 232, 246,
122 128, 24, 24, 26, 26, 26, 36, 36,
123 36, 36, 36, 36, 38, 36, 36, 38,
124 38, 38, 38, 38, 38, 84, 76, 80,
125 80, 80, 76, 84, 88, 86, 82, 82,
126 82, 82, 86, 88, 182, 182, 168, 168,
127 168, 182, 182, 192, 186, 192, 172, 186,
128 192, 394, 382, 354, 382, 394, 406, 394,
129 394, 406, 418, 438, 418, 464, 464, 492,
132 #define TEX_VLC_BITS 10
155 new_dv_vlc_bits[j] <<= 1;
181 run = new_dv_vlc_run[
code] + 1;
193 uint32_t *factor1 = &
ctx->idct_factor[0],
198 static const uint8_t dv100_qstep[16] = {
201 2, 3, 4, 5, 6, 7, 8, 16, 18, 20, 22, 24, 28, 52
203 const uint16_t *iweight1, *iweight2;
205 if (
d->height == 720) {
212 for (
c = 0;
c < 4;
c++) {
213 for (
s = 0;
s < 16;
s++) {
214 for (
i = 0;
i < 64;
i++) {
215 *factor1++ = (dv100_qstep[
s] << (
c + 9)) * iweight1[
i];
216 *factor2++ = (dv100_qstep[
s] << (
c + 9)) * iweight2[
i];
221 static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 };
224 for (
s = 0;
s < 22;
s++) {
225 for (
i =
c = 0;
c < 4;
c++) {
226 for (;
i < dv_quant_areas[
c];
i++) {
228 *factor2++ = (*factor1++) << 1;
244 for (
i = 0;
i < 64;
i++)
248 for (
i = 0;
i < 64;
i++){
250 s->dv_zigzag[1][
i] =
s->idsp.idct_permutation[(j & 7) + (j & 8) * 4 + (j & 48) / 2];
255 s->idct_put[0] =
s->idsp.idct_put;
267 const uint8_t *scan_table =
mb->scan_table;
268 const uint32_t *factor_table =
mb->factor_table;
270 int partial_bit_count =
mb->partial_bit_count;
277 if (partial_bit_count > 0) {
278 re_cache = re_cache >> partial_bit_count |
279 mb->partial_bit_buffer;
280 re_index -= partial_bit_count;
281 mb->partial_bit_count = 0;
300 if (re_index + vlc_len > last_index) {
302 mb->partial_bit_count = last_index - re_index;
303 mb->partial_bit_buffer = re_cache & ~(-1
u >>
mb->partial_bit_count);
304 re_index = last_index;
339 for (
i = 0;
i < 4;
i++) {
340 for (j = 0; j < 8; j++)
348 int stride, int16_t *blocks)
350 s->idsp.idct(blocks + 0*64);
351 s->idsp.idct(blocks + 1*64);
360 int stride, int16_t *blocks)
362 s->idsp.idct(blocks + 0*64);
363 s->idsp.idct(blocks + 1*64);
364 s->idsp.idct(blocks + 2*64);
365 s->idsp.idct(blocks + 3*64);
382 int quant,
dc, dct_mode, class1, j;
383 int mb_index, mb_x, mb_y, last_index;
384 int y_stride, linesize;
388 const uint8_t *buf_ptr;
395 const int log2_blocksize = 3-
s->avctx->lowres;
396 int is_field_mode[5];
397 int vs_bit_buffer_damaged = 0;
398 int mb_bit_buffer_damaged[5] = {0};
402 av_assert1((((uintptr_t) mb_bit_buffer) & 7) == 0);
403 av_assert1((((uintptr_t) vs_bit_buffer) & 7) == 0);
407 memset(sblock, 0, 5 *
DV_MAX_BPM *
sizeof(*sblock));
414 for (mb_index = 0; mb_index < 5; mb_index++, mb1 +=
s->sys->bpm,
block1 +=
s->sys->bpm * 64) {
416 quant = buf_ptr[3] & 0x0f;
418 if ((buf_ptr[3] >> 4) == 0x0E)
419 vs_bit_buffer_damaged = 1;
421 sta = buf_ptr[3] >> 4;
422 }
else if (sta != (buf_ptr[3] >> 4))
423 vs_bit_buffer_damaged = 1;
429 is_field_mode[mb_index] = 0;
430 for (j = 0; j <
s->sys->bpm; j++) {
431 last_index =
s->sys->block_sizes[j];
439 mb->idct_put =
s->idct_put[0];
440 mb->scan_table =
s->dv_zigzag[0];
441 mb->factor_table = &
s->idct_factor[(j >= 4) * 4 * 16 * 64 +
444 is_field_mode[mb_index] |= !j && dct_mode;
446 mb->idct_put =
s->idct_put[dct_mode && log2_blocksize == 3];
447 mb->scan_table =
s->dv_zigzag[dct_mode];
449 &
s->idct_factor[(class1 == 3) * 2 * 22 * 64 +
458 buf_ptr += last_index >> 3;
460 mb->partial_bit_count = 0;
462 ff_dlog(avctx,
"MB block: %d, %d ", mb_index, j);
469 if (
mb->pos >= 64 &&
mb->pos < 127)
470 vs_bit_buffer_damaged = mb_bit_buffer_damaged[mb_index] = 1;
476 if (mb_bit_buffer_damaged[mb_index] > 0)
486 for (j = 0; j <
s->sys->bpm; j++,
block += 64,
mb++) {
493 vs_bit_buffer_damaged = mb_bit_buffer_damaged[mb_index] = 1;
498 if (j >=
s->sys->bpm)
504 block = &sblock[0][0];
509 for (mb_index = 0; mb_index < 5; mb_index++) {
510 for (j = 0; j <
s->sys->bpm; j++) {
511 if (
mb->pos < 64 &&
get_bits_left(&gb) > 0 && !vs_bit_buffer_damaged) {
512 ff_dlog(avctx,
"start %d:%d\n", mb_index, j);
516 if (
mb->pos >= 64 &&
mb->pos < 127) {
518 "AC EOB marker is absent pos=%d\n",
mb->pos);
519 vs_bit_buffer_damaged = 1;
525 if (vs_bit_buffer_damaged && !retried) {
532 block = &sblock[0][0];
534 for (mb_index = 0; mb_index < 5; mb_index++) {
540 (
s->sys->height >= 720 && mb_y != 134)) {
541 y_stride = (
s->frame->linesize[0] <<
542 ((!is_field_mode[mb_index]) * log2_blocksize));
544 y_stride = (2 << log2_blocksize);
546 y_ptr =
s->frame->data[0] +
547 ((mb_y *
s->frame->linesize[0] + mb_x) << log2_blocksize);
548 if (mb_y == 134 && is_field_mode[mb_index]) {
551 linesize =
s->frame->linesize[0] << is_field_mode[mb_index];
552 mb[0].idct_put(y_ptr, linesize,
block + 0 * 64);
553 if (
s->sys->video_stype == 4) {
554 mb[2].idct_put(y_ptr + (1 << log2_blocksize), linesize,
block + 2 * 64);
556 mb[1].idct_put(y_ptr + (1 << log2_blocksize), linesize,
block + 1 * 64);
557 mb[2].idct_put(y_ptr + y_stride, linesize,
block + 2 * 64);
558 mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize,
block + 3 * 64);
567 for (j = 2; j; j--) {
568 uint8_t *c_ptr =
s->frame->data[j] + c_offset;
570 uint64_t aligned_pixels[64 / 8];
571 uint8_t *pixels = (uint8_t *) aligned_pixels;
572 uint8_t *c_ptr1, *ptr1;
574 mb->idct_put(pixels, 8,
block);
575 for (y = 0; y < (1 << log2_blocksize); y++, c_ptr +=
s->frame->linesize[j], pixels += 8) {
576 ptr1 = pixels + ((1 << (log2_blocksize))>>1);
577 c_ptr1 = c_ptr + (
s->frame->linesize[j] << log2_blocksize);
578 for (x = 0; x < (1 <<
FFMAX(log2_blocksize - 1, 0)); x++) {
579 c_ptr[x] = pixels[x];
586 y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
587 s->frame->linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
588 if (mb_y == 134 && is_field_mode[mb_index]) {
593 linesize =
s->frame->linesize[j] << is_field_mode[mb_index];
596 if (
s->sys->bpm == 8) {
612 uint8_t *buf = avpkt->
data;
613 int buf_size = avpkt->
size;
616 const uint8_t *vsc_pack;
617 int apt, is16_9,
ret;
637 frame.f->key_frame = 1;
647 vsc_pack = buf + 80 * 5 + 48 + 5;
650 is16_9 = (vsc_pack[2] & 0x07) == 0x02 ||
651 (!apt && (vsc_pack[2] & 0x07) == 0x07);
660 if (avctx->
height == 720) {
661 frame.f->interlaced_frame = 0;
662 frame.f->top_field_first = 0;
663 }
else if (avctx->
height == 1080) {
664 frame.f->interlaced_frame = 1;
665 frame.f->top_field_first = (vsc_pack[3] & 0x40) == 0x40;
667 frame.f->interlaced_frame = (vsc_pack[3] & 0x10) == 0x10;
668 frame.f->top_field_first = !(vsc_pack[3] & 0x40);
681 return s->sys->frame_size;