misc/libtremor/tremor/res012.c
author koda
Fri, 21 Sep 2012 01:29:33 +0200
changeset 7699 2455207a2c71
parent 7697 767d3c4153a1
child 7849 a12155461b34
permissions -rw-r--r--
blindly trying to fix the android build
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     1
/********************************************************************
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     2
 *                                                                  *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     3
 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     4
 *                                                                  *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     5
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     6
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     7
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
     8
 *                                                                  *
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
     9
 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003    *
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    10
 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    11
 *                                                                  *
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    12
 ********************************************************************
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    13
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    14
 function: residue backend 0, 1 and 2 implementation
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    15
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    16
 ********************************************************************/
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    17
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    18
#include <stdlib.h>
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    19
#include <string.h>
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    20
#include <math.h>
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    21
#include "ogg.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    22
#include "ivorbiscodec.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    23
#include "codec_internal.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    24
#include "codebook.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    25
#include "misc.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    26
#include "os.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    27
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    28
void res_clear_info(vorbis_info_residue *info){
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    29
  if(info){
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    30
    if(info->stagemasks)_ogg_free(info->stagemasks);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    31
    if(info->stagebooks)_ogg_free(info->stagebooks);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    32
    memset(info,0,sizeof(*info));
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    33
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    34
}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    35
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    36
static int ilog(unsigned int v){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    37
  int ret=0;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    38
  while(v){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    39
    ret++;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    40
    v>>=1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    41
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    42
  return(ret);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    43
}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    44
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    45
/* vorbis_info is for range checking */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    46
int res_unpack(vorbis_info_residue *info,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    47
		vorbis_info *vi,oggpack_buffer *opb){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    48
  int j,k;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    49
  codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    50
  memset(info,0,sizeof(*info));
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    51
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    52
  info->type=oggpack_read(opb,16);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    53
  if(info->type>2 || info->type<0)goto errout;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    54
  info->begin=oggpack_read(opb,24);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    55
  info->end=oggpack_read(opb,24);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    56
  info->grouping=oggpack_read(opb,24)+1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    57
  info->partitions=oggpack_read(opb,6)+1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    58
  info->groupbook=oggpack_read(opb,8);
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    59
  if(info->groupbook>=ci->books)goto errout;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    60
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    61
  info->stagemasks=_ogg_malloc(info->partitions*sizeof(*info->stagemasks));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    62
  info->stagebooks=_ogg_malloc(info->partitions*8*sizeof(*info->stagebooks));
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    63
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    64
  for(j=0;j<info->partitions;j++){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    65
    int cascade=oggpack_read(opb,3);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    66
    if(oggpack_read(opb,1))
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    67
      cascade|=(oggpack_read(opb,5)<<3);
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    68
    info->stagemasks[j]=cascade;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    69
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    70
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    71
  for(j=0;j<info->partitions;j++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    72
    for(k=0;k<8;k++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    73
      if((info->stagemasks[j]>>k)&1){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    74
	unsigned char book=oggpack_read(opb,8);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    75
	if(book>=ci->books)goto errout;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    76
	info->stagebooks[j*8+k]=book;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    77
	if(k+1>info->stages)info->stages=k+1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    78
      }else
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    79
	info->stagebooks[j*8+k]=0xff;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    80
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    81
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    82
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    83
  if(oggpack_eop(opb))goto errout;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    84
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    85
  return 0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    86
 errout:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    87
  res_clear_info(info);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    88
  return 1;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    89
}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    90
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    91
int res_inverse(vorbis_dsp_state *vd,vorbis_info_residue *info,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    92
		ogg_int32_t **in,int *nonzero,int ch){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    93
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    94
  int i,j,k,s,used=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    95
  codec_setup_info     *ci=(codec_setup_info *)vd->vi->codec_setup;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    96
  codebook *phrasebook=ci->book_param+info->groupbook;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    97
  int samples_per_partition=info->grouping;
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    98
  int partitions_per_word=phrasebook->dim;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
    99
  int pcmend=ci->blocksizes[vd->W];
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   100
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   101
  if(info->type<2){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   102
    int max=pcmend>>1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   103
    int end=(info->end<max?info->end:max);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   104
    int n=end-info->begin;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   105
    
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   106
    if(n>0){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   107
      int partvals=n/samples_per_partition;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   108
      int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   109
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   110
      for(i=0;i<ch;i++)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   111
	if(nonzero[i])
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   112
	  in[used++]=in[i];
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   113
      ch=used;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   114
      
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   115
      if(used){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   116
	
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   117
	char **partword=(char **)alloca(ch*sizeof(*partword));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   118
	for(j=0;j<ch;j++)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   119
	  partword[j]=(char *)alloca(partwords*partitions_per_word*
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   120
				     sizeof(*partword[j]));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   121
	
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   122
	for(s=0;s<info->stages;s++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   123
	  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   124
	  for(i=0;i<partvals;){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   125
	    if(s==0){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   126
	      /* fetch the partition word for each channel */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   127
	      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   128
	      partword[0][i+partitions_per_word-1]=1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   129
	      for(k=partitions_per_word-2;k>=0;k--)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   130
		partword[0][i+k]=partword[0][i+k+1]*info->partitions;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   131
	      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   132
	      for(j=1;j<ch;j++)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   133
		for(k=partitions_per_word-1;k>=0;k--)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   134
		  partword[j][i+k]=partword[j-1][i+k];
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   135
	      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   136
	      for(j=0;j<ch;j++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   137
		int temp=vorbis_book_decode(phrasebook,&vd->opb);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   138
		if(oggpack_eop(&vd->opb))goto eopbreak;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   139
		
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   140
		/* this can be done quickly in assembly due to the quotient
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   141
		   always being at most six bits */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   142
		for(k=0;k<partitions_per_word;k++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   143
		  ogg_uint32_t div=partword[j][i+k];
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   144
		  partword[j][i+k]=temp/div;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   145
		  temp-=partword[j][i+k]*div;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   146
		}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   147
		
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   148
	      }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   149
	    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   150
	    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   151
	    /* now we decode residual values for the partitions */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   152
	    for(k=0;k<partitions_per_word && i<partvals;k++,i++)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   153
	      for(j=0;j<ch;j++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   154
		long offset=info->begin+i*samples_per_partition;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   155
		if(info->stagemasks[partword[j][i]]&(1<<s)){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   156
		  codebook *stagebook=ci->book_param+
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   157
		    info->stagebooks[(partword[j][i]<<3)+s];
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   158
		  if(info->type){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   159
		    if(vorbis_book_decodev_add(stagebook,in[j]+offset,&vd->opb,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   160
					       samples_per_partition,-8)==-1)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   161
		      goto eopbreak;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   162
		  }else{
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   163
		    if(vorbis_book_decodevs_add(stagebook,in[j]+offset,&vd->opb,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   164
						samples_per_partition,-8)==-1)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   165
		      goto eopbreak;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   166
		  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   167
		}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   168
	      }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   169
	  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   170
	} 
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   171
      }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   172
    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   173
  }else{
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   174
    int max=(pcmend*ch)>>1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   175
    int end=(info->end<max?info->end:max);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   176
    int n=end-info->begin;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   177
    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   178
    if(n>0){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   179
      int partvals=n/samples_per_partition;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   180
      int partwords=(partvals+partitions_per_word-1)/partitions_per_word;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   181
    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   182
      char *partword=
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   183
	(char *)alloca(partwords*partitions_per_word*sizeof(*partword));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   184
      int beginoff=info->begin/ch;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   185
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   186
      for(i=0;i<ch;i++)if(nonzero[i])break;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   187
      if(i==ch)return(0); /* no nonzero vectors */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   188
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   189
      samples_per_partition/=ch;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   190
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   191
      for(s=0;s<info->stages;s++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   192
	for(i=0;i<partvals;){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   193
	  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   194
	  if(s==0){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   195
	    int temp;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   196
	    partword[i+partitions_per_word-1]=1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   197
	    for(k=partitions_per_word-2;k>=0;k--)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   198
	      partword[i+k]=partword[i+k+1]*info->partitions;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   199
	    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   200
	    /* fetch the partition word */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   201
	    temp=vorbis_book_decode(phrasebook,&vd->opb);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   202
	    if(temp==-1)goto eopbreak;
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   203
	    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   204
	    /* this can be done quickly in assembly due to the quotient
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   205
	       always being at most six bits */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   206
	    for(k=0;k<partitions_per_word;k++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   207
	      ogg_uint32_t div=partword[i+k];
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   208
	      partword[i+k]=temp/div;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   209
	      temp-=partword[i+k]*div;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   210
	    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   211
	  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   212
	  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   213
	  /* now we decode residual values for the partitions */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   214
	  for(k=0;k<partitions_per_word && i<partvals;k++,i++){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   215
	    if(info->stagemasks[partword[i]]&(1<<s)){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   216
	      codebook *stagebook=ci->book_param+
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   217
		info->stagebooks[(partword[i]<<3)+s];
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   218
	      if(vorbis_book_decodevv_add(stagebook,in,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   219
					  i*samples_per_partition+beginoff,ch,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   220
					  &vd->opb,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   221
					  samples_per_partition,-8)==-1)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   222
		goto eopbreak;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   223
	    }
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   224
	  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   225
	}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   226
      } 
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   227
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   228
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   229
 errout:
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   230
 eopbreak:
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   231
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   232
  return 0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents: 6045
diff changeset
   233
}    
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   234