[FFmpeg-devel] [PATCH] XMA1 and XMA2 stereo decoders

Michael Niedermayer michael at niedermayer.cc
Wed Nov 11 01:02:47 CET 2015


On Wed, Nov 04, 2015 at 02:18:17PM +0100, Paul B Mahol wrote:
> Signed-off-by: Paul B Mahol <onemda at gmail.com>
[...]
> diff --git a/libavformat/riffdec.c b/libavformat/riffdec.c
> index 26779e1..5022312 100644
> --- a/libavformat/riffdec.c
> +++ b/libavformat/riffdec.c
> @@ -99,10 +99,12 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
>      codec->codec_type  = AVMEDIA_TYPE_AUDIO;
>      if (!big_endian) {
>          id                 = avio_rl16(pb);
> -        codec->channels    = avio_rl16(pb);
> -        codec->sample_rate = avio_rl32(pb);
> -        bitrate            = avio_rl32(pb) * 8LL;
> -        codec->block_align = avio_rl16(pb);
> +        if (id != 0x0165) {
> +            codec->channels    = avio_rl16(pb);
> +            codec->sample_rate = avio_rl32(pb);
> +            bitrate            = avio_rl32(pb) * 8LL;
> +            codec->block_align = avio_rl16(pb);
> +        }
>      } else {
>          id                 = avio_rb16(pb);
>          codec->channels    = avio_rb16(pb);
> @@ -126,7 +128,7 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
>          codec->codec_id  = ff_wav_codec_get_id(id,
>                                                 codec->bits_per_coded_sample);
>      }
> -    if (size >= 18) {  /* We're obviously dealing with WAVEFORMATEX */
> +    if (size >= 18 && id != 0x0165) {  /* We're obviously dealing with WAVEFORMATEX */
>          int cbSize = avio_rl16(pb); /* cbSize */
>          if (big_endian) {
>              avpriv_report_missing_feature(codec, "WAVEFORMATEX support for RIFX files\n");
> @@ -149,6 +151,19 @@ int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb,
>          /* It is possible for the chunk to contain garbage at the end */
>          if (size > 0)
>              avio_skip(pb, size);
> +    } else if (id == 0x0165 && size >= 32) {
> +        int nb_streams, i;
> +
> +        size -= 4;
> +        av_freep(&codec->extradata);
> +        if (ff_get_extradata(codec, pb, size) < 0)
> +            return AVERROR(ENOMEM);
> +        nb_streams         = AV_RL16(codec->extradata + 4);
> +        codec->sample_rate = AV_RL32(codec->extradata + 12);
> +        codec->channels    = 0;
> +        bitrate            = 0;
> +        for (i = 0; i < nb_streams; i++)
> +            codec->channels += codec->extradata[8 + i * 20 + 17];
>      }
>  

>      if (bitrate > INT_MAX) {

coverity belives that bitrate can be uninitialized here

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In a rich man's house there is no place to spit but his face.
-- Diogenes of Sinope
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20151111/243169ff/attachment.sig>


More information about the ffmpeg-devel mailing list