[FFmpeg-devel] [PATCH 08/11] avfilter/avf_showvolume: use log10 instead of log()/M_LN10

Ganesh Ajjanagadde gajjanagadde at gmail.com
Fri Oct 30 00:12:52 CET 2015


On Thu, Oct 29, 2015 at 9:35 AM, Ganesh Ajjanagadde
<gajjanagadde at gmail.com> wrote:
>
> On Oct 29, 2015 9:26 AM, "Ronald S. Bultje" <rsbultje at gmail.com> wrote:
>>
>> Hi,
>>
>> On Thu, Oct 29, 2015 at 8:47 AM, Ganesh Ajjanagadde <gajjanag at mit.edu>
>> wrote:
>>
>> > On Thu, Oct 29, 2015 at 8:22 AM, Paul B Mahol <onemda at gmail.com> wrote:
>> > > On 10/29/15, Ganesh Ajjanagadde <gajjanagadde at gmail.com> wrote:
>> > >> This is likely more precise and conveys the intent better.
>> > >>
>> > >> Signed-off-by: Ganesh Ajjanagadde <gajjanagadde at gmail.com>
>> > >> ---
>> > >>  libavfilter/avf_showvolume.c | 2 +-
>> > >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> > >>
>> > >> diff --git a/libavfilter/avf_showvolume.c
>> > >> b/libavfilter/avf_showvolume.c
>> > >> index 95b5388..395375a 100644
>> > >> --- a/libavfilter/avf_showvolume.c
>> > >> +++ b/libavfilter/avf_showvolume.c
>> > >> @@ -197,7 +197,7 @@ static int filter_frame(AVFilterLink *inlink,
>> > AVFrame
>> > >> *insamples)
>> > >>              max = FFMAX(max, src[i]);
>> > >>
>> > >>          max = av_clipf(max, 0, 1);
>> > >> -        values[VAR_VOLUME] = 20.0 * log(max) / M_LN10;
>> > >> +        values[VAR_VOLUME] = 20.0 * log10(max);
>> > >>          values[VAR_CHANNEL] = c;
>> > >>          color = av_expr_eval(s->c_expr, values, NULL);
>> > >>
>> > >> --
>> > >> 2.6.2
>> > >
>> > > Have you checked which one is faster?
>> > > I really have no opinion on this but gain is neglible.
>> >
>> > No, I have not. I suspect, but have not confirmed that log10 is
>> > slightly slower:
>> >
>> >
>> > https://stackoverflow.com/questions/10810105/explanation-wanted-log10-faster-than-log-and-log2-but-only-with-o2-and-greater
>> > (janneb's comment). Keep in mind their benchmark did not include the
>> > cost of a division.
>>
>>
>> A good compiler (including yours) will merge the division into the
>> multiply:
>> a * func(x) / c
>> is the same as:
>> (a / c) * func(x)
>>
>> and the compiler can pre-calculate the output of a/c into a single
>> constant.
>
> Not necessarily, floating point is not associative.

pushed, thanks.

>
>>
>> Ronald
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list