comparison ac3enc.c @ 2644:6ff5dc0dbaf0 libavcodec

While adding stereo rematrixing, I came across something that needs to be fixed even without adding the feature. The output correctly uses 4 dummy values for the rematrixing flags in block-0, but the bit allocation routine does not take these bits into account. From what I can tell, there was a patch in 2003 that corrected the output to make it DVD and spec compatible, but it didn't correct the bit allocation. It's only 4 bits over the entire 6 blocks, so overflow errors would happen rarely or never, but it's still worth fixing. So here is a fix. patch by (Justin Ruggles {jruggle earthlink net)
author michael
date Thu, 05 May 2005 14:10:52 +0000
parents 582e635cfa08
children ef2149182f1c
comparison
equal deleted inserted replaced
2643:8e42a0463f68 2644:6ff5dc0dbaf0
701 frame_bits += frame_bits_inc[s->acmod]; 701 frame_bits += frame_bits_inc[s->acmod];
702 702
703 /* audio blocks */ 703 /* audio blocks */
704 for(i=0;i<NB_BLOCKS;i++) { 704 for(i=0;i<NB_BLOCKS;i++) {
705 frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */ 705 frame_bits += s->nb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */
706 if (s->acmod == 2) 706 if (s->acmod == 2) {
707 frame_bits++; /* rematstr */ 707 frame_bits++; /* rematstr */
708 if(i==0) frame_bits += 4;
709 }
708 frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */ 710 frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */
709 if (s->lfe) 711 if (s->lfe)
710 frame_bits++; /* lfeexpstr */ 712 frame_bits++; /* lfeexpstr */
711 for(ch=0;ch<s->nb_channels;ch++) { 713 for(ch=0;ch<s->nb_channels;ch++) {
712 if (exp_strategy[i][ch] != EXP_REUSE) 714 if (exp_strategy[i][ch] != EXP_REUSE)