X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fadxdec.c;h=eb05145da99393f414d3142152aea0bb2dd4571a;hb=ef6a9e5e311f09fa8032974fa4d0c1e166a959bb;hp=178ea99dcfc8f2e49d1722d63ea6e8764bae1ee1;hpb=7167ac33a8f2c7d063384c267f984f23d2b73854;p=ffmpeg diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index 178ea99dcfc..eb05145da99 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -81,7 +81,7 @@ static int adx_decode(ADXContext *c, int16_t *out, int offset, s2 = prev->s2; for (i = 0; i < BLOCK_SAMPLES; i++) { d = get_sbits(&gb, 4); - s0 = ((d * (1 << COEFF_BITS)) * scale + c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS; + s0 = d * scale + ((c->coeff[0] * s1 + c->coeff[1] * s2) >> COEFF_BITS); s2 = s1; s1 = av_clip_int16(s0); *out++ = s1; @@ -103,6 +103,22 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, const uint8_t *buf = avpkt->data; const uint8_t *buf_end = buf + avpkt->size; int num_blocks, ch, ret; + size_t new_extradata_size; + uint8_t *new_extradata; + + new_extradata = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, + &new_extradata_size); + if (new_extradata && new_extradata_size > 0) { + int header_size; + if ((ret = ff_adx_decode_header(avctx, new_extradata, + new_extradata_size, &header_size, + c->coeff)) < 0) { + av_log(avctx, AV_LOG_ERROR, "error parsing new ADX extradata\n"); + return AVERROR_INVALIDDATA; + } + + c->eof = 0; + } if (c->eof) { *got_frame_ptr = 0; @@ -183,7 +199,8 @@ AVCodec ff_adpcm_adx_decoder = { .init = adx_decode_init, .decode = adx_decode_frame, .flush = adx_decode_flush, - .capabilities = AV_CODEC_CAP_DR1, + .capabilities = AV_CODEC_CAP_CHANNEL_CONF | + AV_CODEC_CAP_DR1, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_NONE }, };