Commit 22398efa authored by Michael Smith's avatar Michael Smith
Browse files

Default encoding parameters working properly, and check for success in

vorbis_encode_init()/vorbis_encode_init_vbr().

svn path=/trunk/vorbis-tools/; revision=1873
parent 203bddb4
...@@ -49,12 +49,25 @@ int oe_encode(oe_enc_opt *opt) ...@@ -49,12 +49,25 @@ int oe_encode(oe_enc_opt *opt)
/* Have vorbisenc choose a mode for us */ /* Have vorbisenc choose a mode for us */
vorbis_info_init(&vi); vorbis_info_init(&vi);
if(opt->bitrate >= 0 || opt->min_bitrate >= 0 || opt->max_bitrate >=0) if(opt->quality >= 0.0f)
vorbis_encode_init(&vi, opt->channels, opt->rate, opt->min_bitrate*1000, {
opt->bitrate*1000, opt->max_bitrate*1000); if(vorbis_encode_init_vbr(&vi, opt->channels, opt->rate, opt->quality))
{
fprintf(stderr, "Mode initialisation failed: invalid parameters for quality\n");
vorbis_info_clear(&vi);
return 1;
}
}
else else
vorbis_encode_init_vbr(&vi, opt->channels, opt->rate, opt->quality); {
if(vorbis_encode_init(&vi, opt->channels, opt->rate, opt->min_bitrate*1000,
opt->bitrate*1000, opt->max_bitrate*1000))
{
fprintf(stderr, "Mode initialisation failed: invalid parameters for bitrate\n");
vorbis_info_clear(&vi);
return 1;
}
}
/* Now, set up the analysis engine, stream encoder, and other /* Now, set up the analysis engine, stream encoder, and other
preparation before the encoding begins. preparation before the encoding begins.
......
...@@ -61,7 +61,7 @@ int main(int argc, char **argv) ...@@ -61,7 +61,7 @@ int main(int argc, char **argv)
{ {
/* Default values */ /* Default values */
oe_options opt = {"ISO-8859-1", NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL, oe_options opt = {"ISO-8859-1", NULL, 0, NULL, 0, NULL, 0, NULL, 0, NULL,
0, NULL, 0, 0, 0,16,44100,2, NULL,NULL, -1,128,-1, 0.5f,0}; 0, NULL, 0, 0, 0,16,44100,2, NULL,NULL, -1,128,-1, -1.0f,0};
int i; int i;
char **infiles; char **infiles;
...@@ -243,6 +243,7 @@ int main(int argc, char **argv) ...@@ -243,6 +243,7 @@ int main(int argc, char **argv)
enc_opts.bitrate = opt.nominal_bitrate; enc_opts.bitrate = opt.nominal_bitrate;
enc_opts.min_bitrate = opt.min_bitrate; enc_opts.min_bitrate = opt.min_bitrate;
enc_opts.max_bitrate = opt.max_bitrate; enc_opts.max_bitrate = opt.max_bitrate;
enc_opts.quality = opt.quality;
if(!enc_opts.total_samples_per_channel) if(!enc_opts.total_samples_per_channel)
enc_opts.progress_update = update_statistics_notime; enc_opts.progress_update = update_statistics_notime;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment