81 "in DV, input value is: %s\n",
name ?
name :
"unknown");
89 "Valid DV profiles are:\n",
107 s->ildct_cmp = ildct_cmp[5];
110 memset(&fdsp,0,
sizeof(fdsp));
111 memset(&pdsp,0,
sizeof(pdsp));
115 s->fdct[0] = fdsp.
fdct;
118 #if !CONFIG_HARDCODED_TABLES
147 *vlc = 0xfe00 | (
level << 1) | sign;
224 if (pb + 1 >= pb_end) {
268 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
269 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
270 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
271 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
272 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
273 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
274 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
275 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
278 131072, 262144, 257107, 257107, 242189, 242189, 242189, 242189,
279 237536, 237536, 229376, 229376, 200636, 200636, 224973, 224973,
280 223754, 223754, 235923, 235923, 229376, 229376, 217965, 217965,
281 211916, 211916, 196781, 196781, 185364, 185364, 206433, 206433,
282 211916, 211916, 222935, 222935, 200636, 200636, 205964, 205964,
283 200704, 200704, 180568, 180568, 175557, 175557, 195068, 195068,
284 185364, 185364, 188995, 188995, 174606, 174606, 175557, 175557,
285 170627, 170627, 153560, 153560, 165371, 165371, 144651, 144651,
290 #define DV100_SACRIFICE_QUALITY_FOR_SPEED 1
291 #define DV100_ENABLE_FINER 1
294 #define DV100_MAKE_QLEVEL(qno,cno) ((qno<<2) | (cno))
295 #define DV100_QLEVEL_QNO(qlevel) (qlevel>>2)
296 #define DV100_QLEVEL_CNO(qlevel) (qlevel&0x3)
298 #define DV100_NUM_QLEVELS 31
347 #if DV100_SACRIFICE_QUALITY_FOR_SPEED
356 65536, 65536, 32768, 21845, 16384, 13107, 10923, 9362, 8192, 4096, 3641, 3277, 2979, 2731, 2341, 1260,
362 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
363 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
364 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
365 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
366 25575, 25575, 24385, 23831, 23302, 23302, 24966, 24966,
367 24966, 23302, 23302, 21845, 22795, 24385, 24385, 22795,
368 21845, 21400, 21845, 23831, 21845, 21400, 10382, 10700,
369 10700, 10382, 10082, 9620, 10082, 9039, 9039, 8525, },
370 { 8192, 65536, 65536, 61681, 61681, 61681, 41943, 41943,
371 41943, 41943, 40330, 41943, 40330, 41943, 40330, 40330,
372 40330, 38836, 38836, 40330, 40330, 24966, 27594, 26214,
373 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
374 25575, 25575, 24385, 23831, 11523, 11523, 12483, 12483,
375 12483, 11523, 11523, 10923, 11275, 12193, 12193, 11275,
376 10923, 5323, 5490, 5924, 5490, 5323, 5165, 5323,
377 5323, 5165, 5017, 4788, 5017, 4520, 4520, 4263, }
381 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
382 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
383 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
384 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
385 25575, 25575, 24385, 23831, 15420, 15420, 16644, 16644,
386 16644, 15420, 15420, 10923, 11398, 12193, 12193, 11398,
387 10923, 10700, 10923, 11916, 10923, 10700, 5191, 5350,
388 5350, 5191, 5041, 4810, 5041, 4520, 4520, 4263, },
389 { 8192, 43691, 43691, 40330, 40330, 40330, 29127, 29127,
390 29127, 29127, 29127, 29127, 27594, 29127, 29127, 27594,
391 27594, 27594, 27594, 27594, 27594, 12483, 13797, 13107,
392 13107, 13107, 13797, 12483, 11916, 12193, 12788, 12788,
393 12788, 12788, 12193, 11916, 5761, 5761, 6242, 6242,
394 6242, 5761, 5761, 5461, 5638, 5461, 6096, 5638,
395 5461, 2661, 2745, 2962, 2745, 2661, 2583, 2661,
396 2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, }
401 const uint8_t *zigzag_scan,
416 static const int classes[] = { 12, 24, 36, 0xffff };
418 static const int classes[] = { -1, -1, 255, 0xffff };
420 int max = classes[0];
422 const unsigned deadzone =
s->quant_deadzone;
423 const unsigned threshold = 2 * deadzone;
427 for (area = 0; area < 4; area++) {
428 bi->
prev[area] = prev;
433 if (
level + deadzone > threshold) {
461 for (area = 0; area < 4; area++) {
462 bi->
prev[area] = prev;
485 const uint8_t *zigzag_scan,
496 for (
i = 0;
i < 64;
i += 2) {
500 level0 =
blk[zigzag_scan[
i+0]];
501 level1 =
blk[zigzag_scan[
i+1]];
504 bi->
sign[
i+0] = (level0>>31)&1;
505 bi->
sign[
i+1] = (level1>>31)&1;
508 level0 =
FFABS(level0);
509 level1 =
FFABS(level1);
512 level0 = (level0*
weight[
i+0] + 4096 + (1<<17)) >> 18;
513 level1 = (level1*
weight[
i+1] + 4096 + (1<<17)) >> 18;
516 bi->
save[
i+0] = level0;
517 bi->
save[
i+1] = level1;
562 memset(
blk, 0, 64*
sizeof(*
blk));
568 if (
s->sys->height == 1080) {
611 if (
b->area_q[0] == qno &&
b->cno == cno)
612 return b->bit_size[0];
625 for (k = 1; k < 64; k++) {
639 return b->bit_size[0];
653 for (
i = 0;
i < 5;
i++) {
655 for (j = 0; j < 8; j++) {
656 if (blks[8*
i+j].min_qlevel > min_qlevel[
i])
662 for (
i = 0;
i < 5;
i++) {
664 if (qlevels[
i] < min_qlevel[
i])
665 qlevels[
i] = min_qlevel[
i];
669 for (j = 0; j < 8; j++) {
671 size[
i] += size_cache[8*
i+j][qlevels[
i]];
677 int largest =
size[0] % 5;
678 int qlevels_done = 0;
682 for (
i = 0;
i < 5;
i++) {
683 if (qlevels[
i] < qlevels[largest])
689 largest = (largest+1) % 5;
703 for (j = 0; j < 8; j++,
b++) {
705 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
710 size[
i] += size_cache[8*
i+j][qlevels[
i]];
719 int largest =
size[0] % 5;
721 while (qlevels[0] > min_qlevel[0] ||
722 qlevels[1] > min_qlevel[1] ||
723 qlevels[2] > min_qlevel[2] ||
724 qlevels[3] > min_qlevel[3] ||
725 qlevels[4] > min_qlevel[4]) {
728 for (
i = 0;
i < 5;
i++) {
729 if (qlevels[
i] > min_qlevel[
i] && qlevels[
i] > qlevels[largest])
736 largest = (largest+1) % 5;
738 if (qlevels[
i] <= min_qlevel[
i]) {
743 save_qlevel = qlevels[
i];
745 if (qlevels[
i] < min_qlevel[
i])
746 qlevels[
i] = min_qlevel[
i];
754 for (j = 0; j < 8; j++,
b++) {
756 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
759 size[
i] += size_cache[8*
i+j][qlevels[
i]];
765 qlevels[
i] = save_qlevel;
773 for (
i = 0;
i < 5;
i++) {
777 for (j = 0; j < 8; j++,
b++) {
787 int i, j, k,
a, prev,
a2;
797 for (
i = 0;
i < 5;
i++) {
803 for (j = 0; j < 6; j++,
b++) {
804 for (
a = 0;
a < 4;
a++) {
826 b->next[prev] =
b->next[k];
829 b->prev[
a + 1] = prev;
837 }
while (qnos[0] | qnos[1] | qnos[2] | qnos[3] | qnos[4]);
842 for (j = 0; j < 6 * 5; j++,
b++) {
844 for (k =
b->next[prev]; k < 64; k = b->next[k]) {
845 if (
b->mb[k] <
a &&
b->mb[k] > -
a) {
846 b->next[prev] =
b->next[k];
863 for (mb_index = 0; mb_index < 5; mb_index++) {
864 data = dif + mb_index*80 + 4;
881 int mb_x, mb_y, c_offset;
882 ptrdiff_t linesize, y_stride;
883 const uint8_t *y_ptr;
892 int *qnosp = &qnos[0];
895 enc_blk = &enc_blks[0];
896 for (mb_index = 0; mb_index < 5; mb_index++) {
901 y_ptr =
s->frame->data[0] + (mb_y *
s->frame->linesize[0] + mb_x) * 8;
902 linesize =
s->frame->linesize[0];
904 if (
s->sys->height == 1080 && mb_y < 134)
908 for (
i = 1;
i < 8;
i++)
914 (
s->sys->height >= 720 && mb_y != 134)) {
915 y_stride =
s->frame->linesize[0] * (1 << (3*!enc_blk->
dct_mode));
919 y_ptr =
s->frame->data[0] +
920 (mb_y *
s->frame->linesize[0] + mb_x) * 8;
921 linesize =
s->frame->linesize[0];
923 if (
s->sys->video_stype == 4) {
941 for (j = 2; j; j--) {
942 const uint8_t *c_ptr =
s->frame->data[j] + c_offset;
943 linesize =
s->frame->linesize[j];
944 y_stride = (mb_y == 134) ? 8 : (
s->frame->linesize[j] * (1 << (3*!enc_blk->
dct_mode)));
946 uint8_t *
b = scratch;
947 for (
i = 0;
i < 8;
i++) {
948 const uint8_t *d = c_ptr + linesize * 8;
965 if (
s->sys->bpm == 8)
979 for (j = 0; j < 5 *
s->sys->bpm;) {
986 for (
i = 0;
i <
s->sys->bpm;
i++, j++) {
987 int sz =
s->sys->block_sizes[
i] >> 3;
990 put_sbits(&pbs[j], 9, ((enc_blks[j].
mb[0] >> 3) - 1024 + 2) >> 2);
992 put_bits(&pbs[j], 2, enc_blks[j].cno);
1000 for (
i = 0;
i <
s->sys->bpm;
i++)
1001 if (enc_blks[start_mb +
i].partial_bit_count)
1003 &pbs[start_mb +
s->sys->bpm]);
1008 for (j = 0; j < 5 *
s->sys->bpm; j++) {
1009 if (enc_blks[j].partial_bit_count)
1011 if (enc_blks[j].partial_bit_count)
1015 for (j = 0; j < 5 *
s->sys->bpm; j++) {
1051 if (
c->avctx->height >= 720)
1057 (int)(
av_q2d(
c->avctx->sample_aspect_ratio) *
1058 c->avctx->width /
c->avctx->height * 10) >= 17)
1062 buf[0] = (uint8_t) pack_id;
1085 (
c->sys->dsf << 5) |
1086 c->sys->video_stype;
1111 uint8_t seq_num, uint8_t dif_num,
1114 int fsc = chan_num & 1;
1115 int fsp = 1 - (chan_num >> 1);
1117 buf[0] = (uint8_t) t;
1118 buf[1] = (seq_num << 4) |
1128 if (syb_num == 0 || syb_num == 6) {
1129 buf[0] = (fr << 7) |
1132 }
else if (syb_num == 11) {
1133 buf[0] = (fr << 7) |
1136 buf[0] = (fr << 7) |
1150 int chan_offset = 2*(
c->sys->height == 720 &&
c->avctx->frame_num & 1);
1152 for (chan = 0; chan <
c->sys->n_difchan; chan++) {
1153 for (
i = 0;
i <
c->sys->difseg_size;
i++) {
1154 memset(buf, 0xff, 80 * 6);
1163 for (j = 0; j < 2; j++) {
1165 for (k = 0; k < 6; k++)
1171 for (j = 0; j < 3; j++) {
1182 for (j = 0; j < 135; j++) {
1184 memset(buf, 0xff, 80);
1209 c->pix_fmt =
s->sys->pix_fmt;
1225 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1226 #define OFFSET(x) offsetof(DVEncContext, x)
1228 {
"quant_deadzone",
"Quantizer dead zone",
OFFSET(quant_deadzone),
AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024,
VE },
1240 .
p.
name =
"dvvideo",