19 #ifndef AVCODEC_FLOAT2HALF_H
20 #define AVCODEC_FLOAT2HALF_H
26 for (
int i = 0;
i < 256;
i++) {
30 basetable[
i|0x000] = 0x0000;
31 basetable[
i|0x100] = 0x8000;
32 shifttable[
i|0x000] = 24;
33 shifttable[
i|0x100] = 24;
35 basetable[
i|0x000] = (0x0400>>(-e-14));
36 basetable[
i|0x100] = (0x0400>>(-e-14)) | 0x8000;
37 shifttable[
i|0x000] = -e-1;
38 shifttable[
i|0x100] = -e-1;
40 basetable[
i|0x000] = ((e + 15) << 10);
41 basetable[
i|0x100] = ((e + 15) << 10) | 0x8000;
42 shifttable[
i|0x000] = 13;
43 shifttable[
i|0x100] = 13;
45 basetable[
i|0x000] = 0x7C00;
46 basetable[
i|0x100] = 0xFC00;
47 shifttable[
i|0x000] = 24;
48 shifttable[
i|0x100] = 24;
50 basetable[
i|0x000] = 0x7C00;
51 basetable[
i|0x100] = 0xFC00;
52 shifttable[
i|0x000] = 13;
53 shifttable[
i|0x100] = 13;
58 static uint16_t
float2half(uint32_t
f, uint16_t *basetable, uint8_t *shifttable)
62 h = basetable[(
f >> 23) & 0x1ff] + ((
f & 0x007fffff) >> shifttable[(
f >> 23) & 0x1ff]);