58 "Valid DV profiles are:\n",
72 memset(&fdsp,0,
sizeof(fdsp));
73 memset(&mecc,0,
sizeof(mecc));
74 memset(&pdsp,0,
sizeof(pdsp));
83 s->fdct[0] = fdsp.
fdct;
108 *vlc = 0xfe00 | (
level << 1) | sign;
183 vlc = av_mod_uintp2(vlc,
size);
185 if (pb + 1 >= pb_end) {
229 131072, 257107, 257107, 242189, 252167, 242189, 235923, 237536,
230 237536, 235923, 229376, 231390, 223754, 231390, 229376, 222935,
231 224969, 217965, 217965, 224969, 222935, 200636, 218652, 211916,
232 212325, 211916, 218652, 200636, 188995, 196781, 205965, 206433,
233 206433, 205965, 196781, 188995, 185364, 185364, 200636, 200704,
234 200636, 185364, 185364, 174609, 180568, 195068, 195068, 180568,
235 174609, 170091, 175557, 189591, 175557, 170091, 165371, 170627,
236 170627, 165371, 160727, 153560, 160727, 144651, 144651, 136258,
239 131072, 262144, 257107, 257107, 242189, 242189, 242189, 242189,
240 237536, 237536, 229376, 229376, 200636, 200636, 224973, 224973,
241 223754, 223754, 235923, 235923, 229376, 229376, 217965, 217965,
242 211916, 211916, 196781, 196781, 185364, 185364, 206433, 206433,
243 211916, 211916, 222935, 222935, 200636, 200636, 205964, 205964,
244 200704, 200704, 180568, 180568, 175557, 175557, 195068, 195068,
245 185364, 185364, 188995, 188995, 174606, 174606, 175557, 175557,
246 170627, 170627, 153560, 153560, 165371, 165371, 144651, 144651,
251 #define DV100_SACRIFICE_QUALITY_FOR_SPEED 1
252 #define DV100_ENABLE_FINER 1
255 #define DV100_MAKE_QLEVEL(qno,cno) ((qno<<2) | (cno))
256 #define DV100_QLEVEL_QNO(qlevel) (qlevel>>2)
257 #define DV100_QLEVEL_CNO(qlevel) (qlevel&0x3)
259 #define DV100_NUM_QLEVELS 31
308 #if DV100_SACRIFICE_QUALITY_FOR_SPEED
317 65536, 65536, 32768, 21845, 16384, 13107, 10923, 9362, 8192, 4096, 3641, 3277, 2979, 2731, 2341, 1260,
324 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
325 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
326 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
327 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
328 25575, 25575, 24385, 23831, 23302, 23302, 24966, 24966,
329 24966, 23302, 23302, 21845, 22795, 24385, 24385, 22795,
330 21845, 21400, 21845, 23831, 21845, 21400, 10382, 10700,
331 10700, 10382, 10082, 9620, 10082, 9039, 9039, 8525, },
332 { 8192, 65536, 65536, 61681, 61681, 61681, 41943, 41943,
333 41943, 41943, 40330, 41943, 40330, 41943, 40330, 40330,
334 40330, 38836, 38836, 40330, 40330, 24966, 27594, 26214,
335 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
336 25575, 25575, 24385, 23831, 11523, 11523, 12483, 12483,
337 12483, 11523, 11523, 10923, 11275, 12193, 12193, 11275,
338 10923, 5323, 5490, 5924, 5490, 5323, 5165, 5323,
339 5323, 5165, 5017, 4788, 5017, 4520, 4520, 4263, }
343 { 8192, 65536, 65536, 61681, 61681, 61681, 58254, 58254,
344 58254, 58254, 58254, 58254, 55188, 58254, 58254, 55188,
345 55188, 55188, 55188, 55188, 55188, 24966, 27594, 26214,
346 26214, 26214, 27594, 24966, 23831, 24385, 25575, 25575,
347 25575, 25575, 24385, 23831, 15420, 15420, 16644, 16644,
348 16644, 15420, 15420, 10923, 11398, 12193, 12193, 11398,
349 10923, 10700, 10923, 11916, 10923, 10700, 5191, 5350,
350 5350, 5191, 5041, 4810, 5041, 4520, 4520, 4263, },
351 { 8192, 43691, 43691, 40330, 40330, 40330, 29127, 29127,
352 29127, 29127, 29127, 29127, 27594, 29127, 29127, 27594,
353 27594, 27594, 27594, 27594, 27594, 12483, 13797, 13107,
354 13107, 13107, 13797, 12483, 11916, 12193, 12788, 12788,
355 12788, 12788, 12193, 11916, 5761, 5761, 6242, 6242,
356 6242, 5761, 5761, 5461, 5638, 5461, 6096, 5638,
357 5461, 2661, 2745, 2962, 2745, 2661, 2583, 2661,
358 2661, 2583, 2509, 2394, 2509, 2260, 2260, 2131, }
364 const int *
weight,
int bias)
378 static const int classes[] = { 12, 24, 36, 0xffff };
380 static const int classes[] = { -1, -1, 255, 0xffff };
382 int max = classes[0];
384 const unsigned deadzone =
s->quant_deadzone;
385 const unsigned threshold = 2 * deadzone;
389 for (area = 0; area < 4; area++) {
390 bi->
prev[area] = prev;
395 if (
level + deadzone > threshold) {
423 for (area = 0; area < 4; area++) {
424 bi->
prev[area] = prev;
448 const int *
weight,
int bias)
458 for (
i = 0;
i < 64;
i += 2) {
462 level0 =
blk[zigzag_scan[
i+0]];
463 level1 =
blk[zigzag_scan[
i+1]];
466 bi->
sign[
i+0] = (level0>>31)&1;
467 bi->
sign[
i+1] = (level1>>31)&1;
470 level0 =
FFABS(level0);
471 level1 =
FFABS(level1);
474 level0 = (level0*
weight[
i+0] + 4096 + (1<<17)) >> 18;
475 level1 = (level1*
weight[
i+1] + 4096 + (1<<17)) >> 18;
478 bi->
save[
i+0] = level0;
479 bi->
save[
i+1] = level1;
524 memset(
blk, 0, 64*
sizeof(*
blk));
530 if (
s->sys->height == 1080) {
573 if (
b->area_q[0] == qno &&
b->cno == cno)
574 return b->bit_size[0];
587 for (k = 1; k < 64; k++) {
601 return b->bit_size[0];
615 for (
i = 0;
i < 5;
i++) {
617 for (j = 0; j < 8; j++) {
618 if (blks[8*
i+j].min_qlevel > min_qlevel[
i])
624 for (
i = 0;
i < 5;
i++) {
626 if (qlevels[
i] < min_qlevel[
i])
627 qlevels[
i] = min_qlevel[
i];
631 for (j = 0; j < 8; j++) {
633 size[
i] += size_cache[8*
i+j][qlevels[
i]];
639 int largest =
size[0] % 5;
640 int qlevels_done = 0;
644 for (
i = 0;
i < 5;
i++) {
645 if (qlevels[
i] < qlevels[largest])
651 largest = (largest+1) % 5;
665 for (j = 0; j < 8; j++,
b++) {
667 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
672 size[
i] += size_cache[8*
i+j][qlevels[
i]];
681 int largest =
size[0] % 5;
683 while (qlevels[0] > min_qlevel[0] ||
684 qlevels[1] > min_qlevel[1] ||
685 qlevels[2] > min_qlevel[2] ||
686 qlevels[3] > min_qlevel[3] ||
687 qlevels[4] > min_qlevel[4]) {
690 for (
i = 0;
i < 5;
i++) {
691 if (qlevels[
i] > min_qlevel[
i] && qlevels[
i] > qlevels[largest])
698 largest = (largest+1) % 5;
700 if (qlevels[
i] <= min_qlevel[
i]) {
705 save_qlevel = qlevels[
i];
707 if (qlevels[
i] < min_qlevel[
i])
708 qlevels[
i] = min_qlevel[
i];
716 for (j = 0; j < 8; j++,
b++) {
718 if(size_cache[8*
i+j][qlevels[
i]] == 0) {
721 size[
i] += size_cache[8*
i+j][qlevels[
i]];
727 qlevels[
i] = save_qlevel;
735 for (
i = 0;
i < 5;
i++) {
739 for (j = 0; j < 8; j++,
b++) {
749 int i, j, k,
a, prev,
a2;
759 for (
i = 0;
i < 5;
i++) {
765 for (j = 0; j < 6; j++,
b++) {
766 for (
a = 0;
a < 4;
a++) {
788 b->next[prev] =
b->next[k];
791 b->prev[
a + 1] = prev;
799 }
while (qnos[0] | qnos[1] | qnos[2] | qnos[3] | qnos[4]);
804 for (j = 0; j < 6 * 5; j++,
b++) {
806 for (k =
b->next[prev]; k < 64; k = b->next[k]) {
807 if (
b->mb[k] <
a &&
b->mb[k] > -
a) {
808 b->next[prev] =
b->next[k];
825 for (mb_index = 0; mb_index < 5; mb_index++) {
826 data = dif + mb_index*80 + 4;
843 int mb_x, mb_y, c_offset;
844 ptrdiff_t linesize, y_stride;
854 int *qnosp = &qnos[0];
857 enc_blk = &enc_blks[0];
858 for (mb_index = 0; mb_index < 5; mb_index++) {
863 y_ptr =
s->frame->data[0] + (mb_y *
s->frame->linesize[0] + mb_x) * 8;
864 linesize =
s->frame->linesize[0];
866 if (
s->sys->height == 1080 && mb_y < 134)
870 for (
i = 1;
i < 8;
i++)
876 (
s->sys->height >= 720 && mb_y != 134)) {
877 y_stride =
s->frame->linesize[0] * (1 << (3*!enc_blk->
dct_mode));
881 y_ptr =
s->frame->data[0] +
882 (mb_y *
s->frame->linesize[0] + mb_x) * 8;
883 linesize =
s->frame->linesize[0];
885 if (
s->sys->video_stype == 4) {
903 for (j = 2; j; j--) {
904 uint8_t *c_ptr =
s->frame->data[j] + c_offset;
905 linesize =
s->frame->linesize[j];
906 y_stride = (mb_y == 134) ? 8 : (
s->frame->linesize[j] * (1 << (3*!enc_blk->
dct_mode)));
910 for (
i = 0;
i < 8;
i++) {
911 d = c_ptr + linesize * 8;
928 if (
s->sys->bpm == 8)
942 for (j = 0; j < 5 *
s->sys->bpm;) {
949 for (
i = 0;
i <
s->sys->bpm;
i++, j++) {
950 int sz =
s->sys->block_sizes[
i] >> 3;
953 put_sbits(&pbs[j], 9, ((enc_blks[j].
mb[0] >> 3) - 1024 + 2) >> 2);
955 put_bits(&pbs[j], 2, enc_blks[j].cno);
963 for (
i = 0;
i <
s->sys->bpm;
i++)
964 if (enc_blks[start_mb +
i].partial_bit_count)
966 &pbs[start_mb +
s->sys->bpm]);
971 for (j = 0; j < 5 *
s->sys->bpm; j++) {
972 if (enc_blks[j].partial_bit_count)
974 if (enc_blks[j].partial_bit_count)
978 for (j = 0; j < 5 *
s->sys->bpm; j++) {
985 "bitstream written beyond buffer size\n");
1022 if (
c->avctx->height >= 720)
1023 fs =
c->avctx->height == 720 ||
c->frame->top_field_first ? 0x40 : 0x00;
1025 fs =
c->frame->top_field_first ? 0x00 : 0x40;
1028 (
int)(
av_q2d(
c->avctx->sample_aspect_ratio) *
1029 c->avctx->width /
c->avctx->height * 10) >= 17)
1056 (
c->sys->dsf << 5) |
1057 c->sys->video_stype;
1085 int fsc = chan_num & 1;
1086 int fsp = 1 - (chan_num >> 1);
1089 buf[1] = (seq_num << 4) |
1099 if (syb_num == 0 || syb_num == 6) {
1100 buf[0] = (fr << 7) |
1103 }
else if (syb_num == 11) {
1104 buf[0] = (fr << 7) |
1107 buf[0] = (fr << 7) |
1121 int chan_offset = 2*(
c->sys->height == 720 &&
c->avctx->frame_number & 1);
1123 for (chan = 0; chan <
c->sys->n_difchan; chan++) {
1124 for (
i = 0;
i <
c->sys->difseg_size;
i++) {
1125 memset(buf, 0xff, 80 * 6);
1134 for (j = 0; j < 2; j++) {
1136 for (k = 0; k < 6; k++)
1142 for (j = 0; j < 3; j++) {
1153 for (j = 0; j < 135; j++) {
1155 memset(buf, 0xff, 80);
1178 c->pix_fmt =
s->sys->pix_fmt;
1180 #if FF_API_CODED_FRAME
1182 c->coded_frame->key_frame = 1;
1201 #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
1202 #define OFFSET(x) offsetof(DVVideoContext, x)
1204 {
"quant_deadzone",
"Quantizer dead zone",
OFFSET(quant_deadzone),
AV_OPT_TYPE_INT, { .i64 = 7 }, 0, 1024,
VE },