misc/libtremor/tremor/mapping0.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: channel mapping 0 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 <stdio.h>
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    20
#include <string.h>
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    21
#include <math.h>
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    22
#include "ogg.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    23
#include "ivorbiscodec.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    24
#include "mdct.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    25
#include "codec_internal.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    26
#include "codebook.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    27
#include "misc.h"
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    28
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
    29
void mapping_clear_info(vorbis_info_mapping *info){
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    30
  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
    31
    if(info->chmuxlist)_ogg_free(info->chmuxlist);
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
    32
    if(info->submaplist)_ogg_free(info->submaplist);
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
    33
    if(info->coupling)_ogg_free(info->coupling);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    34
    memset(info,0,sizeof(*info));
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
}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    37
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    38
static int ilog(unsigned int v){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    39
  int ret=0;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    40
  if(v)--v;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    41
  while(v){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    42
    ret++;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    43
    v>>=1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    44
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    45
  return(ret);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    46
}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    47
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    48
/* also responsible for range checking */
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
    49
int mapping_info_unpack(vorbis_info_mapping *info,vorbis_info *vi,
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
			oggpack_buffer *opb){
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    51
  int i;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    52
  codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    53
  memset(info,0,sizeof(*info));
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    54
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    55
  if(oggpack_read(opb,1))
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    56
    info->submaps=oggpack_read(opb,4)+1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    57
  else
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    58
    info->submaps=1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    59
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    60
  if(oggpack_read(opb,1)){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    61
    info->coupling_steps=oggpack_read(opb,8)+1;
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
    62
    info->coupling=
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
    63
      _ogg_malloc(info->coupling_steps*sizeof(*info->coupling));
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
    64
    
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    65
    for(i=0;i<info->coupling_steps;i++){
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
    66
      int testM=info->coupling[i].mag=oggpack_read(opb,ilog(vi->channels));
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
    67
      int testA=info->coupling[i].ang=oggpack_read(opb,ilog(vi->channels));
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    68
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    69
      if(testM<0 || 
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    70
	 testA<0 || 
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    71
	 testM==testA || 
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    72
	 testM>=vi->channels ||
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    73
	 testA>=vi->channels) goto err_out;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    74
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    75
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    76
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    77
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    78
  if(oggpack_read(opb,2)>0)goto err_out; /* 2,3:reserved */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    79
    
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    80
  if(info->submaps>1){
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
    81
    info->chmuxlist=_ogg_malloc(sizeof(*info->chmuxlist)*vi->channels);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    82
    for(i=0;i<vi->channels;i++){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    83
      info->chmuxlist[i]=oggpack_read(opb,4);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    84
      if(info->chmuxlist[i]>=info->submaps)goto err_out;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    85
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    86
  }
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
    87
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
  info->submaplist=_ogg_malloc(sizeof(*info->submaplist)*info->submaps);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    89
  for(i=0;i<info->submaps;i++){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    90
    int temp=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
    91
    info->submaplist[i].floor=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
    92
    if(info->submaplist[i].floor>=ci->floors)goto err_out;
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
    info->submaplist[i].residue=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
    94
    if(info->submaplist[i].residue>=ci->residues)goto err_out;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    95
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    96
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
    97
  return 0;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    98
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
    99
 err_out:
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
   100
  mapping_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
   101
  return -1;
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   102
}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   103
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
   104
int mapping_inverse(vorbis_dsp_state *vd,vorbis_info_mapping *info){
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   105
  vorbis_info          *vi=vd->vi;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   106
  codec_setup_info     *ci=(codec_setup_info *)vi->codec_setup;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   107
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   108
  int                   i,j;
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
   109
  long                  n=ci->blocksizes[vd->W];
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   110
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
   111
  ogg_int32_t **pcmbundle=
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
    (ogg_int32_t **)alloca(sizeof(*pcmbundle)*vi->channels);
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
  int          *zerobundle=
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
   114
    (int *)alloca(sizeof(*zerobundle)*vi->channels);
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
  int          *nonzero=
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
    (int *)alloca(sizeof(*nonzero)*vi->channels);
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
  ogg_int32_t **floormemo=
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
    (void **)alloca(sizeof(*floormemo)*vi->channels);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   119
  
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   120
  /* recover the spectral envelope; store it in the PCM vector for now */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   121
  for(i=0;i<vi->channels;i++){
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
   122
    int submap=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
   123
    int floorno;
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
    
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(info->submaps>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
   126
      submap=info->chmuxlist[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
   127
    floorno=info->submaplist[submap].floor;
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
    
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
    if(ci->floor_type[floorno]){
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
      /* floor 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
   131
      floormemo[i]=alloca(sizeof(*floormemo[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
   132
			  floor1_memosize(ci->floor_param[floorno]));
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
      floormemo[i]=floor1_inverse1(vd,ci->floor_param[floorno],floormemo[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
   134
    }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
   135
      /* floor 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
   136
      floormemo[i]=alloca(sizeof(*floormemo[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
   137
			  floor0_memosize(ci->floor_param[floorno]));
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
      floormemo[i]=floor0_inverse1(vd,ci->floor_param[floorno],floormemo[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
   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
    
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   141
    if(floormemo[i])
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   142
      nonzero[i]=1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   143
    else
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   144
      nonzero[i]=0;      
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
   145
    memset(vd->work[i],0,sizeof(*vd->work[i])*n/2);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   146
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   147
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   148
  /* channel coupling can 'dirty' the nonzero listing */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   149
  for(i=0;i<info->coupling_steps;i++){
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
   150
    if(nonzero[info->coupling[i].mag] ||
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
       nonzero[info->coupling[i].ang]){
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
      nonzero[info->coupling[i].mag]=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
   153
      nonzero[info->coupling[i].ang]=1; 
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   154
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   155
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   156
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   157
  /* recover the residue into our working vectors */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   158
  for(i=0;i<info->submaps;i++){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   159
    int ch_in_bundle=0;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   160
    for(j=0;j<vi->channels;j++){
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
   161
      if(!info->chmuxlist || info->chmuxlist[j]==i){
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   162
	if(nonzero[j])
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   163
	  zerobundle[ch_in_bundle]=1;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   164
	else
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   165
	  zerobundle[ch_in_bundle]=0;
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
   166
	pcmbundle[ch_in_bundle++]=vd->work[j];
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   167
      }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   168
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   169
    
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
   170
    res_inverse(vd,ci->residue_param+info->submaplist[i].residue,
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
		pcmbundle,zerobundle,ch_in_bundle);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   172
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   173
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   174
  //for(j=0;j<vi->channels;j++)
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   175
  //_analysis_output("coupled",seq+j,vb->pcm[j],-8,n/2,0,0);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   176
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   177
  /* channel coupling */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   178
  for(i=info->coupling_steps-1;i>=0;i--){
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
   179
    ogg_int32_t *pcmM=vd->work[info->coupling[i].mag];
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
    ogg_int32_t *pcmA=vd->work[info->coupling[i].ang];
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   181
    
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   182
    for(j=0;j<n/2;j++){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   183
      ogg_int32_t mag=pcmM[j];
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   184
      ogg_int32_t ang=pcmA[j];
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   185
      
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   186
      if(mag>0)
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   187
	if(ang>0){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   188
	  pcmM[j]=mag;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   189
	  pcmA[j]=mag-ang;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   190
	}else{
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   191
	  pcmA[j]=mag;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   192
	  pcmM[j]=mag+ang;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   193
	}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   194
      else
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   195
	if(ang>0){
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   196
	  pcmM[j]=mag;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   197
	  pcmA[j]=mag+ang;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   198
	}else{
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   199
	  pcmA[j]=mag;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   200
	  pcmM[j]=mag-ang;
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   201
	}
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   202
    }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   203
  }
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   204
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   205
  //for(j=0;j<vi->channels;j++)
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   206
  //_analysis_output("residue",seq+j,vb->pcm[j],-8,n/2,0,0);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   207
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   208
  /* compute and apply spectral envelope */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   209
  for(i=0;i<vi->channels;i++){
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
   210
    ogg_int32_t *pcm=vd->work[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
   211
    int submap=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
   212
    int floorno;
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
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
    if(info->submaps>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
   215
      submap=info->chmuxlist[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
   216
    floorno=info->submaplist[submap].floor;
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
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(ci->floor_type[floorno]){
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
      /* floor 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
   220
      floor1_inverse2(vd,ci->floor_param[floorno],floormemo[i],pcm);
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
    }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
   222
      /* floor 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
   223
      floor0_inverse2(vd,ci->floor_param[floorno],floormemo[i],pcm);
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
   224
    }
5170
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
  //for(j=0;j<vi->channels;j++)
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   228
  //_analysis_output("mdct",seq+j,vb->pcm[j],-24,n/2,0,1);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   229
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   230
  /* transform the PCM data; takes PCM vector, vb; modifies PCM vector */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   231
  /* only MDCT right now.... */
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
   232
  for(i=0;i<vi->channels;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
   233
    mdct_backward(n,vd->work[i]);
5170
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   234
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   235
  //for(j=0;j<vi->channels;j++)
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   236
  //_analysis_output("imdct",seq+j,vb->pcm[j],-24,n,0,0);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   237
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   238
  /* all done! */
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   239
  return(0);
f7e49eff3708 add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff changeset
   240
}