aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Gisquet <christophe.gisquet@gmail.com>2014-08-17 18:56:45 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-30 21:53:11 +0200
commit60f94f708414b187724d42e904b1b3aabe24ad85 (patch)
tree66ef5ecf1f42f7a6c25ff30aea90f7b79a5339ff
parent7f7cf051edd3562af199be97864e03bc3e3ceda0 (diff)
downloadffmpeg-60f94f708414b187724d42e904b1b3aabe24ad85.tar.gz
alacenc: fix extra bits extraction
The raw coded bits are extracted prior to decorrelation, as is correctly performed by the decoder, and not after. Fixes ticket #2768. Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 96d217832598da7001bc204706476dd1e37f377e) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavcodec/alacenc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c
index e92831f621..56cbfdcedb 100644
--- a/libavcodec/alacenc.c
+++ b/libavcodec/alacenc.c
@@ -395,6 +395,19 @@ static void write_element(AlacEncodeContext *s,
init_sample_buffers(s, channels, samples);
write_element_header(s, element, instance);
+ // extract extra bits if needed
+ if (s->extra_bits) {
+ uint32_t mask = (1 << s->extra_bits) - 1;
+ for (j = 0; j < channels; j++) {
+ int32_t *extra = s->predictor_buf[j];
+ int32_t *smp = s->sample_buf[j];
+ for (i = 0; i < s->frame_size; i++) {
+ extra[i] = smp[i] & mask;
+ smp[i] >>= s->extra_bits;
+ }
+ }
+ }
+
if (channels == 2)
alac_stereo_decorrelation(s);
else
@@ -420,8 +433,7 @@ static void write_element(AlacEncodeContext *s,
uint32_t mask = (1 << s->extra_bits) - 1;
for (i = 0; i < s->frame_size; i++) {
for (j = 0; j < channels; j++) {
- put_bits(pb, s->extra_bits, s->sample_buf[j][i] & mask);
- s->sample_buf[j][i] >>= s->extra_bits;
+ put_bits(pb, s->extra_bits, s->predictor_buf[j][i] & mask);
}
}
}