81 "in DV, input value is: %s\n",
name ?
name :
"unknown");
89 "Valid DV profiles are:\n",
101 memset(&fdsp,0,
sizeof(fdsp));
102 memset(&mecc,0,
sizeof(mecc));
103 memset(&pdsp,0,
sizeof(pdsp));
112 s->fdct[0] = fdsp.
fdct;
115 #if !CONFIG_HARDCODED_TABLES
144 *vlc = 0xfe00 | (
level << 1) | sign;
221 if (pb + 1 >= pb_end) {
265 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
266 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
267 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
268 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
269 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
270 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
271 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
272 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
275 131072, 262144, 257107, 257107, 242189, 242189, 242189, 242189,
276 237536, 237536, 229376, 229376, 200636, 200636, 224973, 224973,
277 223754, 223754, 235923, 235923, 229376, 229376, 217965, 217965,
278 211916, 211916, 196781, 196781, 185364, 185364, 206433, 206433,
279 211916, 211916, 222935, 222935, 200636, 200636, 205964, 205964,
280 200704, 200704, 180568, 180568, 175557, 175557, 195068, 195068,
281 185364, 185364, 188995, 188995, 174606, 174606, 175557, 175557,
282 170627, 170627, 153560, 153560, 165371, 165371, 144651, 144651,
287 #define DV100_SACRIFICE_QUALITY_FOR_SPEED 1
288 #define DV100_ENABLE_FINER 1
291 #define DV100_MAKE_QLEVEL(qno,cno) ((qno<<2) | (cno))
292 #define DV100_QLEVEL_QNO(qlevel) (qlevel>>2)
293 #define DV100_QLEVEL_CNO(qlevel) (qlevel&0x3)
295 #define DV100_NUM_QLEVELS 31
344 #if DV100_SACRIFICE_QUALITY_FOR_SPEED
353 65536, 65536, 32768, 21845, 16384, 13107, 10923, 9362, 8192, 4096, 3641, 3277, 2979, 2731, 2341, 1260,
359 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
360 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
361 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
362 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
363 25575, 25575, 24385, 23831, 23302, 23302, 24966, 24966,
364 24966, 23302, 23302, 21845, 22795, 24385, 24385, 22795,
365 21845, 21400, 21845, 23831, 21845, 21400, 10382, 10700,
366 10700, 10382, 10082, 9620, 10082, 9039, 9039, 8525, },
367 { 8192, 65536, 65536, 61681, 61681, 61681, 41943, 41943,
368 41943, 41943, 40330, 41943, 40330, 41943, 40330, 40330,
369 40330, 38836, 38836, 40330, 40330, 24966, 27594, 26214,
370 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
371 25575, 25575, 24385, 23831, 11523, 11523, 12483, 12483,
372 12483, 11523, 11523, 10923, 11275, 12193, 12193, 11275,
373 10923, 5323, 5490, 5924, 5490, 5323, 5165, 5323,
374 5323, 5165, 5017, 4788, 5017, 4520, 4520, 4263, }
378 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
379 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
380 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
381 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
382 25575, 25575, 24385, 23831, 15420, 15420, 16644, 16644,
383 16644, 15420, 15420, 10923, 11398, 12193, 12193, 11398,
384 10923, 10700, 10923, 11916, 10923, 10700, 5191, 5350,
385 5350, 5191, 5041, 4810, 5041, 4520, 4520, 4263, },
386 { 8192, 43691, 43691, 40330, 40330, 40330, 29127, 29127,
387 29127, 29127, 29127, 29127, 27594, 29127, 29127, 27594,
388 27594, 27594, 27594, 27594, 27594, 12483, 13797, 13107,
389 13107, 13107, 13797, 12483, 11916, 12193, 12788, 12788,
390 12788, 12788, 12193, 11916, 5761, 5761, 6242, 6242,
391 6242, 5761, 5761, 5461, 5638, 5461, 6096, 5638,
392 5461, 2661, 2745, 2962, 2745, 2661, 2583, 2661,
393 2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, }
398 const uint8_t *zigzag_scan,
413 static const int classes[] = { 12, 24, 36, 0xffff };
415 static const int classes[] = { -1, -1, 255, 0xffff };
417 int max = classes[0];
419 const unsigned deadzone =
s->quant_deadzone;
420 const unsigned threshold = 2 * deadzone;
424 for (area = 0; area < 4; area++) {
425 bi->
prev[area] = prev;
430 if (
level + deadzone > threshold) {
458 for (area = 0; area < 4; area++) {
459 bi->
prev[area] = prev;
482 const uint8_t *zigzag_scan,
493 for (
i = 0;
i < 64;
i += 2) {
497 level0 =
blk[zigzag_scan[
i+0]];
498 level1 =
blk[zigzag_scan[
i+1]];
501 bi->
sign[
i+0] = (level0>>31)&1;
502 bi->
sign[
i+1] = (level1>>31)&1;
505 level0 =
FFABS(level0);
506 level1 =
FFABS(level1);
509 level0 = (level0*
weight[
i+0] + 4096 + (1<<17)) >> 18;
510 level1 = (level1*
weight[
i+1] + 4096 + (1<<17)) >> 18;
513 bi->
save[
i+0] = level0;
514 bi->
save[
i+1] = level1;
559 memset(
blk, 0, 64*
sizeof(*
blk));
565 if (
s->sys->height == 1080) {
608 if (
b->area_q[0] == qno &&
b->cno == cno)
609 return b->bit_size[0];
622 for (k = 1; k < 64; k++) {
636 return b->bit_size[0];
650 for (
i = 0;
i < 5;
i++) {
652 for (j = 0; j < 8; j++) {
653 if (blks[8*
i+j].min_qlevel > min_qlevel[
i])
659 for (
i = 0;
i < 5;
i++) {
661 if (qlevels[
i] < min_qlevel[
i])
662 qlevels[
i] = min_qlevel[
i];
666 for (j = 0; j < 8; j++) {
668 size[
i] += size_cache[8*
i+j][qlevels[
i]];
674 int largest =
size[0] % 5;
675 int qlevels_done = 0;
679 for (
i = 0;
i < 5;
i++) {
680 if (qlevels[
i] < qlevels[largest])
686 largest = (largest+1) % 5;
700 for (j = 0; j < 8; j++,
b++) {
702 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
707 size[
i] += size_cache[8*
i+j][qlevels[
i]];
716 int largest =
size[0] % 5;
718 while (qlevels[0] > min_qlevel[0] ||
719 qlevels[1] > min_qlevel[1] ||
720 qlevels[2] > min_qlevel[2] ||
721 qlevels[3] > min_qlevel[3] ||
722 qlevels[4] > min_qlevel[4]) {
725 for (
i = 0;
i < 5;
i++) {
726 if (qlevels[
i] > min_qlevel[
i] && qlevels[
i] > qlevels[largest])
733 largest = (largest+1) % 5;
735 if (qlevels[
i] <= min_qlevel[
i]) {
740 save_qlevel = qlevels[
i];
742 if (qlevels[
i] < min_qlevel[
i])
743 qlevels[
i] = min_qlevel[
i];
751 for (j = 0; j < 8; j++,
b++) {
753 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
756 size[
i] += size_cache[8*
i+j][qlevels[
i]];
762 qlevels[
i] = save_qlevel;
770 for (
i = 0;
i < 5;
i++) {
774 for (j = 0; j < 8; j++,
b++) {
784 int i, j, k,
a, prev,
a2;
794 for (
i = 0;
i < 5;
i++) {
800 for (j = 0; j < 6; j++,
b++) {
801 for (
a = 0;
a < 4;
a++) {
823 b->next[prev] =
b->next[k];
826 b->prev[
a + 1] = prev;
834 }
while (qnos[0] | qnos[1] | qnos[2] | qnos[3] | qnos[4]);
839 for (j = 0; j < 6 * 5; j++,
b++) {
841 for (k =
b->next[prev]; k < 64; k = b->next[k]) {
842 if (
b->mb[k] <
a &&
b->mb[k] > -
a) {
843 b->next[prev] =
b->next[k];
860 for (mb_index = 0; mb_index < 5; mb_index++) {
861 data = dif + mb_index*80 + 4;
878 int mb_x, mb_y, c_offset;
879 ptrdiff_t linesize, y_stride;
880 const uint8_t *y_ptr;
889 int *qnosp = &qnos[0];
892 enc_blk = &enc_blks[0];
893 for (mb_index = 0; mb_index < 5; mb_index++) {
898 y_ptr =
s->frame->data[0] + (mb_y *
s->frame->linesize[0] + mb_x) * 8;
899 linesize =
s->frame->linesize[0];
901 if (
s->sys->height == 1080 && mb_y < 134)
905 for (
i = 1;
i < 8;
i++)
911 (
s->sys->height >= 720 && mb_y != 134)) {
912 y_stride =
s->frame->linesize[0] * (1 << (3*!enc_blk->
dct_mode));
916 y_ptr =
s->frame->data[0] +
917 (mb_y *
s->frame->linesize[0] + mb_x) * 8;
918 linesize =
s->frame->linesize[0];
920 if (
s->sys->video_stype == 4) {
938 for (j = 2; j; j--) {
939 const uint8_t *c_ptr =
s->frame->data[j] + c_offset;
940 linesize =
s->frame->linesize[j];
941 y_stride = (mb_y == 134) ? 8 : (
s->frame->linesize[j] * (1 << (3*!enc_blk->
dct_mode)));
943 uint8_t *
b = scratch;
944 for (
i = 0;
i < 8;
i++) {
945 const uint8_t *
d = c_ptr + linesize * 8;
962 if (
s->sys->bpm == 8)
976 for (j = 0; j < 5 *
s->sys->bpm;) {
983 for (
i = 0;
i <
s->sys->bpm;
i++, j++) {
984 int sz =
s->sys->block_sizes[
i] >> 3;
987 put_sbits(&pbs[j], 9, ((enc_blks[j].
mb[0] >> 3) - 1024 + 2) >> 2);
989 put_bits(&pbs[j], 2, enc_blks[j].cno);
997 for (
i = 0;
i <
s->sys->bpm;
i++)
998 if (enc_blks[start_mb +
i].partial_bit_count)
1000 &pbs[start_mb +
s->sys->bpm]);
1005 for (j = 0; j < 5 *
s->sys->bpm; j++) {
1006 if (enc_blks[j].partial_bit_count)
1008 if (enc_blks[j].partial_bit_count)
1012 for (j = 0; j < 5 *
s->sys->bpm; j++) {
1048 if (
c->avctx->height >= 720)
1049 fs =
c->avctx->height == 720 ||
c->frame->top_field_first ? 0x40 : 0x00;
1051 fs =
c->frame->top_field_first ? 0x00 : 0x40;
1054 (
int)(
av_q2d(
c->avctx->sample_aspect_ratio) *
1055 c->avctx->width /
c->avctx->height * 10) >= 17)
1059 buf[0] = (uint8_t) pack_id;
1082 (
c->sys->dsf << 5) |
1083 c->sys->video_stype;
1108 uint8_t seq_num, uint8_t dif_num,
1111 int fsc = chan_num & 1;
1112 int fsp = 1 - (chan_num >> 1);
1114 buf[0] = (uint8_t) t;
1115 buf[1] = (seq_num << 4) |
1125 if (syb_num == 0 || syb_num == 6) {
1126 buf[0] = (fr << 7) |
1129 }
else if (syb_num == 11) {
1130 buf[0] = (fr << 7) |
1133 buf[0] = (fr << 7) |
1147 int chan_offset = 2*(
c->sys->height == 720 &&
c->avctx->frame_num & 1);
1149 for (chan = 0; chan <
c->sys->n_difchan; chan++) {
1150 for (
i = 0;
i <
c->sys->difseg_size;
i++) {
1151 memset(buf, 0xff, 80 * 6);
1160 for (j = 0; j < 2; j++) {
1162 for (k = 0; k < 6; k++)
1168 for (j = 0; j < 3; j++) {
1179 for (j = 0; j < 135; j++) {
1181 memset(buf, 0xff, 80);
1206 c->pix_fmt =
s->sys->pix_fmt;
1222 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1223 #define OFFSET(x) offsetof(DVEncContext, x)
1225 {
"quant_deadzone",
"Quantizer dead zone",
OFFSET(quant_deadzone),
AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024,
VE },
1237 .
p.
name =
"dvvideo",