Cameron Simpson
2001-Dec-02 21:13 UTC
[vorbis-dev] bug report for oggenc in CVS: vorbis-tools/oggenc/encode.c
I was wondering why my CD ripping was producing short files from some tracks. A superficial examination of the code shows this piece of code in vorbis-tools/oggenc/encode.c: Line 120: /* Main encode loop - continue until end of file */ while(!eos) { [...] /* While we can get enough data from the library to analyse, one block at a time... */ while(vorbis_analysis_blockout(&vd,&vb)==1) { [...] /* If we've gone over a page boundary, we can do actual output, so do so (for however many pages are available) */ while(!eos) { [...] if(ogg_page_eos(&og)) eos = 1; } } } Now, backtracing through vorbis/lib, it seems to me that the inner eos is being used to stop the output when we've temporarily run out of input, which is fine. But the SAME eos flag is used to stop the outer loop. I feel that either eos should be reset after the inner loop, or that there should be a separate eos-like flag used for the inner loop. Am I right of havs I misconstrued things. Certainly when I' getting short track rips: - the input raw data is _not_ all consumed - oggenc exits "normally", with a "Done encoding file message" just like it"s seen end of input I'm off to rebuild oggenc to test this theory, but meanwhile would someone who knows the code properly care to see if I'm right? Thanks, -- Cameron Simpson, DoD#743 cs@zip.com.au http://www.zip.com.au/~cs/ "I'm a lawyer." "Honest?" "No, the usual kind." --- >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-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Monty
2001-Dec-03 01:59 UTC
[vorbis-dev] bug report for oggenc in CVS: vorbis-tools/oggenc/encode.c
On Mon, Dec 03, 2001 at 05:13:04AM +0000, Cameron Simpson wrote:> I was wondering why my CD ripping was producing short files from some tracks. > > A superficial examination of the code shows this piece of code in vorbis-tools/oggenc/encode.c:[...] You misunderstand the code. The eos is set by libvorbis, and libvorbis only sets this when it gets a buffer submission of zero samples. A zero sample buffer submission happens only if the fread() returns zero, and fread returns zero iff it hits end of file. A pipe waiting for more input is not an EOF condition. This might be a bug due to oggenc deciding to stop reading early for some other reason, but the fault would not be in the code you highlight. (BTW, the suggestion of 'resetting' this flag disobeys libvorbis usage documentation and would eventually result in a segfault). Monty --- >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-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
Michael Smith
2001-Dec-03 02:24 UTC
[vorbis-dev] bug report for oggenc in CVS: vorbis-tools/oggenc/encode.c
>Now, backtracing through vorbis/lib, it seems to me that the inner eos is >being used to stop the output when we've temporarily run out of input, >which is fine. But the SAME eos flag is used to stop the outer loop. I >feel that either eos should be reset after the inner loop, or that there >should be a separate eos-like flag used for the inner loop.The eos flag is set once an output page is produced that has the eos flag set - this flag only gets set once all input has been consumed. The inner loop stops on eos once the encode is complete - usually, it breaks out. Then the right thing to do is to also finish the outer loop - which is what the code does. Not sure why you're getting short encodes though - are you encoding from stdin? On windows? I had a report a while ago about short encodes under those circumstances, but couldn't reproduce it here. Michael --- >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-dev-request@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.