Hi, 2014-08-31 23:30 GMT+02:00 Justin Ruggles <[email protected]>: > Masking the value when writing should be unnecessary since it is already > masked out above.
You're right. Patch updated and refreshed. -- Christophe
From 51bc1237bf97af33d1094559bca10359ed689524 Mon Sep 17 00:00:00 2001 From: Christophe Gisquet <[email protected]> Date: Sun, 17 Aug 2014 18:56:45 +0200 Subject: [PATCH 2/3] alacenc: fix extra bits extraction The raw coded bits are extracted prior to decorrelation, as is correctly performed by the decoder, and not after. --- libavcodec/alacenc.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/libavcodec/alacenc.c b/libavcodec/alacenc.c index 117813c..87149db 100644 --- a/libavcodec/alacenc.c +++ b/libavcodec/alacenc.c @@ -394,6 +394,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 @@ -416,11 +429,9 @@ static void write_element(AlacEncodeContext *s, // write extra bits if needed if (s->extra_bits) { - 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]); } } } -- 1.9.2.msysgit.0
_______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
