Re: [FFmpeg-devel] [PATCH 11/11] avutil/rational: use frexp rather than ad-hoc log to get floating point exponent

2015-10-30 Thread Ganesh Ajjanagadde
On Fri, Oct 30, 2015 at 7:14 PM, Michael Niedermayer
 wrote:
> On Thu, Oct 29, 2015 at 12:20:09AM -0400, Ganesh Ajjanagadde wrote:
>> This simplifies and cleans up the code.
>> Furthermore, it is much faster due to absence of the slow log computation.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>> ---
>>  libavutil/rational.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> LGTM and nice speedup!

pushed, thanks.

>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Dictatorship naturally arises out of democracy, and the most aggravated
> form of tyranny and slavery out of the most extreme liberty. -- Plato
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 11/11] avutil/rational: use frexp rather than ad-hoc log to get floating point exponent

2015-10-30 Thread Michael Niedermayer
On Thu, Oct 29, 2015 at 12:20:09AM -0400, Ganesh Ajjanagadde wrote:
> This simplifies and cleans up the code.
> Furthermore, it is much faster due to absence of the slow log computation.
> 
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/rational.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

LGTM and nice speedup!


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

Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 11/11] avutil/rational: use frexp rather than ad-hoc log to get floating point exponent

2015-10-29 Thread Ganesh Ajjanagadde
On Thu, Oct 29, 2015 at 12:20 AM, Ganesh Ajjanagadde
 wrote:
> This simplifies and cleans up the code.
> Furthermore, it is much faster due to absence of the slow log computation.
>
> Signed-off-by: Ganesh Ajjanagadde 
> ---
>  libavutil/rational.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/rational.c b/libavutil/rational.c
> index 21d2bb7..81a9402 100644
> --- a/libavutil/rational.c
> +++ b/libavutil/rational.c
> @@ -106,14 +106,14 @@ AVRational av_sub_q(AVRational b, AVRational c)
>  AVRational av_d2q(double d, int max)
>  {
>  AVRational a;
> -#define LOG2  0.69314718055994530941723212145817656807550013436025
>  int exponent;
>  int64_t den;
>  if (isnan(d))
>  return (AVRational) { 0,0 };
>  if (fabs(d) > INT_MAX + 3LL)
>  return (AVRational) { d < 0 ? -1 : 1, 0 };
> -exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
> +frexp(d, &exponent);
> +exponent = FFMAX(exponent-1, 0);
>  den = 1LL << (61 - exponent);
>  // (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64
>  av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
> --
> 2.6.2
>

Just a note, so that this is not buried: wm4's comment (which I still
disagree with) does not apply to this patch.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 11/11] avutil/rational: use frexp rather than ad-hoc log to get floating point exponent

2015-10-28 Thread Ganesh Ajjanagadde
This simplifies and cleans up the code.
Furthermore, it is much faster due to absence of the slow log computation.

Signed-off-by: Ganesh Ajjanagadde 
---
 libavutil/rational.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/rational.c b/libavutil/rational.c
index 21d2bb7..81a9402 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -106,14 +106,14 @@ AVRational av_sub_q(AVRational b, AVRational c)
 AVRational av_d2q(double d, int max)
 {
 AVRational a;
-#define LOG2  0.69314718055994530941723212145817656807550013436025
 int exponent;
 int64_t den;
 if (isnan(d))
 return (AVRational) { 0,0 };
 if (fabs(d) > INT_MAX + 3LL)
 return (AVRational) { d < 0 ? -1 : 1, 0 };
-exponent = FFMAX( (int)(log(fabs(d) + 1e-20)/LOG2), 0);
+frexp(d, &exponent);
+exponent = FFMAX(exponent-1, 0);
 den = 1LL << (61 - exponent);
 // (int64_t)rint() and llrint() do not work with gcc on ia64 and sparc64
 av_reduce(&a.num, &a.den, floor(d * den + 0.5), den, max);
-- 
2.6.2

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel