[FFmpeg-devel] Patch: add sanity checks for bitrate

Michael Niedermayer michaelni
Fri Aug 20 00:08:04 CEST 2010


On Fri, Aug 06, 2010 at 04:50:21PM +0200, Christian P. Schmidt wrote:
> I've encountered a .ogm that triggered assertions in libavformat's
> estimate_timings_from_bitrate. The root cause was a negative value (-1)
> in the vorbis headers of the audio tracks.
> 
> Attached patch adds sanity checks to the ogg vorbis parser as well as
> the estimate_timings_from_bitrate function.
> 
> Regards,
> Christian

>  oggparsevorbis.c |    6 ++++--
>  utils.c          |    4 ++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 0f6719cb53e64a409722455c8177bfa3ce1bfa8b  sanitycheck_bitrates.patch
> Index: libavformat/oggparsevorbis.c
> ===================================================================
> --- libavformat/oggparsevorbis.c	(revision 24715)
> +++ libavformat/oggparsevorbis.c	(working copy)
> @@ -147,8 +147,8 @@
>   * [audio_channels] = read 8 bit integer as unsigned | Used
>   * [audio_sample_rate] = read 32 bits as unsigned integer | Used
>   * [bitrate_maximum] = read 32 bits as signed integer | Not used yet
> - * [bitrate_nominal] = read 32 bits as signed integer | Not used yet
> - * [bitrate_minimum] = read 32 bits as signed integer | Used as bitrate
> + * [bitrate_nominal] = read 32 bits as signed integer | Used as bitrate
> + * [bitrate_minimum] = read 32 bits as signed integer | Not used yet
>   * [blocksize_0] = read 4 bits as unsigned integer | Not Used
>   * [blocksize_1] = read 4 bits as unsigned integer | Not Used
>   * [framing_flag] = read one bit | Not Used
> @@ -223,6 +223,8 @@
>          st->codec->sample_rate = bytestream_get_le32(&p);
>          p += 4; // skip maximum bitrate
>          st->codec->bit_rate = bytestream_get_le32(&p); // nominal bitrate
> +        if (st->codec->bit_rate<0)
> +            st->codec->bit_rate = 0;
>          p += 4; // skip minimum bitrate
>  
>          blocksize = bytestream_get_byte(&p);
> Index: libavformat/utils.c
> ===================================================================
> --- libavformat/utils.c	(revision 24715)
> +++ libavformat/utils.c	(working copy)
> @@ -1837,7 +1837,7 @@
>      AVStream *st;
>  
>      /* if bit_rate is already set, we believe it */
> -    if (ic->bit_rate == 0) {
> +    if (ic->bit_rate <= 0) {

i dont think that generic code should treat negative bitrate as a unknown
value but rather an internal error.

no comment on the changes to ogg* as i dont maintain that

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

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100820/62364974/attachment.pgp>



More information about the ffmpeg-devel mailing list