Re: [FFmpeg-devel] [PATCH] avcodec/aacenc_is: replace pow(x, 0.75) by x/sqrtf(sqrtf(x))

2016-01-14 Thread Ganesh Ajjanagadde
On Wed, Jan 13, 2016 at 11:27 PM, Claudio Freire  wrote:
> On Mon, Jan 11, 2016 at 7:23 PM, Ganesh Ajjanagadde
>  wrote:
>> This is quite an accurate approximation; testing shows ~ 2ulp error in
>> the floating point result. Tested with FATE.
>>
>> Alternatively, if one wants "full accuracy", one can use powf, or sqrt
>> instead of sqrtf. With powf, one gets 1 ulp error (theoretically should be 
>> 0, as
>> 0.75 is exactly representable) on GNU libm, with sqrt, 0 ulp error.
>>
>> Signed-off-by: Ganesh Ajjanagadde 
>
>
> Pushed.
>
> Took the liberty of abstracting out the pow implementation we
> discussed on IRC into a utility function and push that. It's more
> readable, and next time we'll know clearly that's the way to go.

Good idea, thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/aacenc_is: replace pow(x, 0.75) by x/sqrtf(sqrtf(x))

2016-01-13 Thread Claudio Freire
On Mon, Jan 11, 2016 at 7:23 PM, Ganesh Ajjanagadde
 wrote:
> This is quite an accurate approximation; testing shows ~ 2ulp error in
> the floating point result. Tested with FATE.
>
> Alternatively, if one wants "full accuracy", one can use powf, or sqrt
> instead of sqrtf. With powf, one gets 1 ulp error (theoretically should be 0, 
> as
> 0.75 is exactly representable) on GNU libm, with sqrt, 0 ulp error.
>
> Signed-off-by: Ganesh Ajjanagadde 


Pushed.

Took the liberty of abstracting out the pow implementation we
discussed on IRC into a utility function and push that. It's more
readable, and next time we'll know clearly that's the way to go.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] avcodec/aacenc_is: replace pow(x, 0.75) by x/sqrtf(sqrtf(x))

2016-01-11 Thread Ganesh Ajjanagadde
This is quite an accurate approximation; testing shows ~ 2ulp error in
the floating point result. Tested with FATE.

Alternatively, if one wants "full accuracy", one can use powf, or sqrt
instead of sqrtf. With powf, one gets 1 ulp error (theoretically should be 0, as
0.75 is exactly representable) on GNU libm, with sqrt, 0 ulp error.

Signed-off-by: Ganesh Ajjanagadde 
---
 libavcodec/aacenc_is.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/aacenc_is.c b/libavcodec/aacenc_is.c
index 4f7ec19..846b8ec 100644
--- a/libavcodec/aacenc_is.c
+++ b/libavcodec/aacenc_is.c
@@ -54,7 +54,7 @@ struct AACISError ff_aac_is_encoding_err(AACEncContext *s, 
ChannelElement *cpe,
 FFPsyBand *band0 = &s->psy.ch[s->cur_channel+0].psy_bands[(w+w2)*16+g];
 FFPsyBand *band1 = &s->psy.ch[s->cur_channel+1].psy_bands[(w+w2)*16+g];
 int is_band_type, is_sf_idx = FFMAX(1, sce0->sf_idx[(w+w2)*16+g]-4);
-float e01_34 = phase*pow(ener1/ener0, 3.0/4.0);
+float e01_34 = phase*(ener1/ener0)/sqrtf(sqrtf(ener1/ener0));
 float maxval, dist_spec_err = 0.0f;
 float minthr = FFMIN(band0->threshold, band1->threshold);
 for (i = 0; i < sce0->ics.swb_sizes[g]; i++)
-- 
2.7.0

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