From d73fb7fff6e70a0304b2eb3f61516a7fa1d75ffe Mon Sep 17 00:00:00 2001 From: Monty Date: Tue, 2 Nov 1999 23:27:34 +0000 Subject: [PATCH] Rearranged chaining example into a library interface (vorbisfile.a) and a main() file (chaining_example.c). Need to flesh out vorbisfile.a a bit more. Monty svn path=/trunk/vorbis/; revision=158 --- lib/Makefile.in | 22 +++++--- lib/{chaining_example.c => vorbisfile.c} | 89 +++++++++----------------------- lib/vorbisfile.h | 65 +++++++++++++++++++++++ 3 files changed, 105 insertions(+), 71 deletions(-) rename lib/{chaining_example.c => vorbisfile.c} (86%) create mode 100644 lib/vorbisfile.h diff --git a/lib/Makefile.in b/lib/Makefile.in index aee6429..660eb89 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,6 +1,6 @@ # vorbis makefile configured for use with gcc on any platform -# $Id: Makefile.in,v 1.13 1999/11/02 11:17:34 xiphmont Exp $ +# $Id: Makefile.in,v 1.14 1999/11/02 23:27:32 xiphmont Exp $ ############################################################################### # # @@ -34,6 +34,8 @@ LFILES = framing.o mdct.o smallft.o block.o envelope.o window.o\ lsp.o lpc.o analysis.o synthesis.o psy.o info.o bitwise.o\ spectrum.o +FFILES = vorbisfile.o + EFILES = encoder_example.o decoder_example.o chaining_example.o all: @@ -48,7 +50,8 @@ analysis: profile: $(MAKE) target CFLAGS="$(PROFILE)" -target: libvorbis.a encoder_example decoder_example chaining_example +target: libvorbis.a vorbisfile.a \ + encoder_example decoder_example chaining_example selftest: $(MAKE) clean @@ -67,15 +70,22 @@ decoder_example: $(EFILES) libvorbis.a $(CC) $(CFLAGS) $(LDFLAGS) decoder_example.o libvorbis.a -o \ decoder_example -lm -chaining_example: $(EFILES) libvorbis.a - $(CC) $(CFLAGS) $(LDFLAGS) chaining_example.o libvorbis.a -o \ - chaining_example -lm +chaining_example: $(EFILES) libvorbis.a vorbisfile.a + $(CC) $(CFLAGS) $(LDFLAGS) chaining_example.o \ + vorbisfile.a libvorbis.a -o chaining_example -lm libvorbis.a: $(LFILES) - $(AR) -r libvorbis.a $(LFILES) + $(AR) -r libvorbis.a $^ $(RANLIB) libvorbis.a +vorbisfile.a: $(FFILES) + $(AR) -r vorbisfile.a $^ + $(RANLIB) vorbisfile.a + + $(LFILES): $(HFILES) +$(FFILES): $(HFILES) vorbisfile.h +$(EFILES): $(HFILES) vorbisfile.h info.o: modes.h diff --git a/lib/chaining_example.c b/lib/vorbisfile.c similarity index 86% rename from lib/chaining_example.c rename to lib/vorbisfile.c index df48835..cc3e5bd 100644 --- a/lib/chaining_example.c +++ b/lib/vorbisfile.c @@ -11,7 +11,7 @@ * * ******************************************************************** - function: simple example of opening/seeking chained bitstreams + function: stdio-based convenience library for opening/seeking/decoding author: Monty modifications by: Monty last modification date: Nov 02 1999 @@ -19,11 +19,9 @@ ********************************************************************/ #include -#include -#include #include -#include #include "codec.h" +#include "vorbisfile.h" /* A 'chained bitstream' is a Vorbis bitstream that contains more than one logical bitstream arranged end to end (the only form of Ogg @@ -40,7 +38,7 @@ bitstream structure right off the bat, or find pieces on demand. This example determines and caches structure for the entire bitstream, but builds a virtual decoder on the fly when moving - between links in the chain */ + between links in the chain. */ /* There are also different ways to implement seeking. Enough information exists in an Ogg bitstream to seek to @@ -48,31 +46,6 @@ picking some portion of the stream roughtly in the area if we only want course navigation through the stream. */ -typedef struct { - FILE *f; - int seekable; - long offset; - long end; - ogg_sync_state oy; - - /* If the FILE handle isn't seekable (eg, a pipe), only the current - stream appears */ - int links; - long *offsets; - long *serialnos; - size64 *pcmlengths; - vorbis_info *vi; - - /* Decoding working state local storage */ - int ready; - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - -} OggVorbis_File; - - /************************************************************************* * Many, many internal helpers. The intention is not to be confusing; * rampant duplication and monolithic function implementation would be @@ -455,7 +428,7 @@ double ov_lbtime(OggVorbis_File *vf,int i){ return(0); } -long ov_totaltime(OggVorbis_File *vf){ +double ov_totaltime(OggVorbis_File *vf){ double acc=0; int i; for(i=0;ilinks;i++) @@ -464,51 +437,37 @@ long ov_totaltime(OggVorbis_File *vf){ } /* seek to an offset relative to the *compressed* data */ -int ov_seek_stream; +int ov_seek_stream(OggVorbis_File *vf,long pos){ + + + + +} + +/* seek to the beginning of the next logical bitstream within the + physical bitstream */ +int ov_seek_bitstream(OggVorbis_File *vf,long pos){ + + + +} /* seek to an offset relative to the decompressed *output* stream */ -int ov_seek_pcm; +int ov_seek_pcm(OggVorbis_File *vf,long pos){ -int main(){ - OggVorbis_File ov; - int i; - /* open the file/pipe on stdin */ - if(ov_open(stdin,&ov,NULL,-1)==-1){ - printf("Could not open input as an OggVorbis file.\n\n"); - exit(1); - } - - /* print details about each logical bitstream in the input */ - if(ov.seekable){ - printf("Input bitstream contained %d logical bitstream section(s).\n", - ov.links); - printf("Total bitstream playing time: %ld seconds\n\n", - (long)ov_totaltime(&ov)); +} + +int ov_seek_time(OggVorbis_File *vf,double seconds){ + - }else{ - printf("Standard input was not seekable.\n" - "First logical bitstream information:\n\n"); - } - for(i=0;i and The XIPHOPHORUS Company * + * http://www.xiph.org/ * + * * + ******************************************************************** + + function: stdio-based convenience library for opening/seeking/decoding + author: Monty + modifications by: Monty + last modification date: Nov 02 1999 + + ********************************************************************/ + +#ifndef _VO_FILE_H_ +#define _VO_FILE_H_ + +#include +#include "codec.h" + +typedef struct { + FILE *f; + int seekable; + long offset; + long end; + ogg_sync_state oy; + + /* If the FILE handle isn't seekable (eg, a pipe), only the current + stream appears */ + int links; + long *offsets; + long *serialnos; + size64 *pcmlengths; + vorbis_info *vi; + + /* Decoding working state local storage */ + int ready; + ogg_stream_state os; /* take physical pages, weld into a logical + stream of packets */ + vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ + vorbis_block vb; /* local working space for packet->PCM decode */ + +} OggVorbis_File; + +extern int ov_clear(OggVorbis_File *vf); +extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); + +extern double ov_lbtime(OggVorbis_File *vf,int i); +extern double ov_totaltime(OggVorbis_File *vf); + + +#endif + + + + + + + -- 2.7.4