comparison dv.c @ 7616:685ef77c9fe5 libavcodec

Making block size in bits variable and dependent on the DV spec
author romansh
date Tue, 19 Aug 2008 16:02:43 +0000
parents 290fd3ae1219
children a7ebe82c6331
comparison
equal deleted inserted replaced
7615:290fd3ae1219 7616:685ef77c9fe5
251 uint8_t partial_bit_count; 251 uint8_t partial_bit_count;
252 uint16_t partial_bit_buffer; 252 uint16_t partial_bit_buffer;
253 int shift_offset; 253 int shift_offset;
254 } BlockInfo; 254 } BlockInfo;
255 255
256 /* block size in bits */
257 static const uint16_t block_sizes[6] = {
258 112, 112, 112, 112, 80, 80
259 };
260 /* bit budget for AC only in 5 MBs */ 256 /* bit budget for AC only in 5 MBs */
261 static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5; 257 static const int vs_total_ac_bits = (100 * 4 + 68*2) * 5;
262 /* see dv_88_areas and dv_248_areas for details */ 258 /* see dv_88_areas and dv_248_areas for details */
263 static const int mb_area_start[5] = { 1, 6, 21, 43, 64 }; 259 static const int mb_area_start[5] = { 1, 6, 21, 43, 64 };
264 260
382 buf_ptr += 4; 378 buf_ptr += 4;
383 init_put_bits(&pb, mb_bit_buffer, 80); 379 init_put_bits(&pb, mb_bit_buffer, 80);
384 mb = mb1; 380 mb = mb1;
385 block = block1; 381 block = block1;
386 for(j = 0;j < s->sys->bpm; j++) { 382 for(j = 0;j < s->sys->bpm; j++) {
387 last_index = block_sizes[j]; 383 last_index = s->sys->block_sizes[j];
388 init_get_bits(&gb, buf_ptr, last_index); 384 init_get_bits(&gb, buf_ptr, last_index);
389 385
390 /* get the dc */ 386 /* get the dc */
391 dc = get_sbits(&gb, 9); 387 dc = get_sbits(&gb, 9);
392 dct_mode = get_bits1(&gb); 388 dct_mode = get_bits1(&gb);
909 dv_set_class_number(block, enc_blk, 905 dv_set_class_number(block, enc_blk,
910 enc_blk->dct_mode ? ff_zigzag248_direct : ff_zigzag_direct, 906 enc_blk->dct_mode ? ff_zigzag248_direct : ff_zigzag_direct,
911 enc_blk->dct_mode ? dv_weight_248 : dv_weight_88, 907 enc_blk->dct_mode ? dv_weight_248 : dv_weight_88,
912 j/4); 908 j/4);
913 909
914 init_put_bits(pb, ptr, block_sizes[j]/8); 910 init_put_bits(pb, ptr, s->sys->block_sizes[j]/8);
915 put_bits(pb, 9, (uint16_t)(((enc_blk->mb[0] >> 3) - 1024 + 2) >> 2)); 911 put_bits(pb, 9, (uint16_t)(((enc_blk->mb[0] >> 3) - 1024 + 2) >> 2));
916 put_bits(pb, 1, enc_blk->dct_mode); 912 put_bits(pb, 1, enc_blk->dct_mode);
917 put_bits(pb, 2, enc_blk->cno); 913 put_bits(pb, 2, enc_blk->cno);
918 914
919 vs_bit_size += enc_blk->bit_size[0] + enc_blk->bit_size[1] + 915 vs_bit_size += enc_blk->bit_size[0] + enc_blk->bit_size[1] +
920 enc_blk->bit_size[2] + enc_blk->bit_size[3]; 916 enc_blk->bit_size[2] + enc_blk->bit_size[3];
921 ++enc_blk; 917 ++enc_blk;
922 ++pb; 918 ++pb;
923 ptr += block_sizes[j]/8; 919 ptr += s->sys->block_sizes[j]/8;
924 } 920 }
925 } 921 }
926 922
927 if (vs_total_ac_bits < vs_bit_size) 923 if (vs_total_ac_bits < vs_bit_size)
928 dv_guess_qnos(&enc_blks[0], &qnos[0]); 924 dv_guess_qnos(&enc_blks[0], &qnos[0]);