[Vorbis] ov_open_callbacks takes so much time to open 210 MB OGG file
Pavel Nikitenko
pavnsw at gmail.com
Tue Dec 18 22:45:09 PST 2012
Thanks guys,
I modified code and verified the code the way it generates always
correct OGG file.
And checked output with oggz-validate.exe tool to output no error for
every new generated OGG file.
Modified code the following way:
void FileWriteA :: closeOggFile( void )
{
/* end of file. this can be done implicitly in the mainline,
but it's easier to see here in non-clever fashion.
Tell the library we're at end of stream so that it can handle
the last frame and mark end of stream in the output properly */
vorbis_analysis_wrote(&vd,0);
/* vorbis does some data preanalysis, then divvies up blocks for
more involved (potentially parallel) processing. Get a single
block for encoding now */
while(vorbis_analysis_blockout(&vd,&vb)==1){
/* analysis, assume we want to use bitrate management */
vorbis_analysis(&vb,NULL);
vorbis_bitrate_addblock(&vb);
while(vorbis_bitrate_flushpacket(&vd,&op)){
/* weld the packet into the bitstream */
ogg_stream_packetin(&os,&op);
/* write out pages (if any) */
while(!eos){
int result=ogg_stream_pageout(&os,&og);
if(result==0)break;
fwrite(og.header,1,og.header_len,fd_);
fwrite(og.body,1,og.body_len,fd_);
/* this could be set above, but for illustrative purposes, I do
it here (to show that vorbis does know where the stream
ends) */
if(ogg_page_eos(&og))eos=1;
}
}
}
/* clean up and exit. vorbis_info_clear() must be called last */
ogg_stream_clear(&os);
vorbis_block_clear(&vb);
vorbis_dsp_clear(&vd);
vorbis_comment_clear(&vc);
vorbis_info_clear(&vi);
/* ogg_page and ogg_packet structs always point to storage in
libvorbis. They're never freed or manipulated directly */
fclose(fd_);
}
No I am going to test results, if this will help with the long time
operation of ov_open_callbacks call with big generated OGG files
(around more than 210 MB) as was observed previously. And then I am
going to report back.
Thanks for your help again for now!
Regards,
Pavel
On 18.12.2012 18:54, Ralph Giles wrote:
> On 12-12-16 3:09 PM, Pavel Nikitenko wrote:
>
>> vorbis_analysis_wrote(&vd,0);
> I think you need another loop here to pull out any remaining encoded
> data? E.g. for each block from vorbis_analysis_blockout() call
> vorbis_analysis(), vorbis_bitrate_addblock(),
> vorbis_bitrate_flushpacket(), ogg_stream_packetin().
>
> For the insane delay, I don't know. One of those N^2 time things with
> the Windows POSIX file calls?
>
> -r
More information about the Vorbis
mailing list