summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Wallménius <nils@rockbox.org>2007-07-15 19:55:30 +0000
committerNils Wallménius <nils@rockbox.org>2007-07-15 19:55:30 +0000
commit497a1f07bdfd5b9381399bd6c858f1112f984bf3 (patch)
tree3c6f88b82f09f0b633a0639e47a5611bcb3f181c
parente9d62762e5714366f182fedaf5918b10538e7e76 (diff)
downloadrockbox-497a1f07bdfd5b9381399bd6c858f1112f984bf3.zip
rockbox-497a1f07bdfd5b9381399bd6c858f1112f984bf3.tar.gz
rockbox-497a1f07bdfd5b9381399bd6c858f1112f984bf3.tar.bz2
rockbox-497a1f07bdfd5b9381399bd6c858f1112f984bf3.tar.xz
Clean out unused code
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13910 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/codecs/Tremor/asm_mcf5249.h33
-rw-r--r--apps/codecs/Tremor/bitwise.c15
-rw-r--r--apps/codecs/Tremor/framing.c69
-rw-r--r--apps/codecs/Tremor/info.c48
-rw-r--r--apps/codecs/Tremor/ivorbiscodec.h5
-rw-r--r--apps/codecs/Tremor/ivorbisfile_example.c86
-rw-r--r--apps/codecs/Tremor/ogg.h5
-rw-r--r--apps/codecs/Tremor/vorbisfile.c286
8 files changed, 0 insertions, 547 deletions
diff --git a/apps/codecs/Tremor/asm_mcf5249.h b/apps/codecs/Tremor/asm_mcf5249.h
index 7d366fa..fd816a2 100644
--- a/apps/codecs/Tremor/asm_mcf5249.h
+++ b/apps/codecs/Tremor/asm_mcf5249.h
@@ -306,39 +306,6 @@ void vect_mult_bw(ogg_int32_t *data, LOOKUP_T *window, int n)
"cc", "memory");
}
-#if 0
-/* this routine is subsumed by Jens' asm optimised memset which appears
- to be more efficient anyway; will eventually be deleted */
-static inline
-void mcf5249_vect_zero(ogg_int32_t *ptr, int n)
-{
- /* ensure ptr is aligned to 16-bytes */
- while(n>0 && (int)ptr%16) {
- *ptr++ = 0;
- n--;
- }
- asm volatile ("clr.l %%d0;"
- "clr.l %%d1;"
- "clr.l %%d2;"
- "clr.l %%d3;"
- /* loop start */
- "tst.l %[n];"
- "bra 1f;"
- "0: movem.l %%d0-%%d3, (%[ptr]);"
- "lea (4*4, %[ptr]), %[ptr];"
- "subq.l #4, %[n];" /* done 4 elements */
- "1: bgt 0b;"
- : [n] "+d" (n), [ptr] "+a" (ptr)
- :
- : "%d0","%d1","%d2","%d3","cc","memory");
- /* clear remaining elements */
- while(n>0) {
- *ptr++ = 0;
- n--;
- }
-}
-#endif
-
#endif
#endif
diff --git a/apps/codecs/Tremor/bitwise.c b/apps/codecs/Tremor/bitwise.c
index 55d3712..caa42f4 100644
--- a/apps/codecs/Tremor/bitwise.c
+++ b/apps/codecs/Tremor/bitwise.c
@@ -130,11 +130,6 @@ static int _halt_one(oggpack_buffer *b){
return 0;
}
-int oggpack_eop(oggpack_buffer *b){
- if(b->headend<0)return -1;
- return 0;
-}
-
/* bits <= 32 */
long oggpack_read(oggpack_buffer *b,int bits) ICODE_ATTR_TREMOR_NOT_MDCT;
long oggpack_read(oggpack_buffer *b,int bits){
@@ -217,13 +212,3 @@ long oggpack_read(oggpack_buffer *b,int bits){
return ret;
}
-long oggpack_bytes(oggpack_buffer *b){
- return(b->count+b->headptr-b->head->buffer->data-b->head->begin+
- (b->headbit+7)/8);
-}
-
-long oggpack_bits(oggpack_buffer *b){
- return((b->count+b->headptr-b->head->buffer->data-b->head->begin)*8+
- b->headbit);
-}
-
diff --git a/apps/codecs/Tremor/framing.c b/apps/codecs/Tremor/framing.c
index 1cd5c1e..4fc4a69 100644
--- a/apps/codecs/Tremor/framing.c
+++ b/apps/codecs/Tremor/framing.c
@@ -469,36 +469,6 @@ ogg_uint32_t ogg_page_pageno(ogg_page *og){
return oggbyte_read4(&ob,18);
}
-/* returns the number of packets that are completed on this page (if
- the leading packet is begun on a previous page, but ends on this
- page, it's counted */
-
-/* NOTE:
-If a page consists of a packet begun on a previous page, and a new
-packet begun (but not completed) on this page, the return will be:
- ogg_page_packets(page) ==1,
- ogg_page_continued(page) !=0
-
-If a page happens to be a single packet that was begun on a
-previous page, and spans to the next page (in the case of a three or
-more page packet), the return will be:
- ogg_page_packets(page) ==0,
- ogg_page_continued(page) !=0
-*/
-
-int ogg_page_packets(ogg_page *og){
- int i;
- int n;
- int count=0;
- oggbyte_buffer ob;
- oggbyte_init(&ob,og->header);
-
- n=oggbyte_read1(&ob,26);
- for(i=0;i<n;i++)
- if(oggbyte_read1(&ob,27+i)<255)count++;
- return(count);
-}
-
/* Static CRC calculation table. See older code in CVS for dead
run-time initialization code. */
@@ -770,45 +740,6 @@ long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
return ret;
}
-/* sync the stream and get a page. Keep trying until we find a page.
- Supress 'sync errors' after reporting the first.
-
- return values:
- OGG_HOLE) recapture (hole in data)
- 0) need more data
- 1) page returned
-
- Returns pointers into buffered data; invalidated by next call to
- _stream, _clear, _init, or _buffer */
-
-int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){
-
- /* all we need to do is verify a page at the head of the stream
- buffer. If it doesn't verify, we look for the next potential
- frame */
-
- while(1){
- long ret=ogg_sync_pageseek(oy,og);
- if(ret>0){
- /* have a page */
- return 1;
- }
- if(ret==0){
- /* need more data */
- return 0;
- }
-
- /* head did not start a synced page... skipped some bytes */
- if(!oy->unsynced){
- oy->unsynced=1;
- return OGG_HOLE;
- }
-
- /* loop. keep looking */
-
- }
-}
-
/* clear things to an initial state. Good to call, eg, before seeking */
int ogg_sync_reset(ogg_sync_state *oy){
diff --git a/apps/codecs/Tremor/info.c b/apps/codecs/Tremor/info.c
index c8d9651..c0bd0ae 100644
--- a/apps/codecs/Tremor/info.c
+++ b/apps/codecs/Tremor/info.c
@@ -41,54 +41,6 @@ void vorbis_comment_init(vorbis_comment *vc){
memset(vc,0,sizeof(*vc));
}
-/* This is more or less the same as strncasecmp - but that doesn't exist
- * everywhere, and this is a fairly trivial function, so we include it */
-static int tagcompare(const char *s1, const char *s2, int n){
- int c=0;
- while(c < n){
- if(toupper(s1[c]) != toupper(s2[c]))
- return !0;
- c++;
- }
- return 0;
-}
-
-char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count){
- long i;
- int found = 0;
- int taglen = strlen(tag)+1; /* +1 for the = we append */
- char *fulltag = (char *)alloca(taglen+ 1);
-
- strcpy(fulltag, tag);
- strcat(fulltag, "=");
-
- for(i=0;i<vc->comments;i++){
- if(!tagcompare(vc->user_comments[i], fulltag, taglen)){
- if(count == found)
- /* We return a pointer to the data, not a copy */
- return vc->user_comments[i] + taglen;
- else
- found++;
- }
- }
- return NULL; /* didn't find anything */
-}
-
-int vorbis_comment_query_count(vorbis_comment *vc, char *tag){
- int i,count=0;
- int taglen = strlen(tag)+1; /* +1 for the = we append */
- char *fulltag = (char *)alloca(taglen+1);
- strcpy(fulltag,tag);
- strcat(fulltag, "=");
-
- for(i=0;i<vc->comments;i++){
- if(!tagcompare(vc->user_comments[i], fulltag, taglen))
- count++;
- }
-
- return count;
-}
-
void vorbis_comment_clear(vorbis_comment *vc){
if(vc){
long i;
diff --git a/apps/codecs/Tremor/ivorbiscodec.h b/apps/codecs/Tremor/ivorbiscodec.h
index d4de1fd..b3e6322 100644
--- a/apps/codecs/Tremor/ivorbiscodec.h
+++ b/apps/codecs/Tremor/ivorbiscodec.h
@@ -48,7 +48,6 @@ typedef struct vorbis_info{
long bitrate_upper;
long bitrate_nominal;
long bitrate_lower;
- long bitrate_window;
void *codec_setup;
} vorbis_info;
@@ -57,7 +56,6 @@ typedef struct vorbis_info{
analysis/synthesis state. The DSP state belongs to a specific
logical bitstream ****************************************************/
typedef struct vorbis_dsp_state{
- int analysisp;
vorbis_info *vi;
ogg_int32_t **pcm;
@@ -66,7 +64,6 @@ typedef struct vorbis_dsp_state{
int pcm_current;
int pcm_returned;
- int preextrapolate;
int eofflag;
long lW;
@@ -156,8 +153,6 @@ extern void vorbis_comment_init(vorbis_comment *vc);
extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
extern void vorbis_comment_add_tag(vorbis_comment *vc,
char *tag, char *contents);
-extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
-extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag);
extern void vorbis_comment_clear(vorbis_comment *vc);
extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
diff --git a/apps/codecs/Tremor/ivorbisfile_example.c b/apps/codecs/Tremor/ivorbisfile_example.c
deleted file mode 100644
index 3c34b25..0000000
--- a/apps/codecs/Tremor/ivorbisfile_example.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
- * *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2002 *
- * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function: simple example decoder using vorbisidec
-
- ********************************************************************/
-
-/* Takes a vorbis bitstream from stdin and writes raw stereo PCM to
- stdout using vorbisfile. Using vorbisfile is much simpler than
- dealing with libvorbis. */
-
-#include "config-tremor.h"
-#include <stdio.h>
-#include <vorbis/ivorbiscodec.h>
-#include <vorbis/ivorbisfile.h>
-
-#ifdef _WIN32 /* We need the following two to set stdin/stdout to binary */
-#include <io.h>
-#include <fcntl.h>
-#endif
-
-char pcmout[4096]; /* take 4k out of the data segment, not the stack */
-
-int main(){
- OggVorbis_File vf;
- int eof=0;
- int current_section;
-
-#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
- /* Beware the evil ifdef. We avoid these where we can, but this one we
- cannot. Don't add any more, you'll probably go to hell if you do. */
- _setmode( _fileno( stdin ), _O_BINARY );
- _setmode( _fileno( stdout ), _O_BINARY );
-#endif
-
- if(ov_open(stdin, &vf, NULL, 0) < 0) {
- fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
- exit(1);
- }
-
- /* Throw the comments plus a few lines about the bitstream we're
- decoding */
- {
- char **ptr=ov_comment(&vf,-1)->user_comments;
- vorbis_info *vi=ov_info(&vf,-1);
- while(*ptr){
- fprintf(stderr,"%s\n",*ptr);
- ++ptr;
- }
- fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
- fprintf(stderr,"\nDecoded length: %ld samples\n",
- (long)ov_pcm_total(&vf,-1));
- fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
- }
-
- while(!eof){
- long ret=ov_read(&vf,pcmout,sizeof(pcmout),&current_section);
- if (ret == 0) {
- /* EOF */
- eof=1;
- } else if (ret < 0) {
- /* error in the stream. Not a problem, just reporting it in
- case we (the app) cares. In this case, we don't. */
- } else {
- /* we don't bother dealing with sample rate changes, etc, but
- you'll have to*/
- fwrite(pcmout,1,ret,stdout);
- }
- }
-
- /* cleanup */
- ov_clear(&vf);
-
- fprintf(stderr,"Done.\n");
- return(0);
-}
diff --git a/apps/codecs/Tremor/ogg.h b/apps/codecs/Tremor/ogg.h
index 5f85eb4..7e2785f 100644
--- a/apps/codecs/Tremor/ogg.h
+++ b/apps/codecs/Tremor/ogg.h
@@ -143,9 +143,6 @@ typedef struct {
extern void oggpack_readinit(oggpack_buffer *b,ogg_reference *r);
extern long oggpack_look_full(oggpack_buffer *b,int bits);
extern long oggpack_read(oggpack_buffer *b,int bits);
-extern long oggpack_bytes(oggpack_buffer *b);
-extern long oggpack_bits(oggpack_buffer *b);
-extern int oggpack_eop(oggpack_buffer *b);
/* Inline a few, often called functions */
@@ -221,7 +218,6 @@ extern int ogg_sync_reset(ogg_sync_state *oy);
extern unsigned char *ogg_sync_bufferin(ogg_sync_state *oy, long size);
extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes);
extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
-extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
@@ -243,7 +239,6 @@ extern int ogg_page_eos(ogg_page *og);
extern ogg_int64_t ogg_page_granulepos(ogg_page *og);
extern ogg_uint32_t ogg_page_serialno(ogg_page *og);
extern ogg_uint32_t ogg_page_pageno(ogg_page *og);
-extern int ogg_page_packets(ogg_page *og);
extern int ogg_page_getbuffer(ogg_page *og, unsigned char **buffer);
extern int ogg_packet_release(ogg_packet *op);
diff --git a/apps/codecs/Tremor/vorbisfile.c b/apps/codecs/Tremor/vorbisfile.c
index a32d9f2..ca18ecb 100644
--- a/apps/codecs/Tremor/vorbisfile.c
+++ b/apps/codecs/Tremor/vorbisfile.c
@@ -657,15 +657,6 @@ static int _fetch_and_process_packet(OggVorbis_File *vf,
return ret;
}
-/* if, eg, 64 bit stdio is configured by default, this will build with
- fseek64 */
-#if 0
-static int _fseek64_wrap(FILE *f,ogg_int64_t off,int whence){
- if(f==NULL)return(-1);
- return fseek(f,off,whence);
-}
-#endif
-
static int _ov_open1(void *f,OggVorbis_File *vf,char *initial,
long ibytes, ov_callbacks callbacks){
int offsettest=(f?callbacks.seek_func(f,0,SEEK_CUR):-1);
@@ -774,148 +765,6 @@ int ov_open_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes,
return _ov_open2(vf);
}
-#if 0
-int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes){
- ov_callbacks callbacks = {
- (size_t (*)(void *, size_t, size_t, void *)) fread,
- (int (*)(void *, ogg_int64_t, int)) _fseek64_wrap,
- (int (*)(void *)) fclose,
- (long (*)(void *)) ftell
- };
-
- return ov_open_callbacks((void *)f, vf, initial, ibytes, callbacks);
-}
-#endif
-
-/* Only partially open the vorbis file; test for Vorbisness, and load
- the headers for the first chain. Do not seek (although test for
- seekability). Use ov_test_open to finish opening the file, else
- ov_clear to close/free it. Same return codes as open. */
-
-int ov_test_callbacks(void *f,OggVorbis_File *vf,char *initial,long ibytes,
- ov_callbacks callbacks)
-{
- return _ov_open1(f,vf,initial,ibytes,callbacks);
-}
-
-#if 0
-int ov_test(FILE *f,OggVorbis_File *vf,char *initial,long ibytes){
- ov_callbacks callbacks = {
- (size_t (*)(void *, size_t, size_t, void *)) fread,
- (int (*)(void *, ogg_int64_t, int)) _fseek64_wrap,
- (int (*)(void *)) fclose,
- (long (*)(void *)) ftell
- };
-
- return ov_test_callbacks((void *)f, vf, initial, ibytes, callbacks);
-}
-#endif
-
-int ov_test_open(OggVorbis_File *vf){
- if(vf->ready_state!=PARTOPEN)return(OV_EINVAL);
- return _ov_open2(vf);
-}
-
-/* How many logical bitstreams in this physical bitstream? */
-long ov_streams(OggVorbis_File *vf){
- return vf->links;
-}
-
-/* Is the FILE * associated with vf seekable? */
-long ov_seekable(OggVorbis_File *vf){
- return vf->seekable;
-}
-
-/* returns the bitrate for a given logical bitstream or the entire
- physical bitstream. If the file is open for random access, it will
- find the *actual* average bitrate. If the file is streaming, it
- returns the nominal bitrate (if set) else the average of the
- upper/lower bounds (if set) else -1 (unset).
-
- If you want the actual bitrate field settings, get them from the
- vorbis_info structs */
-
-long ov_bitrate(OggVorbis_File *vf,int i){
- if(vf->ready_state<OPENED)return(OV_EINVAL);
- if(i>=vf->links)return(OV_EINVAL);
- if(!vf->seekable && i!=0)return(ov_bitrate(vf,0));
- if(i<0){
- ogg_int64_t bits=0;
- int i;
- for(i=0;i<vf->links;i++)
- bits+=(vf->offsets[i+1]-vf->dataoffsets[i])*8;
- /* This once read: return(rint(bits/ov_time_total(vf,-1)));
- * gcc 3.x on x86 miscompiled this at optimisation level 2 and above,
- * so this is slightly transformed to make it work.
- */
- return(bits*1000/ov_time_total(vf,-1));
- }else{
- if(vf->seekable){
- /* return the actual bitrate */
- return((vf->offsets[i+1]-vf->dataoffsets[i])*8000/ov_time_total(vf,i));
- }else{
- /* return nominal if set */
- if(vf->vi[i].bitrate_nominal>0){
- return vf->vi[i].bitrate_nominal;
- }else{
- if(vf->vi[i].bitrate_upper>0){
- if(vf->vi[i].bitrate_lower>0){
- return (vf->vi[i].bitrate_upper+vf->vi[i].bitrate_lower)/2;
- }else{
- return vf->vi[i].bitrate_upper;
- }
- }
- return(OV_FALSE);
- }
- }
- }
-}
-
-/* returns the actual bitrate since last call. returns -1 if no
- additional data to offer since last call (or at beginning of stream),
- EINVAL if stream is only partially open
-*/
-long ov_bitrate_instant(OggVorbis_File *vf){
- int link=(vf->seekable?vf->current_link:0);
- long ret;
- if(vf->ready_state<OPENED)return(OV_EINVAL);
- if(vf->samptrack==0)return(OV_FALSE);
- ret=vf->bittrack/vf->samptrack*vf->vi[link].rate;
- vf->bittrack=0;
- vf->samptrack=0;
- return(ret);
-}
-
-/* Guess */
-long ov_serialnumber(OggVorbis_File *vf,int i){
- if(i>=vf->links)return(ov_serialnumber(vf,vf->links-1));
- if(!vf->seekable && i>=0)return(ov_serialnumber(vf,-1));
- if(i<0){
- return(vf->current_serialno);
- }else{
- return(vf->serialnos[i]);
- }
-}
-
-/* returns: total raw (compressed) length of content if i==-1
- raw (compressed) length of that logical bitstream for i==0 to n
- OV_EINVAL if the stream is not seekable (we can't know the length)
- or if stream is only partially open
-*/
-ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i){
- if(vf->ready_state<OPENED)return(OV_EINVAL);
- if(!vf->seekable || i>=vf->links)return(OV_EINVAL);
- if(i<0){
- ogg_int64_t acc=0;
- int i;
- for(i=0;i<vf->links;i++)
- acc+=ov_raw_total(vf,i);
- return(acc);
- }else{
- return(vf->offsets[i+1]-vf->offsets[i]);
- }
-}
-
/* returns: total PCM length (samples) of content if i==-1 PCM length
(samples) of that logical bitstream for i==0 to n
OV_EINVAL if the stream is not seekable (we can't know the
@@ -1417,33 +1266,6 @@ int ov_time_seek(OggVorbis_File *vf,ogg_int64_t milliseconds){
}
}
-/* page-granularity version of ov_time_seek
- returns zero on success, nonzero on failure */
-int ov_time_seek_page(OggVorbis_File *vf,ogg_int64_t milliseconds){
- /* translate time to PCM position and call ov_pcm_seek */
-
- int link=-1;
- ogg_int64_t pcm_total=ov_pcm_total(vf,-1);
- ogg_int64_t time_total=ov_time_total(vf,-1);
-
- if(vf->ready_state<OPENED)return(OV_EINVAL);
- if(!vf->seekable)return(OV_ENOSEEK);
- if(milliseconds<0 || milliseconds>time_total)return(OV_EINVAL);
-
- /* which bitstream section does this time offset occur in? */
- for(link=vf->links-1;link>=0;link--){
- pcm_total-=vf->pcmlengths[link*2+1];
- time_total-=ov_time_total(vf,link);
- if(milliseconds>=time_total)break;
- }
-
- /* enough information to convert time offset to pcm offset */
- {
- ogg_int64_t target=pcm_total+(milliseconds-time_total)*vf->vi[link].rate/1000;
- return(ov_pcm_seek_page(vf,target));
- }
-}
-
/* tell the current stream offset cursor. Note that seek followed by
tell will likely not give the set offset due to caching */
ogg_int64_t ov_raw_tell(OggVorbis_File *vf){
@@ -1451,12 +1273,6 @@ ogg_int64_t ov_raw_tell(OggVorbis_File *vf){
return(vf->offset);
}
-/* return PCM offset (sample) of next PCM sample to be read */
-ogg_int64_t ov_pcm_tell(OggVorbis_File *vf){
- if(vf->ready_state<OPENED)return(OV_EINVAL);
- return(vf->pcm_offset);
-}
-
/* return time offset (milliseconds) of next PCM sample to be read */
ogg_int64_t ov_time_tell(OggVorbis_File *vf) ICODE_ATTR_TREMOR_NOT_MDCT;
ogg_int64_t ov_time_tell(OggVorbis_File *vf){
@@ -1505,108 +1321,6 @@ vorbis_info *ov_info(OggVorbis_File *vf,int link){
}
}
-/* grr, strong typing, grr, no templates/inheritence, grr */
-vorbis_comment *ov_comment(OggVorbis_File *vf,int link){
- if(vf->seekable){
- if(link<0)
- if(vf->ready_state>=STREAMSET)
- return vf->vc+vf->current_link;
- else
- return vf->vc;
- else
- if(link>=vf->links)
- return NULL;
- else
- return vf->vc+link;
- }else{
- return vf->vc;
- }
-}
-
-/* up to this point, everything could more or less hide the multiple
- logical bitstream nature of chaining from the toplevel application
- if the toplevel application didn't particularly care. However, at
- the point that we actually read audio back, the multiple-section
- nature must surface: Multiple bitstream sections do not necessarily
- have to have the same number of channels or sampling rate.
-
- ov_read returns the sequential logical bitstream number currently
- being decoded along with the PCM data in order that the toplevel
- application can take action on channel/sample rate changes. This
- number will be incremented even for streamed (non-seekable) streams
- (for seekable streams, it represents the actual logical bitstream
- index within the physical bitstream. Note that the accessor
- functions above are aware of this dichotomy).
-
- input values: buffer) a buffer to hold packed PCM data for return
- length) the byte length requested to be placed into buffer
-
- return values: <0) error/hole in data (OV_HOLE), partial open (OV_EINVAL)
- 0) EOF
- n) number of bytes of PCM actually returned. The
- below works on a packet-by-packet basis, so the
- return length is not related to the 'length' passed
- in, just guaranteed to fit.
-
- *section) set to the logical bitstream number */
-
-long ov_read(OggVorbis_File *vf,char *buffer,int bytes_req,int *bitstream){
- int i,j;
-
- ogg_int32_t **pcm;
- long samples;
-
- if(vf->ready_state<OPENED)return(OV_EINVAL);
-
- while(1){
- if(vf->ready_state==INITSET){
- samples=vorbis_synthesis_pcmout(&vf->vd,&pcm);
- if(samples)break;
- }
-
- /* suck in another packet */
- {
- int ret=_fetch_and_process_packet(vf,1,1);
- if(ret==OV_EOF)
- return(0);
- if(ret<=0)
- return(ret);
- }
-
- }
-
- if(samples>0){
-
- /* yay! proceed to pack data into the byte buffer */
-
- long channels=ov_info(vf,-1)->channels;
-
- if(channels==1){
- if(samples>(bytes_req/2))
- samples=bytes_req/2;
- }else{
- if(samples>(bytes_req/4))
- samples=bytes_req/4;
- }
-
- for(i=0;i<channels;i++) { /* It's faster in this order */
- ogg_int32_t *src=pcm[i];
- short *dest=((short *)buffer)+i;
- for(j=0;j<samples;j++) {
- *dest=CLIP_TO_15(src[j]>>9);
- dest+=channels;
- }
- }
-
- vorbis_synthesis_read(&vf->vd,samples);
- vf->pcm_offset+=samples;
- if(bitstream)*bitstream=vf->current_link;
- return(samples*2*channels);
- }else{
- return(samples);
- }
-}
-
/* input values: pcm_channels) a float vector per channel of output
length) the sample length being read by the app