[xiph-cvs] cvs commit: vorbis-tools/oggenc encode.h oggenc.c
Michael Smith
msmith at xiph.org
Sat Dec 23 22:34:45 PST 2000
msmith 00/12/23 22:34:45
Modified: oggenc encode.h oggenc.c
Log:
Allow explicit setting of the serial number.
Revision Changes Path
1.6 +2 -1 vorbis-tools/oggenc/encode.h
Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- encode.h 2000/11/30 06:04:45 1.5
+++ encode.h 2000/12/24 06:34:44 1.6
@@ -48,12 +48,13 @@
char *namefmt;
char *outfile;
int kbps;
+ unsigned int serial;
} oe_options;
typedef struct
{
vorbis_comment *comments;
- long serialno;
+ unsigned int serialno;
audio_read_func read_samples;
progress_func progress_update;
1.9 +19 -7 vorbis-tools/oggenc/oggenc.c
Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- oggenc.c 2000/11/30 06:04:45 1.8
+++ oggenc.c 2000/12/24 06:34:44 1.9
@@ -38,6 +38,7 @@
{"bitrate",1,0,'b'},
{"date",1,0,'d'},
{"tracknum",1,0,'N'},
+ {"serial",1,0,'s'},
{NULL,0,0,0}
};
@@ -50,12 +51,11 @@
int main(int argc, char **argv)
{
oe_options opt = {NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, 0,
- 0,0, NULL,NULL,160}; /* Default values */
+ 0,0, NULL,NULL,160,0}; /* Default values */
int i;
char **infiles;
int numfiles;
- long nextserial;
parse_options(argc, argv, &opt);
@@ -87,9 +87,12 @@
exit(1);
}
- /* We randomly pick a serial number. This is then incremented for each file */
- srand(time(NULL));
- nextserial = rand();
+ if(opt.serial == 0)
+ {
+ /* We randomly pick a serial number. This is then incremented for each file */
+ srand(time(NULL));
+ opt.serial = rand();
+ }
for(i = 0; i < numfiles; i++)
{
@@ -108,7 +111,7 @@
/* Set various encoding defaults */
- enc_opts.serialno = nextserial++;
+ enc_opts.serialno = opt.serial++;
enc_opts.progress_update = update_statistics_full;
enc_opts.end_encode = final_statistics;
enc_opts.error = encode_error;
@@ -266,6 +269,9 @@
" -b, --bitrate Choose a bitrate to encode at. Internally,\n"
" a mode approximating this value is chosen.\n"
" Takes an argument in kbps. Default is 160kbps\n"
+ " -s, --serial Specify a serial number for the stream. If encoding\n"
+ " multiple files, this will be incremented for each\n"
+ " stream after the first.\n"
"\n"
" Naming:\n"
" -o, --output=fn Write file to fn (only valid in single-file mode)\n"
@@ -370,7 +376,7 @@
int ret;
int option_index = 1;
- while((ret = getopt_long(argc, argv, "a:b:c:d:hl:n:N:o:qrt:v",
+ while((ret = getopt_long(argc, argv, "a:b:c:d:hl:n:N:o:qrs:t:v",
long_options, &option_index)) != -1)
{
switch(ret)
@@ -394,6 +400,12 @@
case 'l':
opt->album = realloc(opt->album, (++opt->album_count)*sizeof(char *));
opt->album[opt->album_count - 1] = strdup(optarg);
+ break;
+ case 's':
+ /* Would just use atoi(), but that doesn't deal with unsigned
+ * ints. Damn */
+ if(sscanf(optarg, "%u", opt->serial) != 1)
+ opt->serial = 0; /* Failed, so just set to zero */
break;
case 't':
opt->title = realloc(opt->title, (++opt->title_count)*sizeof(char *));
--- >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 'cvs-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 commits
mailing list