61 "Valid DV profiles are:\n",
73 memset(&fdsp,0,
sizeof(fdsp));
74 memset(&mecc,0,
sizeof(mecc));
75 memset(&pdsp,0,
sizeof(pdsp));
84 s->fdct[0] = fdsp.
fdct;
87 #if !CONFIG_HARDCODED_TABLES
116 *vlc = 0xfe00 | (
level << 1) | sign;
193 if (pb + 1 >= pb_end) {
237 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
238 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
239 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
240 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
241 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
242 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
243 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
244 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
247 131072, 262144, 257107, 257107, 242189, 242189, 242189, 242189,
248 237536, 237536, 229376, 229376, 200636, 200636, 224973, 224973,
249 223754, 223754, 235923, 235923, 229376, 229376, 217965, 217965,
250 211916, 211916, 196781, 196781, 185364, 185364, 206433, 206433,
251 211916, 211916, 222935, 222935, 200636, 200636, 205964, 205964,
252 200704, 200704, 180568, 180568, 175557, 175557, 195068, 195068,
253 185364, 185364, 188995, 188995, 174606, 174606, 175557, 175557,
254 170627, 170627, 153560, 153560, 165371, 165371, 144651, 144651,
259 #define DV100_SACRIFICE_QUALITY_FOR_SPEED 1
260 #define DV100_ENABLE_FINER 1
263 #define DV100_MAKE_QLEVEL(qno,cno) ((qno<<2) | (cno))
264 #define DV100_QLEVEL_QNO(qlevel) (qlevel>>2)
265 #define DV100_QLEVEL_CNO(qlevel) (qlevel&0x3)
267 #define DV100_NUM_QLEVELS 31
316 #if DV100_SACRIFICE_QUALITY_FOR_SPEED
325 65536, 65536, 32768, 21845, 16384, 13107, 10923, 9362, 8192, 4096, 3641, 3277, 2979, 2731, 2341, 1260,
331 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
332 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
333 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
334 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
335 25575, 25575, 24385, 23831, 23302, 23302, 24966, 24966,
336 24966, 23302, 23302, 21845, 22795, 24385, 24385, 22795,
337 21845, 21400, 21845, 23831, 21845, 21400, 10382, 10700,
338 10700, 10382, 10082, 9620, 10082, 9039, 9039, 8525, },
339 { 8192, 65536, 65536, 61681, 61681, 61681, 41943, 41943,
340 41943, 41943, 40330, 41943, 40330, 41943, 40330, 40330,
341 40330, 38836, 38836, 40330, 40330, 24966, 27594, 26214,
342 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
343 25575, 25575, 24385, 23831, 11523, 11523, 12483, 12483,
344 12483, 11523, 11523, 10923, 11275, 12193, 12193, 11275,
345 10923, 5323, 5490, 5924, 5490, 5323, 5165, 5323,
346 5323, 5165, 5017, 4788, 5017, 4520, 4520, 4263, }
350 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
351 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
352 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
353 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
354 25575, 25575, 24385, 23831, 15420, 15420, 16644, 16644,
355 16644, 15420, 15420, 10923, 11398, 12193, 12193, 11398,
356 10923, 10700, 10923, 11916, 10923, 10700, 5191, 5350,
357 5350, 5191, 5041, 4810, 5041, 4520, 4520, 4263, },
358 { 8192, 43691, 43691, 40330, 40330, 40330, 29127, 29127,
359 29127, 29127, 29127, 29127, 27594, 29127, 29127, 27594,
360 27594, 27594, 27594, 27594, 27594, 12483, 13797, 13107,
361 13107, 13107, 13797, 12483, 11916, 12193, 12788, 12788,
362 12788, 12788, 12193, 11916, 5761, 5761, 6242, 6242,
363 6242, 5761, 5761, 5461, 5638, 5461, 6096, 5638,
364 5461, 2661, 2745, 2962, 2745, 2661, 2583, 2661,
365 2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, }
370 const uint8_t *zigzag_scan,
371 const int *
weight,
int bias)
385 static const int classes[] = { 12, 24, 36, 0xffff };
387 static const int classes[] = { -1, -1, 255, 0xffff };
389 int max = classes[0];
391 const unsigned deadzone =
s->quant_deadzone;
392 const unsigned threshold = 2 * deadzone;
396 for (area = 0; area < 4; area++) {
397 bi->
prev[area] = prev;
402 if (
level + deadzone > threshold) {
430 for (area = 0; area < 4; area++) {
431 bi->
prev[area] = prev;
454 const uint8_t *zigzag_scan,
455 const int *
weight,
int bias)
465 for (
i = 0;
i < 64;
i += 2) {
469 level0 =
blk[zigzag_scan[
i+0]];
470 level1 =
blk[zigzag_scan[
i+1]];
473 bi->
sign[
i+0] = (level0>>31)&1;
474 bi->
sign[
i+1] = (level1>>31)&1;
477 level0 =
FFABS(level0);
478 level1 =
FFABS(level1);
481 level0 = (level0*
weight[
i+0] + 4096 + (1<<17)) >> 18;
482 level1 = (level1*
weight[
i+1] + 4096 + (1<<17)) >> 18;
485 bi->
save[
i+0] = level0;
486 bi->
save[
i+1] = level1;
531 memset(
blk, 0, 64*
sizeof(*
blk));
537 if (
s->sys->height == 1080) {
580 if (
b->area_q[0] == qno &&
b->cno == cno)
581 return b->bit_size[0];
594 for (k = 1; k < 64; k++) {
608 return b->bit_size[0];
622 for (
i = 0;
i < 5;
i++) {
624 for (j = 0; j < 8; j++) {
625 if (blks[8*
i+j].min_qlevel > min_qlevel[
i])
631 for (
i = 0;
i < 5;
i++) {
633 if (qlevels[
i] < min_qlevel[
i])
634 qlevels[
i] = min_qlevel[
i];
638 for (j = 0; j < 8; j++) {
640 size[
i] += size_cache[8*
i+j][qlevels[
i]];
646 int largest =
size[0] % 5;
647 int qlevels_done = 0;
651 for (
i = 0;
i < 5;
i++) {
652 if (qlevels[
i] < qlevels[largest])
658 largest = (largest+1) % 5;
672 for (j = 0; j < 8; j++,
b++) {
674 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
679 size[
i] += size_cache[8*
i+j][qlevels[
i]];
688 int largest =
size[0] % 5;
690 while (qlevels[0] > min_qlevel[0] ||
691 qlevels[1] > min_qlevel[1] ||
692 qlevels[2] > min_qlevel[2] ||
693 qlevels[3] > min_qlevel[3] ||
694 qlevels[4] > min_qlevel[4]) {
697 for (
i = 0;
i < 5;
i++) {
698 if (qlevels[
i] > min_qlevel[
i] && qlevels[
i] > qlevels[largest])
705 largest = (largest+1) % 5;
707 if (qlevels[
i] <= min_qlevel[
i]) {
712 save_qlevel = qlevels[
i];
714 if (qlevels[
i] < min_qlevel[
i])
715 qlevels[
i] = min_qlevel[
i];
723 for (j = 0; j < 8; j++,
b++) {
725 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
728 size[
i] += size_cache[8*
i+j][qlevels[
i]];
734 qlevels[
i] = save_qlevel;
742 for (
i = 0;
i < 5;
i++) {
746 for (j = 0; j < 8; j++,
b++) {
756 int i, j, k,
a, prev,
a2;
766 for (
i = 0;
i < 5;
i++) {
772 for (j = 0; j < 6; j++,
b++) {
773 for (
a = 0;
a < 4;
a++) {
795 b->next[prev] =
b->next[k];
798 b->prev[
a + 1] = prev;
806 }
while (qnos[0] | qnos[1] | qnos[2] | qnos[3] | qnos[4]);
811 for (j = 0; j < 6 * 5; j++,
b++) {
813 for (k =
b->next[prev]; k < 64; k = b->next[k]) {
814 if (
b->mb[k] <
a &&
b->mb[k] > -
a) {
815 b->next[prev] =
b->next[k];
832 for (mb_index = 0; mb_index < 5; mb_index++) {
833 data = dif + mb_index*80 + 4;
850 int mb_x, mb_y, c_offset;
851 ptrdiff_t linesize, y_stride;
852 const uint8_t *y_ptr;
861 int *qnosp = &qnos[0];
864 enc_blk = &enc_blks[0];
865 for (mb_index = 0; mb_index < 5; mb_index++) {
870 y_ptr =
s->frame->data[0] + (mb_y *
s->frame->linesize[0] + mb_x) * 8;
871 linesize =
s->frame->linesize[0];
873 if (
s->sys->height == 1080 && mb_y < 134)
877 for (
i = 1;
i < 8;
i++)
883 (
s->sys->height >= 720 && mb_y != 134)) {
884 y_stride =
s->frame->linesize[0] * (1 << (3*!enc_blk->
dct_mode));
888 y_ptr =
s->frame->data[0] +
889 (mb_y *
s->frame->linesize[0] + mb_x) * 8;
890 linesize =
s->frame->linesize[0];
892 if (
s->sys->video_stype == 4) {
910 for (j = 2; j; j--) {
911 const uint8_t *c_ptr =
s->frame->data[j] + c_offset;
912 linesize =
s->frame->linesize[j];
913 y_stride = (mb_y == 134) ? 8 : (
s->frame->linesize[j] * (1 << (3*!enc_blk->
dct_mode)));
915 uint8_t *
b = scratch;
916 for (
i = 0;
i < 8;
i++) {
917 const uint8_t *
d = c_ptr + linesize * 8;
934 if (
s->sys->bpm == 8)
948 for (j = 0; j < 5 *
s->sys->bpm;) {
955 for (
i = 0;
i <
s->sys->bpm;
i++, j++) {
956 int sz =
s->sys->block_sizes[
i] >> 3;
959 put_sbits(&pbs[j], 9, ((enc_blks[j].
mb[0] >> 3) - 1024 + 2) >> 2);
961 put_bits(&pbs[j], 2, enc_blks[j].cno);
969 for (
i = 0;
i <
s->sys->bpm;
i++)
970 if (enc_blks[start_mb +
i].partial_bit_count)
972 &pbs[start_mb +
s->sys->bpm]);
977 for (j = 0; j < 5 *
s->sys->bpm; j++) {
978 if (enc_blks[j].partial_bit_count)
980 if (enc_blks[j].partial_bit_count)
984 for (j = 0; j < 5 *
s->sys->bpm; j++) {
1020 if (
c->avctx->height >= 720)
1021 fs =
c->avctx->height == 720 ||
c->frame->top_field_first ? 0x40 : 0x00;
1023 fs =
c->frame->top_field_first ? 0x00 : 0x40;
1026 (
int)(
av_q2d(
c->avctx->sample_aspect_ratio) *
1027 c->avctx->width /
c->avctx->height * 10) >= 17)
1031 buf[0] = (uint8_t) pack_id;
1054 (
c->sys->dsf << 5) |
1055 c->sys->video_stype;
1080 uint8_t seq_num, uint8_t dif_num,
1083 int fsc = chan_num & 1;
1084 int fsp = 1 - (chan_num >> 1);
1086 buf[0] = (uint8_t) t;
1087 buf[1] = (seq_num << 4) |
1097 if (syb_num == 0 || syb_num == 6) {
1098 buf[0] = (fr << 7) |
1101 }
else if (syb_num == 11) {
1102 buf[0] = (fr << 7) |
1105 buf[0] = (fr << 7) |
1119 int chan_offset = 2*(
c->sys->height == 720 &&
c->avctx->frame_number & 1);
1121 for (chan = 0; chan <
c->sys->n_difchan; chan++) {
1122 for (
i = 0;
i <
c->sys->difseg_size;
i++) {
1123 memset(buf, 0xff, 80 * 6);
1132 for (j = 0; j < 2; j++) {
1134 for (k = 0; k < 6; k++)
1140 for (j = 0; j < 3; j++) {
1151 for (j = 0; j < 135; j++) {
1153 memset(buf, 0xff, 80);
1178 c->pix_fmt =
s->sys->pix_fmt;
1194 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1195 #define OFFSET(x) offsetof(DVVideoContext, x)
1197 {
"quant_deadzone",
"Quantizer dead zone",
OFFSET(quant_deadzone),
AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024,
VE },
1209 .
p.
name =
"dvvideo",