FFmpeg
Data Structures | Macros | Functions | Variables
softfloat.h File Reference
#include <stdint.h>
#include "common.h"
#include "avassert.h"
#include "softfloat_tables.h"

Go to the source code of this file.

Data Structures

struct  SoftFloat
 

Macros

#define MIN_EXP   -149
 
#define MAX_EXP   126
 
#define ONE_BITS   29
 

Functions

static av_const double av_sf2double (SoftFloat v)
 Convert a SoftFloat to a double precision float. More...
 
static av_const SoftFloat av_normalize_sf (SoftFloat a)
 
static av_const SoftFloat av_normalize1_sf (SoftFloat a)
 
static av_const SoftFloat av_mul_sf (SoftFloat a, SoftFloat b)
 
static av_const SoftFloat av_div_sf (SoftFloat a, SoftFloat b)
 b has to be normalized and not zero. More...
 
static av_const int av_cmp_sf (SoftFloat a, SoftFloat b)
 Compares two SoftFloats. More...
 
static av_const int av_gt_sf (SoftFloat a, SoftFloat b)
 Compares two SoftFloats. More...
 
static av_const SoftFloat av_add_sf (SoftFloat a, SoftFloat b)
 
static av_const SoftFloat av_sub_sf (SoftFloat a, SoftFloat b)
 
static av_const SoftFloat av_int2sf (int v, int frac_bits)
 Converts a mantisse and exponent to a SoftFloat. More...
 
static av_const int av_sf2int (SoftFloat v, int frac_bits)
 Converts a SoftFloat to an integer. More...
 
static av_always_inline SoftFloat av_sqrt_sf (SoftFloat val)
 Rounding-to-nearest used. More...
 
static av_unused void av_sincos_sf (int a, int *s, int *c)
 Rounding-to-nearest used. More...
 

Variables

static const SoftFloat FLOAT_0 = { 0, MIN_EXP}
 0.0 More...
 
static const SoftFloat FLOAT_05 = { 0x20000000, 0}
 0.5 More...
 
static const SoftFloat FLOAT_1 = { 0x20000000, 1}
 1.0 More...
 
static const SoftFloat FLOAT_EPSILON = { 0x29F16B12, -16}
 A small value. More...
 
static const SoftFloat FLOAT_1584893192 = { 0x32B771ED, 1}
 1.584893192 (10^.2) More...
 
static const SoftFloat FLOAT_100000 = { 0x30D40000, 17}
 100000 More...
 
static const SoftFloat FLOAT_0999999 = { 0x3FFFFBCE, 0}
 0.999999 More...
 
static const SoftFloat FLOAT_MIN = { 0x20000000, MIN_EXP}
 

Macro Definition Documentation

◆ MIN_EXP

#define MIN_EXP   -149

Definition at line 30 of file softfloat.h.

◆ MAX_EXP

#define MAX_EXP   126

Definition at line 31 of file softfloat.h.

◆ ONE_BITS

#define ONE_BITS   29

Definition at line 32 of file softfloat.h.

Function Documentation

◆ av_sf2double()

static av_const double av_sf2double ( SoftFloat  v)
inlinestatic

Convert a SoftFloat to a double precision float.

Definition at line 52 of file softfloat.h.

Referenced by main().

◆ av_normalize_sf()

static av_const SoftFloat av_normalize_sf ( SoftFloat  a)
static

Definition at line 57 of file softfloat.h.

Referenced by av_add_sf(), av_int2sf(), and main().

◆ av_normalize1_sf()

static av_const SoftFloat av_normalize1_sf ( SoftFloat  a)
inlinestatic

Definition at line 79 of file softfloat.h.

Referenced by av_add_sf(), av_div_sf(), av_int2sf(), and av_mul_sf().

◆ av_mul_sf()

static av_const SoftFloat av_mul_sf ( SoftFloat  a,
SoftFloat  b 
)
inlinestatic
Returns
Will not be more denormalized than a*b. So if either input is normalized, then the output will not be worse then the other input. If both are normalized, then the output will be normalized.

Definition at line 102 of file softfloat.h.

Referenced by main(), predict(), sbr_dequant(), sbr_env_estimate(), sbr_gain_calc(), sbr_hf_assemble(), and sbr_hf_inverse_filter().

◆ av_div_sf()

static av_const SoftFloat av_div_sf ( SoftFloat  a,
SoftFloat  b 
)
inlinestatic

b has to be normalized and not zero.

Returns
Will not be more denormalized than a.

Definition at line 116 of file softfloat.h.

Referenced by main(), predict(), ps_tableinit(), sbr_dequant(), sbr_gain_calc(), and sbr_hf_inverse_filter().

◆ av_cmp_sf()

static av_const int av_cmp_sf ( SoftFloat  a,
SoftFloat  b 
)
inlinestatic

Compares two SoftFloats.

Returns
< 0 if the first is less > 0 if the first is greater 0 if they are equal

Definition at line 138 of file softfloat.h.

Referenced by main().

◆ av_gt_sf()

static av_const int av_gt_sf ( SoftFloat  a,
SoftFloat  b 
)
inlinestatic

Compares two SoftFloats.

Returns
1 if a is greater than b, 0 otherwise

Definition at line 150 of file softfloat.h.

Referenced by main(), and sbr_gain_calc().

◆ av_add_sf()

static av_const SoftFloat av_add_sf ( SoftFloat  a,
SoftFloat  b 
)
inlinestatic
Returns
the sum of 2 SoftFloats.

Definition at line 162 of file softfloat.h.

Referenced by av_sub_sf(), main(), predict(), sbr_dequant(), sbr_env_estimate(), sbr_gain_calc(), sbr_hf_assemble(), and sbr_hf_inverse_filter().

◆ av_sub_sf()

static av_const SoftFloat av_sub_sf ( SoftFloat  a,
SoftFloat  b 
)
inlinestatic
Returns
the difference of 2 SoftFloats.

Definition at line 173 of file softfloat.h.

Referenced by predict(), and sbr_hf_inverse_filter().

◆ av_int2sf()

static av_const SoftFloat av_int2sf ( int  v,
int  frac_bits 
)
inlinestatic

Converts a mantisse and exponent to a SoftFloat.

This converts a fixed point value v with frac_bits fractional bits to a SoftFloat.

Returns
a SoftFloat with value v * 2^-frac_bits

Definition at line 185 of file softfloat.h.

Referenced by autocorr_calc(), main(), predict(), ps_tableinit(), sbr_env_estimate(), sbr_gain_calc(), and sbr_sum_square_c().

◆ av_sf2int()

static av_const int av_sf2int ( SoftFloat  v,
int  frac_bits 
)
inlinestatic

Converts a SoftFloat to an integer.

Rounding is to -inf.

Definition at line 198 of file softfloat.h.

Referenced by main().

◆ av_sqrt_sf()

static av_always_inline SoftFloat av_sqrt_sf ( SoftFloat  val)
static

Rounding-to-nearest used.

Definition at line 207 of file softfloat.h.

Referenced by ps_tableinit(), and sbr_gain_calc().

◆ av_sincos_sf()

static av_unused void av_sincos_sf ( int  a,
int *  s,
int *  c 
)
static

Rounding-to-nearest used.

Parameters
aangle in units of (1ULL<<30)/M_PI radians
spointer to where sine in units of (1<<30) is returned
cpointer to where cosine in units of (1<<30) is returned

Definition at line 244 of file softfloat.h.

Referenced by main(), and ps_tableinit().

Variable Documentation

◆ FLOAT_0

const SoftFloat FLOAT_0 = { 0, MIN_EXP}
static

◆ FLOAT_05

const SoftFloat FLOAT_05 = { 0x20000000, 0}
static

0.5

Definition at line 40 of file softfloat.h.

◆ FLOAT_1

const SoftFloat FLOAT_1 = { 0x20000000, 1}
static

1.0

Definition at line 41 of file softfloat.h.

Referenced by ps_tableinit(), read_diff_float_data(), sbr_dequant(), and sbr_gain_calc().

◆ FLOAT_EPSILON

const SoftFloat FLOAT_EPSILON = { 0x29F16B12, -16}
static

A small value.

Definition at line 42 of file softfloat.h.

Referenced by sbr_gain_calc().

◆ FLOAT_1584893192

const SoftFloat FLOAT_1584893192 = { 0x32B771ED, 1}
static

1.584893192 (10^.2)

Definition at line 43 of file softfloat.h.

Referenced by sbr_gain_calc().

◆ FLOAT_100000

const SoftFloat FLOAT_100000 = { 0x30D40000, 17}
static

100000

Definition at line 44 of file softfloat.h.

Referenced by sbr_gain_calc().

◆ FLOAT_0999999

const SoftFloat FLOAT_0999999 = { 0x3FFFFBCE, 0}
static

0.999999

Definition at line 45 of file softfloat.h.

Referenced by sbr_hf_inverse_filter().

◆ FLOAT_MIN

const SoftFloat FLOAT_MIN = { 0x20000000, MIN_EXP}
static

Definition at line 46 of file softfloat.h.

Referenced by sbr_gain_calc().