diff options
author | Rodger Combs <rodger.combs@gmail.com> | 2015-06-20 05:01:27 -0500 |
---|---|---|
committer | Paul B Mahol <onemda@gmail.com> | 2015-06-21 10:32:13 +0000 |
commit | 0f6735194459d8be1a07340f544b4f2c8f1fa316 (patch) | |
tree | 820904dac542ca048b947d3cf1e214290b3f2837 /libavcodec/adpcm.c | |
parent | d2ce10093e374709c5ea660d9b26f05043f1a6cd (diff) | |
download | ffmpeg-0f6735194459d8be1a07340f544b4f2c8f1fa316.tar.gz |
lavc/adpcm: THP: don't use the ADPC/SEEK table when not seeking
This is almost certainly closer to how the actual Nintendo players work,
and fixes some output pops in files with blank ADPC/SEEK tables (like
those from brawlcustommusic).
Diffstat (limited to 'libavcodec/adpcm.c')
-rw-r--r-- | libavcodec/adpcm.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index 94b4de19ed..c6ca8803db 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -86,6 +86,7 @@ static const int swf_index_tables[4][16] = { typedef struct ADPCMDecodeContext { ADPCMChannelStatus status[10]; int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */ + int has_status; } ADPCMDecodeContext; static av_cold int adpcm_decode_init(AVCodecContext * avctx) @@ -1455,10 +1456,15 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, for (n = 0; n < 16; n++) table[i][n] = THP_GET16(gb); - /* Initialize the previous sample. */ - for (i = 0; i < avctx->channels; i++) { - c->status[i].sample1 = THP_GET16(gb); - c->status[i].sample2 = THP_GET16(gb); + if (!c->has_status) { + /* Initialize the previous sample. */ + for (i = 0; i < avctx->channels; i++) { + c->status[i].sample1 = THP_GET16(gb); + c->status[i].sample2 = THP_GET16(gb); + } + c->has_status = 1; + } else { + bytestream2_skip(&gb, avctx->channels * 4); } } @@ -1562,6 +1568,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, return bytestream2_tell(&gb); } +static void adpcm_flush(AVCodecContext *avctx) +{ + ADPCMDecodeContext *c = avctx->priv_data; + c->has_status = 0; +} + static const enum AVSampleFormat sample_fmts_s16[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }; @@ -1580,6 +1592,7 @@ AVCodec ff_ ## name_ ## _decoder = { \ .priv_data_size = sizeof(ADPCMDecodeContext), \ .init = adpcm_decode_init, \ .decode = adpcm_decode_frame, \ + .flush = adpcm_flush, \ .capabilities = CODEC_CAP_DR1, \ .sample_fmts = sample_fmts_, \ } |