[FFmpeg-devel] [PATCH] avutil/softfloat: Move av_sincos_sf() from test c file to a new file
Nedeljko Babic
nedeljko.babic at imgtec.com
Thu Jun 11 15:58:46 CEST 2015
The function cannot be used from the test file, so the new file is created for
it and appropriate changes to Makefile are made
Signed-off-by: Nedeljko Babic <nedeljko.babic at imgtec.com>
---
libavutil/Makefile | 1 +
libavutil/softfloat.c | 49 --------------------------------
libavutil/softfloat_trig.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+), 49 deletions(-)
create mode 100644 libavutil/softfloat_trig.c
diff --git a/libavutil/Makefile b/libavutil/Makefile
index df85cd1..bef4687 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -126,6 +126,7 @@ OBJS = adler32.o \
samplefmt.o \
sha.o \
sha512.o \
+ softfloat_trig.o \
stereo3d.o \
threadmessage.o \
time.o \
diff --git a/libavutil/softfloat.c b/libavutil/softfloat.c
index 4fc6860..37dd758 100644
--- a/libavutil/softfloat.c
+++ b/libavutil/softfloat.c
@@ -37,55 +37,6 @@ 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_trig.c b/libavutil/softfloat_trig.c
new file mode 100644
index 0000000..077154b
--- /dev/null
+++ b/libavutil/softfloat_trig.c
@@ -0,0 +1,70 @@
+/*
+ * copyright (c) 2013 Stanislav Ocovaj <stanislav.ocovaj at imgtec.com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "softfloat.h"
+
+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);
+}
--
1.8.2.1
More information about the ffmpeg-devel
mailing list