コード例 #1
0
/* a truncated packet here just means 'stop working'; it's not an error */
static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
		      ogg_int32_t **in,int ch,
		      long (*decodepart)(codebook *, ogg_int32_t *, 
					 oggpack_buffer *,int,int)){

  long i,j,k,l,s;
  vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
  vorbis_info_residue0 *info=look->info;

  /* move all this setup out later */
  int samples_per_partition=info->grouping;
  int partitions_per_word=look->phrasebook->dim;
  int max=vb->pcmend>>1;
  int end=(info->end<max?info->end:max);
  int n=end-info->begin;

  if(n>0){
    int partvals=n/samples_per_partition;
    int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
    int ***partword=(int ***)alloca(ch*sizeof(*partword));
    
    for(j=0;j<ch;j++)
      partword[j]=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword[j]));
    
    for(s=0;s<look->stages;s++){
      
      /* each loop decodes on partition codeword containing 
	 partitions_pre_word partitions */
      for(i=0,l=0;i<partvals;l++){
	if(s==0){
	  /* fetch the partition word for each channel */
	  for(j=0;j<ch;j++){
	    int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
	    if(temp==-1 || temp>=info->partvals)goto eopbreak;
	    partword[j][l]=look->decodemap[temp];
	    if(partword[j][l]==NULL)goto errout;
	  }
	}
	
	/* now we decode residual values for the partitions */
	for(k=0;k<partitions_per_word && i<partvals;k++,i++)
	  for(j=0;j<ch;j++){
	    long offset=info->begin+i*samples_per_partition;
	    if(info->secondstages[partword[j][l][k]]&(1<<s)){
	      codebook *stagebook=look->partbooks[partword[j][l][k]][s];
	      if(stagebook){
		if(decodepart(stagebook,in[j]+offset,&vb->opb,
			      samples_per_partition,-8)==-1)goto eopbreak;
	      }
	    }
	  }
      } 
    }
  }
 errout:
 eopbreak:
  return(0);
}
コード例 #2
0
/* duplicate code here as speed is somewhat more important */
int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
		 ogg_int32_t **in,int *nonzero,int ch){
  long i,k,l,s;
  vorbis_look_residue0 *look=(vorbis_look_residue0 *)vl;
  vorbis_info_residue0 *info=look->info;

  /* move all this setup out later */
  int samples_per_partition=info->grouping;
  int partitions_per_word=look->phrasebook->dim;
  int max=(vb->pcmend*ch)>>1;
  int end=(info->end<max?info->end:max);
  int n=end-info->begin;

  if(n>0){
    
    int partvals=n/samples_per_partition;
    int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
    int **partword=(int **)_vorbis_block_alloc(vb,partwords*sizeof(*partword));
    int beginoff=info->begin/ch;
    
    for(i=0;i<ch;i++)if(nonzero[i])break;
    if(i==ch)return(0); /* no nonzero vectors */
    
    samples_per_partition/=ch;
    
    for(s=0;s<look->stages;s++){
      for(i=0,l=0;i<partvals;l++){
	
	if(s==0){
	  /* fetch the partition word */
	  int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
	  if(temp==-1 || temp>=info->partvals)goto eopbreak;
	  partword[l]=look->decodemap[temp];
	  if(partword[l]==NULL)goto errout;
	}

	/* now we decode residual values for the partitions */
	for(k=0;k<partitions_per_word && i<partvals;k++,i++)
	  if(info->secondstages[partword[l][k]]&(1<<s)){
	    codebook *stagebook=look->partbooks[partword[l][k]][s];
	    
	    if(stagebook){
	      if(vorbis_book_decodevv_add(stagebook,in,
					  i*samples_per_partition+beginoff,ch,
					  &vb->opb,
					  samples_per_partition,-8)==-1)
		goto eopbreak;
	    }
	  }
      } 
    }
  }
 errout:
 eopbreak:
  return(0);
}
コード例 #3
0
static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
  vorbis_look_floor1 *look=(vorbis_look_floor1 *)in;
  vorbis_info_floor1 *info=look->vi;
  codec_setup_info   *ci=(codec_setup_info *)vb->vd->vi->codec_setup;

  int i,j,k;
  codebook *books=ci->fullbooks;

  /* unpack wrapped/predicted values from stream */
  if(oggpack_read(&vb->opb,1)==1){
    int *fit_value=(int *)_vorbis_block_alloc(vb,(look->posts)*sizeof(*fit_value));

    fit_value[0]=oggpack_read(&vb->opb,ilog(look->quant_q-1));
    fit_value[1]=oggpack_read(&vb->opb,ilog(look->quant_q-1));

    /* partition by partition */
    /* partition by partition */
    for(i=0,j=2;i<info->partitions;i++){
      int classv=info->partitionclass[i];
      int cdim=info->class_dim[classv];
      int csubbits=info->class_subs[classv];
      int csub=1<<csubbits;
      int cval=0;

      /* decode the partition's first stage cascade value */
      if(csubbits){
	cval=vorbis_book_decode(books+info->class_book[classv],&vb->opb);

	if(cval==-1)goto eop;
      }

      for(k=0;k<cdim;k++){
	int book=info->class_subbook[classv][cval&(csub-1)];
	cval>>=csubbits;
	if(book>=0){
	  if((fit_value[j+k]=vorbis_book_decode(books+book,&vb->opb))==-1)
	    goto eop;
	}else{
	  fit_value[j+k]=0;
	}
      }
      j+=cdim;
    }

    /* unwrap positive values and reconsitute via linear interpolation */
    for(i=2;i<look->posts;i++){
      int predicted=render_point(info->postlist[look->loneighbor[i-2]],
				 info->postlist[look->hineighbor[i-2]],
				 fit_value[look->loneighbor[i-2]],
				 fit_value[look->hineighbor[i-2]],
				 info->postlist[i]);
      int hiroom=look->quant_q-predicted;
      int loroom=predicted;
      int room=(hiroom<loroom?hiroom:loroom)<<1;
      int val=fit_value[i];

      if(val){
	if(val>=room){
	  if(hiroom>loroom){
	    val = val-loroom;
	  }else{
	  val = -1-(val-hiroom);
	  }
	}else{
	  if(val&1){
	    val= -((val+1)>>1);
	  }else{
	    val>>=1;
	  }
	}

	fit_value[i]=val+predicted;
	fit_value[look->loneighbor[i-2]]&=0x7fff;
	fit_value[look->hineighbor[i-2]]&=0x7fff;

      }else{
コード例 #4
0
ファイル: RES0.C プロジェクト: en-vorobiov/mpxplay
static int res2_inverse(vorbis_block *vb,vorbis_info_residue *vl,ogg_double_t **in,unsigned int channels)
{
 vorbis_info_residue0 *info=(vorbis_info_residue0 *)vl;
 codebook ***partbookps=&info->partbooks[0];
 oggpack_buffer *vbopb=&vb->opb;
 unsigned int s;

 {
  int **wordpp=info->partwordp;
  codebook **partbookpk=*partbookps++;
  unsigned int injoffset=info->begin,i=info->info_partvals;
  do{
   int *wordpk;
   unsigned int k;
   int temp=vorbis_book_decode(info->phrasebook->decode_tree,vbopb);
   if(temp<0)
    goto eopbreak;
   *wordpp=info->decodemap[temp];
   if(*wordpp==NULL)
    goto errout;
   wordpk=*wordpp;
   k=info->dim;
   do{
    int pwlk=*wordpk++;
    if(info->secondstages[pwlk]&1){
     codebook *stagebook=partbookpk[pwlk];
     if(stagebook){
      if(((res2_decodev_t *)info->setpart)(stagebook,in,injoffset,channels,vbopb,info->samples_per_partition)<0)
       goto eopbreak;
     }
    }
    injoffset+=info->samples_per_partition;
   }while(--i && --k);
   wordpp++;
  }while(i);
 }

 s=info->stages;
 if(--s){
  unsigned int stagebitpos=2;
  do{
   int **wordpp=info->partwordp;
   codebook **partbookpk=*partbookps;
   unsigned int injoffset=info->begin,i=info->info_partvals;
   do{
    int *wordpk=*wordpp;
    unsigned int k=info->dim;
    do{
     int pwlk=*wordpk++;
     if(info->secondstages[pwlk]&stagebitpos){
      codebook *stagebook=partbookpk[pwlk];
      if(stagebook){
       if(((res2_decodev_t *)info->decodepart)(stagebook,in,injoffset,channels,vbopb,info->samples_per_partition)<0)
	goto eopbreak;
      }
     }
     injoffset+=info->samples_per_partition;
    }while(--i && --k);
    wordpp++;
   }while(i);
   partbookps++;
   stagebitpos<<=1;
  }while(--s);
 }

 errout:
 eopbreak:
 return(0);
}
コード例 #5
0
ファイル: RES0.C プロジェクト: en-vorobiov/mpxplay
static int res01_inverse(vorbis_block *vb,vorbis_info_residue *vl,ogg_double_t **in,unsigned int channels)
{
 vorbis_info_residue0 *info=(vorbis_info_residue0 *)vl;
 unsigned int i,ch,k,s,injoffset,stagebitpos;
 oggpack_buffer *vbopb=&vb->opb;
 int **wordpp;
 codebook ***partbookp;

 injoffset=info->begin;
 wordpp=info->partwordp;
 partbookp=&info->partbooks[0];

 i=info->info_partvals;
 do{
  int **wordpch=wordpp;
  ch=channels;
  do{
   int temp=vorbis_book_decode((info->phrasebook)->decode_tree,vbopb);
   if(temp<0)
    goto eopbreak;
   *wordpch=info->decodemap[temp];
   if(*wordpch==NULL)
    goto errout;
   wordpch++;
  }while(--ch);

  k=0;
  do{
   wordpch=wordpp;
   for(ch=0;ch<channels;ch++){
    int pwjlk=(*wordpch)[k];
    if(info->secondstages[pwjlk]&1){
     codebook *stagebook=(*partbookp)[pwjlk];
     if(stagebook)
      if(info->setpart(stagebook,in[ch]+injoffset,vbopb,info->samples_per_partition)<0)
       goto eopbreak;
    }
    wordpch++;
   }
   injoffset+=info->samples_per_partition;
  }while(--i && ++k<info->dim);
  wordpp+=channels;
 }while(i);

 partbookp++;

 s=info->stages;
 if(--s){
  stagebitpos=2;
  do{
   injoffset=info->begin;
   wordpp=info->partwordp;
   i=info->info_partvals;
   do{
    k=0;
    do{
     int **wordpch=wordpp;
     for(ch=0;ch<channels;ch++){
      int pwjlk=(*wordpch)[k];
      if(info->secondstages[pwjlk]&stagebitpos){
       codebook *stagebook=(*partbookp)[pwjlk];
       if(stagebook){
	if(info->decodepart(stagebook,in[ch]+injoffset,vbopb,info->samples_per_partition)<0)
	 goto eopbreak;
       }
      }
      wordpch++;
     }
     injoffset+=info->samples_per_partition;
    }while(--i && ++k<info->dim);
    wordpp+=channels;
   }while(i);
   partbookp++;
   stagebitpos<<=1;
  }while(--s);
 }

 errout:
 eopbreak:
 return(0);
}