Commit 1ff1f089 authored by tahseen's avatar tahseen

Removed codes intended to support vorbis streams in theora files using

libvorbisfile and now only supports skeleton+vorbis in a stream. It now
regains binary compatibility with the vorbis trunk.

svn path=/branches/vorbis-tahseen/; revision=11587
parent 1036be6a
...@@ -49,11 +49,6 @@ typedef struct { ...@@ -49,11 +49,6 @@ typedef struct {
#define STREAMSET 3 #define STREAMSET 3
#define INITSET 4 #define INITSET 4
typedef struct OggBitstreamInfo {
long serialno; /* serialno of this logical bitstream */
char signature[8]; /* header signature of this logical bitstream, like 0x1vorbis */
} OggBitstreamInfo;
typedef struct OggVorbis_File { typedef struct OggVorbis_File {
void *datasource; /* Pointer to a FILE *, etc. */ void *datasource; /* Pointer to a FILE *, etc. */
int seekable; int seekable;
...@@ -89,11 +84,8 @@ typedef struct OggVorbis_File { ...@@ -89,11 +84,8 @@ typedef struct OggVorbis_File {
ov_callbacks callbacks; ov_callbacks callbacks;
OggBitstreamInfo *obi; /* holds information on all logical bitstream contained in the file */
int obilen; /* holds the size of OggBitstreamInfo array */
} OggVorbis_File; } OggVorbis_File;
extern int ov_clear(OggVorbis_File *vf); extern int ov_clear(OggVorbis_File *vf);
extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes); extern int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf,
......
...@@ -230,7 +230,7 @@ static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc, ...@@ -230,7 +230,7 @@ static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc,
long *serialno,ogg_page *og_ptr){ long *serialno,ogg_page *og_ptr){
ogg_page og; ogg_page og;
ogg_packet op; ogg_packet op;
int i,j,ret,skip; int i,ret,skip;
if(!og_ptr){ if(!og_ptr){
ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE); ogg_int64_t llret=_get_next_page(vf,&og,CHUNKSIZE);
...@@ -248,47 +248,23 @@ static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc, ...@@ -248,47 +248,23 @@ static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc,
vorbis_info_init(vi); vorbis_info_init(vi);
vorbis_comment_init(vc); vorbis_comment_init(vc);
i=0; i=0;
while(i<3){ while(i<3){
ogg_stream_pagein(&vf->os,og_ptr); ogg_stream_pagein(&vf->os,og_ptr);
while(i<3){ while(i<3){
skip = 0; skip=0;
int result=ogg_stream_packetout(&vf->os,&op); int result=ogg_stream_packetout(&vf->os,&op);
if(result==0)break; if(result==0)break;
if(result==-1){ if(result==-1){
ret=OV_EBADHEADER; ret=OV_EBADHEADER;
goto bail_header; goto bail_header;
} }
/* trying to find OggBitstreamInfo (obi) has info on this stream. matching info on if(!memcmp(op.packet+1,"vorbis",6)){
* existing stream by using the serialno. if((ret=vorbis_synthesis_headerin(vi,vc,&op)))
*/ goto bail_header;
for(j = 0; j < vf->obilen; ++j) {
if (vf->obi[j].serialno == ogg_page_serialno(og_ptr))
break;
}
/* IMPORTANT: shouldn't use variable j, the value is used later. */
if (j == vf->obilen) {
/* haven't seen this logical stream before, adding it to the OggBitstreamInfo structure */
if (j == 0) {
vf->obi = _ogg_calloc(1, sizeof(OggBitstreamInfo));
} else {
vf->obi = _ogg_realloc(vf->obi, (j+1)*sizeof(OggBitstreamInfo));
}
vf->obi[j].serialno = ogg_page_serialno(og_ptr);
memcpy(vf->obi[j].signature, op.packet, 8);
++vf->obilen;
}
if(memcmp(op.packet+1,"vorbis",6)){
skip = 1;
} else {
++i; ++i;
} }
if(skip == 0){
if((ret=vorbis_synthesis_headerin(vi,vc,&op)))
goto bail_header;
}
} }
if(i<3) if(i<3)
if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){ if(_get_next_page(vf,og_ptr,CHUNKSIZE)<0){
...@@ -296,10 +272,9 @@ static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc, ...@@ -296,10 +272,9 @@ static int _fetch_headers(OggVorbis_File *vf,vorbis_info *vi,vorbis_comment *vc,
goto bail_header; goto bail_header;
} }
if (vf->os.serialno != ogg_page_serialno(og_ptr)) { if (vf->os.serialno != ogg_page_serialno(og_ptr)) {
ogg_stream_reset_serialno(&vf->os,ogg_page_serialno(og_ptr)); ogg_stream_reset_serialno(&vf->os,ogg_page_serialno(og_ptr));
} }
} }
return 0; return 0;
bail_header: bail_header:
...@@ -323,7 +298,7 @@ static void _prefetch_all_headers(OggVorbis_File *vf, ogg_int64_t dataoffset){ ...@@ -323,7 +298,7 @@ static void _prefetch_all_headers(OggVorbis_File *vf, ogg_int64_t dataoffset){
ogg_page og; ogg_page og;
int i; int i;
ogg_int64_t ret; ogg_int64_t ret;
vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi)); vf->vi=_ogg_realloc(vf->vi,vf->links*sizeof(*vf->vi));
vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc)); vf->vc=_ogg_realloc(vf->vc,vf->links*sizeof(*vf->vc));
vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets)); vf->dataoffsets=_ogg_malloc(vf->links*sizeof(*vf->dataoffsets));
...@@ -492,15 +467,6 @@ static int _fetch_and_process_packet(OggVorbis_File *vf, ...@@ -492,15 +467,6 @@ static int _fetch_and_process_packet(OggVorbis_File *vf,
int readp, int readp,
int spanp){ int spanp){
ogg_page og; ogg_page og;
int i;
/* finding the serialno of the first vorbis stream. */
for (i = 0; i < vf->obilen; ++i) {
if (!memcmp(vf->obi[i].signature+1, "vorbis", 6))
break;
}
/* set the serialno of ogg_stream_state in OggVorbis_File */
vf->os.serialno=vf->obi[i].serialno;
/* handle one packet. Try to fetch it from current stream state */ /* handle one packet. Try to fetch it from current stream state */
/* extract packets from page */ /* extract packets from page */
...@@ -594,18 +560,7 @@ static int _fetch_and_process_packet(OggVorbis_File *vf, ...@@ -594,18 +560,7 @@ static int _fetch_and_process_packet(OggVorbis_File *vf,
/* has our decoding just traversed a bitstream boundary? */ /* has our decoding just traversed a bitstream boundary? */
if(vf->ready_state==INITSET){ if(vf->ready_state==INITSET){
if(vf->os.serialno!=ogg_page_serialno(&og)){ if(vf->current_serialno!=ogg_page_serialno(&og)){
/* We need to check if this is a vorbis packet, if so we are assuming we are
* at a bitstream boundary and need to reset the decoder. But if its a
* non-vorbis packet or an packet whose serialno is not known from the header
* we simply skip it.
*/
for (i = 0; i < vf->obilen; ++i) {
if (vf->obi[i].serialno==ogg_page_serialno(&og))
break;
}
if (i<vf->obilen && memcmp(vf->obi[i].signature+1, "vorbis", 6))
goto try_next_page;
if(!spanp) if(!spanp)
return(OV_EOF); return(OV_EOF);
...@@ -669,7 +624,6 @@ static int _fetch_and_process_packet(OggVorbis_File *vf, ...@@ -669,7 +624,6 @@ static int _fetch_and_process_packet(OggVorbis_File *vf,
if(ret<0)return ret; if(ret<0)return ret;
} }
} }
try_next_page:
ogg_stream_pagein(&vf->os,&og); ogg_stream_pagein(&vf->os,&og);
} }
} }
...@@ -685,7 +639,7 @@ static int _ov_open1(void *f,OggVorbis_File *vf,char *initial, ...@@ -685,7 +639,7 @@ static int _ov_open1(void *f,OggVorbis_File *vf,char *initial,
long ibytes, ov_callbacks callbacks){ long ibytes, ov_callbacks callbacks){
int offsettest=(f?callbacks.seek_func(f,0,SEEK_CUR):-1); int offsettest=(f?callbacks.seek_func(f,0,SEEK_CUR):-1);
int ret; int ret;
memset(vf,0,sizeof(*vf)); memset(vf,0,sizeof(*vf));
vf->datasource=f; vf->datasource=f;
vf->callbacks = callbacks; vf->callbacks = callbacks;
...@@ -761,7 +715,6 @@ int ov_clear(OggVorbis_File *vf){ ...@@ -761,7 +715,6 @@ int ov_clear(OggVorbis_File *vf){
if(vf->offsets)_ogg_free(vf->offsets); if(vf->offsets)_ogg_free(vf->offsets);
ogg_sync_clear(&vf->oy); ogg_sync_clear(&vf->oy);
if(vf->datasource)(vf->callbacks.close_func)(vf->datasource); if(vf->datasource)(vf->callbacks.close_func)(vf->datasource);
if(vf->obi)_ogg_free(vf->obi);
memset(vf,0,sizeof(*vf)); memset(vf,0,sizeof(*vf));
} }
#ifdef DEBUG_LEAKS #ifdef DEBUG_LEAKS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment