Message ID | 20180103081424.47388-3-misty@brew.sh |
---|---|
State | Superseded |
Headers | show |
On Wed, Jan 03, 2018 at 07:14:23PM +1100, misty@brew.sh wrote: > From: Misty De Meo <mistydemeo@gmail.com> > > --- > libavcodec/adpcm.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c > index be206c55ba..50ffba0db6 100644 > --- a/libavcodec/adpcm.c > +++ b/libavcodec/adpcm.c > @@ -1115,6 +1115,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, > int16_t *out1 = samples_p[1]; > int samples_per_block = 28 * (3 - avctx->channels) * 4; > int sample_offset = 0; > + int bytes_remaining = 0; > while (bytestream2_get_bytes_left(&gb) >= 128) { > if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb), > &c->status[0], &c->status[1], > @@ -1123,6 +1124,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, > bytestream2_skipu(&gb, 128); > sample_offset += samples_per_block; > } > + /* Less than a full block of data left, e.g. when reading from > + * 2324 byte per sector XA; the remainder is padding */ > + bytes_remaining = bytestream2_get_bytes_left(&gb); the initialization to 0 is unneeded [...]
From: Misty De Meo <mistydemeo@gmail.com> > the initialization to 0 is unneeded OK - updated in the included patch. I've also included a second patch which adds an explicit goto and break in aiffdec, on top of the patch you already applied, and the Changelog entry that I forgot to include in that patch. I realize it's a niche format, but how do you feel about including the fate test for this? It's in this mail: http://ffmpeg.org/pipermail/ffmpeg-devel/2018-January/223413.html Misty De Meo (2): adpcm: consume remainder after consuming XA chunks aiff: add explicit goto got_sound Changelog | 1 + libavcodec/adpcm.c | 7 +++++++ libavformat/aiffdec.c | 3 +++ 3 files changed, 11 insertions(+)
diff --git a/libavcodec/adpcm.c b/libavcodec/adpcm.c index be206c55ba..50ffba0db6 100644 --- a/libavcodec/adpcm.c +++ b/libavcodec/adpcm.c @@ -1115,6 +1115,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, int16_t *out1 = samples_p[1]; int samples_per_block = 28 * (3 - avctx->channels) * 4; int sample_offset = 0; + int bytes_remaining = 0; while (bytestream2_get_bytes_left(&gb) >= 128) { if ((ret = xa_decode(avctx, out0, out1, buf + bytestream2_tell(&gb), &c->status[0], &c->status[1], @@ -1123,6 +1124,12 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data, bytestream2_skipu(&gb, 128); sample_offset += samples_per_block; } + /* Less than a full block of data left, e.g. when reading from + * 2324 byte per sector XA; the remainder is padding */ + bytes_remaining = bytestream2_get_bytes_left(&gb); + if (bytes_remaining > 0) { + bytestream2_skip(&gb, bytes_remaining); + } break; } case AV_CODEC_ID_ADPCM_IMA_EA_EACS:
From: Misty De Meo <mistydemeo@gmail.com> --- libavcodec/adpcm.c | 7 +++++++ 1 file changed, 7 insertions(+)