ReactOS  0.4.13-dev-563-g0561610
layer1.c File Reference
#include "mpg123lib_intern.h"
#include "getbits.h"
#include "debug.h"
Include dependency graph for layer1.c:

Go to the source code of this file.

Macros

#define MINUS_SHIFT(n)   ( (int)(((unsigned int)-1)<<(n)) )
 

Functions

static int check_balloc (mpg123_handle *fr, unsigned int *balloc, unsigned int *end)
 
static int I_step_one (unsigned int balloc[], unsigned int scale_index[2][SBLIMIT], mpg123_handle *fr)
 
static void I_step_two (real fraction[2][SBLIMIT], unsigned int balloc[2 *SBLIMIT], unsigned int scale_index[2][SBLIMIT], mpg123_handle *fr)
 
int do_layer1 (mpg123_handle *fr)
 

Macro Definition Documentation

◆ MINUS_SHIFT

#define MINUS_SHIFT (   n)    ( (int)(((unsigned int)-1)<<(n)) )

Definition at line 88 of file layer1.c.

Function Documentation

◆ check_balloc()

static int check_balloc ( mpg123_handle fr,
unsigned int balloc,
unsigned int end 
)
static

Definition at line 24 of file layer1.c.

25 {
26  unsigned int *ba;
27  for(ba=balloc; ba != end; ++ba)
28  if(*ba == 15)
29  {
30  if(NOQUIET) error("Illegal bit allocation value.");
31  return -1;
32  }
33 
34  return 0;
35 }
#define error(str)
Definition: mkdosfs.c:1605
GLuint GLuint end
Definition: gl.h:1545
#define NOQUIET

Referenced by I_step_one().

◆ do_layer1()

int do_layer1 ( mpg123_handle fr)

Definition at line 158 of file layer1.c.

159 {
160  int clip=0;
161  int i,stereo = fr->stereo;
162  unsigned int balloc[2*SBLIMIT];
163  unsigned int scale_index[2][SBLIMIT];
164  real (*fraction)[SBLIMIT] = fr->layer1.fraction; /* fraction[2][SBLIMIT] */
165  int single = fr->single;
166 
167  fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32;
168 
169  if(stereo == 1 || single == SINGLE_MIX) /* I don't see mixing handled here */
171 
172  if(I_step_one(balloc,scale_index,fr))
173  {
174  if(NOQUIET) error("Aborting layer I decoding after step one.\n");
175  return clip;
176  }
177 
178  for(i=0;i<SCALE_BLOCK;i++)
179  {
180  I_step_two(fraction,balloc,scale_index,fr);
181 
182  if(single != SINGLE_STEREO)
183  clip += (fr->synth_mono)(fraction[single], fr);
184  else
185  clip += (fr->synth_stereo)(fraction[0], fraction[1], fr);
186  }
187 
188  return clip;
189 }
static void I_step_two(real fraction[2][SBLIMIT], unsigned int balloc[2 *SBLIMIT], unsigned int scale_index[2][SBLIMIT], mpg123_handle *fr)
Definition: layer1.c:90
static int I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT], mpg123_handle *fr)
Definition: layer1.c:37
#define error(str)
Definition: mkdosfs.c:1605
#define SCALE_BLOCK
#define SINGLE_STEREO
Definition: frame.h:187
#define SBLIMIT
struct mpg123_handle_struct::@3299 layer1
_Tp _STLP_CALL real(const complex< _Tp > &__z)
Definition: _complex.h:727
float single
Definition: msinkaut.idl:29
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
#define SINGLE_LEFT
Definition: frame.h:188
func_synth_mono synth_mono
Definition: frame.h:181
#define MPG_MD_JOINT_STEREO
#define NOQUIET
func_synth_stereo synth_stereo
Definition: frame.h:180
#define SINGLE_MIX
Definition: frame.h:190

◆ I_step_one()

static int I_step_one ( unsigned int  balloc[],
unsigned int  scale_index[2][SBLIMIT],
mpg123_handle fr 
)
static

Definition at line 37 of file layer1.c.

38 {
39  unsigned int *ba=balloc;
40  unsigned int *sca = (unsigned int *) scale_index;
41 
42  if(fr->stereo == 2)
43  {
44  int i;
45  int jsbound = fr->jsbound;
46  for(i=0;i<jsbound;i++)
47  {
48  *ba++ = getbits(fr, 4);
49  *ba++ = getbits(fr, 4);
50  }
51  for(i=jsbound;i<SBLIMIT;i++) *ba++ = getbits(fr, 4);
52 
53  if(check_balloc(fr, balloc, ba)) return -1;
54 
55  ba = balloc;
56 
57  for(i=0;i<jsbound;i++)
58  {
59  if ((*ba++))
60  *sca++ = getbits(fr, 6);
61  if ((*ba++))
62  *sca++ = getbits(fr, 6);
63  }
64  for (i=jsbound;i<SBLIMIT;i++)
65  if((*ba++))
66  {
67  *sca++ = getbits(fr, 6);
68  *sca++ = getbits(fr, 6);
69  }
70  }
71  else
72  {
73  int i;
74  for(i=0;i<SBLIMIT;i++) *ba++ = getbits(fr, 4);
75 
76  if(check_balloc(fr, balloc, ba)) return -1;
77 
78  ba = balloc;
79  for (i=0;i<SBLIMIT;i++)
80  if ((*ba++))
81  *sca++ = getbits(fr, 6);
82  }
83 
84  return 0;
85 }
#define SBLIMIT
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
static int check_balloc(mpg123_handle *fr, unsigned int *balloc, unsigned int *end)
Definition: layer1.c:24
#define getbits
Definition: intsym.h:195

Referenced by do_layer1().

◆ I_step_two()

static void I_step_two ( real  fraction[2][SBLIMIT],
unsigned int  balloc[2 *SBLIMIT],
unsigned int  scale_index[2][SBLIMIT],
mpg123_handle fr 
)
static

Definition at line 90 of file layer1.c.

91 {
92  int i,n;
93  int smpb[2*SBLIMIT]; /* values: 0-65535 */
94  int *sample;
95  register unsigned int *ba;
96  register unsigned int *sca = (unsigned int *) scale_index;
97 
98  if(fr->stereo == 2)
99  {
100  int jsbound = fr->jsbound;
101  register real *f0 = fraction[0];
102  register real *f1 = fraction[1];
103  ba = balloc;
104  for(sample=smpb,i=0;i<jsbound;i++)
105  {
106  if((n = *ba++)) *sample++ = getbits(fr, n+1);
107 
108  if((n = *ba++)) *sample++ = getbits(fr, n+1);
109  }
110  for(i=jsbound;i<SBLIMIT;i++)
111  if((n = *ba++))
112  *sample++ = getbits(fr, n+1);
113 
114  ba = balloc;
115  for(sample=smpb,i=0;i<jsbound;i++)
116  {
117  if((n=*ba++))
118  *f0++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15(MINUS_SHIFT(n) + (*sample++) + 1), fr->muls[n+1][*sca++]);
119  else *f0++ = DOUBLE_TO_REAL(0.0);
120 
121  if((n=*ba++))
122  *f1++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15(MINUS_SHIFT(n) + (*sample++) + 1), fr->muls[n+1][*sca++]);
123  else *f1++ = DOUBLE_TO_REAL(0.0);
124  }
125  for(i=jsbound;i<SBLIMIT;i++)
126  {
127  if((n=*ba++))
128  {
129  real samp = DOUBLE_TO_REAL_15(MINUS_SHIFT(n) + (*sample++) + 1);
130  *f0++ = REAL_MUL_SCALE_LAYER12(samp, fr->muls[n+1][*sca++]);
131  *f1++ = REAL_MUL_SCALE_LAYER12(samp, fr->muls[n+1][*sca++]);
132  }
133  else *f0++ = *f1++ = DOUBLE_TO_REAL(0.0);
134  }
135  for(i=fr->down_sample_sblimit;i<32;i++)
136  fraction[0][i] = fraction[1][i] = 0.0;
137  }
138  else
139  {
140  register real *f0 = fraction[0];
141  ba = balloc;
142  for(sample=smpb,i=0;i<SBLIMIT;i++)
143  if ((n = *ba++))
144  *sample++ = getbits(fr, n+1);
145 
146  ba = balloc;
147  for(sample=smpb,i=0;i<SBLIMIT;i++)
148  {
149  if((n=*ba++))
150  *f0++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15(MINUS_SHIFT(n) + (*sample++) + 1), fr->muls[n+1][*sca++]);
151  else *f0++ = DOUBLE_TO_REAL(0.0);
152  }
153  for(i=fr->down_sample_sblimit;i<32;i++)
154  fraction[0][i] = DOUBLE_TO_REAL(0.0);
155  }
156 }
#define MINUS_SHIFT(n)
Definition: layer1.c:88
#define DOUBLE_TO_REAL(x)
#define SBLIMIT
GLdouble n
Definition: glext.h:7729
_Tp _STLP_CALL real(const complex< _Tp > &__z)
Definition: _complex.h:727
int down_sample_sblimit
Definition: frame.h:193
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
real muls[27][64]
Definition: frame.h:144
#define REAL_MUL_SCALE_LAYER12(x, y)
#define f1(x, y, z)
Definition: sha1.c:30
#define DOUBLE_TO_REAL_15(x)
#define getbits
Definition: intsym.h:195

Referenced by do_layer1().