| 1 | /******************************************************************** |
| 2 | * * |
| 3 | * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * |
| 4 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
| 5 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
| 6 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
| 7 | * * |
| 8 | * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2010 * |
| 9 | * by the Xiph.Org Foundation https://xiph.org/ * |
| 10 | * * |
| 11 | ******************************************************************** |
| 12 | |
| 13 | function: psychoacoustics not including preecho |
| 14 | |
| 15 | ********************************************************************/ |
| 16 | |
| 17 | #include "vorbis_codec.h"cxx . . $ `<file>/external/vorbis/vorbis_codec.h`/ |
| 18 | #include "vorbis_codec_internal.h"cxx . . $ `<file>/external/vorbis/vorbis_codec_internal.h`/ |
| 19 | |
| 20 | #include "vorbis_masking.h"cxx . . $ `<file>/external/vorbis/vorbis_masking.h`/ |
| 21 | #include "vorbis_psy.h"cxx . . $ `<file>/external/vorbis/vorbis_psy.h`/ |
| 22 | #include "vorbis_os.h"cxx . . $ `<file>/external/vorbis/vorbis_os.h`/ |
| 23 | #include "vorbis_lpc.h"cxx . . $ `<file>/external/vorbis/vorbis_lpc.h`/ |
| 24 | #include "vorbis_smallft.h"cxx . . $ `<file>/external/vorbis/vorbis_smallft.h`/ |
| 25 | #include "vorbis_scales.h"cxx . . $ `<file>/external/vorbis/vorbis_scales.h`/ |
| 26 | #include "vorbis_misc.h"cxx . . $ `<file>/external/vorbis/vorbis_misc.h`/ |
| 27 | |
| 28 | #define NEGINFcxx . . $ `external/vorbis/vorbis_psy.cpp:28:9`! -9999.f |
| 29 | static const double stereo_threshholdscxx . . $ stereo_threshholds.[]={0.0, .5, 1.0, 1.5, 2.5, 4.5, 8.5, 16.5, 9e10}; |
| 30 | static const double stereo_threshholds_limitedcxx . . $ stereo_threshholds_limited.[]={0.0, .5, 1.0, 1.5, 2.0, 2.5, 4.5, 8.5, 9e10}; |
| 31 | |
| 32 | vorbis_look_psy_globalcxx . . $ vorbis_look_psy_global# *_vp_global_lookcxx . . $ _vp_global_look(694741b8775fe5aa).(vorbis_infocxx . . $ vorbis_info# *vi){ |
| 33 | codec_setup_infocxx . . $ codec_setup_info# *ci = (codec_setup_infocxx . . $ codec_setup_info# *) vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 34 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *gi=&ci->psy_g_paramcxx . . $ codec_setup_info#psy_g_param.; |
| 35 | vorbis_look_psy_globalcxx . . $ vorbis_look_psy_global# *look = (vorbis_look_psy_globalcxx . . $ vorbis_look_psy_global# *)_Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(1,sizeof(*look)); |
| 36 | |
| 37 | look->channelscxx . . $ $anonymous_type_1598a95364f6cf37_1#channels.=vi->channelscxx . . $ vorbis_info#channels.; |
| 38 | |
| 39 | look->ampmaxcxx . . $ $anonymous_type_1598a95364f6cf37_1#ampmax.=-9999.; |
| 40 | look->gicxx . . $ $anonymous_type_1598a95364f6cf37_1#gi.=gi; |
| 41 | return(look); |
| 42 | } |
| 43 | |
| 44 | void _vp_global_freecxx . . $ _vp_global_free(aa7a30c4816a9b12).(vorbis_look_psy_globalcxx . . $ vorbis_look_psy_global# *look){ |
| 45 | if(look){ |
| 46 | memset(look,0,sizeof(*look)); |
| 47 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(look); |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | void _vi_gpsy_freecxx . . $ _vi_gpsy_free(e423f5f4e0bd61e0).(vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *i){ |
| 52 | if(i){ |
| 53 | memset(i,0,sizeof(*i)); |
| 54 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(i); |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | void _vi_psy_freecxx . . $ _vi_psy_free(56bda761faefe858).(vorbis_info_psycxx . . $ vorbis_info_psy# *i){ |
| 59 | if(i){ |
| 60 | memset(i,0,sizeof(*i)); |
| 61 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(i); |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | static void min_curvecxx . . $ min_curve(abb9d6b01b35f6ff).(float *c, |
| 66 | float *c2){ |
| 67 | int i; |
| 68 | for(i=0;i<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;i++)if(c2[i]<c[i])c[i]=c2[i]; |
| 69 | } |
| 70 | static void max_curvecxx . . $ max_curve(abb9d6b01b35f6ff).(float *c, |
| 71 | float *c2){ |
| 72 | int i; |
| 73 | for(i=0;i<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;i++)if(c2[i]>c[i])c[i]=c2[i]; |
| 74 | } |
| 75 | |
| 76 | static void attenuate_curvecxx . . $ attenuate_curve(9bd0a12095c43560).(float *c,float att){ |
| 77 | int i; |
| 78 | for(i=0;i<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;i++) |
| 79 | c[i]+=att; |
| 80 | } |
| 81 | |
| 82 | static float ***setup_tone_curvescxx . . $ setup_tone_curves(8746861c5ed0dcfe).(float curveatt_dB[P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!],float binHz,int n, |
| 83 | float center_boost, float center_decay_rate){ |
| 84 | int i,j,k,m; |
| 85 | float ath[EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!]; |
| 86 | float workc[P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!][P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!][EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!]; |
| 87 | float athc[P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!][EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!]; |
| 88 | float *brute_buffer = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*brute_buffer)); |
| 89 | |
| 90 | float ***ret = (float ***) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(sizeof(*ret)*P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!); |
| 91 | |
| 92 | memset(workc,0,sizeof(workc)); |
| 93 | |
| 94 | for(i=0;i<P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!;i++){ |
| 95 | /* we add back in the ATH to avoid low level curves falling off to |
| 96 | -infinity and unnecessarily cutting off high level curves in the |
| 97 | curve limiting (last step). */ |
| 98 | |
| 99 | /* A half-band's settings must be valid over the whole band, and |
| 100 | it's better to mask too little than too much */ |
| 101 | int ath_offset=i*4; |
| 102 | for(j=0;j<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;j++){ |
| 103 | float min=999.; |
| 104 | for(k=0;k<4;k++) |
| 105 | if(j+k+ath_offset<MAX_ATHcxx . . $ `external/vorbis/vorbis_masking.h:23:9`!){ |
| 106 | if(min>ATHcxx . . $ ATH.[j+k+ath_offset])min=ATHcxx . . $ ATH.[j+k+ath_offset]; |
| 107 | }else{ |
| 108 | if(min>ATHcxx . . $ ATH.[MAX_ATHcxx . . $ `external/vorbis/vorbis_masking.h:23:9`!-1])min=ATHcxx . . $ ATH.[MAX_ATHcxx . . $ `external/vorbis/vorbis_masking.h:23:9`!-1]; |
| 109 | } |
| 110 | ath[j]=min; |
| 111 | } |
| 112 | |
| 113 | /* copy curves into working space, replicate the 50dB curve to 30 |
| 114 | and 40, replicate the 100dB curve to 110 */ |
| 115 | for(j=0;j<6;j++) |
| 116 | memcpy(workc[i][j+2],tonemaskscxx . . $ tonemasks.[i][j],EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!*sizeof(*tonemaskscxx . . $ tonemasks.[i][j])); |
| 117 | memcpy(workc[i][0],tonemaskscxx . . $ tonemasks.[i][0],EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!*sizeof(*tonemaskscxx . . $ tonemasks.[i][0])); |
| 118 | memcpy(workc[i][1],tonemaskscxx . . $ tonemasks.[i][0],EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!*sizeof(*tonemaskscxx . . $ tonemasks.[i][0])); |
| 119 | |
| 120 | /* apply centered curve boost/decay */ |
| 121 | for(j=0;j<P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!;j++){ |
| 122 | for(k=0;k<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;k++){ |
| 123 | float adj=center_boost+abscxx . . $ abs(a1851578aea3f541).(EHMER_OFFSETcxx . . $ `external/vorbis/vorbis_masking.h:42:9`!-k)*center_decay_rate; |
| 124 | if(adj<0. && center_boost>0)adj=0.; |
| 125 | if(adj>0. && center_boost<0)adj=0.; |
| 126 | workc[i][j][k]+=adj; |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | /* normalize curves so the driving amplitude is 0dB */ |
| 131 | /* make temp curves with the ATH overlayed */ |
| 132 | for(j=0;j<P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!;j++){ |
| 133 | attenuate_curvecxx . . $ attenuate_curve(9bd0a12095c43560).(workc[i][j],curveatt_dB[i]+100.-(j<2?2:j)*10.-P_LEVEL_0cxx . . $ `external/vorbis/vorbis_psy.h:31:9`!); |
| 134 | memcpy(athc[j],ath,EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!*sizeof(**athc)); |
| 135 | attenuate_curvecxx . . $ attenuate_curve(9bd0a12095c43560).(athc[j],+100.-j*10.f-P_LEVEL_0cxx . . $ `external/vorbis/vorbis_psy.h:31:9`!); |
| 136 | max_curvecxx . . $ max_curve(abb9d6b01b35f6ff).(athc[j],workc[i][j]); |
| 137 | } |
| 138 | |
| 139 | /* Now limit the louder curves. |
| 140 | |
| 141 | the idea is this: We don't know what the playback attenuation |
| 142 | will be; 0dB SL moves every time the user twiddles the volume |
| 143 | knob. So that means we have to use a single 'most pessimal' curve |
| 144 | for all masking amplitudes, right? Wrong. The *loudest* sound |
| 145 | can be in (we assume) a range of ...+100dB] SL. However, sounds |
| 146 | 20dB down will be in a range ...+80], 40dB down is from ...+60], |
| 147 | etc... */ |
| 148 | |
| 149 | for(j=1;j<P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!;j++){ |
| 150 | min_curvecxx . . $ min_curve(abb9d6b01b35f6ff).(athc[j],athc[j-1]); |
| 151 | min_curvecxx . . $ min_curve(abb9d6b01b35f6ff).(workc[i][j],athc[j]); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | for(i=0;i<P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!;i++){ |
| 156 | int hi_curve,lo_curve,bin; |
| 157 | ret[i] = (float **) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(sizeof(**ret)*P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!); |
| 158 | |
| 159 | /* low frequency curves are measured with greater resolution than |
| 160 | the MDCT/FFT will actually give us; we want the curve applied |
| 161 | to the tone data to be pessimistic and thus apply the minimum |
| 162 | masking possible for a given bin. That means that a single bin |
| 163 | could span more than one octave and that the curve will be a |
| 164 | composite of multiple octaves. It also may mean that a single |
| 165 | bin may span > an eighth of an octave and that the eighth |
| 166 | octave values may also be composited. */ |
| 167 | |
| 168 | /* which octave curves will we be compositing? */ |
| 169 | bin=floorcxx . . $ floor(fee4f1d22bc8e617).(fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!(i*.5)/binHz); |
| 170 | lo_curve= ceilcxx . . $ ceil(fbcf3211dfe1bfd1).(toOCcxx . . $ `external/vorbis/vorbis_scales.h:81:9`!(bin*binHz+1)*2); |
| 171 | hi_curve= floorcxx . . $ floor(fbcf3211dfe1bfd1).(toOCcxx . . $ `external/vorbis/vorbis_scales.h:81:9`!((bin+1)*binHz)*2); |
| 172 | if(lo_curve>i)lo_curve=i; |
| 173 | if(lo_curve<0)lo_curve=0; |
| 174 | if(hi_curve>=P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!)hi_curve=P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!-1; |
| 175 | |
| 176 | for(m=0;m<P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!;m++){ |
| 177 | ret[i][m] = (float *) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(sizeof(***ret)*(EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!+2)); |
| 178 | |
| 179 | for(j=0;j<n;j++)brute_buffer[j]=999.; |
| 180 | |
| 181 | /* render the curve into bins, then pull values back into curve. |
| 182 | The point is that any inherent subsampling aliasing results in |
| 183 | a safe minimum */ |
| 184 | for(k=lo_curve;k<=hi_curve;k++){ |
| 185 | int l=0; |
| 186 | |
| 187 | for(j=0;j<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;j++){ |
| 188 | int lo_bin= fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!(j*.125+k*.5-2.0625)/binHz; |
| 189 | int hi_bin= fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!(j*.125+k*.5-1.9375)/binHz+1; |
| 190 | |
| 191 | if(lo_bin<0)lo_bin=0; |
| 192 | if(lo_bin>n)lo_bin=n; |
| 193 | if(lo_bin<l)l=lo_bin; |
| 194 | if(hi_bin<0)hi_bin=0; |
| 195 | if(hi_bin>n)hi_bin=n; |
| 196 | |
| 197 | for(;l<hi_bin && l<n;l++) |
| 198 | if(brute_buffer[l]>workc[k][m][j]) |
| 199 | brute_buffer[l]=workc[k][m][j]; |
| 200 | } |
| 201 | |
| 202 | for(;l<n;l++) |
| 203 | if(brute_buffer[l]>workc[k][m][EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!-1]) |
| 204 | brute_buffer[l]=workc[k][m][EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!-1]; |
| 205 | |
| 206 | } |
| 207 | |
| 208 | /* be equally paranoid about being valid up to next half ocatve */ |
| 209 | if(i+1<P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!){ |
| 210 | int l=0; |
| 211 | k=i+1; |
| 212 | for(j=0;j<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;j++){ |
| 213 | int lo_bin= fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!(j*.125+i*.5-2.0625)/binHz; |
| 214 | int hi_bin= fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!(j*.125+i*.5-1.9375)/binHz+1; |
| 215 | |
| 216 | if(lo_bin<0)lo_bin=0; |
| 217 | if(lo_bin>n)lo_bin=n; |
| 218 | if(lo_bin<l)l=lo_bin; |
| 219 | if(hi_bin<0)hi_bin=0; |
| 220 | if(hi_bin>n)hi_bin=n; |
| 221 | |
| 222 | for(;l<hi_bin && l<n;l++) |
| 223 | if(brute_buffer[l]>workc[k][m][j]) |
| 224 | brute_buffer[l]=workc[k][m][j]; |
| 225 | } |
| 226 | |
| 227 | for(;l<n;l++) |
| 228 | if(brute_buffer[l]>workc[k][m][EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!-1]) |
| 229 | brute_buffer[l]=workc[k][m][EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!-1]; |
| 230 | |
| 231 | } |
| 232 | |
| 233 | |
| 234 | for(j=0;j<EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!;j++){ |
| 235 | int binn=fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!(j*.125+i*.5-2.)/binHz; |
| 236 | if(binn<0){ |
| 237 | ret[i][m][j+2]=-999.; |
| 238 | }else{ |
| 239 | if(binn>=n){ |
| 240 | ret[i][m][j+2]=-999.; |
| 241 | }else{ |
| 242 | ret[i][m][j+2]=brute_buffer[binn]; |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | /* add fenceposts */ |
| 248 | for(j=0;j<EHMER_OFFSETcxx . . $ `external/vorbis/vorbis_masking.h:42:9`!;j++) |
| 249 | if(ret[i][m][j+2]>-200.f)break; |
| 250 | ret[i][m][0]=j; |
| 251 | |
| 252 | for(j=EHMER_MAXcxx . . $ `external/vorbis/vorbis_masking.h:43:9`!-1;j>EHMER_OFFSETcxx . . $ `external/vorbis/vorbis_masking.h:42:9`!+1;j--) |
| 253 | if(ret[i][m][j+2]>-200.f) |
| 254 | break; |
| 255 | ret[i][m][1]=j; |
| 256 | |
| 257 | } |
| 258 | } |
| 259 | |
| 260 | return(ret); |
| 261 | } |
| 262 | |
| 263 | void _vp_psy_initcxx . . $ _vp_psy_init(f2fa2c2006bac383).(vorbis_look_psycxx . . $ vorbis_look_psy# *p,vorbis_info_psycxx . . $ vorbis_info_psy# *vi, |
| 264 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *gi,int n,long rate){ |
| 265 | long i,j,lo=-99,hi=1; |
| 266 | long maxoc; |
| 267 | memset(p,0,sizeof(*p)); |
| 268 | |
| 269 | p->eighth_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#eighth_octave_lines.=gi->eighth_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_0#eighth_octave_lines.; |
| 270 | p->shiftoccxx . . $ $anonymous_type_1598a95364f6cf37_2#shiftoc.=rintcxx . . $ rint(fbcf3211dfe1bfd1).(logcxx . . $ log(fbcf3211dfe1bfd1).(gi->eighth_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_0#eighth_octave_lines.*8.f)/logcxx . . $ log(fbcf3211dfe1bfd1).(2.f))-1; |
| 271 | |
| 272 | p->firstoccxx . . $ $anonymous_type_1598a95364f6cf37_2#firstoc.=toOCcxx . . $ `external/vorbis/vorbis_scales.h:81:9`!(.25f*rate*.5/n)*(1<<(p->shiftoccxx . . $ $anonymous_type_1598a95364f6cf37_2#shiftoc.+1))-gi->eighth_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_0#eighth_octave_lines.; |
| 273 | maxoc=toOCcxx . . $ `external/vorbis/vorbis_scales.h:81:9`!((n+.25f)*rate*.5/n)*(1<<(p->shiftoccxx . . $ $anonymous_type_1598a95364f6cf37_2#shiftoc.+1))+.5f; |
| 274 | p->total_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#total_octave_lines.=maxoc-p->firstoccxx . . $ $anonymous_type_1598a95364f6cf37_2#firstoc.+1; |
| 275 | p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.= (float *) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(n*sizeof(*p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.)); |
| 276 | |
| 277 | p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave. = (long *)_Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(n*sizeof(*p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.)); |
| 278 | p->barkcxx . . $ $anonymous_type_1598a95364f6cf37_2#bark. = (long *) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(n*sizeof(*p->barkcxx . . $ $anonymous_type_1598a95364f6cf37_2#bark.)); |
| 279 | p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.=vi; |
| 280 | p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.=n; |
| 281 | p->ratecxx . . $ $anonymous_type_1598a95364f6cf37_2#rate.=rate; |
| 282 | |
| 283 | /* AoTuV HF weighting */ |
| 284 | p->m_valcxx . . $ $anonymous_type_1598a95364f6cf37_2#m_val. = 1.; |
| 285 | if(rate < 26000) p->m_valcxx . . $ $anonymous_type_1598a95364f6cf37_2#m_val. = 0; |
| 286 | else if(rate < 38000) p->m_valcxx . . $ $anonymous_type_1598a95364f6cf37_2#m_val. = .94; /* 32kHz */ |
| 287 | else if(rate > 46000) p->m_valcxx . . $ $anonymous_type_1598a95364f6cf37_2#m_val. = 1.275; /* 48kHz */ |
| 288 | |
| 289 | /* set up the lookups for a given blocksize and sample rate */ |
| 290 | |
| 291 | for(i=0,j=0;i<MAX_ATHcxx . . $ `external/vorbis/vorbis_masking.h:23:9`!-1;i++){ |
| 292 | int endpos=rintcxx . . $ rint(fee4f1d22bc8e617).(fromOCcxx . . $ `external/vorbis/vorbis_scales.h:82:9`!((i+1)*.125-2.)*2*n/rate); |
| 293 | float base=ATHcxx . . $ ATH.[i]; |
| 294 | if(j<endpos){ |
| 295 | float delta=(ATHcxx . . $ ATH.[i+1]-base)/(endpos-j); |
| 296 | for(;j<endpos && j<n;j++){ |
| 297 | p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.[j]=base+100.; |
| 298 | base+=delta; |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | for(;j<n;j++){ |
| 304 | p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.[j]=p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.[j-1]; |
| 305 | } |
| 306 | |
| 307 | for(i=0;i<n;i++){ |
| 308 | float bark=toBARKcxx . . $ `external/vorbis/vorbis_scales.h:73:9`!(rate/(2*n)*i); |
| 309 | |
| 310 | for(;lo+vi->noisewindowlomincxx . . $ vorbis_info_psy#noisewindowlomin.<i && |
| 311 | toBARKcxx . . $ `external/vorbis/vorbis_scales.h:73:9`!(rate/(2*n)*lo)<(bark-vi->noisewindowlocxx . . $ vorbis_info_psy#noisewindowlo.);lo++); |
| 312 | |
| 313 | for(;hi<=n && (hi<i+vi->noisewindowhimincxx . . $ vorbis_info_psy#noisewindowhimin. || |
| 314 | toBARKcxx . . $ `external/vorbis/vorbis_scales.h:73:9`!(rate/(2*n)*hi)<(bark+vi->noisewindowhicxx . . $ vorbis_info_psy#noisewindowhi.));hi++); |
| 315 | |
| 316 | p->barkcxx . . $ $anonymous_type_1598a95364f6cf37_2#bark.[i]=((lo-1)<<16)+(hi-1); |
| 317 | |
| 318 | } |
| 319 | |
| 320 | for(i=0;i<n;i++) |
| 321 | p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[i]=toOCcxx . . $ `external/vorbis/vorbis_scales.h:81:9`!((i+.25f)*.5*rate/n)*(1<<(p->shiftoccxx . . $ $anonymous_type_1598a95364f6cf37_2#shiftoc.+1))+.5f; |
| 322 | |
| 323 | p->tonecurvescxx . . $ $anonymous_type_1598a95364f6cf37_2#tonecurves.=setup_tone_curvescxx . . $ setup_tone_curves(8746861c5ed0dcfe).(vi->toneattcxx . . $ vorbis_info_psy#toneatt.,rate*.5/n,n, |
| 324 | vi->tone_centerboostcxx . . $ vorbis_info_psy#tone_centerboost.,vi->tone_decaycxx . . $ vorbis_info_psy#tone_decay.); |
| 325 | |
| 326 | /* set up rolling noise median */ |
| 327 | p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset. = (float **) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(P_NOISECURVEScxx . . $ `external/vorbis/vorbis_psy.h:32:9`!*sizeof(*p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset.)); |
| 328 | for(i=0;i<P_NOISECURVEScxx . . $ `external/vorbis/vorbis_psy.h:32:9`!;i++) |
| 329 | p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset.[i]= (float *) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(n*sizeof(**p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset.)); |
| 330 | |
| 331 | for(i=0;i<n;i++){ |
| 332 | float halfoc=toOCcxx . . $ `external/vorbis/vorbis_scales.h:81:9`!((i+.5)*rate/(2.*n))*2.; |
| 333 | int inthalfoc; |
| 334 | float del; |
| 335 | |
| 336 | if(halfoc<0)halfoc=0; |
| 337 | if(halfoc>=P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!-1)halfoc=P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!-1; |
| 338 | inthalfoc=(int)halfoc; |
| 339 | del=halfoc-inthalfoc; |
| 340 | |
| 341 | for(j=0;j<P_NOISECURVEScxx . . $ `external/vorbis/vorbis_psy.h:32:9`!;j++) |
| 342 | p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset.[j][i]= |
| 343 | p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->noiseoffcxx . . $ vorbis_info_psy#noiseoff.[j][inthalfoc]*(1.-del) + |
| 344 | p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->noiseoffcxx . . $ vorbis_info_psy#noiseoff.[j][inthalfoc+1]*del; |
| 345 | |
| 346 | } |
| 347 | #if 0 |
| 348 | { |
| 349 | static int ls=0; |
| 350 | _analysis_output_always("noiseoff0",ls,p->noiseoffset[0],n,1,0,0); |
| 351 | _analysis_output_always("noiseoff1",ls,p->noiseoffset[1],n,1,0,0); |
| 352 | _analysis_output_always("noiseoff2",ls++,p->noiseoffset[2],n,1,0,0); |
| 353 | } |
| 354 | #endif |
| 355 | } |
| 356 | |
| 357 | void _vp_psy_clearcxx . . $ _vp_psy_clear(6d5e2970931fb99a).(vorbis_look_psycxx . . $ vorbis_look_psy# *p){ |
| 358 | int i,j; |
| 359 | if(p){ |
| 360 | if(p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->ath); |
| 361 | if(p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->octave); |
| 362 | if(p->barkcxx . . $ $anonymous_type_1598a95364f6cf37_2#bark.)Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->bark); |
| 363 | if(p->tonecurvescxx . . $ $anonymous_type_1598a95364f6cf37_2#tonecurves.){ |
| 364 | for(i=0;i<P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!;i++){ |
| 365 | for(j=0;j<P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!;j++){ |
| 366 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->tonecurves[i][j]); |
| 367 | } |
| 368 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->tonecurves[i]); |
| 369 | } |
| 370 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->tonecurves); |
| 371 | } |
| 372 | if(p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset.){ |
| 373 | for(i=0;i<P_NOISECURVEScxx . . $ `external/vorbis/vorbis_psy.h:32:9`!;i++){ |
| 374 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->noiseoffset[i]); |
| 375 | } |
| 376 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(p->noiseoffset); |
| 377 | } |
| 378 | memset(p,0,sizeof(*p)); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | /* octave/(8*eighth_octave_lines) x scale and dB y scale */ |
| 383 | static void seed_curvecxx . . $ seed_curve(f6be98fb1f9c639).(float *seed, |
| 384 | const float **curves, |
| 385 | float amp, |
| 386 | int oc, int n, |
| 387 | int linesper,float dBoffset){ |
| 388 | int i,post1; |
| 389 | int seedptr; |
| 390 | const float *posts,*curve; |
| 391 | |
| 392 | int choice=(int)((amp+dBoffset-P_LEVEL_0cxx . . $ `external/vorbis/vorbis_psy.h:31:9`!)*.1f); |
| 393 | choice=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(choice,0); |
| 394 | choice=stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(choice,P_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:30:9`!-1); |
| 395 | posts=curves[choice]; |
| 396 | curve=posts+2; |
| 397 | post1=(int)posts[1]; |
| 398 | seedptr=oc+(posts[0]-EHMER_OFFSETcxx . . $ `external/vorbis/vorbis_masking.h:42:9`!)*linesper-(linesper>>1); |
| 399 | |
| 400 | for(i=posts[0];i<post1;i++){ |
| 401 | if(seedptr>0){ |
| 402 | float lin=amp+curve[i]; |
| 403 | if(seed[seedptr]<lin)seed[seedptr]=lin; |
| 404 | } |
| 405 | seedptr+=linesper; |
| 406 | if(seedptr>=n)break; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | static void seed_loopcxx . . $ seed_loop(ae46f14aa7e540c2).(vorbis_look_psycxx . . $ vorbis_look_psy# *p, |
| 411 | const float ***curves, |
| 412 | const float *f, |
| 413 | const float *flr, |
| 414 | float *seed, |
| 415 | float specmax){ |
| 416 | vorbis_info_psycxx . . $ vorbis_info_psy# *vi=p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.; |
| 417 | long n=p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.,i; |
| 418 | float dBoffset=vi->max_curve_dBcxx . . $ vorbis_info_psy#max_curve_dB.-specmax; |
| 419 | |
| 420 | /* prime the working vector with peak values */ |
| 421 | |
| 422 | for(i=0;i<n;i++){ |
| 423 | float max=f[i]; |
| 424 | long oc=p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[i]; |
| 425 | while(i+1<n && p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[i+1]==oc){ |
| 426 | i++; |
| 427 | if(f[i]>max)max=f[i]; |
| 428 | } |
| 429 | |
| 430 | if(max+6.f>flr[i]){ |
| 431 | oc=oc>>p->shiftoccxx . . $ $anonymous_type_1598a95364f6cf37_2#shiftoc.; |
| 432 | |
| 433 | if(oc>=P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!)oc=P_BANDScxx . . $ `external/vorbis/vorbis_psy.h:29:9`!-1; |
| 434 | if(oc<0)oc=0; |
| 435 | |
| 436 | seed_curvecxx . . $ seed_curve(f6be98fb1f9c639).(seed, |
| 437 | curves[oc], |
| 438 | max, |
| 439 | p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[i]-p->firstoccxx . . $ $anonymous_type_1598a95364f6cf37_2#firstoc., |
| 440 | p->total_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#total_octave_lines., |
| 441 | p->eighth_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#eighth_octave_lines., |
| 442 | dBoffset); |
| 443 | } |
| 444 | } |
| 445 | } |
| 446 | |
| 447 | static void seed_chasecxx . . $ seed_chase(6f02f521f252cd29).(float *seeds, int linesper, long n){ |
| 448 | long *posstack = (long *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*posstack)); |
| 449 | float *ampstack = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*ampstack)); |
| 450 | long stack=0; |
| 451 | long pos=0; |
| 452 | long i; |
| 453 | |
| 454 | for(i=0;i<n;i++){ |
| 455 | if(stack<2){ |
| 456 | posstack[stack]=i; |
| 457 | ampstack[stack++]=seeds[i]; |
| 458 | }else{ |
| 459 | while(1){ |
| 460 | if(seeds[i]<ampstack[stack-1]){ |
| 461 | posstack[stack]=i; |
| 462 | ampstack[stack++]=seeds[i]; |
| 463 | break; |
| 464 | }else{ |
| 465 | if(i<posstack[stack-1]+linesper){ |
| 466 | if(stack>1 && ampstack[stack-1]<=ampstack[stack-2] && |
| 467 | i<posstack[stack-2]+linesper){ |
| 468 | /* we completely overlap, making stack-1 irrelevant. pop it */ |
| 469 | stack--; |
| 470 | continue; |
| 471 | } |
| 472 | } |
| 473 | posstack[stack]=i; |
| 474 | ampstack[stack++]=seeds[i]; |
| 475 | break; |
| 476 | |
| 477 | } |
| 478 | } |
| 479 | } |
| 480 | } |
| 481 | |
| 482 | /* the stack now contains only the positions that are relevant. Scan |
| 483 | 'em straight through */ |
| 484 | |
| 485 | for(i=0;i<stack;i++){ |
| 486 | long endpos; |
| 487 | if(i<stack-1 && ampstack[i+1]>ampstack[i]){ |
| 488 | endpos=posstack[i+1]; |
| 489 | }else{ |
| 490 | endpos=posstack[i]+linesper+1; /* +1 is important, else bin 0 is |
| 491 | discarded in short frames */ |
| 492 | } |
| 493 | if(endpos>n)endpos=n; |
| 494 | for(;pos<endpos;pos++) |
| 495 | seeds[pos]=ampstack[i]; |
| 496 | } |
| 497 | |
| 498 | /* there. Linear time. I now remember this was on a problem set I |
| 499 | had in Grad Skool... I didn't solve it at the time ;-) */ |
| 500 | |
| 501 | } |
| 502 | |
| 503 | /* bleaugh, this is more complicated than it needs to be */ |
| 504 | #include<stdio.h> |
| 505 | static void max_seedscxx . . $ max_seeds(4bac37cb523d88bd).(vorbis_look_psycxx . . $ vorbis_look_psy# *p, |
| 506 | float *seed, |
| 507 | float *flr){ |
| 508 | long n=p->total_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#total_octave_lines.; |
| 509 | int linesper=p->eighth_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#eighth_octave_lines.; |
| 510 | long linpos=0; |
| 511 | long pos; |
| 512 | |
| 513 | seed_chasecxx . . $ seed_chase(6f02f521f252cd29).(seed,linesper,n); /* for masking */ |
| 514 | |
| 515 | pos=p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[0]-p->firstoccxx . . $ $anonymous_type_1598a95364f6cf37_2#firstoc.-(linesper>>1); |
| 516 | |
| 517 | while(linpos+1<p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.){ |
| 518 | float minV=seed[pos]; |
| 519 | long end=((p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[linpos]+p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[linpos+1])>>1)-p->firstoccxx . . $ $anonymous_type_1598a95364f6cf37_2#firstoc.; |
| 520 | if(minV>p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->tone_abs_limitcxx . . $ vorbis_info_psy#tone_abs_limit.)minV=p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->tone_abs_limitcxx . . $ vorbis_info_psy#tone_abs_limit.; |
| 521 | while(pos+1<=end){ |
| 522 | pos++; |
| 523 | if((seed[pos]>NEGINFcxx . . $ `external/vorbis/vorbis_psy.cpp:28:9`! && seed[pos]<minV) || minV==NEGINFcxx . . $ `external/vorbis/vorbis_psy.cpp:28:9`!) |
| 524 | minV=seed[pos]; |
| 525 | } |
| 526 | |
| 527 | end=pos+p->firstoccxx . . $ $anonymous_type_1598a95364f6cf37_2#firstoc.; |
| 528 | for(;linpos<p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n. && p->octavecxx . . $ $anonymous_type_1598a95364f6cf37_2#octave.[linpos]<=end;linpos++) |
| 529 | if(flr[linpos]<minV)flr[linpos]=minV; |
| 530 | } |
| 531 | |
| 532 | { |
| 533 | float minV=seed[p->total_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#total_octave_lines.-1]; |
| 534 | for(;linpos<p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.;linpos++) |
| 535 | if(flr[linpos]<minV)flr[linpos]=minV; |
| 536 | } |
| 537 | |
| 538 | } |
| 539 | |
| 540 | static void bark_noise_hybridmpcxx . . $ bark_noise_hybridmp(4bdc80055b7b610a).(int n,const long *b, |
| 541 | const float *f, |
| 542 | float *noise, |
| 543 | const float offset, |
| 544 | const int fixed){ |
| 545 | |
| 546 | float *N = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*N)); |
| 547 | float *X = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*N)); |
| 548 | float *XX = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*N)); |
| 549 | float *Y = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*N)); |
| 550 | float *XY = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*N)); |
| 551 | |
| 552 | float tN, tX, tXX, tY, tXY; |
| 553 | int i; |
| 554 | |
| 555 | int lo, hi; |
| 556 | float R=0.f; |
| 557 | float A=0.f; |
| 558 | float B=0.f; |
| 559 | float D=1.f; |
| 560 | float w, x, y; |
| 561 | |
| 562 | tN = tX = tXX = tY = tXY = 0.f; |
| 563 | |
| 564 | y = f[0] + offset; |
| 565 | if (y < 1.f) y = 1.f; |
| 566 | |
| 567 | w = y * y * .5; |
| 568 | |
| 569 | tN += w; |
| 570 | tX += w; |
| 571 | tY += w * y; |
| 572 | |
| 573 | N[0] = tN; |
| 574 | X[0] = tX; |
| 575 | XX[0] = tXX; |
| 576 | Y[0] = tY; |
| 577 | XY[0] = tXY; |
| 578 | |
| 579 | for (i = 1, x = 1.f; i < n; i++, x += 1.f) { |
| 580 | |
| 581 | y = f[i] + offset; |
| 582 | if (y < 1.f) y = 1.f; |
| 583 | |
| 584 | w = y * y; |
| 585 | |
| 586 | tN += w; |
| 587 | tX += w * x; |
| 588 | tXX += w * x * x; |
| 589 | tY += w * y; |
| 590 | tXY += w * x * y; |
| 591 | |
| 592 | N[i] = tN; |
| 593 | X[i] = tX; |
| 594 | XX[i] = tXX; |
| 595 | Y[i] = tY; |
| 596 | XY[i] = tXY; |
| 597 | } |
| 598 | |
| 599 | for (i = 0, x = 0.f; i < n; i++, x += 1.f) { |
| 600 | |
| 601 | lo = b[i] >> 16; |
| 602 | hi = b[i] & 0xffff; |
| 603 | if( lo>=0 || -lo>=n ) break; |
| 604 | if( hi>=n ) break; |
| 605 | |
| 606 | tN = N[hi] + N[-lo]; |
| 607 | tX = X[hi] - X[-lo]; |
| 608 | tXX = XX[hi] + XX[-lo]; |
| 609 | tY = Y[hi] + Y[-lo]; |
| 610 | tXY = XY[hi] - XY[-lo]; |
| 611 | |
| 612 | A = tY * tXX - tX * tXY; |
| 613 | B = tN * tXY - tX * tY; |
| 614 | D = tN * tXX - tX * tX; |
| 615 | R = (A + x * B) / D; |
| 616 | if (R < 0.f) R = 0.f; |
| 617 | |
| 618 | noise[i] = R - offset; |
| 619 | } |
| 620 | |
| 621 | for ( ; i < n; i++, x += 1.f) { |
| 622 | |
| 623 | lo = b[i] >> 16; |
| 624 | hi = b[i] & 0xffff; |
| 625 | if( lo<0 || lo>=n ) break; |
| 626 | if( hi>=n ) break; |
| 627 | |
| 628 | tN = N[hi] - N[lo]; |
| 629 | tX = X[hi] - X[lo]; |
| 630 | tXX = XX[hi] - XX[lo]; |
| 631 | tY = Y[hi] - Y[lo]; |
| 632 | tXY = XY[hi] - XY[lo]; |
| 633 | |
| 634 | A = tY * tXX - tX * tXY; |
| 635 | B = tN * tXY - tX * tY; |
| 636 | D = tN * tXX - tX * tX; |
| 637 | R = (A + x * B) / D; |
| 638 | if (R < 0.f) R = 0.f; |
| 639 | |
| 640 | noise[i] = R - offset; |
| 641 | } |
| 642 | |
| 643 | for ( ; i < n; i++, x += 1.f) { |
| 644 | |
| 645 | R = (A + x * B) / D; |
| 646 | if (R < 0.f) R = 0.f; |
| 647 | |
| 648 | noise[i] = R - offset; |
| 649 | } |
| 650 | |
| 651 | if (fixed <= 0) return; |
| 652 | |
| 653 | for (i = 0, x = 0.f; i < n; i++, x += 1.f) { |
| 654 | hi = i + fixed / 2; |
| 655 | lo = hi - fixed; |
| 656 | if ( hi>=n ) break; |
| 657 | if ( lo>=0 ) break; |
| 658 | |
| 659 | tN = N[hi] + N[-lo]; |
| 660 | tX = X[hi] - X[-lo]; |
| 661 | tXX = XX[hi] + XX[-lo]; |
| 662 | tY = Y[hi] + Y[-lo]; |
| 663 | tXY = XY[hi] - XY[-lo]; |
| 664 | |
| 665 | |
| 666 | A = tY * tXX - tX * tXY; |
| 667 | B = tN * tXY - tX * tY; |
| 668 | D = tN * tXX - tX * tX; |
| 669 | R = (A + x * B) / D; |
| 670 | |
| 671 | if (R - offset < noise[i]) noise[i] = R - offset; |
| 672 | } |
| 673 | for ( ; i < n; i++, x += 1.f) { |
| 674 | |
| 675 | hi = i + fixed / 2; |
| 676 | lo = hi - fixed; |
| 677 | if ( hi>=n ) break; |
| 678 | if ( lo<0 ) break; |
| 679 | |
| 680 | tN = N[hi] - N[lo]; |
| 681 | tX = X[hi] - X[lo]; |
| 682 | tXX = XX[hi] - XX[lo]; |
| 683 | tY = Y[hi] - Y[lo]; |
| 684 | tXY = XY[hi] - XY[lo]; |
| 685 | |
| 686 | A = tY * tXX - tX * tXY; |
| 687 | B = tN * tXY - tX * tY; |
| 688 | D = tN * tXX - tX * tX; |
| 689 | R = (A + x * B) / D; |
| 690 | |
| 691 | if (R - offset < noise[i]) noise[i] = R - offset; |
| 692 | } |
| 693 | for ( ; i < n; i++, x += 1.f) { |
| 694 | R = (A + x * B) / D; |
| 695 | if (R - offset < noise[i]) noise[i] = R - offset; |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | void _vp_noisemaskcxx . . $ _vp_noisemask(4bac37cb523d88bd).(vorbis_look_psycxx . . $ vorbis_look_psy# *p, |
| 700 | float *logmdct, |
| 701 | float *logmask){ |
| 702 | |
| 703 | int i,n=p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.; |
| 704 | float *work = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*work)); |
| 705 | |
| 706 | bark_noise_hybridmpcxx . . $ bark_noise_hybridmp(4bdc80055b7b610a).(n,p->barkcxx . . $ $anonymous_type_1598a95364f6cf37_2#bark.,logmdct,logmask, |
| 707 | 140.,-1); |
| 708 | |
| 709 | for(i=0;i<n;i++)work[i]=logmdct[i]-logmask[i]; |
| 710 | |
| 711 | bark_noise_hybridmpcxx . . $ bark_noise_hybridmp(4bdc80055b7b610a).(n,p->barkcxx . . $ $anonymous_type_1598a95364f6cf37_2#bark.,work,logmask,0., |
| 712 | p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->noisewindowfixedcxx . . $ vorbis_info_psy#noisewindowfixed.); |
| 713 | |
| 714 | for(i=0;i<n;i++)work[i]=logmdct[i]-work[i]; |
| 715 | |
| 716 | #if 0 |
| 717 | { |
| 718 | static int seq=0; |
| 719 | |
| 720 | float work2[n]; |
| 721 | for(i=0;i<n;i++){ |
| 722 | work2[i]=logmask[i]+work[i]; |
| 723 | } |
| 724 | |
| 725 | if(seq&1) |
| 726 | _analysis_output("median2R",seq/2,work,n,1,0,0); |
| 727 | else |
| 728 | _analysis_output("median2L",seq/2,work,n,1,0,0); |
| 729 | |
| 730 | if(seq&1) |
| 731 | _analysis_output("envelope2R",seq/2,work2,n,1,0,0); |
| 732 | else |
| 733 | _analysis_output("envelope2L",seq/2,work2,n,1,0,0); |
| 734 | seq++; |
| 735 | } |
| 736 | #endif |
| 737 | |
| 738 | for(i=0;i<n;i++){ |
| 739 | int dB=logmask[i]+.5; |
| 740 | if(dB>=NOISE_COMPAND_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:34:9`!)dB=NOISE_COMPAND_LEVELScxx . . $ `external/vorbis/vorbis_psy.h:34:9`!-1; |
| 741 | if(dB<0)dB=0; |
| 742 | logmask[i]= work[i]+p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->noisecompandcxx . . $ vorbis_info_psy#noisecompand.[dB]; |
| 743 | } |
| 744 | |
| 745 | } |
| 746 | |
| 747 | void _vp_tonemaskcxx . . $ _vp_tonemask(50d8a29655683052).(vorbis_look_psycxx . . $ vorbis_look_psy# *p, |
| 748 | float *logfft, |
| 749 | float *logmask, |
| 750 | float global_specmax, |
| 751 | float local_specmax){ |
| 752 | |
| 753 | int i,n=p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.; |
| 754 | |
| 755 | float *seed = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*seed)*p->total_octave_lines); |
| 756 | float att=local_specmax+p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->ath_adjattcxx . . $ vorbis_info_psy#ath_adjatt.; |
| 757 | for(i=0;i<p->total_octave_linescxx . . $ $anonymous_type_1598a95364f6cf37_2#total_octave_lines.;i++)seed[i]=NEGINFcxx . . $ `external/vorbis/vorbis_psy.cpp:28:9`!; |
| 758 | |
| 759 | /* set the ATH (floating below localmax, not global max by a |
| 760 | specified att) */ |
| 761 | if(att<p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->ath_maxattcxx . . $ vorbis_info_psy#ath_maxatt.)att=p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->ath_maxattcxx . . $ vorbis_info_psy#ath_maxatt.; |
| 762 | |
| 763 | for(i=0;i<n;i++) |
| 764 | logmask[i]=p->athcxx . . $ $anonymous_type_1598a95364f6cf37_2#ath.[i]+att; |
| 765 | |
| 766 | /* tone masking */ |
| 767 | seed_loopcxx . . $ seed_loop(ae46f14aa7e540c2).(p,(const float ***)p->tonecurvescxx . . $ $anonymous_type_1598a95364f6cf37_2#tonecurves.,logfft,logmask,seed,global_specmax); |
| 768 | max_seedscxx . . $ max_seeds(4bac37cb523d88bd).(p,seed,logmask); |
| 769 | |
| 770 | } |
| 771 | |
| 772 | void _vp_offset_and_mixcxx . . $ _vp_offset_and_mix(170b71c7d29f2c57).(vorbis_look_psycxx . . $ vorbis_look_psy# *p, |
| 773 | float *noise, |
| 774 | float *tone, |
| 775 | int offset_select, |
| 776 | float *logmask, |
| 777 | float *mdct, |
| 778 | float *logmdct){ |
| 779 | int i,n=p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.; |
| 780 | float de, coeffi, cx;/* AoTuV */ |
| 781 | float toneatt=p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->tone_masterattcxx . . $ vorbis_info_psy#tone_masteratt.[offset_select]; |
| 782 | |
| 783 | cx = p->m_valcxx . . $ $anonymous_type_1598a95364f6cf37_2#m_val.; |
| 784 | |
| 785 | for(i=0;i<n;i++){ |
| 786 | float val= noise[i]+p->noiseoffsetcxx . . $ $anonymous_type_1598a95364f6cf37_2#noiseoffset.[offset_select][i]; |
| 787 | if(val>p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->noisemaxsuppcxx . . $ vorbis_info_psy#noisemaxsupp.)val=p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->noisemaxsuppcxx . . $ vorbis_info_psy#noisemaxsupp.; |
| 788 | logmask[i] = stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(val,tone[i]+toneatt); |
| 789 | |
| 790 | |
| 791 | /* AoTuV */ |
| 792 | /** @ M1 ** |
| 793 | The following codes improve a noise problem. |
| 794 | A fundamental idea uses the value of masking and carries out |
| 795 | the relative compensation of the MDCT. |
| 796 | However, this code is not perfect and all noise problems cannot be solved. |
| 797 | by Aoyumi @ 2004/04/18 |
| 798 | */ |
| 799 | |
| 800 | if(offset_select == 1) { |
| 801 | coeffi = -17.2; /* coeffi is a -17.2dB threshold */ |
| 802 | val = val - logmdct[i]; /* val == mdct line value relative to floor in dB */ |
| 803 | |
| 804 | if(val > coeffi){ |
| 805 | /* mdct value is > -17.2 dB below floor */ |
| 806 | |
| 807 | de = 1.0-((val-coeffi)*0.005*cx); |
| 808 | /* pro-rated attenuation: |
| 809 | -0.00 dB boost if mdct value is -17.2dB (relative to floor) |
| 810 | -0.77 dB boost if mdct value is 0dB (relative to floor) |
| 811 | -1.64 dB boost if mdct value is +17.2dB (relative to floor) |
| 812 | etc... */ |
| 813 | |
| 814 | if(de < 0) de = 0.0001; |
| 815 | }else |
| 816 | /* mdct value is <= -17.2 dB below floor */ |
| 817 | |
| 818 | de = 1.0-((val-coeffi)*0.0003*cx); |
| 819 | /* pro-rated attenuation: |
| 820 | +0.00 dB atten if mdct value is -17.2dB (relative to floor) |
| 821 | +0.45 dB atten if mdct value is -34.4dB (relative to floor) |
| 822 | etc... */ |
| 823 | |
| 824 | mdct[i] *= de; |
| 825 | |
| 826 | } |
| 827 | } |
| 828 | } |
| 829 | |
| 830 | float _vp_ampmax_decaycxx . . $ _vp_ampmax_decay(a7ce48d8b6e7e8de).(float amp,vorbis_dsp_statecxx . . $ vorbis_dsp_state# *vd){ |
| 831 | vorbis_infocxx . . $ vorbis_info# *vi=vd->vicxx . . $ vorbis_dsp_state#vi.; |
| 832 | codec_setup_infocxx . . $ codec_setup_info# *ci = (codec_setup_infocxx . . $ codec_setup_info# *) vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 833 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *gi=&ci->psy_g_paramcxx . . $ codec_setup_info#psy_g_param.; |
| 834 | |
| 835 | int n=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[vd->Wcxx . . $ vorbis_dsp_state#W.]/2; |
| 836 | float secs=(float)n/vi->ratecxx . . $ vorbis_info#rate.; |
| 837 | |
| 838 | amp+=secs*gi->ampmax_att_per_seccxx . . $ $anonymous_type_1598a95364f6cf37_0#ampmax_att_per_sec.; |
| 839 | if(amp<-9999)amp=-9999; |
| 840 | return(amp); |
| 841 | } |
| 842 | |
| 843 | static float FLOOR1_fromdB_LOOKUPcxx . . $ FLOOR1_fromdB_LOOKUP.[256]={ |
| 844 | 1.0649863e-07F, 1.1341951e-07F, 1.2079015e-07F, 1.2863978e-07F, |
| 845 | 1.3699951e-07F, 1.4590251e-07F, 1.5538408e-07F, 1.6548181e-07F, |
| 846 | 1.7623575e-07F, 1.8768855e-07F, 1.9988561e-07F, 2.128753e-07F, |
| 847 | 2.2670913e-07F, 2.4144197e-07F, 2.5713223e-07F, 2.7384213e-07F, |
| 848 | 2.9163793e-07F, 3.1059021e-07F, 3.3077411e-07F, 3.5226968e-07F, |
| 849 | 3.7516214e-07F, 3.9954229e-07F, 4.2550680e-07F, 4.5315863e-07F, |
| 850 | 4.8260743e-07F, 5.1396998e-07F, 5.4737065e-07F, 5.8294187e-07F, |
| 851 | 6.2082472e-07F, 6.6116941e-07F, 7.0413592e-07F, 7.4989464e-07F, |
| 852 | 7.9862701e-07F, 8.5052630e-07F, 9.0579828e-07F, 9.6466216e-07F, |
| 853 | 1.0273513e-06F, 1.0941144e-06F, 1.1652161e-06F, 1.2409384e-06F, |
| 854 | 1.3215816e-06F, 1.4074654e-06F, 1.4989305e-06F, 1.5963394e-06F, |
| 855 | 1.7000785e-06F, 1.8105592e-06F, 1.9282195e-06F, 2.0535261e-06F, |
| 856 | 2.1869758e-06F, 2.3290978e-06F, 2.4804557e-06F, 2.6416497e-06F, |
| 857 | 2.8133190e-06F, 2.9961443e-06F, 3.1908506e-06F, 3.3982101e-06F, |
| 858 | 3.6190449e-06F, 3.8542308e-06F, 4.1047004e-06F, 4.3714470e-06F, |
| 859 | 4.6555282e-06F, 4.9580707e-06F, 5.2802740e-06F, 5.6234160e-06F, |
| 860 | 5.9888572e-06F, 6.3780469e-06F, 6.7925283e-06F, 7.2339451e-06F, |
| 861 | 7.7040476e-06F, 8.2047000e-06F, 8.7378876e-06F, 9.3057248e-06F, |
| 862 | 9.9104632e-06F, 1.0554501e-05F, 1.1240392e-05F, 1.1970856e-05F, |
| 863 | 1.2748789e-05F, 1.3577278e-05F, 1.4459606e-05F, 1.5399272e-05F, |
| 864 | 1.6400004e-05F, 1.7465768e-05F, 1.8600792e-05F, 1.9809576e-05F, |
| 865 | 2.1096914e-05F, 2.2467911e-05F, 2.3928002e-05F, 2.5482978e-05F, |
| 866 | 2.7139006e-05F, 2.8902651e-05F, 3.0780908e-05F, 3.2781225e-05F, |
| 867 | 3.4911534e-05F, 3.7180282e-05F, 3.9596466e-05F, 4.2169667e-05F, |
| 868 | 4.4910090e-05F, 4.7828601e-05F, 5.0936773e-05F, 5.4246931e-05F, |
| 869 | 5.7772202e-05F, 6.1526565e-05F, 6.5524908e-05F, 6.9783085e-05F, |
| 870 | 7.4317983e-05F, 7.9147585e-05F, 8.4291040e-05F, 8.9768747e-05F, |
| 871 | 9.5602426e-05F, 0.00010181521F, 0.00010843174F, 0.00011547824F, |
| 872 | 0.00012298267F, 0.00013097477F, 0.00013948625F, 0.00014855085F, |
| 873 | 0.00015820453F, 0.00016848555F, 0.00017943469F, 0.00019109536F, |
| 874 | 0.00020351382F, 0.00021673929F, 0.00023082423F, 0.00024582449F, |
| 875 | 0.00026179955F, 0.00027881276F, 0.00029693158F, 0.00031622787F, |
| 876 | 0.00033677814F, 0.00035866388F, 0.00038197188F, 0.00040679456F, |
| 877 | 0.00043323036F, 0.00046138411F, 0.00049136745F, 0.00052329927F, |
| 878 | 0.00055730621F, 0.00059352311F, 0.00063209358F, 0.00067317058F, |
| 879 | 0.00071691700F, 0.00076350630F, 0.00081312324F, 0.00086596457F, |
| 880 | 0.00092223983F, 0.00098217216F, 0.0010459992F, 0.0011139742F, |
| 881 | 0.0011863665F, 0.0012634633F, 0.0013455702F, 0.0014330129F, |
| 882 | 0.0015261382F, 0.0016253153F, 0.0017309374F, 0.0018434235F, |
| 883 | 0.0019632195F, 0.0020908006F, 0.0022266726F, 0.0023713743F, |
| 884 | 0.0025254795F, 0.0026895994F, 0.0028643847F, 0.0030505286F, |
| 885 | 0.0032487691F, 0.0034598925F, 0.0036847358F, 0.0039241906F, |
| 886 | 0.0041792066F, 0.0044507950F, 0.0047400328F, 0.0050480668F, |
| 887 | 0.0053761186F, 0.0057254891F, 0.0060975636F, 0.0064938176F, |
| 888 | 0.0069158225F, 0.0073652516F, 0.0078438871F, 0.0083536271F, |
| 889 | 0.0088964928F, 0.009474637F, 0.010090352F, 0.010746080F, |
| 890 | 0.011444421F, 0.012188144F, 0.012980198F, 0.013823725F, |
| 891 | 0.014722068F, 0.015678791F, 0.016697687F, 0.017782797F, |
| 892 | 0.018938423F, 0.020169149F, 0.021479854F, 0.022875735F, |
| 893 | 0.024362330F, 0.025945531F, 0.027631618F, 0.029427276F, |
| 894 | 0.031339626F, 0.033376252F, 0.035545228F, 0.037855157F, |
| 895 | 0.040315199F, 0.042935108F, 0.045725273F, 0.048696758F, |
| 896 | 0.051861348F, 0.055231591F, 0.058820850F, 0.062643361F, |
| 897 | 0.066714279F, 0.071049749F, 0.075666962F, 0.080584227F, |
| 898 | 0.085821044F, 0.091398179F, 0.097337747F, 0.10366330F, |
| 899 | 0.11039993F, 0.11757434F, 0.12521498F, 0.13335215F, |
| 900 | 0.14201813F, 0.15124727F, 0.16107617F, 0.17154380F, |
| 901 | 0.18269168F, 0.19456402F, 0.20720788F, 0.22067342F, |
| 902 | 0.23501402F, 0.25028656F, 0.26655159F, 0.28387361F, |
| 903 | 0.30232132F, 0.32196786F, 0.34289114F, 0.36517414F, |
| 904 | 0.38890521F, 0.41417847F, 0.44109412F, 0.46975890F, |
| 905 | 0.50028648F, 0.53279791F, 0.56742212F, 0.60429640F, |
| 906 | 0.64356699F, 0.68538959F, 0.72993007F, 0.77736504F, |
| 907 | 0.82788260F, 0.88168307F, 0.9389798F, 1.F, |
| 908 | }; |
| 909 | |
| 910 | /* this is for per-channel noise normalization */ |
| 911 | static int apsortcxx . . $ apsort(9148c8c3ff42c9d8).(const void *a, const void *b){ |
| 912 | float f1=**(float**)a; |
| 913 | float f2=**(float**)b; |
| 914 | return (f1<f2)-(f1>f2); |
| 915 | } |
| 916 | |
| 917 | static void flag_losslesscxx . . $ flag_lossless(5c5d0c78e0e9497a).(int limit, float prepoint, float postpoint, float *mdct, |
| 918 | float *floor, int *flag, int i, int jn){ |
| 919 | int j; |
| 920 | for(j=0;j<jn;j++){ |
| 921 | float point = j>=limit-i ? postpoint : prepoint; |
| 922 | float r = fabscxx . . $ fabs(fbcf3211dfe1bfd1).(mdct[j])/floor[j]; |
| 923 | if(r<point) |
| 924 | flag[j]=0; |
| 925 | else |
| 926 | flag[j]=1; |
| 927 | } |
| 928 | } |
| 929 | |
| 930 | /* Overload/Side effect: On input, the *q vector holds either the |
| 931 | quantized energy (for elements with the flag set) or the absolute |
| 932 | values of the *r vector (for elements with flag unset). On output, |
| 933 | *q holds the quantized energy for all elements */ |
| 934 | static float noise_normalizecxx . . $ noise_normalize(a77ccd105b0678e7).(vorbis_look_psycxx . . $ vorbis_look_psy# *p, int limit, float *r, float *q, float *f, int *flags, float acc, int i, int n, int *out){ |
| 935 | |
| 936 | vorbis_info_psycxx . . $ vorbis_info_psy# *vi=p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.; |
| 937 | float **sort = (float **) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*sort)); |
| 938 | int j,count=0; |
| 939 | int start = (vi->normal_pcxx . . $ vorbis_info_psy#normal_p. ? vi->normal_startcxx . . $ vorbis_info_psy#normal_start.-i : n); |
| 940 | if(start>n)start=n; |
| 941 | |
| 942 | /* force classic behavior where only energy in the current band is considered */ |
| 943 | acc=0.f; |
| 944 | |
| 945 | /* still responsible for populating *out where noise norm not in |
| 946 | effect. There's no need to [re]populate *q in these areas */ |
| 947 | for(j=0;j<start;j++){ |
| 948 | if(!flags || !flags[j]){ /* lossless coupling already quantized. |
| 949 | Don't touch; requantizing based on |
| 950 | energy would be incorrect. */ |
| 951 | float ve = q[j]/f[j]; |
| 952 | if(r[j]<0) |
| 953 | out[j] = -rintcxx . . $ rint(fbcf3211dfe1bfd1).(sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(ve)); |
| 954 | else |
| 955 | out[j] = rintcxx . . $ rint(fbcf3211dfe1bfd1).(sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(ve)); |
| 956 | } |
| 957 | } |
| 958 | |
| 959 | /* sort magnitudes for noise norm portion of partition */ |
| 960 | for(;j<n;j++){ |
| 961 | if(!flags || !flags[j]){ /* can't noise norm elements that have |
| 962 | already been loslessly coupled; we can |
| 963 | only account for their energy error */ |
| 964 | float ve = q[j]/f[j]; |
| 965 | /* Despite all the new, more capable coupling code, for now we |
| 966 | implement noise norm as it has been up to this point. Only |
| 967 | consider promotions to unit magnitude from 0. In addition |
| 968 | the only energy error counted is quantizations to zero. */ |
| 969 | /* also-- the original point code only applied noise norm at > pointlimit */ |
| 970 | if(ve<.25f && (!flags || j>=limit-i)){ |
| 971 | acc += ve; |
| 972 | sort[count++]=q+j; /* q is fabs(r) for unflagged element */ |
| 973 | }else{ |
| 974 | /* For now: no acc adjustment for nonzero quantization. populate *out and q as this value is final. */ |
| 975 | if(r[j]<0) |
| 976 | out[j] = -rintcxx . . $ rint(fbcf3211dfe1bfd1).(sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(ve)); |
| 977 | else |
| 978 | out[j] = rintcxx . . $ rint(fbcf3211dfe1bfd1).(sqrtcxx . . $ sqrt(fbcf3211dfe1bfd1).(ve)); |
| 979 | q[j] = out[j]*out[j]*f[j]; |
| 980 | } |
| 981 | }/* else{ |
| 982 | again, no energy adjustment for error in nonzero quant-- for now |
| 983 | }*/ |
| 984 | } |
| 985 | |
| 986 | if(count){ |
| 987 | /* noise norm to do */ |
| 988 | qsortcxx . . $ qsort(ebb60b13a65e77d7).(sort,count,sizeof(*sort),apsortcxx . . $ apsort(9148c8c3ff42c9d8).); |
| 989 | for(j=0;j<count;j++){ |
| 990 | int k=sort[j]-q; |
| 991 | if(acc>=vi->normal_threshcxx . . $ vorbis_info_psy#normal_thresh.){ |
| 992 | out[k]=unitnormcxx . . $ unitnorm(fbcf3211dfe1bfd1).(r[k]); |
| 993 | acc-=1.f; |
| 994 | q[k]=f[k]; |
| 995 | }else{ |
| 996 | out[k]=0; |
| 997 | q[k]=0.f; |
| 998 | } |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | return acc; |
| 1003 | } |
| 1004 | |
| 1005 | /* Noise normalization, quantization and coupling are not wholly |
| 1006 | seperable processes in depth>1 coupling. */ |
| 1007 | void _vp_couple_quantize_normalizecxx . . $ _vp_couple_quantize_normalize(d7662a120b588da6).(int blobno, |
| 1008 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *g, |
| 1009 | vorbis_look_psycxx . . $ vorbis_look_psy# *p, |
| 1010 | vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *vi, |
| 1011 | float **mdct, |
| 1012 | int **iwork, |
| 1013 | int *nonzero, |
| 1014 | int sliding_lowpass, |
| 1015 | int ch){ |
| 1016 | |
| 1017 | int i; |
| 1018 | int n = p->ncxx . . $ $anonymous_type_1598a95364f6cf37_2#n.; |
| 1019 | int partition=(p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->normal_pcxx . . $ vorbis_info_psy#normal_p. ? p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->normal_partitioncxx . . $ vorbis_info_psy#normal_partition. : 16); |
| 1020 | int limit = g->coupling_pointlimitcxx . . $ $anonymous_type_1598a95364f6cf37_0#coupling_pointlimit.[p->vicxx . . $ $anonymous_type_1598a95364f6cf37_2#vi.->blockflagcxx . . $ vorbis_info_psy#blockflag.][blobno]; |
| 1021 | float prepoint=stereo_threshholdscxx . . $ stereo_threshholds.[g->coupling_prepointampcxx . . $ $anonymous_type_1598a95364f6cf37_0#coupling_prepointamp.[blobno]]; |
| 1022 | float postpoint=stereo_threshholdscxx . . $ stereo_threshholds.[g->coupling_postpointampcxx . . $ $anonymous_type_1598a95364f6cf37_0#coupling_postpointamp.[blobno]]; |
| 1023 | #if 0 |
| 1024 | float de=0.1*p->m_val; /* a blend of the AoTuV M2 and M3 code here and below */ |
| 1025 | #endif |
| 1026 | |
| 1027 | /* mdct is our raw mdct output, floor not removed. */ |
| 1028 | /* inout passes in the ifloor, passes back quantized result */ |
| 1029 | |
| 1030 | /* unquantized energy (negative indicates amplitude has negative sign) */ |
| 1031 | float **raw = (float **) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*sizeof(*raw)); |
| 1032 | |
| 1033 | /* dual pupose; quantized energy (if flag set), othersize fabs(raw) */ |
| 1034 | float **quant = (float **) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*sizeof(*quant)); |
| 1035 | |
| 1036 | /* floor energy */ |
| 1037 | float **floor = (float **) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*sizeof(*floor)); |
| 1038 | |
| 1039 | /* flags indicating raw/quantized status of elements in raw vector */ |
| 1040 | int **flag = (int **) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*sizeof(*flag)); |
| 1041 | |
| 1042 | /* non-zero flag working vector */ |
| 1043 | int *nz = (int *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*sizeof(*nz)); |
| 1044 | |
| 1045 | /* energy surplus/defecit tracking */ |
| 1046 | float *acc = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!((ch+vi->coupling_steps)*sizeof(*acc)); |
| 1047 | |
| 1048 | /* The threshold of a stereo is changed with the size of n */ |
| 1049 | if(n > 1000) |
| 1050 | postpoint=stereo_threshholds_limitedcxx . . $ stereo_threshholds_limited.[g->coupling_postpointampcxx . . $ $anonymous_type_1598a95364f6cf37_0#coupling_postpointamp.[blobno]]; |
| 1051 | |
| 1052 | raw[0] = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*partition*sizeof(**raw)); |
| 1053 | quant[0] = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*partition*sizeof(**quant)); |
| 1054 | floor[0] = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*partition*sizeof(**floor)); |
| 1055 | flag[0] = (int *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(ch*partition*sizeof(**flag)); |
| 1056 | |
| 1057 | for(i=1;i<ch;i++){ |
| 1058 | raw[i] = &raw[0][partition*i]; |
| 1059 | quant[i] = &quant[0][partition*i]; |
| 1060 | floor[i] = &floor[0][partition*i]; |
| 1061 | flag[i] = &flag[0][partition*i]; |
| 1062 | } |
| 1063 | for(i=0;i<ch+vi->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.;i++) |
| 1064 | acc[i]=0.f; |
| 1065 | |
| 1066 | for(i=0;i<n;i+=partition){ |
| 1067 | int k,j,jn = partition > n-i ? n-i : partition; |
| 1068 | int step,track = 0; |
| 1069 | |
| 1070 | memcpy(nz,nonzero,sizeof(*nz)*ch); |
| 1071 | |
| 1072 | /* prefill */ |
| 1073 | memset(flag[0],0,ch*partition*sizeof(**flag)); |
| 1074 | for(k=0;k<ch;k++){ |
| 1075 | int *iout = &iwork[k][i]; |
| 1076 | if(nz[k]){ |
| 1077 | |
| 1078 | for(j=0;j<jn;j++) |
| 1079 | floor[k][j] = FLOOR1_fromdB_LOOKUPcxx . . $ FLOOR1_fromdB_LOOKUP.[iout[j]]; |
| 1080 | |
| 1081 | flag_losslesscxx . . $ flag_lossless(5c5d0c78e0e9497a).(limit,prepoint,postpoint,&mdct[k][i],floor[k],flag[k],i,jn); |
| 1082 | |
| 1083 | for(j=0;j<jn;j++){ |
| 1084 | quant[k][j] = raw[k][j] = mdct[k][i+j]*mdct[k][i+j]; |
| 1085 | if(mdct[k][i+j]<0.f) raw[k][j]*=-1.f; |
| 1086 | floor[k][j]*=floor[k][j]; |
| 1087 | } |
| 1088 | |
| 1089 | acc[track]=noise_normalizecxx . . $ noise_normalize(a77ccd105b0678e7).(p,limit,raw[k],quant[k],floor[k],nullptr,acc[track],i,jn,iout); |
| 1090 | |
| 1091 | }else{ |
| 1092 | for(j=0;j<jn;j++){ |
| 1093 | floor[k][j] = 1e-10f; |
| 1094 | raw[k][j] = 0.f; |
| 1095 | quant[k][j] = 0.f; |
| 1096 | flag[k][j] = 0; |
| 1097 | iout[j]=0; |
| 1098 | } |
| 1099 | acc[track]=0.f; |
| 1100 | } |
| 1101 | track++; |
| 1102 | } |
| 1103 | |
| 1104 | /* coupling */ |
| 1105 | for(step=0;step<vi->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.;step++){ |
| 1106 | int Mi = vi->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[step]; |
| 1107 | int Ai = vi->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[step]; |
| 1108 | int *iM = &iwork[Mi][i]; |
| 1109 | int *iA = &iwork[Ai][i]; |
| 1110 | float *reM = raw[Mi]; |
| 1111 | float *reA = raw[Ai]; |
| 1112 | float *qeM = quant[Mi]; |
| 1113 | float *qeA = quant[Ai]; |
| 1114 | float *floorM = floor[Mi]; |
| 1115 | float *floorA = floor[Ai]; |
| 1116 | int *fM = flag[Mi]; |
| 1117 | int *fA = flag[Ai]; |
| 1118 | |
| 1119 | if(nz[Mi] || nz[Ai]){ |
| 1120 | nz[Mi] = nz[Ai] = 1; |
| 1121 | |
| 1122 | for(j=0;j<jn;j++){ |
| 1123 | |
| 1124 | if(j<sliding_lowpass-i){ |
| 1125 | if(fM[j] || fA[j]){ |
| 1126 | /* lossless coupling */ |
| 1127 | |
| 1128 | reM[j] = fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reM[j])+fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reA[j]); |
| 1129 | qeM[j] = qeM[j]+qeA[j]; |
| 1130 | fM[j]=fA[j]=1; |
| 1131 | |
| 1132 | /* couple iM/iA */ |
| 1133 | { |
| 1134 | int A = iM[j]; |
| 1135 | int B = iA[j]; |
| 1136 | |
| 1137 | if(abscxx . . $ abs(a1851578aea3f541).(A)>abscxx . . $ abs(a1851578aea3f541).(B)){ |
| 1138 | iA[j]=(A>0?A-B:B-A); |
| 1139 | }else{ |
| 1140 | iA[j]=(B>0?A-B:B-A); |
| 1141 | iM[j]=B; |
| 1142 | } |
| 1143 | |
| 1144 | /* collapse two equivalent tuples to one */ |
| 1145 | if(iA[j]>=abscxx . . $ abs(a1851578aea3f541).(iM[j])*2){ |
| 1146 | iA[j]= -iA[j]; |
| 1147 | iM[j]= -iM[j]; |
| 1148 | } |
| 1149 | |
| 1150 | } |
| 1151 | |
| 1152 | }else{ |
| 1153 | /* lossy (point) coupling */ |
| 1154 | if(j<limit-i){ |
| 1155 | /* dipole */ |
| 1156 | reM[j] += reA[j]; |
| 1157 | qeM[j] = fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reM[j]); |
| 1158 | }else{ |
| 1159 | #if 0 |
| 1160 | /* AoTuV */ |
| 1161 | /** @ M2 ** |
| 1162 | The boost problem by the combination of noise normalization and point stereo is eased. |
| 1163 | However, this is a temporary patch. |
| 1164 | by Aoyumi @ 2004/04/18 |
| 1165 | */ |
| 1166 | float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit))); |
| 1167 | /* elliptical */ |
| 1168 | if(reM[j]+reA[j]<0){ |
| 1169 | reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate); |
| 1170 | }else{ |
| 1171 | reM[j] = (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate); |
| 1172 | } |
| 1173 | #else |
| 1174 | /* elliptical */ |
| 1175 | if(reM[j]+reA[j]<0){ |
| 1176 | reM[j] = - (qeM[j] = fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reM[j])+fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reA[j])); |
| 1177 | }else{ |
| 1178 | reM[j] = (qeM[j] = fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reM[j])+fabscxx . . $ fabs(fbcf3211dfe1bfd1).(reA[j])); |
| 1179 | } |
| 1180 | #endif |
| 1181 | |
| 1182 | } |
| 1183 | reA[j]=qeA[j]=0.f; |
| 1184 | fA[j]=1; |
| 1185 | iA[j]=0; |
| 1186 | } |
| 1187 | } |
| 1188 | floorM[j]=floorA[j]=floorM[j]+floorA[j]; |
| 1189 | } |
| 1190 | /* normalize the resulting mag vector */ |
| 1191 | acc[track]=noise_normalizecxx . . $ noise_normalize(a77ccd105b0678e7).(p,limit,raw[Mi],quant[Mi],floor[Mi],flag[Mi],acc[track],i,jn,iM); |
| 1192 | track++; |
| 1193 | } |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | for(i=0;i<vi->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.;i++){ |
| 1198 | /* make sure coupling a zero and a nonzero channel results in two |
| 1199 | nonzero channels. */ |
| 1200 | if(nonzero[vi->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[i]] || |
| 1201 | nonzero[vi->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[i]]){ |
| 1202 | nonzero[vi->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[i]]=1; |
| 1203 | nonzero[vi->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[i]]=1; |
| 1204 | } |
| 1205 | } |
| 1206 | } |