[FFmpeg-devel] [PATCH] avcodec: loongson fix optimized ff_sqrt bug
Michael Niedermayer
michaelni at gmx.at
Thu May 14 13:42:33 CEST 2015
On Thu, May 14, 2015 at 05:49:32PM +0800, 周晓勇 wrote:
> From a825fc8ad61d6296d12cc4074eda494e4b978fa3 Mon Sep 17 00:00:00 2001
> From: ZhouXiaoyong <zhouxiaoyong at loongson.cn>
> Date: Fri, 15 May 2015 01:30:42 +0800
> Subject: [PATCH] avcodec: loongson fix optimized ff_sqrt bug
>
> Signed-off-by: ZhouXiaoyong <zhouxiaoyong at loongson.cn>
> ---
> libavcodec/mips/mathops.h | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/libavcodec/mips/mathops.h b/libavcodec/mips/mathops.h
> index cdc7705..76a0f2d 100644
> --- a/libavcodec/mips/mathops.h
> +++ b/libavcodec/mips/mathops.h
> @@ -76,15 +76,12 @@ static inline av_const int mid_pred(int a, int b, int c)
> #define ff_sqrt ff_sqrt
> static inline av_const unsigned int ff_sqrt(unsigned int a)
> {
> - unsigned int b;
> + float b;
> + __asm__ ("sqrt.s %0, %1 \n\t"
> + : "=f"(b)
> + : "f"((float)a));
>
> - __asm__ ("ctc1 %1, $f0 \n\t"
> - "sqrt.s $f2, $f0 \n\t"
> - "cvt.w.s $f0, $f2 \n\t"
> - "cfc1 %0, $f0 \n\t"
> - : "=r"(b)
> - : "r"(a));
> - return b;
> + return (unsigned int)b;
this is not ok
you cant use C floats for implementing integer code
integer code, like ff_sqrt must be bitexact, floats per C spec are not
bitexact
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The real ebay dictionary, page 2
"100% positive feedback" - "All either got their money back or didnt complain"
"Best seller ever, very honest" - "Seller refunded buyer after failed scam"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150514/337da535/attachment.asc>
More information about the ffmpeg-devel
mailing list