summaryrefslogtreecommitdiff
path: root/libavutil/float2half.h
diff options
context:
space:
mode:
authorTimo Rothenpieler <timo@rothenpieler.org>2022-08-10 01:53:10 +0200
committerTimo Rothenpieler <timo@rothenpieler.org>2022-08-19 22:09:36 +0200
commit6dc79f1d04eb88ec97360c45be4cadc66b7e5780 (patch)
tree1d798db458f52f60adba3356d05308c06763c8c0 /libavutil/float2half.h
parentf3fb528cd5bfecec6835a3951c75903a194ae1ad (diff)
downloadffmpeg-6dc79f1d04eb88ec97360c45be4cadc66b7e5780.tar.gz
avutil/half2float: move non-inline init code out of header
Diffstat (limited to 'libavutil/float2half.h')
-rw-r--r--libavutil/float2half.h36
1 files changed, 2 insertions, 34 deletions
diff --git a/libavutil/float2half.h b/libavutil/float2half.h
index 3548aa1d45..20fdc2a36b 100644
--- a/libavutil/float2half.h
+++ b/libavutil/float2half.h
@@ -26,41 +26,9 @@ typedef struct Float2HalfTables {
uint8_t shifttable[512];
} Float2HalfTables;
-static void init_float2half_tables(Float2HalfTables *t)
-{
- for (int i = 0; i < 256; i++) {
- int e = i - 127;
-
- if (e < -24) { // Very small numbers map to zero
- t->basetable[i|0x000] = 0x0000;
- t->basetable[i|0x100] = 0x8000;
- t->shifttable[i|0x000] = 24;
- t->shifttable[i|0x100] = 24;
- } else if (e < -14) { // Small numbers map to denorms
- t->basetable[i|0x000] = (0x0400>>(-e-14));
- t->basetable[i|0x100] = (0x0400>>(-e-14)) | 0x8000;
- t->shifttable[i|0x000] = -e-1;
- t->shifttable[i|0x100] = -e-1;
- } else if (e <= 15) { // Normal numbers just lose precision
- t->basetable[i|0x000] = ((e + 15) << 10);
- t->basetable[i|0x100] = ((e + 15) << 10) | 0x8000;
- t->shifttable[i|0x000] = 13;
- t->shifttable[i|0x100] = 13;
- } else if (e < 128) { // Large numbers map to Infinity
- t->basetable[i|0x000] = 0x7C00;
- t->basetable[i|0x100] = 0xFC00;
- t->shifttable[i|0x000] = 24;
- t->shifttable[i|0x100] = 24;
- } else { // Infinity and NaN's stay Infinity and NaN's
- t->basetable[i|0x000] = 0x7C00;
- t->basetable[i|0x100] = 0xFC00;
- t->shifttable[i|0x000] = 13;
- t->shifttable[i|0x100] = 13;
- }
- }
-}
+void ff_init_float2half_tables(Float2HalfTables *t);
-static uint16_t float2half(uint32_t f, const Float2HalfTables *t)
+static inline uint16_t float2half(uint32_t f, const Float2HalfTables *t)
{
uint16_t h;