22 #include "../ogg/ogg.h"
23 #include "../vorbis/codec.h"
43 memset(info,0,
sizeof(*info));
48 static int ilog(
unsigned int v){
106 memset(info,0,
sizeof(*info));
148 mapping0_free_info(info);
163 static float FLOOR1_fromdB_LOOKUP[256]={
164 1.0649863e-07
F, 1.1341951e-07
F, 1.2079015e-07
F, 1.2863978e-07
F,
165 1.3699951e-07
F, 1.4590251e-07
F, 1.5538408e-07
F, 1.6548181e-07
F,
166 1.7623575e-07
F, 1.8768855e-07
F, 1.9988561e-07
F, 2.128753e-07
F,
167 2.2670913e-07
F, 2.4144197e-07
F, 2.5713223e-07
F, 2.7384213e-07
F,
168 2.9163793e-07
F, 3.1059021e-07
F, 3.3077411e-07
F, 3.5226968e-07
F,
169 3.7516214e-07
F, 3.9954229e-07
F, 4.2550680e-07
F, 4.5315863e-07
F,
170 4.8260743e-07
F, 5.1396998e-07
F, 5.4737065e-07
F, 5.8294187e-07
F,
171 6.2082472e-07
F, 6.6116941e-07
F, 7.0413592e-07
F, 7.4989464e-07
F,
172 7.9862701e-07
F, 8.5052630e-07
F, 9.0579828e-07
F, 9.6466216e-07
F,
173 1.0273513e-06
F, 1.0941144e-06
F, 1.1652161e-06
F, 1.2409384e-06
F,
174 1.3215816e-06
F, 1.4074654e-06
F, 1.4989305e-06
F, 1.5963394e-06
F,
175 1.7000785e-06
F, 1.8105592e-06
F, 1.9282195e-06
F, 2.0535261e-06
F,
176 2.1869758e-06
F, 2.3290978e-06
F, 2.4804557e-06
F, 2.6416497e-06
F,
177 2.8133190e-06
F, 2.9961443e-06
F, 3.1908506e-06
F, 3.3982101e-06
F,
178 3.6190449e-06
F, 3.8542308e-06
F, 4.1047004e-06
F, 4.3714470e-06
F,
179 4.6555282e-06
F, 4.9580707e-06
F, 5.2802740e-06
F, 5.6234160e-06
F,
180 5.9888572e-06
F, 6.3780469e-06
F, 6.7925283e-06
F, 7.2339451e-06
F,
181 7.7040476e-06
F, 8.2047000e-06
F, 8.7378876e-06
F, 9.3057248e-06
F,
182 9.9104632e-06
F, 1.0554501e-05
F, 1.1240392e-05
F, 1.1970856e-05
F,
183 1.2748789e-05
F, 1.3577278e-05
F, 1.4459606e-05
F, 1.5399272e-05
F,
184 1.6400004e-05
F, 1.7465768e-05
F, 1.8600792e-05
F, 1.9809576e-05
F,
185 2.1096914e-05
F, 2.2467911e-05
F, 2.3928002e-05
F, 2.5482978e-05
F,
186 2.7139006e-05
F, 2.8902651e-05
F, 3.0780908e-05
F, 3.2781225e-05
F,
187 3.4911534e-05
F, 3.7180282e-05
F, 3.9596466e-05
F, 4.2169667e-05
F,
188 4.4910090e-05
F, 4.7828601e-05
F, 5.0936773e-05
F, 5.4246931e-05
F,
189 5.7772202e-05
F, 6.1526565e-05
F, 6.5524908e-05
F, 6.9783085e-05
F,
190 7.4317983e-05
F, 7.9147585e-05
F, 8.4291040e-05
F, 8.9768747e-05
F,
191 9.5602426e-05
F, 0.00010181521F, 0.00010843174F, 0.00011547824F,
192 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F,
193 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F,
194 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F,
195 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F,
196 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F,
197 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F,
198 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F,
199 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F,
200 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F,
201 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F,
202 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F,
203 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F,
204 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F,
205 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F,
206 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F,
207 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F,
208 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F,
209 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F,
210 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F,
211 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F,
212 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F,
213 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F,
214 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F,
215 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F,
216 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F,
217 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F,
218 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F,
219 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F,
220 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F,
221 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F,
222 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F,
223 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F,
224 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F,
225 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F,
226 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F,
227 0.82788260F, 0.88168307F, 0.9389798F, 1.F,
233 const float *logmdct,
234 const float *logmask);
239 int *post,
int *ilogmask);
251 int *nonzero = alloca(
sizeof(*nonzero)*vi->
channels);
256 float global_ampmax=vbi->
ampmax;
257 float *local_ampmax=alloca(
sizeof(*local_ampmax)*vi->
channels);
260 int modenumber=vb->
W;
263 b->
psy+blocktype+(vb->
W?2:0);
271 float *pcm =vb->
pcm[
i];
276 scale_dB=todB(&scale);
303 logfft[0]=scale_dB+todB(pcm);
304 local_ampmax[
i]=logfft[0];
306 float temp=pcm[
j]*pcm[
j]+pcm[
j+1]*pcm[
j+1];
307 temp=logfft[(
j+1)>>1]=scale_dB+.5
f*todB(&temp);
308 if(temp>local_ampmax[i])local_ampmax[
i]=temp;
311 if(local_ampmax[i]>0.
f)local_ampmax[
i]=0.f;
312 if(local_ampmax[i]>global_ampmax)global_ampmax=local_ampmax[
i];
335 float *mdct =gmdct[
i];
336 float *logfft =vb->
pcm[
i];
338 float *logmdct =logfft+n/2;
339 float *logmask =logfft;
344 memset(floor_posts[i],0,
sizeof(**floor_posts)*
PACKETBLOBS);
347 logmdct[
j]=todB(mdct+
j);
484 floor_posts[i][PACKETBLOBS/2],
485 floor_posts[i][PACKETBLOBS-1],
486 (k-PACKETBLOBS/2)*65536/(PACKETBLOBS/2));
490 vbi->
ampmax=global_ampmax;
507 float **res_bundle=alloca(
sizeof(*res_bundle)*vi->
channels);
508 float **couple_bundle=alloca(
sizeof(*couple_bundle)*vi->
channels);
509 int *zerobundle=alloca(
sizeof(*zerobundle)*vi->
channels);
510 int **sortindex=alloca(
sizeof(*sortindex)*vi->
channels);
527 memset(sortindex,0,
sizeof(*sortindex)*vi->
channels);
530 float *mdct =gmdct[
i];
531 sortindex[
i]=alloca(
sizeof(**sortindex)*n/2);
554 float *mdct =gmdct[
i];
556 int *ilogmask=ilogmaskch[
i]=
565 sprintf(buf,
"maskI%c%d",i?
'R':
'L',k);
568 work[
j]=FLOOR1_fromdB_LOOKUP[ilogmask[
j]];
586 work[
j]=FLOOR1_fromdB_LOOKUP[ilogmask[
j]]*(res+n/2)[
j];
587 sprintf(buf,
"resI%c%d",i?
'R':
'L',k);
616 long **classifications;
621 zerobundle[ch_in_bundle]=0;
622 if(nonzero[
j])zerobundle[ch_in_bundle]=1;
623 res_bundle[ch_in_bundle]=vb->
pcm[
j];
624 couple_bundle[ch_in_bundle++]=vb->
pcm[
j]+n/2;
629 class(vb,b->
residue[resnum],couple_bundle,zerobundle,ch_in_bundle);
633 couple_bundle,
NULL,zerobundle,ch_in_bundle,classifications);
662 float **pcmbundle=alloca(
sizeof(*pcmbundle)*vi->
channels);
663 int *zerobundle=alloca(
sizeof(*zerobundle)*vi->
channels);
665 int *nonzero =alloca(
sizeof(*nonzero)*vi->
channels);
666 void **floormemo=alloca(
sizeof(*floormemo)*vi->
channels);
677 memset(vb->
pcm[i],0,
sizeof(*vb->
pcm[i])*n/2);
695 zerobundle[ch_in_bundle]=1;
697 zerobundle[ch_in_bundle]=0;
698 pcmbundle[ch_in_bundle++]=vb->
pcm[
j];
704 pcmbundle,zerobundle,ch_in_bundle);
737 float *pcm=vb->
pcm[
i];
747 float *pcm=vb->
pcm[
i];
int ** _vp_quantize_couple_sort(vorbis_block *vb, vorbis_look_psy *p, vorbis_info_mapping0 *vi, float **mags)
void _vp_tonemask(vorbis_look_psy *p, float *logfft, float *logmask, float global_specmax, float local_specmax)
int sliding_lowpass[2][PACKETBLOBS]
GLenum GLenum GLenum GLenum GLenum scale
void _analysis_output(char *base, int i, float *v, int n, int bark, int dB, ogg_int64_t off)
void mdct_forward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out)
void oggpack_write(oggpack_buffer *b, unsigned long value, int bits)
int * floor1_interpolate_fit(vorbis_block *vb, vorbis_look_floor *look, int *A, int *B, int del)
void _vp_noise_normalize_sort(vorbis_look_psy *p, float *magnitudes, int *sortedindex)
struct vorbis_info_psy * vi
void _vp_offset_and_mix(vorbis_look_psy *p, float *noise, float *tone, int offset_select, float *logmask)
void mdct_backward(mdct_lookup *init, DATA_TYPE *in, DATA_TYPE *out)
vorbis_look_transform ** transform[2]
void _vp_remove_floor(vorbis_look_psy *p, float *mdct, int *codedflr, float *residue, int sliding_lowpass)
int floor1_encode(vorbis_block *vb, vorbis_look_floor *look, int *post, int *ilogmask)
ogg_uint32_t packetblob_markers[PACKETBLOBS]
vorbis_info_psy_global psy_g_param
vorbis_func_mapping mapping0_exportbundle
vorbis_func_floor * _floor_P[]
int vorbis_bitrate_managed(vorbis_block *vb)
vorbis_func_residue * _residue_P[]
void _vorbis_apply_window(float *d, int *winno, long *blocksizes, int lW, int W, int nW)
void _vp_couple(int blobno, vorbis_info_psy_global *g, vorbis_look_psy *p, vorbis_info_mapping0 *vi, float **res, float **mag_memo, int **mag_sort, int **ifloor, int *nonzero, int sliding_lowpass)
vorbis_look_residue ** residue
long oggpack_bytes(oggpack_buffer *b)
void _vp_noise_normalize(vorbis_look_psy *p, float *in, float *out, int *sortedindex)
float ** _vp_quantize_couple_memo(vorbis_block *vb, vorbis_info_psy_global *g, vorbis_look_psy *p, vorbis_info_mapping0 *vi, float **mdct)
int * floor1_fit(vorbis_block *vb, vorbis_look_floor *look, const float *logmdct, const float *logmask)
void oggpack_writealign(oggpack_buffer *b)
void _vp_noisemask(vorbis_look_psy *p, float *logmdct, float *logmask)
long oggpack_read(oggpack_buffer *b, int bits)
int sprintf(idStr &string, const char *fmt,...)
void * _vorbis_block_alloc(vorbis_block *vb, long bytes)
void drft_forward(drft_lookup *l, float *data)
vorbis_info_mapping * map_param[64]