[FFmpeg-devel] [PATCH] fix the SAMPLE_FMT_NONE case in ffmdec.c

Måns Rullgård mans
Tue Mar 16 17:26:00 CET 2010


"Ronald S. Bultje" <rsbultje at gmail.com> writes:

> Hi Peter,
>
> On Tue, Mar 16, 2010 at 2:34 AM, Peter Ross <pross at xvid.org> wrote:
>> On Mon, Mar 15, 2010 at 04:15:10PM -0400, Ronald S. Bultje wrote:
>>> --- libavformat/ffmdec.c ? ? ?(revision 22550)
>>> +++ libavformat/ffmdec.c ? ? ?(working copy)
>>> @@ -355,6 +355,8 @@
>>> ? ? ? ? ? ? ?codec->channels = get_le16(pb);
>>> ? ? ? ? ? ? ?codec->frame_size = get_le16(pb);
>>
>>> ? ? ? ? ? ? ?codec->sample_fmt = get_le16(pb);
>>> + ? ? ? ? ? ?if (codec->sample_fmt == (1 << 16) - 1)
>>> + ? ? ? ? ? ? ? ?codec->sample_fmt = -1;
>>
>> why not read it as a signed 16-bit integer? e.g.
>> ? ? ? ?codec->sample_fmt = sign_extend( get_le16(), 16 )
>
> True, I didn't know it existed, thanks for the pointer. New patch
> attached (works the same as previous).
>
> Ronald
>
> Index: libavformat/ffmdec.c
> ===================================================================
> --- libavformat/ffmdec.c	(revision 22565)
> +++ libavformat/ffmdec.c	(working copy)
> @@ -21,6 +21,7 @@
>  
>  #include "libavutil/intreadwrite.h"
>  #include "avformat.h"
> +#include "libavcodec/get_bits.h"
>  #include "ffm.h"
>  #if CONFIG_FFSERVER
>  #include <unistd.h>
> @@ -354,7 +355,7 @@
>              codec->sample_rate = get_be32(pb);
>              codec->channels = get_le16(pb);
>              codec->frame_size = get_le16(pb);
> -            codec->sample_fmt = get_le16(pb);
> +            codec->sample_fmt = sign_extend(get_le16(pb), 16);
>              break;
>          default:
>              goto fail;

sign_extend() is in mathops.h, not get_bits.h

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list