[FFmpeg-devel] [PATCH 2/3] adpcm: consume remainder after consuming XA chunks

Michael Niedermayer michael at niedermayer.cc
Thu Jan 4 22:39:01 EET 2018


On Wed, Jan 03, 2018 at 07:14:23PM +1100, misty at brew.sh wrote:
> From: Misty De Meo <mistydemeo at 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

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180104/7830e19e/attachment.sig>


More information about the ffmpeg-devel mailing list