From 132041f06fe30eff483769e19681bb2d5f92f26c Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Thu, 5 May 2005 14:10:52 +0000 Subject: [PATCH] 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) Originally committed as revision 4179 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavcodec/ac3enc.c | 4 +++- tests/ffmpeg.regression.ref | 2 +- tests/rotozoom.regression.ref | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index b690e1c359..aae06e4545 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -703,8 +703,10 @@ static int compute_bit_allocation(AC3EncodeContext *s, /* audio blocks */ for(i=0;inb_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */ - if (s->acmod == 2) + if (s->acmod == 2) { frame_bits++; /* rematstr */ + if(i==0) frame_bits += 4; + } frame_bits += 2 * s->nb_channels; /* chexpstr[2] * c */ if (s->lfe) frame_bits++; /* lfeexpstr */ diff --git a/tests/ffmpeg.regression.ref b/tests/ffmpeg.regression.ref index f3809b0f99..96285aa089 100644 --- a/tests/ffmpeg.regression.ref +++ b/tests/ffmpeg.regression.ref @@ -136,7 +136,7 @@ stddev: 10.99 PSNR:27.30 bytes:7602176 6956f2c5185c4edbae648c614992a14b *./data/out.wav stddev:9330.70 PSNR:16.92 bytes:527360 stddev:4396.13 PSNR:23.46 bytes:526336 -d056da679e6d6682812fffb28a7f0db6 *./data/a-ac3.rm +3bc982921d6354be383ba37c1dbcf958 *./data/a-ac3.rm 97983 ./data/a-ac3.rm 9e6e66847a568ef4f1f229b0939d2aae *./data/a-g726.wav 24268 ./data/a-g726.wav diff --git a/tests/rotozoom.regression.ref b/tests/rotozoom.regression.ref index 540f4176fc..0eff4aaa06 100644 --- a/tests/rotozoom.regression.ref +++ b/tests/rotozoom.regression.ref @@ -136,7 +136,7 @@ stddev: 3.43 PSNR:37.39 bytes:7602176 6956f2c5185c4edbae648c614992a14b *./data/out.wav stddev:9330.70 PSNR:16.92 bytes:527360 stddev:4396.13 PSNR:23.46 bytes:526336 -d056da679e6d6682812fffb28a7f0db6 *./data/a-ac3.rm +3bc982921d6354be383ba37c1dbcf958 *./data/a-ac3.rm 97983 ./data/a-ac3.rm 9e6e66847a568ef4f1f229b0939d2aae *./data/a-g726.wav 24268 ./data/a-g726.wav