[FFmpeg-devel] [PATCH] aacenc: Fix coefficient calculation for mid/side.

Nathan Caldwell saintdev
Wed Oct 6 07:40:16 CEST 2010


The current code incorrectly subtracts the second channel from the
just calculated mid channel. Instead it should be subtracting the
second channel from the first.
---
 libavcodec/aacenc.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 1646489..d0a7238 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -314,8 +314,10 @@ static void
adjust_frame_information(AACEncContext *apc, ChannelElement *cpe, in
                 //apply M/S
                 if (cpe->common_window && !ch && cpe->ms_mask[w + g]) {
                     for (i = 0; i < ics->swb_sizes[g]; i++) {
-                        cpe->ch[0].coeffs[start+i] =
(cpe->ch[0].coeffs[start+i] + cpe->ch[1].coeffs[start+i]) / 2.0;
-                        cpe->ch[1].coeffs[start+i] =
cpe->ch[0].coeffs[start+i] - cpe->ch[1].coeffs[start+i];
+                        float ch0 = cpe->ch[0].coeffs[start+i];
+                        float ch1 = cpe->ch[1].coeffs[start+i];
+                        cpe->ch[0].coeffs[start+i] = (ch0 + ch1) / 2.0;
+                        cpe->ch[1].coeffs[start+i] = (ch0 - ch1) / 2.0;
                     }
                 }
                 start += ics->swb_sizes[g];
-- 
1.7.3.1



More information about the ffmpeg-devel mailing list