diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-06-05 13:30:54 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-06-05 13:42:05 +0200 |
commit | d3585c53debe4563533def485c9eef876e538073 (patch) | |
tree | 0eb1965263ab992d2aadf573fa573814de053d2d /libavutil | |
parent | 19ed3e35a5cd188de69f3635f56d9e51c2f720d5 (diff) | |
download | ffmpeg-d3585c53debe4563533def485c9eef876e538073.tar.gz |
avutil/softfloat: Move av_sincos_sf() from header to c file
The function is quite big and trigonometric functions should not really
be used in speed critical code
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/softfloat.c | 49 | ||||
-rw-r--r-- | libavutil/softfloat.h | 49 |
2 files changed, 50 insertions, 48 deletions
diff --git a/libavutil/softfloat.c b/libavutil/softfloat.c index 37dd758b31..4fc6860e65 100644 --- a/libavutil/softfloat.c +++ b/libavutil/softfloat.c @@ -37,6 +37,55 @@ static av_const double av_sf2double(SoftFloat v) { else return (double)v.mant / (double)(1 << (-v.exp)); } +void av_sincos_sf(int a, int *s, int *c) +{ + int idx, sign; + int sv, cv; + int st, ct; + + idx = a >> 26; + sign = (idx << 27) >> 31; + cv = av_costbl_1_sf[idx & 0xf]; + cv = (cv ^ sign) - sign; + + idx -= 8; + sign = (idx << 27) >> 31; + sv = av_costbl_1_sf[idx & 0xf]; + sv = (sv ^ sign) - sign; + + idx = a >> 21; + ct = av_costbl_2_sf[idx & 0x1f]; + st = av_sintbl_2_sf[idx & 0x1f]; + + idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); + + sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); + + cv = idx; + + idx = a >> 16; + ct = av_costbl_3_sf[idx & 0x1f]; + st = av_sintbl_3_sf[idx & 0x1f]; + + idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); + + sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); + cv = idx; + + idx = a >> 11; + + ct = (int)(((int64_t)av_costbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + + (int64_t)av_costbl_4_sf[(idx & 0x1f)+1]*(a & 0x7ff) + + 0x400) >> 11); + st = (int)(((int64_t)av_sintbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + + (int64_t)av_sintbl_4_sf[(idx & 0x1f) + 1] * (a & 0x7ff) + + 0x400) >> 11); + + *c = (int)(((int64_t)cv * ct + (int64_t)sv * st + 0x20000000) >> 30); + + *s = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); +} + int main(void){ SoftFloat one= av_int2sf(1, 0); SoftFloat sf1, sf2, sf3; diff --git a/libavutil/softfloat.h b/libavutil/softfloat.h index 7938c208eb..0f22f057d2 100644 --- a/libavutil/softfloat.h +++ b/libavutil/softfloat.h @@ -175,53 +175,6 @@ static av_always_inline SoftFloat av_sqrt_sf(SoftFloat val) /** * Rounding-to-nearest used. */ -static av_always_inline void av_sincos_sf(int a, int *s, int *c) -{ - int idx, sign; - int sv, cv; - int st, ct; - - idx = a >> 26; - sign = (idx << 27) >> 31; - cv = av_costbl_1_sf[idx & 0xf]; - cv = (cv ^ sign) - sign; - - idx -= 8; - sign = (idx << 27) >> 31; - sv = av_costbl_1_sf[idx & 0xf]; - sv = (sv ^ sign) - sign; - - idx = a >> 21; - ct = av_costbl_2_sf[idx & 0x1f]; - st = av_sintbl_2_sf[idx & 0x1f]; - - idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); - - sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); - - cv = idx; - - idx = a >> 16; - ct = av_costbl_3_sf[idx & 0x1f]; - st = av_sintbl_3_sf[idx & 0x1f]; - - idx = (int)(((int64_t)cv * ct - (int64_t)sv * st + 0x20000000) >> 30); - - sv = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); - cv = idx; - - idx = a >> 11; - - ct = (int)(((int64_t)av_costbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + - (int64_t)av_costbl_4_sf[(idx & 0x1f)+1]*(a & 0x7ff) + - 0x400) >> 11); - st = (int)(((int64_t)av_sintbl_4_sf[idx & 0x1f] * (0x800 - (a & 0x7ff)) + - (int64_t)av_sintbl_4_sf[(idx & 0x1f) + 1] * (a & 0x7ff) + - 0x400) >> 11); - - *c = (int)(((int64_t)cv * ct + (int64_t)sv * st + 0x20000000) >> 30); - - *s = (int)(((int64_t)cv * st + (int64_t)sv * ct + 0x20000000) >> 30); -} +void av_sincos_sf(int a, int *s, int *c); #endif /* AVUTIL_SOFTFLOAT_H */ |