diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-18 20:10:30 +0100 |
---|---|---|
committer | Justin Ruggles <justin.ruggles@gmail.com> | 2012-01-03 16:28:17 -0500 |
commit | 4f1a787744ee79137f224c08b9283d028a272d60 (patch) | |
tree | 3bec85be5e2921c2d89dc3a79c56bc83fe036fc0 /libavcodec/adxdec.c | |
parent | cbaef7d16ef53d34fc0b3e3915a2d5a5909aadf0 (diff) | |
download | ffmpeg-4f1a787744ee79137f224c08b9283d028a272d60.tar.gz |
adxdec: Do not require extradata.
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: Justin Ruggles <justin.ruggles@gmail.com>
Diffstat (limited to 'libavcodec/adxdec.c')
-rw-r--r-- | libavcodec/adxdec.c | 35 |
1 files changed, 26 insertions, 9 deletions
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c index e9104133fa..4ccaf2e9f2 100644 --- a/libavcodec/adxdec.c +++ b/libavcodec/adxdec.c @@ -38,16 +38,16 @@ static av_cold int adx_decode_init(AVCodecContext *avctx) ADXContext *c = avctx->priv_data; int ret, header_size; - if (avctx->extradata_size < 24) - return AVERROR_INVALIDDATA; - - if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata, - avctx->extradata_size, &header_size, - c->coeff)) < 0) { - av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); - return AVERROR_INVALIDDATA; + if (avctx->extradata_size >= 24) { + if ((ret = avpriv_adx_decode_header(avctx, avctx->extradata, + avctx->extradata_size, &header_size, + c->coeff)) < 0) { + av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); + return AVERROR_INVALIDDATA; + } + c->channels = avctx->channels; + c->header_parsed = 1; } - c->channels = avctx->channels; avctx->sample_fmt = AV_SAMPLE_FMT_S16; @@ -107,6 +107,23 @@ static int adx_decode_frame(AVCodecContext *avctx, void *data, return buf_size; } + if (!c->header_parsed && buf_size >= 2 && AV_RB16(buf) == 0x8000) { + int header_size; + if ((ret = avpriv_adx_decode_header(avctx, buf, buf_size, &header_size, + c->coeff)) < 0) { + av_log(avctx, AV_LOG_ERROR, "error parsing ADX header\n"); + return AVERROR_INVALIDDATA; + } + c->channels = avctx->channels; + c->header_parsed = 1; + if (buf_size < header_size) + return AVERROR_INVALIDDATA; + buf += header_size; + buf_size -= header_size; + } + if (!c->header_parsed) + return AVERROR_INVALIDDATA; + /* calculate number of blocks in the packet */ num_blocks = buf_size / (BLOCK_SIZE * c->channels); |