OLD | NEW |
1 /* | 1 /* |
2 * DV decoder | 2 * DV decoder |
3 * Copyright (c) 2002 Fabrice Bellard | 3 * Copyright (c) 2002 Fabrice Bellard |
4 * Copyright (c) 2004 Roman Shaposhnik | 4 * Copyright (c) 2004 Roman Shaposhnik |
5 * | 5 * |
6 * DV encoder | 6 * DV encoder |
7 * Copyright (c) 2003 Roman Shaposhnik | 7 * Copyright (c) 2003 Roman Shaposhnik |
8 * | 8 * |
9 * 50 Mbps (DVCPRO50) support | 9 * 50 Mbps (DVCPRO50) support |
10 * Copyright (c) 2006 Daniel Maas <dmaas@maasdigital.com> | 10 * Copyright (c) 2006 Daniel Maas <dmaas@maasdigital.com> |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 int quant, dc, dct_mode, class1, j; | 525 int quant, dc, dct_mode, class1, j; |
526 int mb_index, mb_x, mb_y, last_index; | 526 int mb_index, mb_x, mb_y, last_index; |
527 int y_stride, linesize; | 527 int y_stride, linesize; |
528 DCTELEM *block, *block1; | 528 DCTELEM *block, *block1; |
529 int c_offset; | 529 int c_offset; |
530 uint8_t *y_ptr; | 530 uint8_t *y_ptr; |
531 const uint8_t *buf_ptr; | 531 const uint8_t *buf_ptr; |
532 PutBitContext pb, vs_pb; | 532 PutBitContext pb, vs_pb; |
533 GetBitContext gb; | 533 GetBitContext gb; |
534 BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; | 534 BlockInfo mb_data[5 * DV_MAX_BPM], *mb, *mb1; |
535 DECLARE_ALIGNED_16(DCTELEM, sblock)[5*DV_MAX_BPM][64]; | 535 LOCAL_ALIGNED_16(DCTELEM, sblock, [5*DV_MAX_BPM], [64]); |
536 DECLARE_ALIGNED_16(uint8_t, mb_bit_buffer)[80 + 4]; /* allow some slack */ | 536 LOCAL_ALIGNED_16(uint8_t, mb_bit_buffer, [80 + 4]); /* allow some slack */ |
537 DECLARE_ALIGNED_16(uint8_t, vs_bit_buffer)[5 * 80 + 4]; /* allow some slack
*/ | 537 LOCAL_ALIGNED_16(uint8_t, vs_bit_buffer, [5 * 80 + 4]); /* allow some slack
*/ |
538 const int log2_blocksize = 3-s->avctx->lowres; | 538 const int log2_blocksize = 3-s->avctx->lowres; |
539 int is_field_mode[5]; | 539 int is_field_mode[5]; |
540 | 540 |
541 assert((((int)mb_bit_buffer) & 7) == 0); | 541 assert((((int)mb_bit_buffer) & 7) == 0); |
542 assert((((int)vs_bit_buffer) & 7) == 0); | 542 assert((((int)vs_bit_buffer) & 7) == 0); |
543 | 543 |
544 memset(sblock, 0, sizeof(sblock)); | 544 memset(sblock, 0, 5*DV_MAX_BPM*sizeof(*sblock)); |
545 | 545 |
546 /* pass 1 : read DC and AC coefficients in blocks */ | 546 /* pass 1 : read DC and AC coefficients in blocks */ |
547 buf_ptr = &s->buf[work_chunk->buf_offset*80]; | 547 buf_ptr = &s->buf[work_chunk->buf_offset*80]; |
548 block1 = &sblock[0][0]; | 548 block1 = &sblock[0][0]; |
549 mb1 = mb_data; | 549 mb1 = mb_data; |
550 init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); | 550 init_put_bits(&vs_pb, vs_bit_buffer, 5 * 80); |
551 for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s
->sys->bpm * 64) { | 551 for (mb_index = 0; mb_index < 5; mb_index++, mb1 += s->sys->bpm, block1 += s
->sys->bpm * 64) { |
552 /* skip header */ | 552 /* skip header */ |
553 quant = buf_ptr[3] & 0x0f; | 553 quant = buf_ptr[3] & 0x0f; |
554 buf_ptr += 4; | 554 buf_ptr += 4; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 } | 826 } |
827 } | 827 } |
828 | 828 |
829 return 0; | 829 return 0; |
830 } | 830 } |
831 | 831 |
832 static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i
nt linesize, DVVideoContext *s, int bias) | 832 static av_always_inline int dv_init_enc_block(EncBlockInfo* bi, uint8_t *data, i
nt linesize, DVVideoContext *s, int bias) |
833 { | 833 { |
834 const int *weight; | 834 const int *weight; |
835 const uint8_t* zigzag_scan; | 835 const uint8_t* zigzag_scan; |
836 DECLARE_ALIGNED_16(DCTELEM, blk)[64]; | 836 LOCAL_ALIGNED_16(DCTELEM, blk, [64]); |
837 int i, area; | 837 int i, area; |
838 /* We offer two different methods for class number assignment: the | 838 /* We offer two different methods for class number assignment: the |
839 method suggested in SMPTE 314M Table 22, and an improved | 839 method suggested in SMPTE 314M Table 22, and an improved |
840 method. The SMPTE method is very conservative; it assigns class | 840 method. The SMPTE method is very conservative; it assigns class |
841 3 (i.e. severe quantization) to any block where the largest AC | 841 3 (i.e. severe quantization) to any block where the largest AC |
842 component is greater than 36. FFmpeg's DV encoder tracks AC bit | 842 component is greater than 36. FFmpeg's DV encoder tracks AC bit |
843 consumption precisely, so there is no need to bias most blocks | 843 consumption precisely, so there is no need to bias most blocks |
844 towards strongly lossy compression. Instead, we assign class 2 | 844 towards strongly lossy compression. Instead, we assign class 2 |
845 to most blocks, and use class 3 only when strictly necessary | 845 to most blocks, and use class 3 only when strictly necessary |
846 (for blocks whose largest AC component exceeds 255). */ | 846 (for blocks whose largest AC component exceeds 255). */ |
(...skipping 12 matching lines...) Expand all Loading... |
859 bi->partial_bit_count = 0; | 859 bi->partial_bit_count = 0; |
860 bi->partial_bit_buffer = 0; | 860 bi->partial_bit_buffer = 0; |
861 bi->cur_ac = 0; | 861 bi->cur_ac = 0; |
862 if (data) { | 862 if (data) { |
863 bi->dct_mode = dv_guess_dct_mode(s, data, linesize); | 863 bi->dct_mode = dv_guess_dct_mode(s, data, linesize); |
864 s->get_pixels(blk, data, linesize); | 864 s->get_pixels(blk, data, linesize); |
865 s->fdct[bi->dct_mode](blk); | 865 s->fdct[bi->dct_mode](blk); |
866 } else { | 866 } else { |
867 /* We rely on the fact that encoding all zeros leads to an immediate EOB
, | 867 /* We rely on the fact that encoding all zeros leads to an immediate EOB
, |
868 which is precisely what the spec calls for in the "dummy" blocks. */ | 868 which is precisely what the spec calls for in the "dummy" blocks. */ |
869 memset(blk, 0, sizeof(blk)); | 869 memset(blk, 0, 64*sizeof(*blk)); |
870 bi->dct_mode = 0; | 870 bi->dct_mode = 0; |
871 } | 871 } |
872 bi->mb[0] = blk[0]; | 872 bi->mb[0] = blk[0]; |
873 | 873 |
874 zigzag_scan = bi->dct_mode ? ff_zigzag248_direct : ff_zigzag_direct; | 874 zigzag_scan = bi->dct_mode ? ff_zigzag248_direct : ff_zigzag_direct; |
875 weight = bi->dct_mode ? dv_weight_248 : dv_weight_88; | 875 weight = bi->dct_mode ? dv_weight_248 : dv_weight_88; |
876 | 876 |
877 for (area = 0; area < 4; area++) { | 877 for (area = 0; area < 4; area++) { |
878 bi->prev[area] = prev; | 878 bi->prev[area] = prev; |
879 bi->bit_size[area] = 1; // 4 areas 4 bits for EOB :) | 879 bi->bit_size[area] = 1; // 4 areas 4 bits for EOB :) |
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 sizeof(DVVideoContext), | 1352 sizeof(DVVideoContext), |
1353 dvvideo_init, | 1353 dvvideo_init, |
1354 NULL, | 1354 NULL, |
1355 dvvideo_close, | 1355 dvvideo_close, |
1356 dvvideo_decode_frame, | 1356 dvvideo_decode_frame, |
1357 CODEC_CAP_DR1, | 1357 CODEC_CAP_DR1, |
1358 NULL, | 1358 NULL, |
1359 .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), | 1359 .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), |
1360 }; | 1360 }; |
1361 #endif | 1361 #endif |
OLD | NEW |