summaryrefslogtreecommitdiffstats
path: root/libavcodec/adxdec.c
diff options
context:
space:
mode:
authorJustin Ruggles <justin.ruggles@gmail.com>2011-11-20 14:21:32 -0500
committerJustin Ruggles <justin.ruggles@gmail.com>2011-11-26 16:25:06 -0500
commitb237248e297760648307356efa5fcbfe16844829 (patch)
tree76ac03216c87ddc68904f9abe3e1e5a89c25604b /libavcodec/adxdec.c
parent954d94dd5e13ba7a5e9e049d0f980bddced9644c (diff)
downloadffmpeg-streaming-b237248e297760648307356efa5fcbfe16844829.zip
ffmpeg-streaming-b237248e297760648307356efa5fcbfe16844829.tar.gz
adx: calculate correct LPC coeffs
Instead of using fixed coefficients, the correct way is to calculate the coefficients using the highpass cutoff frequency from the ADX stream header and the sample rate.
Diffstat (limited to 'libavcodec/adxdec.c')
-rw-r--r--libavcodec/adxdec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index 93bbc6b..f9f17cd 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -59,7 +59,7 @@ static void adx_decode(ADXContext *c, int16_t *out, const uint8_t *in, int ch)
s2 = prev->s2;
for (i = 0; i < 32; i++) {
d = get_sbits(&gb, 4);
- s0 = ((d << COEFF_BITS) * scale + COEFF1 * s1 - COEFF2 * s2) >> COEFF_BITS;
+ s0 = ((d << COEFF_BITS) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS;
s2 = s1;
s1 = av_clip_int16(s0);
*out = s1;
@@ -81,7 +81,7 @@ static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
int bufsize)
{
ADXContext *c = avctx->priv_data;
- int offset;
+ int offset, cutoff;
if (AV_RB16(buf) != 0x8000)
return AVERROR_INVALIDDATA;
@@ -98,6 +98,9 @@ static int adx_decode_header(AVCodecContext *avctx, const uint8_t *buf,
return AVERROR_INVALIDDATA;
avctx->bit_rate = avctx->sample_rate * avctx->channels * 18 * 8 / 32;
+ cutoff = AV_RB16(buf + 16);
+ ff_adx_calculate_coeffs(cutoff, avctx->sample_rate, COEFF_BITS, c->coeff);
+
return offset;
}
OpenPOWER on IntegriCloud