| 19 | #include "libavutil/float2half.h" |
| 20 | |
| 21 | void ff_init_float2half_tables(Float2HalfTables *t) |
| 22 | { |
| 23 | #if !HAVE_FAST_FLOAT16 |
| 24 | for (int i = 0; i < 256; i++) { |
| 25 | int e = i - 127; |
| 26 | |
| 27 | if (e < -24) { // Very small numbers map to zero |
| 28 | t->basetable[i|0x000] = 0x0000; |
| 29 | t->basetable[i|0x100] = 0x8000; |
| 30 | t->shifttable[i|0x000] = 24; |
| 31 | t->shifttable[i|0x100] = 24; |
| 32 | } else if (e < -14) { // Small numbers map to denorms |
| 33 | t->basetable[i|0x000] = (0x0400>>(-e-14)); |
| 34 | t->basetable[i|0x100] = (0x0400>>(-e-14)) | 0x8000; |
| 35 | t->shifttable[i|0x000] = -e-1; |
| 36 | t->shifttable[i|0x100] = -e-1; |
| 37 | } else if (e <= 15) { // Normal numbers just lose precision |
| 38 | t->basetable[i|0x000] = ((e + 15) << 10); |
| 39 | t->basetable[i|0x100] = ((e + 15) << 10) | 0x8000; |
| 40 | t->shifttable[i|0x000] = 13; |
| 41 | t->shifttable[i|0x100] = 13; |
| 42 | } else if (e < 128) { // Large numbers map to Infinity |
| 43 | t->basetable[i|0x000] = 0x7C00; |
| 44 | t->basetable[i|0x100] = 0xFC00; |
| 45 | t->shifttable[i|0x000] = 24; |
| 46 | t->shifttable[i|0x100] = 24; |
| 47 | } else { // Infinity and NaN's stay Infinity and NaN's |
| 48 | t->basetable[i|0x000] = 0x7C00; |
| 49 | t->basetable[i|0x100] = 0xFC00; |
| 50 | t->shifttable[i|0x000] = 13; |
| 51 | t->shifttable[i|0x100] = 13; |
| 52 | } |
| 53 | } |
| 54 | #endif |
| 55 | } |
no outgoing calls
no test coverage detected