diff options
author | Zane van Iperen <zane@zanevaniperen.com> | 2020-11-02 15:47:24 +1000 |
---|---|---|
committer | Zane van Iperen <zane@zanevaniperen.com> | 2020-11-09 14:58:37 +1000 |
commit | 50d3a751aab0bd7a831b12f8336c47c315a5f579 (patch) | |
tree | 834bfb08005797df73f459786e6bd1e7a44c6803 /libavcodec/adpcm.c | |
parent | d6912294d39b5d15cba0236e06e5a3710e57a1a0 (diff) |
avcodec/adpcm_ima_amv: use coded sample count
Signed-off-by: Zane van Iperen <zane@zanevaniperen.com>
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r-- | libavcodec/adpcm.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 7b618dba17..7762694e3e 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -775,7 +775,6 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, case AV_CODEC_ID_ADPCM_IMA_DAT4: case AV_CODEC_ID_ADPCM_IMA_MOFLEX: case AV_CODEC_ID_ADPCM_IMA_ISS: header_size = 4 * ch; break; - case AV_CODEC_ID_ADPCM_IMA_AMV: header_size = 8; break; case AV_CODEC_ID_ADPCM_IMA_SMJPEG: header_size = 4 * ch; break; } if (header_size > 0) @@ -783,6 +782,13 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb, /* more complex formats */ switch (avctx->codec->id) { + case AV_CODEC_ID_ADPCM_IMA_AMV: + bytestream2_skip(gb, 4); + has_coded_samples = 1; + *coded_samples = bytestream2_get_le32u(gb); + nb_samples = FFMIN((buf_size - 8) * 2, *coded_samples); + bytestream2_seek(gb, -8, SEEK_CUR); + break; case AV_CODEC_ID_ADPCM_EA: has_coded_samples = 1; *coded_samples = bytestream2_get_le32(gb); @@ -1699,6 +1705,17 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3); *samples++ = adpcm_ima_expand_nibble(&c->status[0], v & 0xf, 3); } + + if (nb_samples & 1) { + int v = bytestream2_get_byteu(&gb); + *samples++ = adpcm_ima_expand_nibble(&c->status[0], v >> 4, 3); + + if (v & 0x0F) { + /* Holds true on all the http://samples.mplayerhq.hu/amv samples. */ + av_log(avctx, AV_LOG_WARNING, "Last nibble set on packet with odd sample count.\n"); + av_log(avctx, AV_LOG_WARNING, "Sample will be skipped.\n"); + } + } break; case AV_CODEC_ID_ADPCM_IMA_SMJPEG: for (i = 0; i < avctx->channels; i++) { |