[vorbis] Encoding process
ignacio at openservices.net
Sun Sep 2 13:19:27 PDT 2001
I apologize for bugging you all again, but I've been trying to wrap my head
around the encoding process and I'm about to have an aneurysm :P
I've gone through oggenc.c, encode.c, and audio.c and I think I have a basic
idea of what happens. I got it down in pseudocode as follows:
1 get parameters
2 init vorbis_comment -- vorbis_comment_init()
3 init vorbis_info -- vorbis_info_init()
4 start encoding with info and params -- vorbis_encode_init()
5 init vorbis_dsp_state from info -- vorbis_analysis_init()
6 init vorbis_block from dsp -- vorbis_block_init()
7 init ogg_stream_state with serial -- ogg_stream_init()
8 fill vorbis_comment -- vorbis_comment_add()
9 create header packets from dsp -- vorbis_analysis_headerout()
10 dump header packets to stream -- ogg_stream_packetin()
11 while pages need to be flushed from stream: -- ogg_stream_flush()
12 flush stream to page -- above
13 write page to file -- fwrite()
14 if nothing written:
15 fatal error
17 get buffer from dsp -- vorbis_analysis_buffer()
18 get some data into buffer
19 if no data:
20 flush dsp -- vorbis_analysis_wrote(..., 0)
22 tell dsp how much data in buffer -- vorbis_analysis_wrote()
23 while blocks from dsp to analyze: -- vorbis_analysis_blockout()
24 analyze block into packet -- vorbis_analysis()
25 dump packet into stream -- ogg_stream_packetin()
26 while not end of stream:
27 get page from stream: -- ogg_stream_pageout()
28 if no page available:
30 write page to file
31 if nothing written:
32 fatal error
33 check if end of stream -- ogg_page_eos()
34 clear stream -- ogg_stream_clear()
35 clear block -- vorbis_block_clear()
36 clear dsp -- vorbis_dsp_clear
37 clear info -- vorbis_info_clear()
First of all, is the above correct? If not please let me know.
Second, I want to partition the above process into multiple functions i.e., so
that the "forever:" part on line 16 is handled outside. I just want to verify
that I have my ideas correct:
1) Lines 1 through 8 in initialization function
2) Lines 9 through 15 in header-creation function
3) Lines 17 through 33 in data-write function
4) Lines 34 through 27 in cleanup function
Are there any caveats in doing it that way?
Third, does the vorbis_comments structure ever get cleaned up?
Fourth, what exactly is the ogg_page_eos() function on line 33 for? I have it
marked down as detected end-of-stream, but I'm certain that it's doing
something far more subtle than that.
Fifth, how does "extra" data get flushed through the encoder? Via line 20? Is
it possible to do that in the cleanup section if the rest is done?
Ignacio Vazquez-Abrams <ignacio at openservices.net>
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis