[xiph-cvs] cvs commit: vorbis-tools/oggenc encode.c encode.h oggenc.c
Michael Smith
msmith at xiph.org
Sat Jan 26 22:21:49 PST 2002
msmith 02/01/26 22:21:48
Modified: oggenc encode.c encode.h oggenc.c
Log:
Introduce --managed option (no short version). Usage of -b/-m/-M without first
specifying --managed is now deprecated, and gives a long message about this.
Also fixed some other bugs people introduced while I was away.
Revision Changes Path
1.18 +9 -8 vorbis-tools/oggenc/encode.c
Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- encode.c 2002/01/26 11:06:40 1.17
+++ encode.c 2002/01/27 06:21:48 1.18
@@ -47,14 +47,13 @@
/* get start time. */
timer = timer_start();
opt->start_encode(opt->infilename, opt->filename, opt->bitrate,
- opt->quality);
+ opt->quality, opt->managed);
/* Have vorbisenc choose a mode for us */
vorbis_info_init(&vi);
- if(opt->quality >= 0.0f)
+ if(!opt->managed)
{
- printf(_("Encoding with VBR\n"));
if(vorbis_encode_init_vbr(&vi, opt->channels, opt->rate, opt->quality))
{
fprintf(stderr, _("Mode initialisation failed: invalid parameters for quality\n"));
@@ -64,7 +63,6 @@
}
else
{
- printf(_("Encoding with managed bitrates.\n"));
if(vorbis_encode_init(&vi, opt->channels, opt->rate,
opt->max_bitrate>0?opt->max_bitrate*1000:-1,
opt->bitrate*1000,
@@ -285,22 +283,25 @@
fprintf(stderr, "\n%s\n", errmsg);
}
-void start_encode_full(char *fn, char *outfn, int bitrate, float quality)
+void start_encode_full(char *fn, char *outfn, int bitrate, float quality,
+ int managed)
{
- if(quality >= 0.0f)
+ if(!managed)
fprintf(stderr, _("Encoding %s%s%s to \n %s%s%s at quality %2.2f\n"),
fn?"\"":"", fn?fn:_("standard input"), fn?"\"":"",
outfn?"\"":"", outfn?outfn:_("standard output"), outfn?"\"":"",
quality * 10);
else
fprintf(stderr, _("Encoding %s%s%s to \n "
- "%s%s%s at bitrate %d kbps\n"),
+ "%s%s%s at bitrate %d kbps,\n"
+ "using full bitrate management engine\n"),
fn?"\"":"", fn?fn:_("standard input"), fn?"\"":"",
outfn?"\"":"", outfn?outfn:_("standard output"), outfn?"\"":"",
bitrate);
}
-void start_encode_null(char *fn, char *outfn, int bitrate, float quality)
+void start_encode_null(char *fn, char *outfn, int bitrate, float quality,
+ int managed)
{
}
<p><p>1.15 +7 -3 vorbis-tools/oggenc/encode.h
Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- encode.h 2002/01/27 05:26:56 1.14
+++ encode.h 2002/01/27 06:21:48 1.15
@@ -12,7 +12,7 @@
typedef void (*enc_end_func)(char *fn, double time, int rate,
long samples, long bytes);
typedef void (*enc_start_func)(char *fn, char *outfn, int bitrate,
- float quality);
+ float quality, int managed);
typedef void (*error_func)(char *errormessage);
@@ -23,8 +23,10 @@
void update_statistics_full(char *fn, long total, long done, double time);
void update_statistics_notime(char *fn, long total, long done, double time);
void update_statistics_null(char *fn, long total, long done, double time);
-void start_encode_full(char *fn, char *outfn, int bitrate, float quality);
-void start_encode_null(char *fn, char *outfn, int bitrate, float quality);
+void start_encode_full(char *fn, char *outfn, int bitrate, float quality,
+ int managed);
+void start_encode_null(char *fn, char *outfn, int bitrate, float quality,
+ int managed);
void final_statistics(char *fn, double time, int rate, long total_samples,
long bytes);
void final_statistics_null(char *fn, double time, int rate, long total_samples,
@@ -61,6 +63,7 @@
char *outfile;
/* All 3 in kbps */
+ int managed;
int min_bitrate;
int nominal_bitrate;
int max_bitrate;
@@ -90,6 +93,7 @@
int samplesize;
/* Various bitrate/quality options */
+ int managed;
int bitrate;
int min_bitrate;
int max_bitrate;
<p><p>1.44 +45 -9 vorbis-tools/oggenc/oggenc.c
Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- oggenc.c 2002/01/27 05:26:56 1.43
+++ oggenc.c 2002/01/27 06:21:48 1.44
@@ -53,6 +53,7 @@
{"date",1,0,'d'},
{"tracknum",1,0,'N'},
{"serial",1,0,'s'},
+ {"managed", 0, 0, 0},
{NULL,0,0,0}
};
@@ -70,7 +71,7 @@
/* Default values */
oe_options opt = {NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
0, NULL, 0, NULL, 0, 0, 0,16,44100,2, NULL,DEFAULT_NAMEFMT_REMOVE,
- DEFAULT_NAMEFMT_REPLACE, NULL, -1,-1,-1,-1,0};
+ DEFAULT_NAMEFMT_REPLACE, NULL, 0, -1,128,-1,0.3,0};
int i;
char **infiles;
@@ -267,6 +268,7 @@
enc_opts.comments = &vc;
enc_opts.filename = out_fn;
enc_opts.infilename = infiles[i];
+ enc_opts.managed = opt.managed;
enc_opts.bitrate = opt.nominal_bitrate;
enc_opts.min_bitrate = opt.min_bitrate;
enc_opts.max_bitrate = opt.max_bitrate;
@@ -300,6 +302,19 @@
}
+static void print_deprecated_message(void) {
+ fprintf(stderr, "WARNING: Usage of the bitrate options (-b, -m, -M) has been deprecated\n"
+ "To use these, you must specify that you wish to use managed mode, using\n"
+ "the --managed option.\n"
+ "This will cause oggenc to enable the full bitrate management engine.\n"
+ "You should do this ONLY if bitrate management is critical to your usage\n"
+ "(for example, certain audio streaming applications).\n"
+ "Usage of the bitrate management engine will generally decrease quality,\n"
+ "using the normal fully VBR modes (quality specified using -q) is\n"
+ "very highly recommended for most users.\n"
+ "Usage of the -managed option will become MANDATORY in the next release.\n\n");
+}
+
static void usage(void)
{
fprintf(stdout,
@@ -488,8 +503,15 @@
switch(ret)
{
case 0:
- fprintf(stderr, _("Internal error parsing command line options\n"));
- exit(1);
+ if(!strcmp(long_options[option_index].name, "managed")) {
+ fprintf(stderr, "Enabling bitrate management engine\n");
+ opt->managed = 1;
+ }
+ else {
+ fprintf(stderr, _("Internal error parsing command line options\n"));
+ exit(1);
+ }
+
break;
case 'a':
opt->artist = realloc(opt->artist, (++opt->artist_count)*sizeof(char *));
@@ -526,13 +548,24 @@
opt->title[opt->title_count - 1] = strdup(optarg);
break;
case 'b':
- if(sscanf(optarg, "%d", &opt->nominal_bitrate)
- != 1) {
- fprintf(stderr, _("Warning: nominal bitrate \"%s\" not recognised\n"), optarg);
- opt->nominal_bitrate = -1;
+ if(!opt->managed) {
+ print_deprecated_message();
+ opt->managed = 1;
+ }
+
+ if(sscanf(optarg, "%d", &opt->nominal_bitrate)
+ != 1) {
+ fprintf(stderr, _("Warning: nominal bitrate \"%s\" not recognised\n"), optarg);
+ opt->nominal_bitrate = -1;
}
+
break;
case 'm':
+ if(!opt->managed) {
+ print_deprecated_message();
+ opt->managed = 1;
+ }
+
if(sscanf(optarg, "%d", &opt->min_bitrate)
!= 1) {
fprintf(stderr, _("Warning: minimum bitrate \"%s\" not recognised\n"), optarg);
@@ -540,6 +573,11 @@
}
break;
case 'M':
+ if(!opt->managed) {
+ print_deprecated_message();
+ opt->managed = 1;
+ }
+
if(sscanf(optarg, "%d", &opt->max_bitrate)
!= 1) {
fprintf(stderr, _("Warning: maximum bitrate \"%s\" not recognised\n"), optarg);
@@ -660,8 +698,6 @@
}
}
- if (opt->min_bitrate < 0 && opt->nominal_bitrate < 0 && opt->max_bitrate < 0 && opt->quality < 0.f)
- opt->quality = 0.3f;
}
static void add_tag(vorbis_comment *vc, oe_options *opt,char *name, char *value)
<p><p><p>--- >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