author | koda |
Thu, 22 Sep 2011 01:18:31 +0200 | |
changeset 5985 | d276be65b745 |
parent 5170 | f7e49eff3708 |
permissions | -rw-r--r-- |
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 |
* * |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
9 |
* THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 * |
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: PCM data vector blocking, windowing and dis/reassembly |
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 <stdio.h> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
19 |
#include <stdlib.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 "ogg.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
22 |
#include "ivorbiscodec.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
23 |
#include "codec_internal.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
24 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
25 |
#include "window.h" |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
26 |
#include "registry.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 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
29 |
static int ilog(unsigned int v){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
30 |
int ret=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
31 |
if(v)--v; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
32 |
while(v){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
33 |
ret++; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
34 |
v>>=1; |
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 |
return(ret); |
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 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
39 |
/* pcm accumulator examples (not exhaustive): |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
40 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
41 |
<-------------- lW ----------------> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
42 |
<--------------- W ----------------> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
43 |
: .....|..... _______________ | |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
44 |
: .''' | '''_--- | |\ | |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
45 |
:.....''' |_____--- '''......| | \_______| |
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 |
|<------ Sl ------>| > Sr < |endW |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
48 |
|beginSl |endSl | |endSr |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
49 |
|beginW |endlW |beginSr |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
50 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
51 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
52 |
|< lW >| |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
53 |
<--------------- W ----------------> |
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 |
| | ' `/ | ---_ | |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
56 |
|___.'___/`. | ---_____| |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
57 |
|_______|__|_______|_________________| |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
58 |
| >|Sl|< |<------ Sr ----->|endW |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
59 |
| | |endSl |beginSr |endSr |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
60 |
|beginW | |endlW |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
61 |
mult[0] |beginSl mult[n] |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
62 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
63 |
<-------------- lW -----------------> |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
64 |
|<--W-->| |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
65 |
: .............. ___ | | |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
66 |
: .''' |`/ \ | | |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
67 |
:.....''' |/`....\|...| |
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 |
|Sl |Sr |endW |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
70 |
| | |endSr |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
71 |
| |beginSr |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
72 |
| |endSl |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
73 |
|beginSl |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
74 |
|beginW |
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 |
/* block abstraction setup *********************************************/ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
78 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
79 |
#ifndef WORD_ALIGN |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
80 |
#define WORD_ALIGN 8 |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
81 |
#endif |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
82 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
83 |
int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
84 |
memset(vb,0,sizeof(*vb)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
85 |
vb->vd=v; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
86 |
vb->localalloc=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
87 |
vb->localstore=NULL; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
88 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
89 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
90 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
91 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
92 |
void *_vorbis_block_alloc(vorbis_block *vb,long bytes){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
93 |
bytes=(bytes+(WORD_ALIGN-1)) & ~(WORD_ALIGN-1); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
94 |
if(bytes+vb->localtop>vb->localalloc){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
95 |
/* can't just _ogg_realloc... there are outstanding pointers */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
96 |
if(vb->localstore){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
97 |
struct alloc_chain *link=(struct alloc_chain *)_ogg_malloc(sizeof(*link)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
98 |
vb->totaluse+=vb->localtop; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
99 |
link->next=vb->reap; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
100 |
link->ptr=vb->localstore; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
101 |
vb->reap=link; |
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 |
/* highly conservative */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
104 |
vb->localalloc=bytes; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
105 |
vb->localstore=_ogg_malloc(vb->localalloc); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
106 |
vb->localtop=0; |
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 |
{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
109 |
void *ret=(void *)(((char *)vb->localstore)+vb->localtop); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
110 |
vb->localtop+=bytes; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
111 |
return ret; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
112 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
113 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
114 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
115 |
/* reap the chain, pull the ripcord */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
116 |
void _vorbis_block_ripcord(vorbis_block *vb){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
117 |
/* reap the chain */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
118 |
struct alloc_chain *reap=vb->reap; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
119 |
while(reap){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
120 |
struct alloc_chain *next=reap->next; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
121 |
_ogg_free(reap->ptr); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
122 |
memset(reap,0,sizeof(*reap)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
123 |
_ogg_free(reap); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
124 |
reap=next; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
125 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
126 |
/* consolidate storage */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
127 |
if(vb->totaluse){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
128 |
vb->localstore=_ogg_realloc(vb->localstore,vb->totaluse+vb->localalloc); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
129 |
vb->localalloc+=vb->totaluse; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
130 |
vb->totaluse=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
131 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
132 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
133 |
/* pull the ripcord */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
134 |
vb->localtop=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
135 |
vb->reap=NULL; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
136 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
137 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
138 |
int vorbis_block_clear(vorbis_block *vb){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
139 |
_vorbis_block_ripcord(vb); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
140 |
if(vb->localstore)_ogg_free(vb->localstore); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
141 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
142 |
memset(vb,0,sizeof(*vb)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
143 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
144 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
145 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
146 |
static int _vds_init(vorbis_dsp_state *v,vorbis_info *vi){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
147 |
int i; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
148 |
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
|
149 |
private_state *b=NULL; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
150 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
151 |
memset(v,0,sizeof(*v)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
152 |
b=(private_state *)(v->backend_state=_ogg_calloc(1,sizeof(*b))); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
153 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
154 |
v->vi=vi; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
155 |
b->modebits=ilog(ci->modes); |
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 |
/* Vorbis I uses only window type 0 */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
158 |
b->window[0]=_vorbis_window(0,ci->blocksizes[0]/2); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
159 |
b->window[1]=_vorbis_window(0,ci->blocksizes[1]/2); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
160 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
161 |
/* finish the codebooks */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
162 |
if(!ci->fullbooks){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
163 |
ci->fullbooks=(codebook *)_ogg_calloc(ci->books,sizeof(*ci->fullbooks)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
164 |
for(i=0;i<ci->books;i++){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
165 |
vorbis_book_init_decode(ci->fullbooks+i,ci->book_param[i]); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
166 |
/* decode codebooks are now standalone after init */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
167 |
vorbis_staticbook_destroy(ci->book_param[i]); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
168 |
ci->book_param[i]=NULL; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
169 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
170 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
171 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
172 |
v->pcm_storage=ci->blocksizes[1]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
173 |
v->pcm=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcm)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
174 |
v->pcmret=(ogg_int32_t **)_ogg_malloc(vi->channels*sizeof(*v->pcmret)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
175 |
for(i=0;i<vi->channels;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
176 |
v->pcm[i]=(ogg_int32_t *)_ogg_calloc(v->pcm_storage,sizeof(*v->pcm[i])); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
177 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
178 |
/* all 1 (large block) or 0 (small block) */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
179 |
/* explicitly set for the sake of clarity */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
180 |
v->lW=0; /* previous window size */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
181 |
v->W=0; /* current window size */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
182 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
183 |
/* initialize all the mapping/backend lookups */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
184 |
b->mode=(vorbis_look_mapping **)_ogg_calloc(ci->modes,sizeof(*b->mode)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
185 |
for(i=0;i<ci->modes;i++){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
186 |
int mapnum=ci->mode_param[i]->mapping; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
187 |
int maptype=ci->map_type[mapnum]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
188 |
b->mode[i]=_mapping_P[maptype]->look(v,ci->mode_param[i], |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
189 |
ci->map_param[mapnum]); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
190 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
191 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
192 |
} |
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 |
int vorbis_synthesis_restart(vorbis_dsp_state *v){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
195 |
vorbis_info *vi=v->vi; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
196 |
codec_setup_info *ci; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
197 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
198 |
if(!v->backend_state)return -1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
199 |
if(!vi)return -1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
200 |
ci=vi->codec_setup; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
201 |
if(!ci)return -1; |
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 |
v->centerW=ci->blocksizes[1]/2; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
204 |
v->pcm_current=v->centerW; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
205 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
206 |
v->pcm_returned=-1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
207 |
v->granulepos=-1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
208 |
v->sequence=-1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
209 |
((private_state *)(v->backend_state))->sample_count=-1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
210 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
211 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
212 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
213 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
214 |
int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
215 |
_vds_init(v,vi); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
216 |
vorbis_synthesis_restart(v); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
217 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
218 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
219 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
220 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
221 |
void vorbis_dsp_clear(vorbis_dsp_state *v){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
222 |
int i; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
223 |
if(v){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
224 |
vorbis_info *vi=v->vi; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
225 |
codec_setup_info *ci=(codec_setup_info *)(vi?vi->codec_setup:NULL); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
226 |
private_state *b=(private_state *)v->backend_state; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
227 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
228 |
if(v->pcm){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
229 |
for(i=0;i<vi->channels;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
230 |
if(v->pcm[i])_ogg_free(v->pcm[i]); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
231 |
_ogg_free(v->pcm); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
232 |
if(v->pcmret)_ogg_free(v->pcmret); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
233 |
} |
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 |
/* free mode lookups; these are actually vorbis_look_mapping structs */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
236 |
if(ci){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
237 |
for(i=0;i<ci->modes;i++){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
238 |
int mapnum=ci->mode_param[i]->mapping; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
239 |
int maptype=ci->map_type[mapnum]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
240 |
if(b && b->mode)_mapping_P[maptype]->free_look(b->mode[i]); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
241 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
242 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
243 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
244 |
if(b){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
245 |
if(b->mode)_ogg_free(b->mode); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
246 |
_ogg_free(b); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
247 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
248 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
249 |
memset(v,0,sizeof(*v)); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
250 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
251 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
252 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
253 |
/* Unlike in analysis, the window is only partially applied for each |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
254 |
block. The time domain envelope is not yet handled at the point of |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
255 |
calling (as it relies on the previous block). */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
256 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
257 |
int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
258 |
vorbis_info *vi=v->vi; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
259 |
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
|
260 |
private_state *b=v->backend_state; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
261 |
int i,j; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
262 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
263 |
if(v->pcm_current>v->pcm_returned && v->pcm_returned!=-1)return(OV_EINVAL); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
264 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
265 |
v->lW=v->W; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
266 |
v->W=vb->W; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
267 |
v->nW=-1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
268 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
269 |
if((v->sequence==-1)|| |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
270 |
(v->sequence+1 != vb->sequence)){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
271 |
v->granulepos=-1; /* out of sequence; lose count */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
272 |
b->sample_count=-1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
273 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
274 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
275 |
v->sequence=vb->sequence; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
276 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
277 |
if(vb->pcm){ /* no pcm to process if vorbis_synthesis_trackonly |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
278 |
was called on block */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
279 |
int n=ci->blocksizes[v->W]/2; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
280 |
int n0=ci->blocksizes[0]/2; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
281 |
int n1=ci->blocksizes[1]/2; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
282 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
283 |
int thisCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
284 |
int prevCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
285 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
286 |
if(v->centerW){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
287 |
thisCenter=n1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
288 |
prevCenter=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
289 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
290 |
thisCenter=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
291 |
prevCenter=n1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
292 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
293 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
294 |
/* v->pcm is now used like a two-stage double buffer. We don't want |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
295 |
to have to constantly shift *or* adjust memory usage. Don't |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
296 |
accept a new block until the old is shifted out */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
297 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
298 |
/* overlap/add PCM */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
299 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
300 |
for(j=0;j<vi->channels;j++){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
301 |
/* the overlap/add section */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
302 |
if(v->lW){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
303 |
if(v->W){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
304 |
/* large/large */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
305 |
ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
306 |
ogg_int32_t *p=vb->pcm[j]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
307 |
for(i=0;i<n1;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
308 |
pcm[i]+=p[i]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
309 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
310 |
/* large/small */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
311 |
ogg_int32_t *pcm=v->pcm[j]+prevCenter+n1/2-n0/2; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
312 |
ogg_int32_t *p=vb->pcm[j]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
313 |
for(i=0;i<n0;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
314 |
pcm[i]+=p[i]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
315 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
316 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
317 |
if(v->W){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
318 |
/* small/large */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
319 |
ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
320 |
ogg_int32_t *p=vb->pcm[j]+n1/2-n0/2; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
321 |
for(i=0;i<n0;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
322 |
pcm[i]+=p[i]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
323 |
for(;i<n1/2+n0/2;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
324 |
pcm[i]=p[i]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
325 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
326 |
/* small/small */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
327 |
ogg_int32_t *pcm=v->pcm[j]+prevCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
328 |
ogg_int32_t *p=vb->pcm[j]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
329 |
for(i=0;i<n0;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
330 |
pcm[i]+=p[i]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
331 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
332 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
333 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
334 |
/* the copy section */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
335 |
{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
336 |
ogg_int32_t *pcm=v->pcm[j]+thisCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
337 |
ogg_int32_t *p=vb->pcm[j]+n; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
338 |
for(i=0;i<n;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
339 |
pcm[i]=p[i]; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
340 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
341 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
342 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
343 |
if(v->centerW) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
344 |
v->centerW=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
345 |
else |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
346 |
v->centerW=n1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
347 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
348 |
/* deal with initial packet state; we do this using the explicit |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
349 |
pcm_returned==-1 flag otherwise we're sensitive to first block |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
350 |
being short or long */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
351 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
352 |
if(v->pcm_returned==-1){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
353 |
v->pcm_returned=thisCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
354 |
v->pcm_current=thisCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
355 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
356 |
v->pcm_returned=prevCenter; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
357 |
v->pcm_current=prevCenter+ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
358 |
ci->blocksizes[v->lW]/4+ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
359 |
ci->blocksizes[v->W]/4; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
360 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
361 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
362 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
363 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
364 |
/* track the frame number... This is for convenience, but also |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
365 |
making sure our last packet doesn't end with added padding. If |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
366 |
the last packet is partial, the number of samples we'll have to |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
367 |
return will be past the vb->granulepos. |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
368 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
369 |
This is not foolproof! It will be confused if we begin |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
370 |
decoding at the last page after a seek or hole. In that case, |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
371 |
we don't have a starting point to judge where the last frame |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
372 |
is. For this reason, vorbisfile will always try to make sure |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
373 |
it reads the last two marked pages in proper sequence */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
374 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
375 |
if(b->sample_count==-1){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
376 |
b->sample_count=0; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
377 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
378 |
b->sample_count+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
379 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
380 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
381 |
if(v->granulepos==-1){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
382 |
if(vb->granulepos!=-1){ /* only set if we have a position to set to */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
383 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
384 |
v->granulepos=vb->granulepos; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
385 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
386 |
/* is this a short page? */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
387 |
if(b->sample_count>v->granulepos){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
388 |
/* corner case; if this is both the first and last audio page, |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
389 |
then spec says the end is cut, not beginning */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
390 |
if(vb->eofflag){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
391 |
/* trim the end */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
392 |
/* no preceeding granulepos; assume we started at zero (we'd |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
393 |
have to in a short single-page stream) */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
394 |
/* granulepos could be -1 due to a seek, but that would result |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
395 |
in a long coun`t, not short count */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
396 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
397 |
v->pcm_current-=(b->sample_count-v->granulepos); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
398 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
399 |
/* trim the beginning */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
400 |
v->pcm_returned+=(b->sample_count-v->granulepos); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
401 |
if(v->pcm_returned>v->pcm_current) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
402 |
v->pcm_returned=v->pcm_current; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
403 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
404 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
405 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
406 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
407 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
408 |
}else{ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
409 |
v->granulepos+=ci->blocksizes[v->lW]/4+ci->blocksizes[v->W]/4; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
410 |
if(vb->granulepos!=-1 && v->granulepos!=vb->granulepos){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
411 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
412 |
if(v->granulepos>vb->granulepos){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
413 |
long extra=v->granulepos-vb->granulepos; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
414 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
415 |
if(extra) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
416 |
if(vb->eofflag){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
417 |
/* partial last frame. Strip the extra samples off */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
418 |
v->pcm_current-=extra; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
419 |
} /* else {Shouldn't happen *unless* the bitstream is out of |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
420 |
spec. Either way, believe the bitstream } */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
421 |
} /* else {Shouldn't happen *unless* the bitstream is out of |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
422 |
spec. Either way, believe the bitstream } */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
423 |
v->granulepos=vb->granulepos; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
424 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
425 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
426 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
427 |
/* Update, cleanup */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
428 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
429 |
if(vb->eofflag)v->eofflag=1; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
430 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
431 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
432 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
433 |
/* pcm==NULL indicates we just want the pending samples, no more */ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
434 |
int vorbis_synthesis_pcmout(vorbis_dsp_state *v,ogg_int32_t ***pcm){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
435 |
vorbis_info *vi=v->vi; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
436 |
if(v->pcm_returned>-1 && v->pcm_returned<v->pcm_current){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
437 |
if(pcm){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
438 |
int i; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
439 |
for(i=0;i<vi->channels;i++) |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
440 |
v->pcmret[i]=v->pcm[i]+v->pcm_returned; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
441 |
*pcm=v->pcmret; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
442 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
443 |
return(v->pcm_current-v->pcm_returned); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
444 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
445 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
446 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
447 |
|
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
448 |
int vorbis_synthesis_read(vorbis_dsp_state *v,int bytes){ |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
449 |
if(bytes && v->pcm_returned+bytes>v->pcm_current)return(OV_EINVAL); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
450 |
v->pcm_returned+=bytes; |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
451 |
return(0); |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
452 |
} |
f7e49eff3708
add libTremor sources (integer-only libvorbis implementation) to repo and ios project
koda
parents:
diff
changeset
|
453 |