| 1 | /******************************************************************** |
| 2 | * * |
| 3 | * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. * |
| 4 | * * |
| 5 | * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * |
| 6 | * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * |
| 7 | * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * |
| 8 | * * |
| 9 | * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
| 10 | * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ * |
| 11 | * * |
| 12 | ******************************************************************** |
| 13 | |
| 14 | function: channel mapping 0 implementation |
| 15 | |
| 16 | ********************************************************************/ |
| 17 | |
| 18 | #include <stdlib.h> |
| 19 | #include <stdio.h> |
| 20 | #include <string.h> |
| 21 | #include <math.h> |
| 22 | #include "ogg.h"cxx . . $ `<file>/mednafen/tremor/ogg.h`/ |
| 23 | #include "ivorbiscodec.h"cxx . . $ `<file>/mednafen/tremor/ivorbiscodec.h`/ |
| 24 | #include "mdct.h"cxx . . $ `<file>/mednafen/tremor/mdct.h`/ |
| 25 | #include "codec_internal.h"cxx . . $ `<file>/mednafen/tremor/codec_internal.h`/ |
| 26 | #include "codebook.h"cxx . . $ `<file>/mednafen/tremor/codebook.h`/ |
| 27 | #include "window.h"cxx . . $ `<file>/mednafen/tremor/window.h`/ |
| 28 | #include "registry.h"cxx . . $ `<file>/mednafen/tremor/registry.h`/ |
| 29 | #include "misc.h"cxx . . $ `<file>/mednafen/tremor/misc.h`/ |
| 30 | |
| 31 | /* simplistic, wasteful way of doing this (unique lookup for each |
| 32 | mode/submapping); there should be a central repository for |
| 33 | identical lookups. That will require minor work, so I'm putting it |
| 34 | off as low priority. |
| 35 | |
| 36 | Why a lookup for each backend in a given mode? Because the |
| 37 | blocksize is set by the mode, and low backend lookups may require |
| 38 | parameters from other areas of the mode/mapping */ |
| 39 | |
| 40 | typedef structcxx . . $ $anonymous_type_13bf9a070a8544b1_0# { |
| 41 | vorbis_info_modecxx . . $ vorbis_info_mode# *modecxx . . $ $anonymous_type_13bf9a070a8544b1_0#mode.; |
| 42 | vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *mapcxx . . $ $anonymous_type_13bf9a070a8544b1_0#map.; |
| 43 | |
| 44 | vorbis_look_floorcxx . . $ vorbis_look_floor# **floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.; |
| 45 | |
| 46 | vorbis_look_residuecxx . . $ vorbis_look_residue# **residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.; |
| 47 | |
| 48 | vorbis_func_floorcxx . . $ vorbis_func_floor# **floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.; |
| 49 | vorbis_func_residuecxx . . $ vorbis_func_residue# **residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.; |
| 50 | |
| 51 | int chcxx . . $ $anonymous_type_13bf9a070a8544b1_0#ch.; |
| 52 | long lastframecxx . . $ $anonymous_type_13bf9a070a8544b1_0#lastframe.; /* if a different mode is called, we need to |
| 53 | invalidate decay */ |
| 54 | } vorbis_look_mapping0cxx . . $ vorbis_look_mapping0#; |
| 55 | |
| 56 | static void mapping0_free_infocxx . . $ mapping0_free_info(5d22bdacc48458e8).(vorbis_info_mappingcxx . . $ vorbis_info_mapping# *i){ |
| 57 | vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *info=(vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *)i; |
| 58 | if(info){ |
| 59 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(info,0,sizeof(*info)); |
| 60 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(info); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static void mapping0_free_lookcxx . . $ mapping0_free_look(5d22bdacc48458e8).(vorbis_look_mappingcxx . . $ vorbis_look_mapping# *look){ |
| 65 | int i; |
| 66 | vorbis_look_mapping0cxx . . $ vorbis_look_mapping0# *l=(vorbis_look_mapping0cxx . . $ vorbis_look_mapping0# *)look; |
| 67 | if(l){ |
| 68 | |
| 69 | for(i=0;i<l->mapcxx . . $ $anonymous_type_13bf9a070a8544b1_0#map.->submapscxx . . $ vorbis_info_mapping0#submaps.;i++){ |
| 70 | l->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.[i]->free_lookcxx . . $ $anonymous_type_c7374eb872c22577_0#free_look.(l->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.[i]); |
| 71 | l->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.[i]->free_lookcxx . . $ $anonymous_type_c7374eb872c22577_3#free_look.(l->residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.[i]); |
| 72 | } |
| 73 | |
| 74 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(l->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.); |
| 75 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(l->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.); |
| 76 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(l->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.); |
| 77 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(l->residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.); |
| 78 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(l,0,sizeof(*l)); |
| 79 | _ogg_freecxx . . $ `mednafen/tremor/os_types.h:25:9`!(l); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | static vorbis_look_mappingcxx . . $ vorbis_look_mapping# *mapping0_lookcxx . . $ mapping0_look(f9c763c507a8abc9).(vorbis_dsp_statecxx . . $ vorbis_dsp_state# *vd,vorbis_info_modecxx . . $ vorbis_info_mode# *vm, |
| 84 | vorbis_info_mappingcxx . . $ vorbis_info_mapping# *m){ |
| 85 | int i; |
| 86 | vorbis_infocxx . . $ vorbis_info# *vi=vd->vicxx . . $ vorbis_dsp_state#vi.; |
| 87 | codec_setup_infocxx . . $ codec_setup_info# *ci=(codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 88 | vorbis_look_mapping0cxx . . $ vorbis_look_mapping0# *look=(vorbis_look_mapping0cxx . . $ vorbis_look_mapping0# *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(1,sizeof(*look)); |
| 89 | vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *info=look->mapcxx . . $ $anonymous_type_13bf9a070a8544b1_0#map.=(vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *)m; |
| 90 | look->modecxx . . $ $anonymous_type_13bf9a070a8544b1_0#mode.=vm; |
| 91 | |
| 92 | look->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.=(vorbis_look_floorcxx . . $ vorbis_look_floor# **)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(info->submapscxx . . $ vorbis_info_mapping0#submaps.,sizeof(*look->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.)); |
| 93 | |
| 94 | look->residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.=(vorbis_look_residuecxx . . $ vorbis_look_residue# **)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(info->submapscxx . . $ vorbis_info_mapping0#submaps.,sizeof(*look->residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.)); |
| 95 | |
| 96 | look->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.=(vorbis_func_floorcxx . . $ vorbis_func_floor# **)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(info->submapscxx . . $ vorbis_info_mapping0#submaps.,sizeof(*look->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.)); |
| 97 | look->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.=(vorbis_func_residuecxx . . $ vorbis_func_residue# **)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(info->submapscxx . . $ vorbis_info_mapping0#submaps.,sizeof(*look->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.)); |
| 98 | |
| 99 | for(i=0;i<info->submapscxx . . $ vorbis_info_mapping0#submaps.;i++){ |
| 100 | int floornum=info->floorsubmapcxx . . $ vorbis_info_mapping0#floorsubmap.[i]; |
| 101 | int resnum=info->residuesubmapcxx . . $ vorbis_info_mapping0#residuesubmap.[i]; |
| 102 | |
| 103 | look->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.[i]=_floor_Pcxx . . $ _floor_P.[ci->floor_typecxx . . $ codec_setup_info#floor_type.[floornum]]; |
| 104 | look->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.[i]=look->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.[i]-> |
| 105 | lookcxx . . $ $anonymous_type_c7374eb872c22577_0#look.(vd,vm,ci->floor_paramcxx . . $ codec_setup_info#floor_param.[floornum]); |
| 106 | look->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.[i]=_residue_Pcxx . . $ _residue_P.[ci->residue_typecxx . . $ codec_setup_info#residue_type.[resnum]]; |
| 107 | look->residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.[i]=look->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.[i]-> |
| 108 | lookcxx . . $ $anonymous_type_c7374eb872c22577_3#look.(vd,vm,ci->residue_paramcxx . . $ codec_setup_info#residue_param.[resnum]); |
| 109 | |
| 110 | } |
| 111 | |
| 112 | look->chcxx . . $ $anonymous_type_13bf9a070a8544b1_0#ch.=vi->channelscxx . . $ vorbis_info#channels.; |
| 113 | |
| 114 | return(look); |
| 115 | } |
| 116 | |
| 117 | static int ilogcxx . . $ ilog(4c679297bf94b9eb).(unsigned int v){ |
| 118 | int ret=0; |
| 119 | if(v)--v; |
| 120 | while(v){ |
| 121 | ret++; |
| 122 | v>>=1; |
| 123 | } |
| 124 | return(ret); |
| 125 | } |
| 126 | |
| 127 | /* also responsible for range checking */ |
| 128 | static vorbis_info_mappingcxx . . $ vorbis_info_mapping# *mapping0_unpackcxx . . $ mapping0_unpack(eeac8d4f838aca31).(vorbis_infocxx . . $ vorbis_info# *vi,oggpack_buffercxx . . $ oggpack_buffer# *opb){ |
| 129 | int i,b; |
| 130 | vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *info=(vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *)_ogg_calloccxx . . $ `mednafen/tremor/os_types.h:23:9`!(1,sizeof(*info)); |
| 131 | codec_setup_infocxx . . $ codec_setup_info# *ci=(codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 132 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(info,0,sizeof(*info)); |
| 133 | |
| 134 | b=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,1); |
| 135 | if(b<0)goto err_out; |
| 136 | if(b){ |
| 137 | info->submapscxx . . $ vorbis_info_mapping0#submaps.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,4)+1; |
| 138 | if(info->submapscxx . . $ vorbis_info_mapping0#submaps.<=0)goto err_out; |
| 139 | }else |
| 140 | info->submapscxx . . $ vorbis_info_mapping0#submaps.=1; |
| 141 | |
| 142 | b=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,1); |
| 143 | if(b<0)goto err_out; |
| 144 | if(b){ |
| 145 | info->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8)+1; |
| 146 | if(info->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.<=0)goto err_out; |
| 147 | for(i=0;i<info->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.;i++){ |
| 148 | int testM=info->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,ilogcxx . . $ ilog(4c679297bf94b9eb).(vi->channelscxx . . $ vorbis_info#channels.)); |
| 149 | int testA=info->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,ilogcxx . . $ ilog(4c679297bf94b9eb).(vi->channelscxx . . $ vorbis_info#channels.)); |
| 150 | |
| 151 | if(testM<0 || |
| 152 | testA<0 || |
| 153 | testM==testA || |
| 154 | testM>=vi->channelscxx . . $ vorbis_info#channels. || |
| 155 | testA>=vi->channelscxx . . $ vorbis_info#channels.) goto err_out; |
| 156 | } |
| 157 | |
| 158 | } |
| 159 | |
| 160 | if(oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,2)!=0)goto err_out; /* 2,3:reserved */ |
| 161 | |
| 162 | if(info->submapscxx . . $ vorbis_info_mapping0#submaps.>1){ |
| 163 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++){ |
| 164 | info->chmuxlistcxx . . $ vorbis_info_mapping0#chmuxlist.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,4); |
| 165 | if(info->chmuxlistcxx . . $ vorbis_info_mapping0#chmuxlist.[i]>=info->submapscxx . . $ vorbis_info_mapping0#submaps. || info->chmuxlistcxx . . $ vorbis_info_mapping0#chmuxlist.[i]<0)goto err_out; |
| 166 | } |
| 167 | } |
| 168 | for(i=0;i<info->submapscxx . . $ vorbis_info_mapping0#submaps.;i++){ |
| 169 | int temp=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8); |
| 170 | if(temp>=ci->timescxx . . $ codec_setup_info#times.)goto err_out; |
| 171 | info->floorsubmapcxx . . $ vorbis_info_mapping0#floorsubmap.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8); |
| 172 | if(info->floorsubmapcxx . . $ vorbis_info_mapping0#floorsubmap.[i]>=ci->floorscxx . . $ codec_setup_info#floors. || info->floorsubmapcxx . . $ vorbis_info_mapping0#floorsubmap.[i]<0)goto err_out; |
| 173 | info->residuesubmapcxx . . $ vorbis_info_mapping0#residuesubmap.[i]=oggpack_readcxx . . $ oggpack_read(e96bf1ebf62076a2).(opb,8); |
| 174 | if(info->residuesubmapcxx . . $ vorbis_info_mapping0#residuesubmap.[i]>=ci->residuescxx . . $ codec_setup_info#residues. || info->residuesubmapcxx . . $ vorbis_info_mapping0#residuesubmap.[i]<0) |
| 175 | goto err_out; |
| 176 | } |
| 177 | |
| 178 | return info; |
| 179 | |
| 180 | err_out: |
| 181 | mapping0_free_infocxx . . $ mapping0_free_info(5d22bdacc48458e8).(info); |
| 182 | return(NULLcxx . . $ `<external>/15298297234472979974/stddef.h:419:9`!); |
| 183 | } |
| 184 | |
| 185 | static int seqcxx . . $ seq.=0; |
| 186 | static int mapping0_inversecxx . . $ mapping0_inverse(e82853f66750014d).(vorbis_blockcxx . . $ vorbis_block# *vb,vorbis_look_mappingcxx . . $ vorbis_look_mapping# *l){ |
| 187 | vorbis_dsp_statecxx . . $ vorbis_dsp_state# *vd=vb->vdcxx . . $ vorbis_block#vd.; |
| 188 | vorbis_infocxx . . $ vorbis_info# *vi=vd->vicxx . . $ vorbis_dsp_state#vi.; |
| 189 | codec_setup_infocxx . . $ codec_setup_info# *ci=(codec_setup_infocxx . . $ codec_setup_info# *)vi->codec_setupcxx . . $ vorbis_info#codec_setup.; |
| 190 | private_statecxx . . $ private_state# *b=(private_statecxx . . $ private_state# *)vd->backend_statecxx . . $ vorbis_dsp_state#backend_state.; |
| 191 | vorbis_look_mapping0cxx . . $ vorbis_look_mapping0# *look=(vorbis_look_mapping0cxx . . $ vorbis_look_mapping0# *)l; |
| 192 | vorbis_info_mapping0cxx . . $ vorbis_info_mapping0# *info=look->mapcxx . . $ $anonymous_type_13bf9a070a8544b1_0#map.; |
| 193 | |
| 194 | int i,j; |
| 195 | long n=vb->pcmendcxx . . $ vorbis_block#pcmend.=ci->blocksizescxx . . $ codec_setup_info#blocksizes.[vb->Wcxx . . $ vorbis_block#W.]; |
| 196 | |
| 197 | ogg_int32_tcxx . . $ ogg_int32_t# **pcmbundle=(ogg_int32_tcxx . . $ ogg_int32_t# **)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*pcmbundle)*vi->channels); |
| 198 | int *zerobundle=(int *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*zerobundle)*vi->channels); |
| 199 | |
| 200 | int *nonzero =(int *)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*nonzero)*vi->channels); |
| 201 | void **floormemo=(void **)allocacxx . . $ `<external>/11612401604547820122/alloca.h:35:10`!(sizeof(*floormemo)*vi->channels); |
| 202 | |
| 203 | /* time domain information decode (note that applying the |
| 204 | information would have to happen later; we'll probably add a |
| 205 | function entry to the harness for that later */ |
| 206 | /* NOT IMPLEMENTED */ |
| 207 | |
| 208 | /* recover the spectral envelope; store it in the PCM vector for now */ |
| 209 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++){ |
| 210 | int submap=info->chmuxlistcxx . . $ vorbis_info_mapping0#chmuxlist.[i]; |
| 211 | floormemo[i]=look->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.[submap]-> |
| 212 | inverse1cxx . . $ $anonymous_type_c7374eb872c22577_0#inverse1.(vb,look->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.[submap]); |
| 213 | if(floormemo[i]) |
| 214 | nonzero[i]=1; |
| 215 | else |
| 216 | nonzero[i]=0; |
| 217 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(vb->pcmcxx . . $ vorbis_block#pcm.[i],0,sizeof(*vb->pcmcxx . . $ vorbis_block#pcm.[i])*n/2); |
| 218 | } |
| 219 | |
| 220 | /* channel coupling can 'dirty' the nonzero listing */ |
| 221 | for(i=0;i<info->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.;i++){ |
| 222 | if(nonzero[info->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[i]] || |
| 223 | nonzero[info->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[i]]){ |
| 224 | nonzero[info->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[i]]=1; |
| 225 | nonzero[info->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[i]]=1; |
| 226 | } |
| 227 | } |
| 228 | |
| 229 | /* recover the residue into our working vectors */ |
| 230 | for(i=0;i<info->submapscxx . . $ vorbis_info_mapping0#submaps.;i++){ |
| 231 | int ch_in_bundle=0; |
| 232 | for(j=0;j<vi->channelscxx . . $ vorbis_info#channels.;j++){ |
| 233 | if(info->chmuxlistcxx . . $ vorbis_info_mapping0#chmuxlist.[j]==i){ |
| 234 | if(nonzero[j]) |
| 235 | zerobundle[ch_in_bundle]=1; |
| 236 | else |
| 237 | zerobundle[ch_in_bundle]=0; |
| 238 | pcmbundle[ch_in_bundle++]=vb->pcmcxx . . $ vorbis_block#pcm.[j]; |
| 239 | } |
| 240 | } |
| 241 | |
| 242 | look->residue_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_func.[i]->inversecxx . . $ $anonymous_type_c7374eb872c22577_3#inverse.(vb,look->residue_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#residue_look.[i], |
| 243 | pcmbundle,zerobundle,ch_in_bundle); |
| 244 | } |
| 245 | |
| 246 | //for(j=0;j<vi->channels;j++) |
| 247 | //_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0); |
| 248 | |
| 249 | |
| 250 | /* channel coupling */ |
| 251 | for(i=info->coupling_stepscxx . . $ vorbis_info_mapping0#coupling_steps.-1;i>=0;i--){ |
| 252 | ogg_int32_tcxx . . $ ogg_int32_t# *pcmM=vb->pcmcxx . . $ vorbis_block#pcm.[info->coupling_magcxx . . $ vorbis_info_mapping0#coupling_mag.[i]]; |
| 253 | ogg_int32_tcxx . . $ ogg_int32_t# *pcmA=vb->pcmcxx . . $ vorbis_block#pcm.[info->coupling_angcxx . . $ vorbis_info_mapping0#coupling_ang.[i]]; |
| 254 | |
| 255 | for(j=0;j<n/2;j++){ |
| 256 | ogg_int32_tcxx . . $ ogg_int32_t# mag=pcmM[j]; |
| 257 | ogg_int32_tcxx . . $ ogg_int32_t# ang=pcmA[j]; |
| 258 | |
| 259 | if(mag>0) |
| 260 | if(ang>0){ |
| 261 | pcmM[j]=mag; |
| 262 | pcmA[j]=mag-ang; |
| 263 | }else{ |
| 264 | pcmA[j]=mag; |
| 265 | pcmM[j]=mag+ang; |
| 266 | } |
| 267 | else |
| 268 | if(ang>0){ |
| 269 | pcmM[j]=mag; |
| 270 | pcmA[j]=mag+ang; |
| 271 | }else{ |
| 272 | pcmA[j]=mag; |
| 273 | pcmM[j]=mag-ang; |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | //for(j=0;j<vi->channels;j++) |
| 279 | //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0); |
| 280 | |
| 281 | /* compute and apply spectral envelope */ |
| 282 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++){ |
| 283 | ogg_int32_tcxx . . $ ogg_int32_t# *pcm=vb->pcmcxx . . $ vorbis_block#pcm.[i]; |
| 284 | int submap=info->chmuxlistcxx . . $ vorbis_info_mapping0#chmuxlist.[i]; |
| 285 | look->floor_funccxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_func.[submap]-> |
| 286 | inverse2cxx . . $ $anonymous_type_c7374eb872c22577_0#inverse2.(vb,look->floor_lookcxx . . $ $anonymous_type_13bf9a070a8544b1_0#floor_look.[submap],floormemo[i],pcm); |
| 287 | } |
| 288 | |
| 289 | //for(j=0;j<vi->channels;j++) |
| 290 | //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1); |
| 291 | |
| 292 | /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */ |
| 293 | /* only MDCT right now.... */ |
| 294 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++){ |
| 295 | ogg_int32_tcxx . . $ ogg_int32_t# *pcm=vb->pcmcxx . . $ vorbis_block#pcm.[i]; |
| 296 | mdct_backwardcxx . . $ mdct_backward(5768b2fa0fe719ec).(n,pcm,pcm); |
| 297 | } |
| 298 | |
| 299 | //for(j=0;j<vi->channels;j++) |
| 300 | //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0); |
| 301 | |
| 302 | /* window the data */ |
| 303 | for(i=0;i<vi->channelscxx . . $ vorbis_info#channels.;i++){ |
| 304 | ogg_int32_tcxx . . $ ogg_int32_t# *pcm=vb->pcmcxx . . $ vorbis_block#pcm.[i]; |
| 305 | if(nonzero[i]) |
| 306 | _vorbis_apply_windowcxx . . $ _vorbis_apply_window(8d42a4f87b1249b5).(pcm,b->windowcxx . . $ private_state#window.,ci->blocksizescxx . . $ codec_setup_info#blocksizes.,vb->lWcxx . . $ vorbis_block#lW.,vb->Wcxx . . $ vorbis_block#W.,vb->nWcxx . . $ vorbis_block#nW.); |
| 307 | else |
| 308 | for(j=0;j<n;j++) |
| 309 | pcm[j]=0; |
| 310 | |
| 311 | } |
| 312 | |
| 313 | //for(j=0;j<vi->channels;j++) |
| 314 | //_analysis_output("window",seq+j,vb->pcm[j],-24,n,0,0); |
| 315 | |
| 316 | seqcxx . . $ seq.+=vi->channelscxx . . $ vorbis_info#channels.; |
| 317 | /* all done! */ |
| 318 | return(0); |
| 319 | } |
| 320 | |
| 321 | /* export hooks */ |
| 322 | vorbis_func_mappingcxx . . $ vorbis_func_mapping# mapping0_exportbundlecxx . . $ mapping0_exportbundle.={ |
| 323 | &mapping0_unpackcxx . . $ mapping0_unpack(eeac8d4f838aca31)., |
| 324 | &mapping0_lookcxx . . $ mapping0_look(f9c763c507a8abc9)., |
| 325 | &mapping0_free_infocxx . . $ mapping0_free_info(5d22bdacc48458e8)., |
| 326 | &mapping0_free_lookcxx . . $ mapping0_free_look(5d22bdacc48458e8)., |
| 327 | &mapping0_inversecxx . . $ mapping0_inverse(e82853f66750014d). |
| 328 | }; |