Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygensynth_ntom.h
Go to the documentation of this file.
00001 /* 00002 synth_ntom.h: ntom-resampling synth functions 00003 00004 This header is used multiple times to create different variants of this function. 00005 Hint: MONO_NAME, MONO2STEREO_NAME, SYNTH_NAME and SAMPLE_T as well as WRITE_SAMPLE do vary. 00006 00007 copyright 1995-2008 by the mpg123 project - free software under the terms of the LGPL 2.1 00008 see COPYING and AUTHORS files in distribution or http://mpg123.org 00009 initially written by Michael Hipp, generalized by Thomas Orgis 00010 00011 Well, this is very simple resampling... you may or may not like what you hear. 00012 But it's cheap. 00013 But still, we don't implement a non-autoincrement version of this one. 00014 */ 00015 00016 /* Note: These mono functions would also work generically, 00017 it's just that they need a runtime calculation for the conversion loop... 00018 The fixed XtoY functions have the chance for loop unrolling... */ 00019 00020 int MONO_NAME(real *bandPtr, mpg123_handle *fr) 00021 { 00022 SAMPLE_T samples_tmp[8*64]; 00023 SAMPLE_T *tmp1 = samples_tmp; 00024 size_t i; 00025 int ret; 00026 00027 size_t pnt = fr->buffer.fill; 00028 unsigned char *samples = fr->buffer.data; 00029 fr->buffer.data = (unsigned char*) samples_tmp; 00030 fr->buffer.fill = 0; 00031 ret = SYNTH_NAME(bandPtr, 0, fr, 1); 00032 fr->buffer.data = samples; 00033 00034 samples += pnt; 00035 for(i=0;i<(fr->buffer.fill/(2*sizeof(SAMPLE_T)));i++) 00036 { 00037 *( (SAMPLE_T *)samples) = *tmp1; 00038 samples += sizeof(SAMPLE_T); 00039 tmp1 += 2; 00040 } 00041 fr->buffer.fill = pnt + (fr->buffer.fill/2); 00042 00043 return ret; 00044 } 00045 00046 00047 int MONO2STEREO_NAME(real *bandPtr, mpg123_handle *fr) 00048 { 00049 size_t i; 00050 int ret; 00051 size_t pnt1 = fr->buffer.fill; 00052 unsigned char *samples = fr->buffer.data + pnt1; 00053 00054 ret = SYNTH_NAME(bandPtr, 0, fr, 1); 00055 00056 for(i=0;i<((fr->buffer.fill-pnt1)/(2*sizeof(SAMPLE_T)));i++) 00057 { 00058 ((SAMPLE_T *)samples)[1] = ((SAMPLE_T *)samples)[0]; 00059 samples+=2*sizeof(SAMPLE_T); 00060 } 00061 00062 return ret; 00063 } 00064 00065 00066 int SYNTH_NAME(real *bandPtr,int channel, mpg123_handle *fr, int final) 00067 { 00068 static const int step = 2; 00069 SAMPLE_T *samples = (SAMPLE_T *) (fr->buffer.data + fr->buffer.fill); 00070 00071 real *b0, **buf; /* (*buf)[0x110]; */ 00072 int clip = 0; 00073 int bo1; 00074 int ntom; 00075 00076 if(fr->have_eq_settings) do_equalizer(bandPtr,channel,fr->equalizer); 00077 00078 if(!channel) 00079 { 00080 fr->bo--; 00081 fr->bo &= 0xf; 00082 buf = fr->real_buffs[0]; 00083 ntom = fr->ntom_val[1] = fr->ntom_val[0]; 00084 } 00085 else 00086 { 00087 samples++; 00088 buf = fr->real_buffs[1]; 00089 ntom = fr->ntom_val[1]; 00090 } 00091 00092 if(fr->bo & 0x1) 00093 { 00094 b0 = buf[0]; 00095 bo1 = fr->bo; 00096 dct64(buf[1]+((fr->bo+1)&0xf),buf[0]+fr->bo,bandPtr); 00097 } 00098 else 00099 { 00100 b0 = buf[1]; 00101 bo1 = fr->bo+1; 00102 dct64(buf[0]+fr->bo,buf[1]+fr->bo+1,bandPtr); 00103 } 00104 00105 { 00106 register int j; 00107 real *window = fr->decwin + 16 - bo1; 00108 00109 for (j=16;j;j--,window+=0x10) 00110 { 00111 real sum; 00112 00113 ntom += fr->ntom_step; 00114 if(ntom < NTOM_MUL) 00115 { 00116 window += 16; 00117 b0 += 16; 00118 continue; 00119 } 00120 00121 sum = REAL_MUL_SYNTH(*window++, *b0++); 00122 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00123 sum += REAL_MUL_SYNTH(*window++, *b0++); 00124 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00125 sum += REAL_MUL_SYNTH(*window++, *b0++); 00126 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00127 sum += REAL_MUL_SYNTH(*window++, *b0++); 00128 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00129 sum += REAL_MUL_SYNTH(*window++, *b0++); 00130 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00131 sum += REAL_MUL_SYNTH(*window++, *b0++); 00132 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00133 sum += REAL_MUL_SYNTH(*window++, *b0++); 00134 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00135 sum += REAL_MUL_SYNTH(*window++, *b0++); 00136 sum -= REAL_MUL_SYNTH(*window++, *b0++); 00137 00138 while(ntom >= NTOM_MUL) 00139 { 00140 WRITE_SAMPLE(samples,sum,clip); 00141 samples += step; 00142 ntom -= NTOM_MUL; 00143 } 00144 } 00145 00146 ntom += fr->ntom_step; 00147 if(ntom >= NTOM_MUL) 00148 { 00149 real sum; 00150 sum = REAL_MUL_SYNTH(window[0x0], b0[0x0]); 00151 sum += REAL_MUL_SYNTH(window[0x2], b0[0x2]); 00152 sum += REAL_MUL_SYNTH(window[0x4], b0[0x4]); 00153 sum += REAL_MUL_SYNTH(window[0x6], b0[0x6]); 00154 sum += REAL_MUL_SYNTH(window[0x8], b0[0x8]); 00155 sum += REAL_MUL_SYNTH(window[0xA], b0[0xA]); 00156 sum += REAL_MUL_SYNTH(window[0xC], b0[0xC]); 00157 sum += REAL_MUL_SYNTH(window[0xE], b0[0xE]); 00158 00159 while(ntom >= NTOM_MUL) 00160 { 00161 WRITE_SAMPLE(samples,sum,clip); 00162 samples += step; 00163 ntom -= NTOM_MUL; 00164 } 00165 } 00166 00167 b0-=0x10,window-=0x20; 00168 window += bo1<<1; 00169 00170 for (j=15;j;j--,b0-=0x20,window-=0x10) 00171 { 00172 real sum; 00173 00174 ntom += fr->ntom_step; 00175 if(ntom < NTOM_MUL) 00176 { 00177 window -= 16; 00178 b0 += 16; 00179 continue; 00180 } 00181 00182 sum = REAL_MUL_SYNTH(-*(--window), *b0++); 00183 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00184 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00185 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00186 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00187 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00188 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00189 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00190 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00191 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00192 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00193 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00194 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00195 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00196 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00197 sum -= REAL_MUL_SYNTH(*(--window), *b0++); 00198 00199 while(ntom >= NTOM_MUL) 00200 { 00201 WRITE_SAMPLE(samples,sum,clip); 00202 samples += step; 00203 ntom -= NTOM_MUL; 00204 } 00205 } 00206 } 00207 00208 fr->ntom_val[channel] = ntom; 00209 if(final) fr->buffer.fill = ((unsigned char *) samples - fr->buffer.data - (channel ? sizeof(SAMPLE_T) : 0)); 00210 00211 return clip; 00212 } 00213 Generated on Sat May 26 2012 04:31:59 for ReactOS by
1.7.6.1
|