ReactOS 0.4.15-dev-7934-g1dc8d80
dither_impl.h File Reference
#include "config.h"
#include "compat.h"
#include "dither.h"
Include dependency graph for dither_impl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define LAP   100
 

Functions

static float rand_xorshift32 (uint32_t *seed)
 
static void white_noise (float *table, size_t count)
 
static void tpdf_noise (float *table, size_t count)
 
static void highpass_tpdf_noise (float *table, size_t count)
 
void mpg123_noise (float *table, size_t count, enum mpg123_noise_type noisetype)
 
void dither_table_init (float *dithertable)
 

Variables

static const uint32_t init_seed = 2463534242UL
 

Macro Definition Documentation

◆ LAP

#define LAP   100

Definition at line 15 of file dither_impl.h.

Function Documentation

◆ dither_table_init()

void dither_table_init ( float dithertable)

Definition at line 116 of file dither_impl.h.

117{
118 highpass_tpdf_noise(dithertable, DITHERSIZE);
119}
#define DITHERSIZE
Definition: dither.h:12
static void highpass_tpdf_noise(float *table, size_t count)
Definition: dither_impl.h:65

◆ highpass_tpdf_noise()

static void highpass_tpdf_noise ( float table,
size_t  count 
)
static

Definition at line 65 of file dither_impl.h.

66{
67 size_t i;
68 uint32_t seed = init_seed;
69 /* Ensure some minimum lap for keeping the high-pass filter circular. */
70 size_t lap = count > 2*LAP ? LAP : count/2;
71
72 float input_noise;
73 float xv[9], yv[9];
74
75 for(i=0;i<9;i++)
76 {
77 xv[i] = yv[i] = 0.0f;
78 }
79
80 for(i=0;i<count+lap;i++)
81 {
82 if(i==count) seed=init_seed;
83
84 /* generate and add 2 random numbers, to make a TPDF noise distribution */
85 input_noise = rand_xorshift32(&seed) + rand_xorshift32(&seed);
86
87 /* apply 8th order Chebyshev high-pass IIR filter */
88 /* Coefficients are from http://www-users.cs.york.ac.uk/~fisher/mkfilter/trad.html
89 Given parameters are: Chebyshev, Highpass, ripple=-1, order=8, samplerate=44100, corner1=19000 */
90 xv[0] = xv[1]; xv[1] = xv[2]; xv[2] = xv[3]; xv[3] = xv[4]; xv[4] = xv[5]; xv[5] = xv[6]; xv[6] = xv[7]; xv[7] = xv[8];
91 xv[8] = input_noise / 1.382814179e+07;
92 yv[0] = yv[1]; yv[1] = yv[2]; yv[2] = yv[3]; yv[3] = yv[4]; yv[4] = yv[5]; yv[5] = yv[6]; yv[6] = yv[7]; yv[7] = yv[8];
93 yv[8] = (xv[0] + xv[8]) - 8 * (xv[1] + xv[7]) + 28 * (xv[2] + xv[6])
94 - 56 * (xv[3] + xv[5]) + 70 * xv[4]
95 + ( -0.6706204984 * yv[0]) + ( -5.3720827038 * yv[1])
96 + (-19.0865382480 * yv[2]) + (-39.2831607860 * yv[3])
97 + (-51.2308985070 * yv[4]) + (-43.3590135780 * yv[5])
98 + (-23.2632305320 * yv[6]) + ( -7.2370122050 * yv[7]);
99 if(i>=lap) table[i-lap] = yv[8] * 3.0f;
100 }
101}
#define LAP
Definition: dither_impl.h:15
static float rand_xorshift32(uint32_t *seed)
Definition: dither_impl.h:22
static const uint32_t init_seed
Definition: dither_impl.h:13
UINT32 uint32_t
Definition: types.h:75
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248

Referenced by dither_table_init(), and mpg123_noise().

◆ mpg123_noise()

void mpg123_noise ( float table,
size_t  count,
enum mpg123_noise_type  noisetype 
)

Definition at line 103 of file dither_impl.h.

104{
105 switch(noisetype)
106 {
111 break;
112 }
113}
@ mpg123_white_noise
Definition: dither.h:15
@ mpg123_tpdf_noise
Definition: dither.h:16
@ mpg123_highpass_tpdf_noise
Definition: dither.h:17
static void tpdf_noise(float *table, size_t count)
Definition: dither_impl.h:56
static void white_noise(float *table, size_t count)
Definition: dither_impl.h:47

◆ rand_xorshift32()

static float rand_xorshift32 ( uint32_t seed)
static

Definition at line 22 of file dither_impl.h.

23{
24 union
25 {
26 uint32_t i;
27 float f;
28 } fi;
29
30 fi.i = *seed;
31 fi.i ^= (fi.i<<13);
32 fi.i ^= (fi.i>>17);
33 fi.i ^= (fi.i<<5);
34 *seed = fi.i;
35
36 /* scale the number to [-0.5, 0.5] */
37#ifdef IEEE_FLOAT
38 fi.i = (fi.i>>9)|0x3f800000;
39 fi.f -= 1.5f;
40#else
41 fi.f = (double)fi.i / 4294967295.0;
42 fi.f -= 0.5f;
43#endif
44 return fi.f;
45}
#define f
Definition: ke_i.h:83
static const char mbstate_t *static wchar_t const char mbstate_t *static const wchar_t int *static double
Definition: string.c:80

Referenced by highpass_tpdf_noise(), tpdf_noise(), and white_noise().

◆ tpdf_noise()

static void tpdf_noise ( float table,
size_t  count 
)
static

Definition at line 56 of file dither_impl.h.

57{
58 size_t i;
59 uint32_t seed = init_seed;
60
61 for(i=0; i<count; ++i)
62 table[i] = rand_xorshift32(&seed) + rand_xorshift32(&seed);
63}

Referenced by mpg123_noise().

◆ white_noise()

static void white_noise ( float table,
size_t  count 
)
static

Definition at line 47 of file dither_impl.h.

48{
49 size_t i;
50 uint32_t seed = init_seed;
51
52 for(i=0; i<count; ++i)
53 table[i] = rand_xorshift32(&seed);
54}

Referenced by mpg123_noise().

Variable Documentation

◆ init_seed

const uint32_t init_seed = 2463534242UL
static

Definition at line 13 of file dither_impl.h.

Referenced by highpass_tpdf_noise(), tpdf_noise(), and white_noise().