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

Alex Converse alex.converse
Tue Oct 12 10:51:48 CEST 2010


On Tue, Oct 5, 2010 at 10:40 PM, Nathan Caldwell <saintdev at gmail.com> wrote:
> 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];

Just to reiterate what I said on IRC these seem mathematically
equivalent for well behaved floats. I'd like to see some ABX or other
testing to prove that this is actually changes anything.

Comments from the peanut gallery welcome.

Thanks,

Alex



More information about the ffmpeg-devel mailing list