| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * This file is part of FFmpeg. | ||
| 3 | * | ||
| 4 | * FFmpeg is free software; you can redistribute it and/or | ||
| 5 | * modify it under the terms of the GNU Lesser General Public | ||
| 6 | * License as published by the Free Software Foundation; either | ||
| 7 | * version 2.1 of the License, or (at your option) any later version. | ||
| 8 | * | ||
| 9 | * FFmpeg is distributed in the hope that it will be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 12 | * Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public | ||
| 15 | * License along with FFmpeg; if not, write to the Free Software | ||
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include "libavutil/float2half.h" | ||
| 20 | |||
| 21 | 184 | void ff_init_float2half_tables(Float2HalfTables *t) | |
| 22 | { | ||
| 23 | #if !HAVE_FAST_FLOAT16 | ||
| 24 |
2/2✓ Branch 0 taken 47104 times.
✓ Branch 1 taken 184 times.
|
47288 | for (int i = 0; i < 256; i++) { |
| 25 | 47104 | int e = i - 127; | |
| 26 | |||
| 27 |
2/2✓ Branch 0 taken 18952 times.
✓ Branch 1 taken 28152 times.
|
47104 | if (e < -24) { // Very small numbers map to zero |
| 28 | 18952 | t->basetable[i|0x000] = 0x0000; | |
| 29 | 18952 | t->basetable[i|0x100] = 0x8000; | |
| 30 | 18952 | t->shifttable[i|0x000] = 24; | |
| 31 | 18952 | t->shifttable[i|0x100] = 24; | |
| 32 |
2/2✓ Branch 0 taken 1840 times.
✓ Branch 1 taken 26312 times.
|
28152 | } else if (e < -14) { // Small numbers map to denorms |
| 33 | 1840 | t->basetable[i|0x000] = (0x0400>>(-e-14)); | |
| 34 | 1840 | t->basetable[i|0x100] = (0x0400>>(-e-14)) | 0x8000; | |
| 35 | 1840 | t->shifttable[i|0x000] = -e-1; | |
| 36 | 1840 | t->shifttable[i|0x100] = -e-1; | |
| 37 |
2/2✓ Branch 0 taken 5520 times.
✓ Branch 1 taken 20792 times.
|
26312 | } else if (e <= 15) { // Normal numbers just lose precision |
| 38 | 5520 | t->basetable[i|0x000] = ((e + 15) << 10); | |
| 39 | 5520 | t->basetable[i|0x100] = ((e + 15) << 10) | 0x8000; | |
| 40 | 5520 | t->shifttable[i|0x000] = 13; | |
| 41 | 5520 | t->shifttable[i|0x100] = 13; | |
| 42 |
2/2✓ Branch 0 taken 20608 times.
✓ Branch 1 taken 184 times.
|
20792 | } else if (e < 128) { // Large numbers map to Infinity |
| 43 | 20608 | t->basetable[i|0x000] = 0x7C00; | |
| 44 | 20608 | t->basetable[i|0x100] = 0xFC00; | |
| 45 | 20608 | t->shifttable[i|0x000] = 24; | |
| 46 | 20608 | t->shifttable[i|0x100] = 24; | |
| 47 | } else { // Infinity and NaN's stay Infinity and NaN's | ||
| 48 | 184 | t->basetable[i|0x000] = 0x7C00; | |
| 49 | 184 | t->basetable[i|0x100] = 0xFC00; | |
| 50 | 184 | t->shifttable[i|0x000] = 13; | |
| 51 | 184 | t->shifttable[i|0x100] = 13; | |
| 52 | } | ||
| 53 | } | ||
| 54 | #endif | ||
| 55 | 184 | } | |
| 56 |