misc/libtremor/tremor/dsp.c
author koda
Fri, 21 Sep 2012 00:50:04 +0200
changeset 7697 767d3c4153a1
permissions -rw-r--r--
switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7697
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     1
/********************************************************************
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     2
 *                                                                  *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     3
 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE.   *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     4
 *                                                                  *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     5
 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     6
 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     7
 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     8
 *                                                                  *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
     9
 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003    *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    10
 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/                  *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    11
 *                                                                  *
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    12
 ********************************************************************
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    13
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    14
 function: PCM data vector blocking, windowing and dis/reassembly
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    15
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    16
 ********************************************************************/
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    17
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    18
#include <stdlib.h> 
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    19
#include "ogg.h"
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    20
#include "mdct.h"
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    21
#include "ivorbiscodec.h"
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    22
#include "codec_internal.h"
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    23
#include "misc.h"
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    24
#include "window_lookup.h"
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    25
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    26
int vorbis_dsp_restart(vorbis_dsp_state *v){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    27
  if(!v)return -1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    28
  {
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    29
    vorbis_info *vi=v->vi;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    30
    codec_setup_info *ci;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    31
    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    32
    if(!vi)return -1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    33
    ci=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:
diff changeset
    34
    if(!ci)return -1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    35
    
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    36
    v->out_end=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    37
    v->out_begin=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    38
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    39
    v->granulepos=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    40
    v->sequence=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    41
    v->sample_count=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    42
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    43
  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:
diff changeset
    44
}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    45
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    46
vorbis_dsp_state *vorbis_dsp_create(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:
diff changeset
    47
  int i;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    48
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    49
  vorbis_dsp_state *v=_ogg_calloc(1,sizeof(*v));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    50
  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:
diff changeset
    51
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    52
  v->vi=vi;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    53
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    54
  v->work=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->work));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    55
  v->mdctright=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->mdctright));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    56
  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:
diff changeset
    57
    v->work[i]=(ogg_int32_t *)_ogg_calloc(1,(ci->blocksizes[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:
diff changeset
    58
					  sizeof(*v->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:
diff changeset
    59
    v->mdctright[i]=(ogg_int32_t *)_ogg_calloc(1,(ci->blocksizes[1]>>2)*
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    60
					       sizeof(*v->mdctright[i]));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    61
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    62
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    63
  v->lW=0; /* previous window size */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    64
  v->W=0;  /* current window size */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    65
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    66
  vorbis_dsp_restart(v);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    67
  return v;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    68
}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    69
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    70
void vorbis_dsp_destroy(vorbis_dsp_state *v){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    71
  int i;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    72
  if(v){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    73
    vorbis_info *vi=v->vi;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    74
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    75
    if(v->work){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    76
      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:
diff changeset
    77
        if(v->work[i])_ogg_free(v->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:
diff changeset
    78
      _ogg_free(v->work);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    79
    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    80
    if(v->mdctright){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    81
      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:
diff changeset
    82
        if(v->mdctright[i])_ogg_free(v->mdctright[i]);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    83
      _ogg_free(v->mdctright);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    84
    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    85
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    86
    _ogg_free(v);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
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:
diff changeset
    88
}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    89
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    90
static LOOKUP_T *_vorbis_window(int left){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    91
  switch(left){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    92
  case 32:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    93
    return vwin64;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    94
  case 64:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    95
    return vwin128;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    96
  case 128:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    97
    return vwin256;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    98
  case 256:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
    99
    return vwin512;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   100
  case 512:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   101
    return vwin1024;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   102
  case 1024:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   103
    return vwin2048;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   104
  case 2048:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   105
    return vwin4096;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   106
#ifndef LIMIT_TO_64kHz
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   107
  case 4096:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   108
    return vwin8192;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   109
#endif
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   110
  default:
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   111
    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:
diff changeset
   112
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   113
}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   114
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   115
/* pcm==0 indicates we just want the pending samples, no more */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   116
int vorbis_dsp_pcmout(vorbis_dsp_state *v,ogg_int16_t *pcm,int samples){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   117
  vorbis_info *vi=v->vi;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   118
  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:
diff changeset
   119
  if(v->out_begin>-1 && v->out_begin<v->out_end){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   120
    int n=v->out_end-v->out_begin;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   121
    if(pcm){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   122
      int i;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   123
      if(n>samples)n=samples;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   124
      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:
diff changeset
   125
	mdct_unroll_lap(ci->blocksizes[0],ci->blocksizes[1],
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   126
			v->lW,v->W,v->work[i],v->mdctright[i],
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   127
			_vorbis_window(ci->blocksizes[0]>>1),
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   128
			_vorbis_window(ci->blocksizes[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:
diff changeset
   129
			pcm+i,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:
diff changeset
   130
			v->out_begin,v->out_begin+n);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
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:
diff changeset
   132
    return(n);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   133
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   134
  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:
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:
diff changeset
   136
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   137
int vorbis_dsp_read(vorbis_dsp_state *v,int s){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   138
  if(s && v->out_begin+s>v->out_end)return(OV_EINVAL);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   139
  v->out_begin+=s;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   140
  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:
diff changeset
   141
}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   142
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   143
long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   144
  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:
diff changeset
   145
  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:
diff changeset
   146
  int                  mode;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   147
  int modebits=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   148
  int v=ci->modes;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
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:
diff changeset
   150
  oggpack_readinit(&opb,op->packet);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   151
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   152
  /* Check the packet type */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   153
  if(oggpack_read(&opb,1)!=0){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   154
    /* Oops.  This is not an audio data packet */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   155
    return(OV_ENOTAUDIO);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   156
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   157
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   158
  while(v>1){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   159
    modebits++;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   160
    v>>=1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   161
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   162
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   163
  /* read our mode and pre/post windowsize */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   164
  mode=oggpack_read(&opb,modebits);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   165
  if(mode==-1)return(OV_EBADPACKET);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   166
  return(ci->blocksizes[ci->mode_param[mode].blockflag]);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
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:
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:
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:
diff changeset
   170
static int ilog(ogg_uint32_t v){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   171
  int ret=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   172
  if(v)--v;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   173
  while(v){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   174
    ret++;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   175
    v>>=1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   176
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   177
  return(ret);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   178
}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   179
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   180
int vorbis_dsp_synthesis(vorbis_dsp_state *vd,ogg_packet *op,int decodep){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   181
  vorbis_info          *vi=vd->vi;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   182
  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:
diff changeset
   183
  int                   mode,i;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   184
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   185
  oggpack_readinit(&vd->opb,op->packet);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   186
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   187
  /* Check the packet type */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   188
  if(oggpack_read(&vd->opb,1)!=0){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   189
    /* Oops.  This is not an audio data packet */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   190
    return OV_ENOTAUDIO ;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   191
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   192
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   193
  /* read our mode and pre/post windowsize */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   194
  mode=oggpack_read(&vd->opb,ilog(ci->modes));
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   195
  if(mode==-1 || mode>=ci->modes) return OV_EBADPACKET;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   196
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   197
  /* shift information we still need from last window */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   198
  vd->lW=vd->W;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   199
  vd->W=ci->mode_param[mode].blockflag;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   200
  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:
diff changeset
   201
    mdct_shift_right(ci->blocksizes[vd->lW],vd->work[i],vd->mdctright[i]);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   202
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   203
  if(vd->W){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   204
    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:
diff changeset
   205
    oggpack_read(&vd->opb,1);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   206
    temp=oggpack_read(&vd->opb,1);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   207
    if(temp==-1) return OV_EBADPACKET;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   208
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   209
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   210
  /* packet decode and portions of synthesis that rely on only this block */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   211
  if(decodep){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   212
    mapping_inverse(vd,ci->map_param+ci->mode_param[mode].mapping);
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
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:
diff changeset
   214
    if(vd->out_begin==-1){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   215
      vd->out_begin=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   216
      vd->out_end=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   217
    }else{
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   218
      vd->out_begin=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   219
      vd->out_end=ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   220
    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   221
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   222
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   223
  /* track the frame number... This is for convenience, but also
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   224
     making sure our last packet doesn't end with added padding.
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   225
     
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   226
     This is not foolproof!  It will be confused if we begin
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   227
     decoding at the last page after a seek or hole.  In that case,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   228
     we don't have a starting point to judge where the last frame
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   229
     is.  For this reason, vorbisfile will always try to make sure
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   230
     it reads the last two marked pages in proper sequence */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
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:
diff changeset
   232
  /* if we're out of sequence, dump granpos tracking until we sync back up */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   233
  if(vd->sequence==-1 || vd->sequence+1 != op->packetno-3){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   234
    /* out of sequence; lose count */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   235
    vd->granulepos=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   236
    vd->sample_count=-1;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   237
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   238
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   239
  vd->sequence=op->packetno;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   240
  vd->sequence=vd->sequence-3;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   241
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   242
  if(vd->sample_count==-1){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   243
    vd->sample_count=0;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   244
  }else{
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   245
    vd->sample_count+=
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   246
      ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   247
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   248
  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   249
  if(vd->granulepos==-1){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   250
    if(op->granulepos!=-1){ /* only set if we have a
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   251
			       position to set to */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   252
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   253
      vd->granulepos=op->granulepos;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   254
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   255
      /* is this a short page? */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   256
      if(vd->sample_count>vd->granulepos){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   257
	/* corner case; if this is both the first and last audio page,
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   258
	   then spec says the end is cut, not beginning */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   259
	if(op->e_o_s){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   260
	  /* trim the end */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   261
	  /* no preceeding granulepos; assume we started at zero (we'd
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   262
	     have to in a short single-page stream) */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   263
	  /* granulepos could be -1 due to a seek, but that would result
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   264
	     in a long coun t, not short count */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   265
	  
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   266
	  vd->out_end-=vd->sample_count-vd->granulepos;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   267
	}else{
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   268
	  /* trim the beginning */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   269
	  vd->out_begin+=vd->sample_count-vd->granulepos;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   270
	  if(vd->out_begin>vd->out_end)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   271
	    vd->out_begin=vd->out_end;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   272
	}
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   273
	
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   274
      }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   275
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   276
    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   277
  }else{
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   278
    vd->granulepos+=
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   279
      ci->blocksizes[vd->lW]/4+ci->blocksizes[vd->W]/4;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   280
    if(op->granulepos!=-1 && vd->granulepos!=op->granulepos){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   281
      
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   282
      if(vd->granulepos>op->granulepos){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   283
	long extra=vd->granulepos-op->granulepos;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   284
	
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   285
	if(extra)
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   286
	  if(op->e_o_s){
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   287
	    /* partial last frame.  Strip the extra samples off */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   288
	    vd->out_end-=extra;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   289
	  } /* else {Shouldn't happen *unless* the bitstream is out of
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   290
	       spec.  Either way, believe the bitstream } */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   291
      } /* else {Shouldn't happen *unless* the bitstream is out of
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   292
	   spec.  Either way, believe the bitstream } */
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   293
      vd->granulepos=op->granulepos;
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   294
    }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   295
  }
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   296
767d3c4153a1 switch the Tremor implementation from the Cocos2D one to the lowmem-no-byte branch and let's see what happens
koda
parents:
diff changeset
   297
  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:
diff changeset
   298
}