-
-
Save rcombs/2ee9b4bb33f5568031db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 02014d4816de6fd5501f8db1634143401b4ebd0e | |
Author: Rodger Combs <rodger.combs@gmail.com> | |
Date: Fri Jun 19 02:51:32 2015 -0500 | |
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). | |
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c | |
index 94b4de1..c6ca880 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_, \ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment