[PATCH] vcut - fix several corner cases
This is being posted here for internal documentation purposes.
Michael Gold's original message follows:
"it fixes the following bugs in vcut:
- When cutting too close to the beginning of a file, vcut exits after printing "Unhandled special case: first file too short?", leaving both output files empty.
- If the cutpoint is the last sample on any page other than the final page, the same message is printed and the second file remains empty.
- When cutting a file that's had a partial page deleted from the beginning (e.g. the second file produced by a previous execution of vcut), vcut doesn't flush the stream after the second audio packet (as required by the Vorbis I specification, section A.2). This causes the previously-cut data to reappear in the first output file, making it larger than expected.
- If the cutpoint is on the final page, the message "Found EOS before cut point" is printed. The first output file is correct, but the second contains fewer samples than expected.
With the patch, the first 3 cases produce the correct output. The last case (cutting on the final page) works correctly as long as the cutpoint isn't in the final packet; if it is, a warning is printed and the second output file remains empty (since it doesn't appear possible to write a file containing a single packet that is cut at both ends)."