| 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-2009 * |
| 9 | * by the Xiph.Org Foundation https://xiph.org/ * |
| 10 | * * |
| 11 | ******************************************************************** |
| 12 | |
| 13 | function: PCM data envelope analysis |
| 14 | |
| 15 | ********************************************************************/ |
| 16 | |
| 17 | #include "ogg.h"cxx . . $ `<file>/external/vorbis/ogg.h`/ |
| 18 | #include "vorbis_codec.h"cxx . . $ `<file>/external/vorbis/vorbis_codec.h`/ |
| 19 | #include "vorbis_codec_internal.h"cxx . . $ `<file>/external/vorbis/vorbis_codec_internal.h`/ |
| 20 | |
| 21 | #include "vorbis_os.h"cxx . . $ `<file>/external/vorbis/vorbis_os.h`/ |
| 22 | #include "vorbis_scales.h"cxx . . $ `<file>/external/vorbis/vorbis_scales.h`/ |
| 23 | #include "vorbis_envelope.h"cxx . . $ `<file>/external/vorbis/vorbis_envelope.h`/ |
| 24 | #include "vorbis_mdct.h"cxx . . $ `<file>/external/vorbis/vorbis_mdct.h`/ |
| 25 | #include "vorbis_misc.h"cxx . . $ `<file>/external/vorbis/vorbis_misc.h`/ |
| 26 | |
| 27 | void _ve_envelope_initcxx . . $ _ve_envelope_init(848e42712f4cb0d0).(envelope_lookupcxx . . $ envelope_lookup# *e,vorbis_infocxx . . $ vorbis_info# *vi){ |
| 28 | codec_setup_infocxx . . $ codec_setup_info# *ci = (codec_setup_infocxx . . $ codec_setup_info# *) vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 29 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *gi=&ci->psy_g_paramcxx . . $ codec_setup_info#psy_g_param.; |
| 30 | int ch=vi->channelscxx . . $ vorbis_info#channels.; |
| 31 | int i,j; |
| 32 | int n=e->winlengthcxx . . $ $anonymous_type_c661d92e27ede393_2#winlength.=128; |
| 33 | e->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.=64; /* not random */ |
| 34 | |
| 35 | e->minenergycxx . . $ $anonymous_type_c661d92e27ede393_2#minenergy.=gi->preecho_minenergycxx . . $ $anonymous_type_1598a95364f6cf37_0#preecho_minenergy.; |
| 36 | e->chcxx . . $ $anonymous_type_c661d92e27ede393_2#ch.=ch; |
| 37 | e->storagecxx . . $ $anonymous_type_c661d92e27ede393_2#storage.=128; |
| 38 | e->cursorcxx . . $ $anonymous_type_c661d92e27ede393_2#cursor.=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[1]/2; |
| 39 | e->mdct_wincxx . . $ $anonymous_type_c661d92e27ede393_2#mdct_win.= (float *) _Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(n,sizeof(*e->mdct_wincxx . . $ $anonymous_type_c661d92e27ede393_2#mdct_win.)); |
| 40 | mdct_initcxx . . $ mdct_init(2a3f85341570e261).(&e->mdctcxx . . $ $anonymous_type_c661d92e27ede393_2#mdct.,n); |
| 41 | |
| 42 | for(i=0;i<n;i++){ |
| 43 | e->mdct_wincxx . . $ $anonymous_type_c661d92e27ede393_2#mdct_win.[i]=sincxx . . $ sin(fee4f1d22bc8e617).(i/(n-1.)*M_PIcxx . . $ `melder/NUMmath.h:48:9`!); |
| 44 | e->mdct_wincxx . . $ $anonymous_type_c661d92e27ede393_2#mdct_win.[i]*=e->mdct_wincxx . . $ $anonymous_type_c661d92e27ede393_2#mdct_win.[i]; |
| 45 | } |
| 46 | |
| 47 | /* magic follows */ |
| 48 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[0].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=2; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[0].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=4; |
| 49 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[1].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=4; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[1].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=5; |
| 50 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[2].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=6; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[2].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=6; |
| 51 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[3].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=9; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[3].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=8; |
| 52 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[4].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=13; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[4].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=8; |
| 53 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[5].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=17; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[5].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=8; |
| 54 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[6].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.=22; e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[6].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.=8; |
| 55 | |
| 56 | for(j=0;j<VE_BANDScxx . . $ `external/vorbis/vorbis_envelope.h:27:9`!;j++){ |
| 57 | n=e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.; |
| 58 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].windowcxx . . $ $anonymous_type_c661d92e27ede393_1#window.= (float *) _Melder_malloccxx . . $ _Melder_malloc(1de1fe46563a6a2a).(n*sizeof(*e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[0].windowcxx . . $ $anonymous_type_c661d92e27ede393_1#window.)); |
| 59 | for(i=0;i<n;i++){ |
| 60 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].windowcxx . . $ $anonymous_type_c661d92e27ede393_1#window.[i]=sincxx . . $ sin(fee4f1d22bc8e617).((i+.5)/n*M_PIcxx . . $ `melder/NUMmath.h:48:9`!); |
| 61 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].totalcxx . . $ $anonymous_type_c661d92e27ede393_1#total.+=e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].windowcxx . . $ $anonymous_type_c661d92e27ede393_1#window.[i]; |
| 62 | } |
| 63 | e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].totalcxx . . $ $anonymous_type_c661d92e27ede393_1#total.=1./e->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.[j].totalcxx . . $ $anonymous_type_c661d92e27ede393_1#total.; |
| 64 | } |
| 65 | |
| 66 | e->filtercxx . . $ $anonymous_type_c661d92e27ede393_2#filter. = (envelope_filter_statecxx . . $ envelope_filter_state# *) _Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(VE_BANDScxx . . $ `external/vorbis/vorbis_envelope.h:27:9`!*ch,sizeof(*e->filtercxx . . $ $anonymous_type_c661d92e27ede393_2#filter.)); |
| 67 | e->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark. = (int *) _Melder_calloccxx . . $ _Melder_calloc(d58a73cf1dc24cbb).(e->storagecxx . . $ $anonymous_type_c661d92e27ede393_2#storage.,sizeof(*e->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.)); |
| 68 | |
| 69 | } |
| 70 | |
| 71 | void _ve_envelope_clearcxx . . $ _ve_envelope_clear(ab9a1450d5363011).(envelope_lookupcxx . . $ envelope_lookup# *e){ |
| 72 | int i; |
| 73 | mdct_clearcxx . . $ mdct_clear(952f3468780f0a48).(&e->mdctcxx . . $ $anonymous_type_c661d92e27ede393_2#mdct.); |
| 74 | for(i=0;i<VE_BANDScxx . . $ `external/vorbis/vorbis_envelope.h:27:9`!;i++) |
| 75 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(e->band[i].window); |
| 76 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(e->mdct_win); |
| 77 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(e->filter); |
| 78 | Melder_freecxx . . $ `melder/melder_alloc.h:38:9`!(e->mark); |
| 79 | memset(e,0,sizeof(*e)); |
| 80 | } |
| 81 | |
| 82 | /* fairly straight threshhold-by-band based until we find something |
| 83 | that works better and isn't patented. */ |
| 84 | |
| 85 | static int _ve_ampcxx . . $ _ve_amp(1c74afd81f3c55ad).(envelope_lookupcxx . . $ envelope_lookup# *ve, |
| 86 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *gi, |
| 87 | float *data, |
| 88 | envelope_bandcxx . . $ envelope_band# *bands, |
| 89 | envelope_filter_statecxx . . $ envelope_filter_state# *filters){ |
| 90 | long n=ve->winlengthcxx . . $ $anonymous_type_c661d92e27ede393_2#winlength.; |
| 91 | int ret=0; |
| 92 | long i,j; |
| 93 | float decay; |
| 94 | |
| 95 | /* we want to have a 'minimum bar' for energy, else we're just |
| 96 | basing blocks on quantization noise that outweighs the signal |
| 97 | itself (for low power signals) */ |
| 98 | |
| 99 | float minV=ve->minenergycxx . . $ $anonymous_type_c661d92e27ede393_2#minenergy.; |
| 100 | float *vec = (float *) allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(n*sizeof(*vec)); |
| 101 | |
| 102 | /* stretch is used to gradually lengthen the number of windows |
| 103 | considered prevoius-to-potential-trigger */ |
| 104 | int stretch=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(VE_MINSTRETCHcxx . . $ `external/vorbis/vorbis_envelope.h:30:9`!,ve->stretchcxx . . $ $anonymous_type_c661d92e27ede393_2#stretch./2); |
| 105 | float penalty=gi->stretch_penaltycxx . . $ $anonymous_type_1598a95364f6cf37_0#stretch_penalty.-(ve->stretchcxx . . $ $anonymous_type_c661d92e27ede393_2#stretch./2-VE_MINSTRETCHcxx . . $ `external/vorbis/vorbis_envelope.h:30:9`!); |
| 106 | if(penalty<0.f)penalty=0.f; |
| 107 | if(penalty>gi->stretch_penaltycxx . . $ $anonymous_type_1598a95364f6cf37_0#stretch_penalty.)penalty=gi->stretch_penaltycxx . . $ $anonymous_type_1598a95364f6cf37_0#stretch_penalty.; |
| 108 | |
| 109 | /*_analysis_output_always("lpcm",seq2,data,n,0,0, |
| 110 | totalshift+pos*ve->searchstep);*/ |
| 111 | |
| 112 | /* window and transform */ |
| 113 | for(i=0;i<n;i++) |
| 114 | vec[i]=data[i]*ve->mdct_wincxx . . $ $anonymous_type_c661d92e27ede393_2#mdct_win.[i]; |
| 115 | mdct_forwardcxx . . $ mdct_forward(409b9efa9c1187a7).(&ve->mdctcxx . . $ $anonymous_type_c661d92e27ede393_2#mdct.,vec,vec); |
| 116 | |
| 117 | /*_analysis_output_always("mdct",seq2,vec,n/2,0,1,0); */ |
| 118 | |
| 119 | /* near-DC spreading function; this has nothing to do with |
| 120 | psychoacoustics, just sidelobe leakage and window size */ |
| 121 | { |
| 122 | float temp=vec[0]*vec[0]+.7*vec[1]*vec[1]+.2*vec[2]*vec[2]; |
| 123 | int ptr=filters->nearptrcxx . . $ $anonymous_type_c661d92e27ede393_0#nearptr.; |
| 124 | |
| 125 | /* the accumulation is regularly refreshed from scratch to avoid |
| 126 | floating point creep */ |
| 127 | if(ptr==0){ |
| 128 | decay=filters->nearDC_acccxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC_acc.=filters->nearDC_partialacccxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC_partialacc.+temp; |
| 129 | filters->nearDC_partialacccxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC_partialacc.=temp; |
| 130 | }else{ |
| 131 | decay=filters->nearDC_acccxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC_acc.+=temp; |
| 132 | filters->nearDC_partialacccxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC_partialacc.+=temp; |
| 133 | } |
| 134 | filters->nearDC_acccxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC_acc.-=filters->nearDCcxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC.[ptr]; |
| 135 | filters->nearDCcxx . . $ $anonymous_type_c661d92e27ede393_0#nearDC.[ptr]=temp; |
| 136 | |
| 137 | decay*=(1./(VE_NEARDCcxx . . $ `external/vorbis/vorbis_envelope.h:28:9`!+1)); |
| 138 | filters->nearptrcxx . . $ $anonymous_type_c661d92e27ede393_0#nearptr.++; |
| 139 | if(filters->nearptrcxx . . $ $anonymous_type_c661d92e27ede393_0#nearptr.>=VE_NEARDCcxx . . $ `external/vorbis/vorbis_envelope.h:28:9`!)filters->nearptrcxx . . $ $anonymous_type_c661d92e27ede393_0#nearptr.=0; |
| 140 | decay=todBcxx . . $ todB(bdb257eee332afa4).(&decay)*.5-15.f; |
| 141 | } |
| 142 | |
| 143 | /* perform spreading and limiting, also smooth the spectrum. yes, |
| 144 | the MDCT results in all real coefficients, but it still *behaves* |
| 145 | like real/imaginary pairs */ |
| 146 | for(i=0;i<n/2;i+=2){ |
| 147 | float val=vec[i]*vec[i]+vec[i+1]*vec[i+1]; |
| 148 | val=todBcxx . . $ todB(bdb257eee332afa4).(&val)*.5f; |
| 149 | if(val<decay)val=decay; |
| 150 | if(val<minV)val=minV; |
| 151 | vec[i>>1]=val; |
| 152 | decay-=8.; |
| 153 | } |
| 154 | |
| 155 | /*_analysis_output_always("spread",seq2++,vec,n/4,0,0,0);*/ |
| 156 | |
| 157 | /* perform preecho/postecho triggering by band */ |
| 158 | for(j=0;j<VE_BANDScxx . . $ `external/vorbis/vorbis_envelope.h:27:9`!;j++){ |
| 159 | float acc=0.; |
| 160 | float valmax,valmin; |
| 161 | |
| 162 | /* accumulate amplitude */ |
| 163 | for(i=0;i<bands[j].endcxx . . $ $anonymous_type_c661d92e27ede393_1#end.;i++) |
| 164 | acc+=vec[i+bands[j].begincxx . . $ $anonymous_type_c661d92e27ede393_1#begin.]*bands[j].windowcxx . . $ $anonymous_type_c661d92e27ede393_1#window.[i]; |
| 165 | |
| 166 | acc*=bands[j].totalcxx . . $ $anonymous_type_c661d92e27ede393_1#total.; |
| 167 | |
| 168 | /* convert amplitude to delta */ |
| 169 | { |
| 170 | int p,thiss=filters[j].ampptrcxx . . $ $anonymous_type_c661d92e27ede393_0#ampptr.; |
| 171 | float postmax,postmin,premax=-99999.f,premin=99999.f; |
| 172 | |
| 173 | p=thiss; |
| 174 | p--; |
| 175 | if(p<0)p+=VE_AMPcxx . . $ `external/vorbis/vorbis_envelope.h:25:9`!; |
| 176 | postmax=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(acc,filters[j].ampbufcxx . . $ $anonymous_type_c661d92e27ede393_0#ampbuf.[p]); |
| 177 | postmin=stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(acc,filters[j].ampbufcxx . . $ $anonymous_type_c661d92e27ede393_0#ampbuf.[p]); |
| 178 | |
| 179 | for(i=0;i<stretch;i++){ |
| 180 | p--; |
| 181 | if(p<0)p+=VE_AMPcxx . . $ `external/vorbis/vorbis_envelope.h:25:9`!; |
| 182 | premax=stdcxx . . $ std/::maxcxx . . $ std/max(2a338fce5842aa6a).(premax,filters[j].ampbufcxx . . $ $anonymous_type_c661d92e27ede393_0#ampbuf.[p]); |
| 183 | premin=stdcxx . . $ std/::mincxx . . $ std/min(2a338fce5842aa6a).(premin,filters[j].ampbufcxx . . $ $anonymous_type_c661d92e27ede393_0#ampbuf.[p]); |
| 184 | } |
| 185 | |
| 186 | valmin=postmin-premin; |
| 187 | valmax=postmax-premax; |
| 188 | |
| 189 | /*filters[j].markers[pos]=valmax;*/ |
| 190 | filters[j].ampbufcxx . . $ $anonymous_type_c661d92e27ede393_0#ampbuf.[thiss]=acc; |
| 191 | filters[j].ampptrcxx . . $ $anonymous_type_c661d92e27ede393_0#ampptr.++; |
| 192 | if(filters[j].ampptrcxx . . $ $anonymous_type_c661d92e27ede393_0#ampptr.>=VE_AMPcxx . . $ `external/vorbis/vorbis_envelope.h:25:9`!)filters[j].ampptrcxx . . $ $anonymous_type_c661d92e27ede393_0#ampptr.=0; |
| 193 | } |
| 194 | |
| 195 | /* look at min/max, decide trigger */ |
| 196 | if(valmax>gi->preecho_threshcxx . . $ $anonymous_type_1598a95364f6cf37_0#preecho_thresh.[j]+penalty){ |
| 197 | ret|=1; |
| 198 | ret|=4; |
| 199 | } |
| 200 | if(valmin<gi->postecho_threshcxx . . $ $anonymous_type_1598a95364f6cf37_0#postecho_thresh.[j]-penalty)ret|=2; |
| 201 | } |
| 202 | |
| 203 | return(ret); |
| 204 | } |
| 205 | |
| 206 | #if 0 |
| 207 | static int seq=0; |
| 208 | static ogg_int64_t totalshift=-1024; |
| 209 | #endif |
| 210 | |
| 211 | long _ve_envelope_searchcxx . . $ _ve_envelope_search(e89517d26da739e6).(vorbis_dsp_statecxx . . $ vorbis_dsp_state# *v){ |
| 212 | vorbis_infocxx . . $ vorbis_info# *vi=v->vicxx . . $ vorbis_dsp_state#vi.; |
| 213 | codec_setup_infocxx . . $ codec_setup_info# *ci = (codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 214 | vorbis_info_psy_globalcxx . . $ vorbis_info_psy_global# *gi=&ci->psy_g_paramcxx . . $ codec_setup_info#psy_g_param.; |
| 215 | envelope_lookupcxx . . $ envelope_lookup# *ve=((private_statecxx . . $ private_state# *)(v->backend_statecxx . . $ vorbis_dsp_state#backend_state.))->vecxx . . $ private_state#ve.; |
| 216 | long i,j; |
| 217 | |
| 218 | int first=ve->currentcxx . . $ $anonymous_type_c661d92e27ede393_2#current./ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.; |
| 219 | int last=v->pcm_currentcxx . . $ vorbis_dsp_state#pcm_current./ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.-VE_WINcxx . . $ `external/vorbis/vorbis_envelope.h:23:9`!; |
| 220 | if(first<0)first=0; |
| 221 | |
| 222 | /* make sure we have enough storage to match the PCM */ |
| 223 | if(last+VE_WINcxx . . $ `external/vorbis/vorbis_envelope.h:23:9`!+VE_POSTcxx . . $ `external/vorbis/vorbis_envelope.h:24:9`!>ve->storagecxx . . $ $anonymous_type_c661d92e27ede393_2#storage.){ |
| 224 | ve->storagecxx . . $ $anonymous_type_c661d92e27ede393_2#storage.=last+VE_WINcxx . . $ `external/vorbis/vorbis_envelope.h:23:9`!+VE_POSTcxx . . $ `external/vorbis/vorbis_envelope.h:24:9`!; /* be sure */ |
| 225 | ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark. = (int *) Melder_realloccxx . . $ Melder_realloc(d42fd80046fa8ace).(ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.,ve->storagecxx . . $ $anonymous_type_c661d92e27ede393_2#storage.*sizeof(*ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.)); |
| 226 | } |
| 227 | |
| 228 | for(j=first;j<last;j++){ |
| 229 | int ret=0; |
| 230 | |
| 231 | ve->stretchcxx . . $ $anonymous_type_c661d92e27ede393_2#stretch.++; |
| 232 | if(ve->stretchcxx . . $ $anonymous_type_c661d92e27ede393_2#stretch.>VE_MAXSTRETCHcxx . . $ `external/vorbis/vorbis_envelope.h:31:9`!*2) |
| 233 | ve->stretchcxx . . $ $anonymous_type_c661d92e27ede393_2#stretch.=VE_MAXSTRETCHcxx . . $ `external/vorbis/vorbis_envelope.h:31:9`!*2; |
| 234 | |
| 235 | for(i=0;i<ve->chcxx . . $ $anonymous_type_c661d92e27ede393_2#ch.;i++){ |
| 236 | float *pcm=v->pcmcxx . . $ vorbis_dsp_state#pcm.[i]+ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.*(j); |
| 237 | ret|=_ve_ampcxx . . $ _ve_amp(1c74afd81f3c55ad).(ve,gi,pcm,ve->bandcxx . . $ $anonymous_type_c661d92e27ede393_2#band.,ve->filtercxx . . $ $anonymous_type_c661d92e27ede393_2#filter.+i*VE_BANDScxx . . $ `external/vorbis/vorbis_envelope.h:27:9`!); |
| 238 | } |
| 239 | |
| 240 | ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[j+VE_POSTcxx . . $ `external/vorbis/vorbis_envelope.h:24:9`!]=0; |
| 241 | if(ret&1){ |
| 242 | ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[j]=1; |
| 243 | ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[j+1]=1; |
| 244 | } |
| 245 | |
| 246 | if(ret&2){ |
| 247 | ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[j]=1; |
| 248 | if(j>0)ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[j-1]=1; |
| 249 | } |
| 250 | |
| 251 | if(ret&4)ve->stretchcxx . . $ $anonymous_type_c661d92e27ede393_2#stretch.=-1; |
| 252 | } |
| 253 | |
| 254 | ve->currentcxx . . $ $anonymous_type_c661d92e27ede393_2#current.=last*ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.; |
| 255 | |
| 256 | { |
| 257 | long centerW=v->centerWcxx . . $ vorbis_dsp_state#centerW.; |
| 258 | long testW= |
| 259 | centerW+ |
| 260 | ci->blocksizescxx . . $ codec_setup_info#blocksizes.[v->Wcxx . . $ vorbis_dsp_state#W.]/4+ |
| 261 | ci->blocksizescxx . . $ codec_setup_info#blocksizes.[1]/2+ |
| 262 | ci->blocksizescxx . . $ codec_setup_info#blocksizes.[0]/4; |
| 263 | |
| 264 | j=ve->cursorcxx . . $ $anonymous_type_c661d92e27ede393_2#cursor.; |
| 265 | |
| 266 | while(j<ve->currentcxx . . $ $anonymous_type_c661d92e27ede393_2#current.-(ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.)){/* account for postecho |
| 267 | working back one window */ |
| 268 | if(j>=testW)return(1); |
| 269 | |
| 270 | ve->cursorcxx . . $ $anonymous_type_c661d92e27ede393_2#cursor.=j; |
| 271 | |
| 272 | if(ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[j/ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.]){ |
| 273 | if(j>centerW){ |
| 274 | |
| 275 | #if 0 |
| 276 | if(j>ve->curmark){ |
| 277 | float *marker=alloca(v->pcm_current*sizeof(*marker)); |
| 278 | int l,m; |
| 279 | memset(marker,0,sizeof(*marker)*v->pcm_current); |
| 280 | fprintf(stderr,"mark! seq=%d, cursor:%fs time:%fs\n", |
| 281 | seq, |
| 282 | (totalshift+ve->cursor)/44100., |
| 283 | (totalshift+j)/44100.); |
| 284 | _analysis_output_always("pcmL",seq,v->pcm[0],v->pcm_current,0,0,totalshift); |
| 285 | _analysis_output_always("pcmR",seq,v->pcm[1],v->pcm_current,0,0,totalshift); |
| 286 | |
| 287 | _analysis_output_always("markL",seq,v->pcm[0],j,0,0,totalshift); |
| 288 | _analysis_output_always("markR",seq,v->pcm[1],j,0,0,totalshift); |
| 289 | |
| 290 | for(m=0;m<VE_BANDS;m++){ |
| 291 | char buf[80]; |
| 292 | sprintf(buf,"delL%d",m); |
| 293 | for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m].markers[l]*.1; |
| 294 | _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); |
| 295 | } |
| 296 | |
| 297 | for(m=0;m<VE_BANDS;m++){ |
| 298 | char buf[80]; |
| 299 | sprintf(buf,"delR%d",m); |
| 300 | for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->filter[m+VE_BANDS].markers[l]*.1; |
| 301 | _analysis_output_always(buf,seq,marker,v->pcm_current,0,0,totalshift); |
| 302 | } |
| 303 | |
| 304 | for(l=0;l<last;l++)marker[l*ve->searchstep]=ve->mark[l]*.4; |
| 305 | _analysis_output_always("mark",seq,marker,v->pcm_current,0,0,totalshift); |
| 306 | |
| 307 | |
| 308 | seq++; |
| 309 | |
| 310 | } |
| 311 | #endif |
| 312 | |
| 313 | ve->curmarkcxx . . $ $anonymous_type_c661d92e27ede393_2#curmark.=j; |
| 314 | if(j>=testW)return(1); |
| 315 | return(0); |
| 316 | } |
| 317 | } |
| 318 | j+=ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | return(-1); |
| 323 | } |
| 324 | |
| 325 | int _ve_envelope_markcxx . . $ _ve_envelope_mark(6cb399ae167b2de8).(vorbis_dsp_statecxx . . $ vorbis_dsp_state# *v){ |
| 326 | envelope_lookupcxx . . $ envelope_lookup# *ve=((private_statecxx . . $ private_state# *)(v->backend_statecxx . . $ vorbis_dsp_state#backend_state.))->vecxx . . $ private_state#ve.; |
| 327 | vorbis_infocxx . . $ vorbis_info# *vi=v->vicxx . . $ vorbis_dsp_state#vi.; |
| 328 | codec_setup_infocxx . . $ codec_setup_info# *ci = (codec_setup_infocxx . . $ codec_setup_info# *) vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 329 | long centerW=v->centerWcxx . . $ vorbis_dsp_state#centerW.; |
| 330 | long beginW=centerW-ci->blocksizescxx . . $ codec_setup_info#blocksizes.[v->Wcxx . . $ vorbis_dsp_state#W.]/4; |
| 331 | long endW=centerW+ci->blocksizescxx . . $ codec_setup_info#blocksizes.[v->Wcxx . . $ vorbis_dsp_state#W.]/4; |
| 332 | if(v->Wcxx . . $ vorbis_dsp_state#W.){ |
| 333 | beginW-=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[v->lWcxx . . $ vorbis_dsp_state#lW.]/4; |
| 334 | endW+=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[v->nWcxx . . $ vorbis_dsp_state#nW.]/4; |
| 335 | }else{ |
| 336 | beginW-=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[0]/4; |
| 337 | endW+=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[0]/4; |
| 338 | } |
| 339 | |
| 340 | if(ve->curmarkcxx . . $ $anonymous_type_c661d92e27ede393_2#curmark.>=beginW && ve->curmarkcxx . . $ $anonymous_type_c661d92e27ede393_2#curmark.<endW)return(1); |
| 341 | { |
| 342 | long first=beginW/ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.; |
| 343 | long last=endW/ve->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.; |
| 344 | long i; |
| 345 | for(i=first;i<last;i++) |
| 346 | if(ve->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.[i])return(1); |
| 347 | } |
| 348 | return(0); |
| 349 | } |
| 350 | |
| 351 | void _ve_envelope_shiftcxx . . $ _ve_envelope_shift(4f0e5bedd573f2b7).(envelope_lookupcxx . . $ envelope_lookup# *e,long shift){ |
| 352 | int smallsize=e->currentcxx . . $ $anonymous_type_c661d92e27ede393_2#current./e->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.+VE_POSTcxx . . $ `external/vorbis/vorbis_envelope.h:24:9`!; /* adjust for placing marks |
| 353 | ahead of ve->current */ |
| 354 | int smallshift=shift/e->searchstepcxx . . $ $anonymous_type_c661d92e27ede393_2#searchstep.; |
| 355 | |
| 356 | memmove(e->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.,e->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.+smallshift,(smallsize-smallshift)*sizeof(*e->markcxx . . $ $anonymous_type_c661d92e27ede393_2#mark.)); |
| 357 | |
| 358 | #if 0 |
| 359 | for(i=0;i<VE_BANDS*e->ch;i++) |
| 360 | memmove(e->filter[i].markers, |
| 361 | e->filter[i].markers+smallshift, |
| 362 | (1024-smallshift)*sizeof(*(*e->filter).markers)); |
| 363 | totalshift+=shift; |
| 364 | #endif |
| 365 | |
| 366 | e->currentcxx . . $ $anonymous_type_c661d92e27ede393_2#current.-=shift; |
| 367 | if(e->curmarkcxx . . $ $anonymous_type_c661d92e27ede393_2#curmark.>=0) |
| 368 | e->curmarkcxx . . $ $anonymous_type_c661d92e27ede393_2#curmark.-=shift; |
| 369 | e->cursorcxx . . $ $anonymous_type_c661d92e27ede393_2#cursor.-=shift; |
| 370 | } |