It's nice to get an evening to work on transcode every one in a
while ;)
I've written and committed (to CVS HEAD) a new command line parser
for transcode. Aside from moving all the old parsing code out of main()
(ugh) and rewriting it more cleanly, the new parser takes advantage of
macros to keep option names, help messages, and processing code all in
the same place (src/cmdline_def.h). Aside from the obvious benefit of
not having to update several separate pieces of code to add a single
option, it has the advantage of turning this:
Usage: transcode [options]
options:
-i name input file/directory/device/mountpoint name
-H n auto-probe n MB of source (0=off) [1]
-p file read audio stream from separate file [off]
-x vmod[,amod] video[,audio] import modules [null]
-a a[,v] extract audio[,video] track [0,0]
--dvd_access_delay N delay DVD access by N seconds [3]
[...]
into this:
Usage: transcode [options...]
Options:
-h/--help print this usage message and exit
-v/--version print version and exit
-q/--verbose level verbosity (0=quiet,1=info,2=debug) [1]
======== Input, output, and control files ========
-i/--input file input file/directory/device/mountpoint name
-o/--output file output file name
--avi_limit size split output AVI file after "size" MB [2048]
[...]
without having to manually reformat the text every time something changes.
(If one were adventurous, the option macros could probably be expanded to
include manpage documentation as well, which then got parsed by cpp into
nroff source...)
The overall parsing routine and its helper functions are in
src/cmdline.[ch]. I've also taken a bunch of variables used in option
handling that used to be main() local and dropped them in cmdline.c as
global variables until something better is found to be done with them.
Functionally, there are only a few changes, which should affect few if
any people (but speak up if it hits you):
* The undocumented long option names for most of the short options have
changed, e.g. -i is now --input instead of --input_file.
* -u buffers,threads is now deprecated (-u buffers is fine; use
--threads to specify the number of threads).
* --keep_asr is now disabled, as the code implementing it is broken (it
doesn't interact properly with other options). If you need to keep
the same aspect ratio, calculate the appropriate values manually.
* --color is now gone entirely, because it didn't actually do anything.
* -V and --debug are now included in the help message (I have no idea
what the latter does, but the old code checked for it, so I've left
it in).
I've done some preliminary tests here, and there don't seem to be any
regressions at first glance. If something does pop up, comment out the
#define NEW_CMDLINE_CODE
line in src/transcode.c to re-enable the original processing code. The
new code will still get compiled in, but (aside from the moved variables)
won't get used.
--Andrew Church
[EMAIL PROTECTED]
http://achurch.org/