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

Frank Barchard fbarchard
Tue Jun 1 23:10:54 CEST 2010


On Tue, Jun 1, 2010 at 11:35 AM, Ronald S. Bultje <rsbultje at gmail.com>wrote:

> Hi,
>
> On Tue, Jun 1, 2010 at 2:28 PM, Frank Barchard <fbarchard at google.com>
> wrote:
> > Improves quality for ff vorbis encoding of silence.> +        if
> (average) {
> > +            average *= pow(tot_average / average, 0.5) * pow(1.25,
> position/200.); // MAGIC!
> > +        } else {
> > +            average = 0;
> > +        }
>
> The last 3 lines seem unnecessary?
>

True.  Fixed in updated patch.

On Tue, Jun 1, 2010 at 12:39 PM, Michael Niedermayer <michaelni at gmx.at>
 wrote:

> On Tue, Jun 01, 2010 at 11:28:40AM -0700, Frank Barchard wrote:
> > Improves quality for ff vorbis encoding of silence.
> >
> > -        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) ?
>

This works
if (average) average *= sqrt(tot_average / average) * pow(1.25f, position*
0.005f); // MAGIC!

Tested with tiny_psnr, as well as listening - no difference using sqrt
vs pow(,0.5).
Updated patch attached.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vorbis_divzero_fixsqrt.patch
Type: application/octet-stream
Size: 612 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100601/9931a1f1/attachment.obj>



More information about the ffmpeg-devel mailing list