mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-16 03:50:05 +01:00
avutil/half2float: move non-inline init code out of header
This commit is contained in:
@@ -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;
|
||||
void ff_init_float2half_tables(Float2HalfTables *t);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t float2half(uint32_t f, const Float2HalfTables *t)
|
||||
static inline uint16_t float2half(uint32_t f, const Float2HalfTables *t)
|
||||
{
|
||||
uint16_t h;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user