On Sat, Nov 14, 2015 at 4:48 PM, Paul B Mahol <one...@gmail.com> wrote: > On 11/14/15, Ganesh Ajjanagadde <gajjanaga...@gmail.com> wrote: >> It is known that the naive sqrt(x*x + y*y) approach for computing the >> hypotenuse suffers from overflow and accuracy issues, see e.g >> http://www.johndcook.com/blog/2010/06/02/whats-so-hard-about-finding-a-hypotenuse/. >> This adds hypot support to FFmpeg, a C99 function. >> >> On platforms without hypot, this patch for simplicity does the naive >> direct computation outlined above. Improvements can be made separately. >> >> Signed-off-by: Ganesh Ajjanagadde <gajjanaga...@gmail.com> >> --- >> configure | 2 ++ >> libavutil/libm.h | 8 ++++++++ >> 2 files changed, 10 insertions(+) >> >> diff --git a/configure b/configure >> index d518b21..45df724 100755 >> --- a/configure >> +++ b/configure >> @@ -1774,6 +1774,7 @@ MATH_FUNCS=" >> exp2 >> exp2f >> expf >> + hypot >> isinf >> isnan >> ldexpf >> @@ -5309,6 +5310,7 @@ disabled crystalhd || check_lib >> libcrystalhd/libcrystalhd_if.h DtsCrystalHDVersi >> >> atan2f_args=2 >> copysign_args=2 >> +hypot_args=2 >> ldexpf_args=2 >> powf_args=2 >> >> diff --git a/libavutil/libm.h b/libavutil/libm.h >> index 6c17b28..ab5df1b 100644 >> --- a/libavutil/libm.h >> +++ b/libavutil/libm.h >> @@ -82,6 +82,14 @@ static av_always_inline float cbrtf(float x) >> #define exp2f(x) ((float)exp2(x)) >> #endif /* HAVE_EXP2F */ >> >> +#if !HAVE_HYPOT >> +#undef hypot >> +static av_always_inline av_const double hypot(double x, double y) >> +{ >> + return sqrt(x*x + y*y); >> +} >> +#endif /* HAVE_HYPOT */ >> + >> #if !HAVE_ISINF >> static av_always_inline av_const int isinf(float x) >> { >> -- >> 2.6.2 >> >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > > nonsense. either do the right thing or don't touch the code.
Nonsense is technically incorrect: this patch is a Pareto improvement: on C99, it is a strict improvement, on others it is identical. Please refrain from such hysterical claims. I assumed incremental improvements are ok. Will resubmit with a more elaborate fallback. _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel