[FFmpeg-devel] [PATCH] PCM: fail gracefully if the audio parameters are wrong.
Michael Niedermayer
michaelni
Thu Apr 10 18:33:51 CEST 2008
On Thu, Apr 10, 2008 at 05:02:59PM +0200, Nicolas George wrote:
> Hi.
>
> The attached patch checks that the sample rate and channels count is correct
> for raw PCM files.
>
> If the channels count is not set in the AVFormatParameters,
> av_find_stream_info crashes on a division by zero, which is not cool. The
> problem does not occur with ffmpeg itself, since it always sets the sample
> rate and the channels count.
>
> Regards,
>
> --
> Nicolas George
> diff --git a/libavformat/raw.c b/libavformat/raw.c
> index d4b1389..81215b4 100644
> --- a/libavformat/raw.c
> +++ b/libavformat/raw.c
> @@ -80,6 +80,12 @@ static int raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
>
> switch(st->codec->codec_type) {
> case CODEC_TYPE_AUDIO:
> + if(ap->sample_rate == 0 || ap->channels == 0) {
> + av_log(s, AV_LOG_ERROR,
> + "Bad sample rate (%d) or channels count (%d)\n",
> + ap->sample_rate, ap->channels);
> + return -1;
> + }
First there are tabs
Second the patch is fundamentally wrong as neither sample rate nor channels
are needed for demuxing raw. (in principle, what the actual code needs is
not an argument, the code can be buggy)
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080410/e1c83107/attachment.pgp>
More information about the ffmpeg-devel
mailing list