[FFmpeg-devel] [PATCH] vorbis_enc.c: avoid div zero that causes noise

Michael Niedermayer michaelni
Tue Jun 1 21:39:32 CEST 2010


On Tue, Jun 01, 2010 at 11:28:40AM -0700, Frank Barchard wrote:
> Improves quality for ff vorbis encoding of silence.
> 
> Some audio files had clicking, typically at the beginning or end.  It was
> tracked down to a divide by zero.
> Two samples that improve in quality with the patch are:
> pitivi - http://jeff.ecchi.ca/public/test-html5.html
> red -
> http://movies.apple.com/movies/us/hd_gallery/gl1800/1080p/artbeats_red_m1080p.mov

>  vorbis_enc.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> a722e06c3d168792378167c715af092f1bdbf9c2  vorbis_divzero_fix.patch
> Index: libavcodec/vorbis_enc.c
> ===================================================================
> --- libavcodec/vorbis_enc.c	(revision 23412)
> +++ libavcodec/vorbis_enc.c	(working copy)
> @@ -681,7 +681,11 @@
>          float average = averages[i];
>          int j;
>  
> -        average *= pow(tot_average / average, 0.5) * pow(1.25, position/200.); // MAGIC!
> +        if (average) {
> +            average *= pow(tot_average / average, 0.5) * pow(1.25, position/200.); // MAGIC!

does
average= sqrt(tot_average * average) *  pow(1.25, position*0.005)

work as well (without the 0 special casing of course) ?

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

Freedom in capitalist society always remains about the same as it was in
ancient Greek republics: Freedom for slave owners. -- Vladimir Lenin
-------------- 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/20100601/741a1a16/attachment.pgp>



More information about the ffmpeg-devel mailing list