summaryrefslogtreecommitdiffstats
path: root/libavcodec/aaccoder.c
diff options
context:
space:
mode:
authorRostislav Pehlivanov <atomnuker@gmail.com>2015-07-02 19:13:02 +0100
committerMichael Niedermayer <michaelni@gmx.at>2015-07-03 13:27:25 +0200
commit57848ef3c6a135caeb1f8034cadc157a38947009 (patch)
treeb33fca7e59b77d5c0ff97371dd8f226a63aa2682 /libavcodec/aaccoder.c
parent8e607c747eca582a4ef66fa85a27492f517cde1d (diff)
downloadffmpeg-streaming-57848ef3c6a135caeb1f8034cadc157a38947009.zip
ffmpeg-streaming-57848ef3c6a135caeb1f8034cadc157a38947009.tar.gz
aaccoder: fix M/S coding
There were some mistakes in the code for M/S stereo, this commit fixes them. The start variable was not being reset for every window and every access to the coefficients was incorrect as well. This fixes that by properly addressing the coefficients using both windows and setting the start on every window to zero. Reviewed-by: Claudio Freire <klaussfreire@gmail.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/aaccoder.c')
-rw-r--r--libavcodec/aaccoder.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index cd996b2..aaf70d5 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -1166,6 +1166,7 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe,
if (!cpe->common_window)
return;
for (w = 0; w < sce0->ics.num_windows; w += sce0->ics.group_len[w]) {
+ start = 0;
for (g = 0; g < sce0->ics.num_swb; g++) {
if (!cpe->ch[0].zeroes[w*16+g] && !cpe->ch[1].zeroes[w*16+g]) {
float dist1 = 0.0f, dist2 = 0.0f;
@@ -1175,22 +1176,22 @@ static void search_for_ms(AACEncContext *s, ChannelElement *cpe,
float minthr = FFMIN(band0->threshold, band1->threshold);
float maxthr = FFMAX(band0->threshold, band1->threshold);
for (i = 0; i < sce0->ics.swb_sizes[g]; i++) {
- M[i] = (sce0->pcoeffs[start+w2*128+i]
- + sce1->pcoeffs[start+w2*128+i]) * 0.5;
+ M[i] = (sce0->pcoeffs[start+(w+w2)*128+i]
+ + sce1->pcoeffs[start+(w+w2)*128+i]) * 0.5;
S[i] = M[i]
- - sce1->pcoeffs[start+w2*128+i];
+ - sce1->pcoeffs[start+(w+w2)*128+i];
}
- abs_pow34_v(L34, sce0->coeffs+start+w2*128, sce0->ics.swb_sizes[g]);
- abs_pow34_v(R34, sce1->coeffs+start+w2*128, sce0->ics.swb_sizes[g]);
+ abs_pow34_v(L34, sce0->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
+ abs_pow34_v(R34, sce1->coeffs+start+(w+w2)*128, sce0->ics.swb_sizes[g]);
abs_pow34_v(M34, M, sce0->ics.swb_sizes[g]);
abs_pow34_v(S34, S, sce0->ics.swb_sizes[g]);
- dist1 += quantize_band_cost(s, sce0->coeffs + start + w2*128,
+ dist1 += quantize_band_cost(s, sce0->coeffs + start + (w+w2)*128,
L34,
sce0->ics.swb_sizes[g],
sce0->sf_idx[(w+w2)*16+g],
sce0->band_type[(w+w2)*16+g],
lambda / band0->threshold, INFINITY, NULL);
- dist1 += quantize_band_cost(s, sce1->coeffs + start + w2*128,
+ dist1 += quantize_band_cost(s, sce1->coeffs + start + (w+w2)*128,
R34,
sce1->ics.swb_sizes[g],
sce1->sf_idx[(w+w2)*16+g],
OpenPOWER on IntegriCloud