FFmpeg
half2float.h
Go to the documentation of this file.
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
36 
38 
39 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  f = t->mantissatable[t->offsettable[h >> 10] + (h & 0x3ff)] + t->exponenttable[h >> 10];
52 
53  return f;
54 #endif
55 }
56 
57 #endif /* AVUTIL_HALF2FLOAT_H */
Half2FloatTables
Definition: half2float.h:27
ff_init_half2float_tables
void ff_init_half2float_tables(Half2FloatTables *t)
Definition: half2float.c:39
u
#define u(width, name, range_min, range_max)
Definition: cbs_h2645.c:262
av_float2int
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
Definition: intfloat.h:50
intfloat.h
dummy
int dummy
Definition: motion.c:65
f
f
Definition: af_crystalizer.c:122
Half2FloatTables::offsettable
uint16_t offsettable[64]
Definition: half2float.h:33
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:269
half2float
static uint32_t half2float(uint16_t h, const Half2FloatTables *t)
Definition: half2float.h:39
Half2FloatTables::exponenttable
uint32_t exponenttable[64]
Definition: half2float.h:32
Half2FloatTables::mantissatable
uint32_t mantissatable[3072]
Definition: half2float.h:31
h
h
Definition: vp9dsp_template.c:2038