[FFmpeg-devel] [PATCH] let the ffpcm set sample_fmt for wav audio streams
Baptiste Coudurier
baptiste.coudurier
Thu Nov 26 21:12:06 CET 2009
On 11/26/09 10:20 AM, Jai Menon wrote:
> On Thu, Nov 26, 2009 at 06:12:17PM +0100, Michael Niedermayer wrote:
>> On Thu, Nov 26, 2009 at 05:43:28PM +0530, Jai Menon wrote:
>>> Hi,
>>>
>>> All the 24bit PCM WAV files I have show the wrong sample_fmt. Would it
>>> be okay if we let the decoder set correct sample_fmt instead of the
>>> default s16. Attached patch is more or less what I mean. Please tell
>>> me if I'm missing something, or if there is a better way to show
>>> correct stream info.
>>> Thanks.
>>>
>>> --
>>> Jai Menon
>>
>>> riff.c | 2 ++
>>> 1 file changed, 2 insertions(+)
>>> f6e0cd818e7c167c93fe9e4baec767455af2bac3 sample_fmt_wav.patch
>>> Index: libavformat/riff.c
>>> ===================================================================
>>> --- libavformat/riff.c (revision 20584)
>>> +++ libavformat/riff.c (working copy)
>>> @@ -450,6 +450,8 @@
>>> codec->sample_rate = get_le32(pb);
>>> codec->bit_rate = get_le32(pb) * 8;
>>> codec->block_align = get_le16(pb);
>>> + codec->sample_fmt = SAMPLE_FMT_NONE;
>>
>> you want to change
>> s->sample_fmt= SAMPLE_FMT_S16; // FIXME: set to NONE
>> in avcodec_get_context_defaults2()
>> i suspect ...
>> dunno if that can just done or if it will need more changes but adding
>> =NONE hacks in lavf is not a good idea
>
> Indeed, my bad. I really think the fixme is correct though and the
> decoder should do the right thing. I verified that make codectest
> passes (fulltest fails because lavftest reference needs to be updated,
> but thats a different issue). Patch attached. If something breaks
> later, I guess we can "fix" it by setting correct sample_fmt in that
> case.
>
>
>
> sample_fmt_fix.patch
>
>
> diff --git a/libavcodec/options.c b/libavcodec/options.c
> index ded294e..fa64294 100644
> --- a/libavcodec/options.c
> +++ b/libavcodec/options.c
> @@ -437,7 +437,7 @@ void avcodec_get_context_defaults2(AVCodecContext *s, enum CodecType codec_type)
> s->execute2= avcodec_default_execute2;
> s->sample_aspect_ratio= (AVRational){0,1};
> s->pix_fmt= PIX_FMT_NONE;
> - s->sample_fmt= SAMPLE_FMT_S16; // FIXME: set to NONE
> + s->sample_fmt= SAMPLE_FMT_NONE;
>
> s->palctrl = NULL;
> s->reget_buffer= avcodec_default_reget_buffer;
>
>
Please apply it :)
--
Baptiste COUDURIER
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
FFmpeg maintainer http://www.ffmpeg.org
More information about the ffmpeg-devel
mailing list