Re: ov_open_callbacks takes so much time to open 210 MB OGG file
Pavel Nikitenko <[email protected]> Mon, 17 Dec 2012 01:14:19 +0100
| Newsgroups | gmane.comp.multimedia.ogg.vorbis.general |
|---|---|
| Message-ID | <[email protected]> |
Here is my compiled EXE file of the little modified vorbisfile_example.c code. http://dl.dropbox.com/u/3532445/win/vorbisdec_static.zip It takes 23.3 minutes for ov_open_callbacks to open the file, no joke. Here is my VS2010 project file with all the source codes included including libvorbis-1.3.3, libogg 1.3.0 and my vorbisfile_example.c code. http://dl.dropbox.com/u/3532445/win/vorbis_example_ov_open_callbacks_test.zip I use vorbis_static.sln VS2010 solution file in the libvorbis-1.3.3\win32\VS2010 to compile vorbisfile_example.c code and the vorbisdec_static.exe is generated in: libvorbis-1.3.3\win32\VS2010\Win32\Release\vorbisdec_static.exe Pavel On 16.12.2012 20:26, [email protected] wrote: > On Sun, Dec 16, 2012 at 12:12 PM, Pavel Nikitenko <[email protected]> wrote: >> Hi Monty, >> >> Did you have a chance to look on the observed issue with ov_open_callbacks, >> please? > Yes; the file opens properly here using the last few vorbis releases > [630ms in my test--- higher than I'd like, but meh... 52 links]. You > are using the 1.3.3 "Omnipresent" release for both encode and decode? > I also checked using your lightly modified vorbisfile_example.c just in case. > >>> It looks something is wrong. Either something with ov_open_callbacks if it >>> is not optimized or the OGG is not generated as it should. > There are some problems in the generated Ogg, but like I said, they > would not cause a problem of this magnitude. A stock build here > successfully opens, parses and decodes the file. > >>> I do not >>> understand much terminology of the OGG file format. The OGG file is >>> generated by appending of new OGG file at the end of previously generated >>> OGG file. If there would be better way, I would use it for sure. > That is the correct way to put two Ogg files together. However, the > files that are being appended in your Ogg are unfinished fragments; > the streams are not being flushed and closed out before beginning the > next. In addition, it looks like there is some unencapsulated data > being placed between section (perhaps caused by the same bug). > > Eg, the normal way to do this in encoding is to call > vorbis_analysis_wrote with a write length of zero indicating the end > of data. At that point, the vorbis encoder will flush internal > pending data and a construct a final Ogg end-of-stream page. > > Also... are these streams intended to be encoded as quadraphonic? Two > of the channels in your file are completely unused. > > Again, all of this is likely completely unrelated to the lengthy open time. > > Monty _______________________________________________ Vorbis mailing list [email protected] http://lists.xiph.org/mailman/listinfo/vorbis
vorbisfile_example.c
(text/plain, 3.4 KB)
/********************************************************************
* *
* THIS FILE IS PART OF THE OggVorbis SOFTWARE 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 SOURCE CODE IS (C) COPYRIGHT 1994-2007 *
* by the Xiph.Org Foundation http://www.xiph.org/ *
* *
********************************************************************
function: simple example decoder using vorbisfile
last mod: $Id: vorbisfile_example.c 16328 2009-07-24 01:51:10Z xiphmont $
********************************************************************/
/* 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 <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <vorbis/codec.h>
#include <vorbis/vorbisfile.h>
#include <ctime>
#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
fprintf(stderr,"Starting to measure time of ov_open_callbacks.");
clock_t start,end;
start=clock();
fprintf(stderr,"\nclock start:=%d\n",start);
if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) {
fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
exit(1);
}
end=clock();
fprintf(stderr,"clock end:=%d\n",end);
fprintf(stderr,"time=%f\n",((double)(end-start))/CLK_TCK);
/* 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);
}
fprintf(stderr,"Decompressing...");
while(!eof){
long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,¤t_section);
if (ret == 0) {
/* EOF */
eof=1;
} else if (ret < 0) {
if(ret==OV_EBADLINK){
fprintf(stderr,"Corrupt bitstream section! Exiting.\n");
exit(1);
}
/* some other 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);
}
}
fprintf(stderr,"Decompressing finished.");
/* cleanup */
ov_clear(&vf);
fprintf(stderr,"Done.\n");
return(0);
}