mapping0.java

来自「java ogg player library. for play back o」· Java 代码 · 共 567 行 · 第 1/2 页

JAVA
567
字号
    LookMapping0 look=(LookMapping0)l;    InfoMapping0 info=look.map;    InfoMode mode=look.mode;    int n=vb.pcmend;    float[] window=vd.window[vb.W][vb.lW][vb.nW][mode.windowtype];    float[][] pcmbundle=new float[vi.channles][];    int[] nonzero=new int[vi.channels];      // time domain pre-window: NONE IMPLEMENTED     // window the PCM data: takes PCM vector, vb; modifies PCM vector     for(int i=0;i<vi.channels;i++){       float[] pcm=vb.pcm[i];       for(int j=0;j<n;j++)         pcm[j]*=window[j];     }	         // time-domain post-window: NONE IMPLEMENTED     // transform the PCM data; takes PCM vector, vb; modifies PCM vector     // only MDCT right now....     for(int i=0;i<vi.channels;i++){       float[] pcm=vb.pcm[i];       mdct_forward(vd.transform[vb.W][0],pcm,pcm);     }     {       float[] floor=_vorbis_block_alloc(vb,n*sizeof(float)/2);           for(int i=0;i<vi.channels;i++){         float[] pcm=vb.pcm[i];         float[] decay=look.decay[i];         int submap=info.chmuxlist[i];         // if some other mode/mapping was called last frame, our decay         // accumulator is out of date.  Clear it.         //if(look.lastframe+1 != vb->sequence)  	 //  memset(decay,0,n*sizeof(float)/2);         // perform psychoacoustics; do masking         _vp_compute_mask(look.psy_look[submap],pcm,floor,decay);          _analysis_output("mdct",seq,pcm,n/2,0,1);         _analysis_output("lmdct",seq,pcm,n/2,0,0);         _analysis_output("prefloor",seq,floor,n/2,0,1);         // perform floor encoding         nonzero[i]=look.floor_func[submap]. 	            forward(vb,look.floor_look[submap],floor,floor,look.floor_state[i]);         _analysis_output("floor",seq,floor,n/2,0,1);         // apply the floor, do optional noise levelling         _vp_apply_floor(look->psy_look+submap,pcm,floor);               _analysis_output("res",seq++,pcm,n/2,0,0);     }         // perform residue encoding with residue mapping; this is     // multiplexed.  All the channels belonging to one submap are     // encoded (values interleaved), then the next submap, etc         for(int i=0;i<info.submaps;i++){       int ch_in_bundle=0;        for(int j=0;j<vi.channels;j++){	  if(info.chmuxlist[j]==i && nonzero[j]==1){	    pcmbundle[ch_in_bundle++]=vb.pcm[j]; 	  }        }        look.residue_func[i].forward(vb,look.residue_look[i], pcmbundle,ch_in_bundle);      }    }    look.lastframe=vb.sequence;    return(0);  }*/  float[][] pcmbundle=null;  int[] zerobundle=null;  int[] nonzero=null;  Object[] floormemo=null;  synchronized int inverse(Block vb, Object l){    //System.err.println("Mapping0.inverse");    DspState vd=vb.vd;    Info vi=vd.vi;    LookMapping0 look=(LookMapping0)l;    InfoMapping0 info=look.map;    InfoMode mode=look.mode;    int n=vb.pcmend=vi.blocksizes[vb.W];    float[] window=vd.window[vb.W][vb.lW][vb.nW][mode.windowtype];    // float[][] pcmbundle=new float[vi.channels][];    // int[] nonzero=new int[vi.channels];    if(pcmbundle==null || pcmbundle.length<vi.channels){      pcmbundle=new float[vi.channels][];      nonzero=new int[vi.channels];      zerobundle=new int[vi.channels];      floormemo=new Object[vi.channels];    }      // time domain information decode (note that applying the    // information would have to happen later; we'll probably add a    // function entry to the harness for that later    // NOT IMPLEMENTED    // recover the spectral envelope; store it in the PCM vector for now     for(int i=0;i<vi.channels;i++){      float[] pcm=vb.pcm[i];      int submap=info.chmuxlist[i];      floormemo[i]=look.floor_func[submap].inverse1(vb,look.						    floor_look[submap],						    floormemo[i]						    );      if(floormemo[i]!=null){ nonzero[i]=1; }      else{ nonzero[i]=0; }      for(int j=0; j<n/2; j++){        pcm[j]=0;      }                       //_analysis_output("ifloor",seq+i,pcm,n/2,0,1);    }    for(int i=0; i<info.coupling_steps; i++){      if(nonzero[info.coupling_mag[i]]!=0 ||         nonzero[info.coupling_ang[i]]!=0){        nonzero[info.coupling_mag[i]]=1;        nonzero[info.coupling_ang[i]]=1;      }    }    // recover the residue, apply directly to the spectral envelope    for(int i=0;i<info.submaps;i++){      int ch_in_bundle=0;      for(int j=0;j<vi.channels;j++){        if(info.chmuxlist[j]==i){          if(nonzero[j]!=0){            zerobundle[ch_in_bundle]=1;	  }          else{            zerobundle[ch_in_bundle]=0;	  }	  pcmbundle[ch_in_bundle++]=vb.pcm[j];	}      }      look.residue_func[i].inverse(vb,look.residue_look[i],				   pcmbundle,zerobundle,ch_in_bundle);    }    for(int i=info.coupling_steps-1;i>=0;i--){      float[] pcmM=vb.pcm[info.coupling_mag[i]];      float[] pcmA=vb.pcm[info.coupling_ang[i]];      for(int j=0;j<n/2;j++){        float mag=pcmM[j];        float ang=pcmA[j];        if(mag>0){          if(ang>0){            pcmM[j]=mag;            pcmA[j]=mag-ang;          }          else{            pcmA[j]=mag;            pcmM[j]=mag+ang;          }	}        else{          if(ang>0){            pcmM[j]=mag;            pcmA[j]=mag+ang;          }          else{            pcmA[j]=mag;            pcmM[j]=mag-ang;          }	}      }    }//    /* compute and apply spectral envelope */    for(int i=0;i<vi.channels;i++){      float[] pcm=vb.pcm[i];      int submap=info.chmuxlist[i];      look.floor_func[submap].inverse2(vb,look.floor_look[submap],floormemo[i],pcm);    }    // transform the PCM data; takes PCM vector, vb; modifies PCM vector    // only MDCT right now....    for(int i=0;i<vi.channels;i++){      float[] pcm=vb.pcm[i];      //_analysis_output("out",seq+i,pcm,n/2,0,0);      ((Mdct)vd.transform[vb.W][0]).backward(pcm,pcm);    }    // now apply the decoded pre-window time information    // NOT IMPLEMENTED      // window the data    for(int i=0;i<vi.channels;i++){      float[] pcm=vb.pcm[i];      if(nonzero[i]!=0){        for(int j=0;j<n;j++){	  pcm[j]*=window[j];        }      }      else{        for(int j=0;j<n;j++){	  pcm[j]=0.f;	}      }      //_analysis_output("final",seq++,pcm,n,0,0);    }	        // now apply the decoded post-window time information    // NOT IMPLEMENTED    // all done!    return(0);  }  private static int ilog2(int v){    int ret=0;    while(v>1){      ret++;      v>>>=1;    }    return(ret);  }}class InfoMapping0{  int   submaps;  // <= 16  int[] chmuxlist=new int[256];   // up to 256 channels in a Vorbis stream    int[] timesubmap=new int[16];   // [mux]  int[] floorsubmap=new int[16];  // [mux] submap to floors  int[] residuesubmap=new int[16];// [mux] submap to residue  int[] psysubmap=new int[16];    // [mux]; encode only  int   coupling_steps;  int[] coupling_mag=new int[256];  int[] coupling_ang=new int[256];  void free(){    chmuxlist=null;    timesubmap=null;    floorsubmap=null;    residuesubmap=null;    psysubmap=null;    coupling_mag=null;    coupling_ang=null;  }}class LookMapping0{  InfoMode mode;  InfoMapping0 map;  Object[] time_look;  Object[] floor_look;  Object[] floor_state;  Object[] residue_look;   PsyLook[] psy_look;  FuncTime[] time_func;   FuncFloor[] floor_func;   FuncResidue[] residue_func;  int ch;  float[][] decay;  int lastframe; // if a different mode is called, we need to                  // invalidate decay and floor state}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?