FFmpeg coverage


Directory: ../../../ffmpeg/
File: src/libavutil/half2float.h
Date: 2024-11-20 23:03:26
Exec Total Coverage
Lines: 3 3 100.0%
Functions: 1 1 100.0%
Branches: 0 0 -%

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 #ifndef AVUTIL_HALF2FLOAT_H
20 #define AVUTIL_HALF2FLOAT_H
21
22 #include <stdint.h>
23 #include "intfloat.h"
24
25 #include "config.h"
26
27 typedef struct Half2FloatTables {
28 #if HAVE_FAST_FLOAT16
29 uint8_t dummy;
30 #else
31 uint32_t mantissatable[3072];
32 uint32_t exponenttable[64];
33 uint16_t offsettable[64];
34 #endif
35 } Half2FloatTables;
36
37 void ff_init_half2float_tables(Half2FloatTables *t);
38
39 11272192 static inline uint32_t half2float(uint16_t h, const Half2FloatTables *t)
40 {
41 #if HAVE_FAST_FLOAT16
42 union {
43 _Float16 f;
44 uint16_t i;
45 } u;
46 u.i = h;
47 return av_float2int(u.f);
48 #else
49 uint32_t f;
50
51 11272192 f = t->mantissatable[t->offsettable[h >> 10] + (h & 0x3ff)] + t->exponenttable[h >> 10];
52
53 11272192 return f;
54 #endif
55 }
56
57 #endif /* AVUTIL_HALF2FLOAT_H */
58