Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenlayer1.c
Go to the documentation of this file.
00001 /* 00002 layer1.c: the layer 1 decoder 00003 00004 copyright 1995-2009 by the mpg123 project - free software under the terms of the LGPL 2.1 00005 see COPYING and AUTHORS files in distribution or http://mpg123.org 00006 initially written by Michael Hipp 00007 00008 may have a few bugs after last optimization ... 00009 */ 00010 00011 #include "mpg123lib_intern.h" 00012 #include "getbits.h" 00013 00014 void I_step_one(unsigned int balloc[], unsigned int scale_index[2][SBLIMIT],mpg123_handle *fr) 00015 { 00016 unsigned int *ba=balloc; 00017 unsigned int *sca = (unsigned int *) scale_index; 00018 00019 if(fr->stereo == 2) 00020 { 00021 int i; 00022 int jsbound = fr->jsbound; 00023 for(i=0;i<jsbound;i++) 00024 { 00025 *ba++ = getbits(fr, 4); 00026 *ba++ = getbits(fr, 4); 00027 } 00028 for(i=jsbound;i<SBLIMIT;i++) *ba++ = getbits(fr, 4); 00029 00030 ba = balloc; 00031 00032 for(i=0;i<jsbound;i++) 00033 { 00034 if ((*ba++)) 00035 *sca++ = getbits(fr, 6); 00036 if ((*ba++)) 00037 *sca++ = getbits(fr, 6); 00038 } 00039 for (i=jsbound;i<SBLIMIT;i++) 00040 if((*ba++)) 00041 { 00042 *sca++ = getbits(fr, 6); 00043 *sca++ = getbits(fr, 6); 00044 } 00045 } 00046 else 00047 { 00048 int i; 00049 for(i=0;i<SBLIMIT;i++) *ba++ = getbits(fr, 4); 00050 00051 ba = balloc; 00052 for (i=0;i<SBLIMIT;i++) 00053 if ((*ba++)) 00054 *sca++ = getbits(fr, 6); 00055 } 00056 } 00057 00058 void I_step_two(real fraction[2][SBLIMIT],unsigned int balloc[2*SBLIMIT], unsigned int scale_index[2][SBLIMIT],mpg123_handle *fr) 00059 { 00060 int i,n; 00061 int smpb[2*SBLIMIT]; /* values: 0-65535 */ 00062 int *sample; 00063 register unsigned int *ba; 00064 register unsigned int *sca = (unsigned int *) scale_index; 00065 00066 if(fr->stereo == 2) 00067 { 00068 int jsbound = fr->jsbound; 00069 register real *f0 = fraction[0]; 00070 register real *f1 = fraction[1]; 00071 ba = balloc; 00072 for(sample=smpb,i=0;i<jsbound;i++) 00073 { 00074 if((n = *ba++)) *sample++ = getbits(fr, n+1); 00075 00076 if((n = *ba++)) *sample++ = getbits(fr, n+1); 00077 } 00078 for(i=jsbound;i<SBLIMIT;i++) 00079 if((n = *ba++)) 00080 *sample++ = getbits(fr, n+1); 00081 00082 ba = balloc; 00083 for(sample=smpb,i=0;i<jsbound;i++) 00084 { 00085 if((n=*ba++)) 00086 *f0++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1), fr->muls[n+1][*sca++]); 00087 else *f0++ = DOUBLE_TO_REAL(0.0); 00088 00089 if((n=*ba++)) 00090 *f1++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1), fr->muls[n+1][*sca++]); 00091 else *f1++ = DOUBLE_TO_REAL(0.0); 00092 } 00093 for(i=jsbound;i<SBLIMIT;i++) 00094 { 00095 if((n=*ba++)) 00096 { 00097 real samp = DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1); 00098 *f0++ = REAL_MUL_SCALE_LAYER12(samp, fr->muls[n+1][*sca++]); 00099 *f1++ = REAL_MUL_SCALE_LAYER12(samp, fr->muls[n+1][*sca++]); 00100 } 00101 else *f0++ = *f1++ = DOUBLE_TO_REAL(0.0); 00102 } 00103 for(i=fr->down_sample_sblimit;i<32;i++) 00104 fraction[0][i] = fraction[1][i] = 0.0; 00105 } 00106 else 00107 { 00108 register real *f0 = fraction[0]; 00109 ba = balloc; 00110 for(sample=smpb,i=0;i<SBLIMIT;i++) 00111 if ((n = *ba++)) 00112 *sample++ = getbits(fr, n+1); 00113 00114 ba = balloc; 00115 for(sample=smpb,i=0;i<SBLIMIT;i++) 00116 { 00117 if((n=*ba++)) 00118 *f0++ = REAL_MUL_SCALE_LAYER12(DOUBLE_TO_REAL_15( ((-1)<<n) + (*sample++) + 1), fr->muls[n+1][*sca++]); 00119 else *f0++ = DOUBLE_TO_REAL(0.0); 00120 } 00121 for(i=fr->down_sample_sblimit;i<32;i++) 00122 fraction[0][i] = DOUBLE_TO_REAL(0.0); 00123 } 00124 } 00125 00126 int do_layer1(mpg123_handle *fr) 00127 { 00128 int clip=0; 00129 int i,stereo = fr->stereo; 00130 unsigned int balloc[2*SBLIMIT]; 00131 unsigned int scale_index[2][SBLIMIT]; 00132 real (*fraction)[SBLIMIT] = fr->layer1.fraction; /* fraction[2][SBLIMIT] */ 00133 int single = fr->single; 00134 00135 fr->jsbound = (fr->mode == MPG_MD_JOINT_STEREO) ? (fr->mode_ext<<2)+4 : 32; 00136 00137 if(stereo == 1 || single == SINGLE_MIX) /* I don't see mixing handled here */ 00138 single = SINGLE_LEFT; 00139 00140 I_step_one(balloc,scale_index,fr); 00141 00142 for(i=0;i<SCALE_BLOCK;i++) 00143 { 00144 I_step_two(fraction,balloc,scale_index,fr); 00145 00146 if(single != SINGLE_STEREO) 00147 clip += (fr->synth_mono)(fraction[single], fr); 00148 else 00149 clip += (fr->synth_stereo)(fraction[0], fraction[1], fr); 00150 } 00151 00152 return clip; 00153 } 00154 00155 Generated on Fri May 25 2012 04:32:36 for ReactOS by
1.7.6.1
|