aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Barbato <lu_zero@gentoo.org>2013-07-09 14:44:02 +0200
committerLuca Barbato <lu_zero@gentoo.org>2013-09-21 15:02:49 +0200
commitb64bd2e18bac1bd3e3e0ae4aebcad1c33f031c66 (patch)
tree78bbcd8dcad80d5c70eef19b600622ee8454d965
parentb9dea1a085c4705e480bd17dfa8c8ce227fdce76 (diff)
downloadffmpeg-b64bd2e18bac1bd3e3e0ae4aebcad1c33f031c66.tar.gz
qdm2: refactor joined stereo support
qdm2 does support only two channels. Loop over the run once. Reported-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind CC: libav-stable@libav.org (cherry picked from commit adadc3f2443d25b375e21e801516ccfd78e0b080) Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
-rw-r--r--libavcodec/qdm2.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index 856f9a4c92..365f717bcc 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -769,7 +769,7 @@ static void fill_coding_method_array (sb_int8_array tone_level_idx, sb_int8_arra
static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int length, int sb_min, int sb_max)
{
int sb, j, k, n, ch, run, channels;
- int joined_stereo, zero_encoding, chs;
+ int joined_stereo, zero_encoding;
int type34_first;
float type34_div = 0;
float type34_predictor;
@@ -923,16 +923,18 @@ static void synthfilt_build_sb_samples (QDM2Context *q, GetBitContext *gb, int l
}
if (joined_stereo) {
- float tmp[10][MPA_MAX_CHANNELS];
-
- for (k = 0; k < run; k++) {
- tmp[k][0] = samples[k];
- tmp[k][1] = (sign_bits[(j + k) / 8]) ? -samples[k] : samples[k];
+ for (k = 0; k < run && j + k < 128; k++) {
+ q->sb_samples[0][j + k][sb] =
+ q->tone_level[0][sb][(j + k) / 2] * samples[k];
+ if (q->nb_channels == 2) {
+ if (sign_bits[(j + k) / 8])
+ q->sb_samples[1][j + k][sb] =
+ q->tone_level[1][sb][(j + k) / 2] * -samples[k];
+ else
+ q->sb_samples[1][j + k][sb] =
+ q->tone_level[1][sb][(j + k) / 2] * samples[k];
+ }
}
- for (chs = 0; chs < q->nb_channels; chs++)
- for (k = 0; k < run; k++)
- if ((j + k) < 128)
- q->sb_samples[chs][j + k][sb] = q->tone_level[chs][sb][((j + k)/2)] * tmp[k][chs];
} else {
for (k = 0; k < run; k++)
if ((j + k) < 128)