69 32768, 16705, 16705, 17734, 17032, 17734, 18205, 18081,
70 18081, 18205, 18725, 18562, 19195, 18562, 18725, 19266,
71 19091, 19705, 19705, 19091, 19266, 21407, 19643, 20267,
72 20228, 20267, 19643, 21407, 22725, 21826, 20853, 20806,
73 20806, 20853, 21826, 22725, 23170, 23170, 21407, 21400,
74 21407, 23170, 23170, 24598, 23786, 22018, 22018, 23786,
75 24598, 25251, 24465, 22654, 24465, 25251, 25972, 25172,
76 25172, 25972, 26722, 27969, 26722, 29692, 29692, 31521,
79 32768, 16384, 16705, 16705, 17734, 17734, 17734, 17734,
80 18081, 18081, 18725, 18725, 21407, 21407, 19091, 19091,
81 19195, 19195, 18205, 18205, 18725, 18725, 19705, 19705,
82 20267, 20267, 21826, 21826, 23170, 23170, 20806, 20806,
83 20267, 20267, 19266, 19266, 21407, 21407, 20853, 20853,
84 21400, 21400, 23786, 23786, 24465, 24465, 22018, 22018,
85 23170, 23170, 22725, 22725, 24598, 24598, 24465, 24465,
86 25172, 25172, 27969, 27969, 25972, 25972, 29692, 29692
93 128, 16, 16, 17, 17, 17, 18, 18,
94 18, 18, 18, 18, 19, 18, 18, 19,
95 19, 19, 19, 19, 19, 42, 38, 40,
96 40, 40, 38, 42, 44, 43, 41, 41,
97 41, 41, 43, 44, 45, 45, 42, 42,
98 42, 45, 45, 48, 46, 43, 43, 46,
99 48, 49, 48, 44, 48, 49, 101, 98,
100 98, 101, 104, 109, 104, 116, 116, 123,
103 128, 16, 16, 17, 17, 17, 25, 25,
104 25, 25, 26, 25, 26, 25, 26, 26,
105 26, 27, 27, 26, 26, 42, 38, 40,
106 40, 40, 38, 42, 44, 43, 41, 41,
107 41, 41, 43, 44, 91, 91, 84, 84,
108 84, 91, 91, 96, 93, 86, 86, 93,
109 96, 197, 191, 177, 191, 197, 203, 197,
110 197, 203, 209, 219, 209, 232, 232, 246,
113 128, 16, 16, 17, 17, 17, 18, 18,
114 18, 18, 18, 18, 19, 18, 18, 19,
115 19, 19, 19, 19, 19, 42, 38, 40,
116 40, 40, 38, 42, 44, 43, 41, 41,
117 41, 41, 43, 44, 68, 68, 63, 63,
118 63, 68, 68, 96, 92, 86, 86, 92,
119 96, 98, 96, 88, 96, 98, 202, 196,
120 196, 202, 208, 218, 208, 232, 232, 246,
123 128, 24, 24, 26, 26, 26, 36, 36,
124 36, 36, 36, 36, 38, 36, 36, 38,
125 38, 38, 38, 38, 38, 84, 76, 80,
126 80, 80, 76, 84, 88, 86, 82, 82,
127 82, 82, 86, 88, 182, 182, 168, 168,
128 168, 182, 182, 192, 186, 192, 172, 186,
129 192, 394, 382, 354, 382, 394, 406, 394,
130 394, 406, 418, 438, 418, 464, 464, 492,
133 #define TEX_VLC_BITS 10
156 new_dv_vlc_bits[j] <<= 1;
182 run = new_dv_vlc_run[
code] + 1;
194 uint32_t *factor1 = &
ctx->idct_factor[0],
199 static const uint8_t dv100_qstep[16] = {
202 2, 3, 4, 5, 6, 7, 8, 16, 18, 20, 22, 24, 28, 52
204 const uint16_t *iweight1, *iweight2;
206 if (
d->height == 720) {
213 for (
c = 0;
c < 4;
c++) {
214 for (
s = 0;
s < 16;
s++) {
215 for (
i = 0;
i < 64;
i++) {
216 *factor1++ = (dv100_qstep[
s] << (
c + 9)) * iweight1[
i];
217 *factor2++ = (dv100_qstep[
s] << (
c + 9)) * iweight2[
i];
222 static const uint8_t dv_quant_areas[4] = { 6, 21, 43, 64 };
225 for (
s = 0;
s < 22;
s++) {
226 for (
i =
c = 0;
c < 4;
c++) {
227 for (;
i < dv_quant_areas[
c];
i++) {
229 *factor2++ = (*factor1++) << 1;
245 for (
i = 0;
i < 64;
i++)
249 for (
i = 0;
i < 64;
i++){
251 s->dv_zigzag[1][
i] =
s->idsp.idct_permutation[(j & 7) + (j & 8) * 4 + (j & 48) / 2];
256 s->idct_put[0] =
s->idsp.idct_put;
268 const uint8_t *scan_table =
mb->scan_table;
269 const uint32_t *factor_table =
mb->factor_table;
271 int partial_bit_count =
mb->partial_bit_count;
278 if (partial_bit_count > 0) {
279 re_cache = re_cache >> partial_bit_count |
280 mb->partial_bit_buffer;
281 re_index -= partial_bit_count;
282 mb->partial_bit_count = 0;
301 if (re_index + vlc_len > last_index) {
303 mb->partial_bit_count = last_index - re_index;
304 mb->partial_bit_buffer = re_cache & ~(-1
u >>
mb->partial_bit_count);
305 re_index = last_index;
340 for (
i = 0;
i < 4;
i++) {
341 for (j = 0; j < 8; j++)
349 int stride, int16_t *blocks)
351 s->idsp.idct(blocks + 0*64);
352 s->idsp.idct(blocks + 1*64);
361 int stride, int16_t *blocks)
363 s->idsp.idct(blocks + 0*64);
364 s->idsp.idct(blocks + 1*64);
365 s->idsp.idct(blocks + 2*64);
366 s->idsp.idct(blocks + 3*64);
383 int quant,
dc, dct_mode, class1, j;
384 int mb_index, mb_x, mb_y, last_index;
385 int y_stride, linesize;
389 const uint8_t *buf_ptr;
396 const int log2_blocksize = 3-
s->avctx->lowres;
397 int is_field_mode[5];
398 int vs_bit_buffer_damaged = 0;
399 int mb_bit_buffer_damaged[5] = {0};
403 av_assert1((((uintptr_t) mb_bit_buffer) & 7) == 0);
404 av_assert1((((uintptr_t) vs_bit_buffer) & 7) == 0);
408 memset(sblock, 0, 5 *
DV_MAX_BPM *
sizeof(*sblock));
415 for (mb_index = 0; mb_index < 5; mb_index++, mb1 +=
s->sys->bpm,
block1 +=
s->sys->bpm * 64) {
417 quant = buf_ptr[3] & 0x0f;
419 if ((buf_ptr[3] >> 4) == 0x0E)
420 vs_bit_buffer_damaged = 1;
422 sta = buf_ptr[3] >> 4;
423 }
else if (sta != (buf_ptr[3] >> 4))
424 vs_bit_buffer_damaged = 1;
430 is_field_mode[mb_index] = 0;
431 for (j = 0; j <
s->sys->bpm; j++) {
432 last_index =
s->sys->block_sizes[j];
440 mb->idct_put =
s->idct_put[0];
441 mb->scan_table =
s->dv_zigzag[0];
442 mb->factor_table = &
s->idct_factor[(j >= 4) * 4 * 16 * 64 +
445 is_field_mode[mb_index] |= !j && dct_mode;
447 mb->idct_put =
s->idct_put[dct_mode && log2_blocksize == 3];
448 mb->scan_table =
s->dv_zigzag[dct_mode];
450 &
s->idct_factor[(class1 == 3) * 2 * 22 * 64 +
459 buf_ptr += last_index >> 3;
461 mb->partial_bit_count = 0;
463 ff_dlog(avctx,
"MB block: %d, %d ", mb_index, j);
470 if (
mb->pos >= 64 &&
mb->pos < 127)
471 vs_bit_buffer_damaged = mb_bit_buffer_damaged[mb_index] = 1;
477 if (mb_bit_buffer_damaged[mb_index] > 0)
487 for (j = 0; j <
s->sys->bpm; j++,
block += 64,
mb++) {
494 vs_bit_buffer_damaged = mb_bit_buffer_damaged[mb_index] = 1;
499 if (j >=
s->sys->bpm)
505 block = &sblock[0][0];
510 for (mb_index = 0; mb_index < 5; mb_index++) {
511 for (j = 0; j <
s->sys->bpm; j++) {
512 if (
mb->pos < 64 &&
get_bits_left(&gb) > 0 && !vs_bit_buffer_damaged) {
513 ff_dlog(avctx,
"start %d:%d\n", mb_index, j);
517 if (
mb->pos >= 64 &&
mb->pos < 127) {
519 "AC EOB marker is absent pos=%d\n",
mb->pos);
520 vs_bit_buffer_damaged = 1;
526 if (vs_bit_buffer_damaged && !retried) {
533 block = &sblock[0][0];
535 for (mb_index = 0; mb_index < 5; mb_index++) {
541 (
s->sys->height >= 720 && mb_y != 134)) {
542 y_stride = (
s->frame->linesize[0] <<
543 ((!is_field_mode[mb_index]) * log2_blocksize));
545 y_stride = (2 << log2_blocksize);
547 y_ptr =
s->frame->data[0] +
548 ((mb_y *
s->frame->linesize[0] + mb_x) << log2_blocksize);
549 if (mb_y == 134 && is_field_mode[mb_index]) {
552 linesize =
s->frame->linesize[0] << is_field_mode[mb_index];
553 mb[0].idct_put(y_ptr, linesize,
block + 0 * 64);
554 if (
s->sys->video_stype == 4) {
555 mb[2].idct_put(y_ptr + (1 << log2_blocksize), linesize,
block + 2 * 64);
557 mb[1].idct_put(y_ptr + (1 << log2_blocksize), linesize,
block + 1 * 64);
558 mb[2].idct_put(y_ptr + y_stride, linesize,
block + 2 * 64);
559 mb[3].idct_put(y_ptr + (1 << log2_blocksize) + y_stride, linesize,
block + 3 * 64);
568 for (j = 2; j; j--) {
569 uint8_t *c_ptr =
s->frame->data[j] + c_offset;
571 uint64_t aligned_pixels[64 / 8];
572 uint8_t *pixels = (uint8_t *) aligned_pixels;
573 uint8_t *c_ptr1, *ptr1;
575 mb->idct_put(pixels, 8,
block);
576 for (y = 0; y < (1 << log2_blocksize); y++, c_ptr +=
s->frame->linesize[j], pixels += 8) {
577 ptr1 = pixels + ((1 << (log2_blocksize))>>1);
578 c_ptr1 = c_ptr + (
s->frame->linesize[j] << log2_blocksize);
579 for (x = 0; x < (1 <<
FFMAX(log2_blocksize - 1, 0)); x++) {
580 c_ptr[x] = pixels[x];
587 y_stride = (mb_y == 134) ? (1 << log2_blocksize) :
588 s->frame->linesize[j] << ((!is_field_mode[mb_index]) * log2_blocksize);
589 if (mb_y == 134 && is_field_mode[mb_index]) {
594 linesize =
s->frame->linesize[j] << is_field_mode[mb_index];
597 if (
s->sys->bpm == 8) {
613 uint8_t *buf = avpkt->
data;
614 int buf_size = avpkt->
size;
616 const uint8_t *vsc_pack;
617 int apt, is16_9,
ret;
637 frame->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->interlaced_frame = 0;
662 frame->top_field_first = 0;
663 }
else if (avctx->
height == 1080) {
664 frame->interlaced_frame = 1;
665 frame->top_field_first = (vsc_pack[3] & 0x40) == 0x40;
667 frame->interlaced_frame = (vsc_pack[3] & 0x10) == 0x10;
668 frame->top_field_first = !(vsc_pack[3] & 0x40);
681 return s->sys->frame_size;