[xiph-cvs] cvs commit: vorbis-tools/oggenc encode.c encode.h oggenc.c
Michael Smith
msmith at xiph.org
Sun Jun 30 01:51:37 PDT 2002
msmith 02/06/30 01:51:37
Modified: oggenc encode.c encode.h oggenc.c
Log:
Use new libvorbis features.
Can now use --bitrate to choose an approximate bitrate but still use full VBR.
--managed is required to make it use managed modes. Documentation not yet updated.
Revision Changes Path
1.22 +29 -12 vorbis-tools/oggenc/encode.c
Index: encode.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- encode.c 2002/05/22 10:27:11 1.21
+++ encode.c 2002/06/30 08:51:36 1.22
@@ -55,18 +55,18 @@
/* Have vorbisenc choose a mode for us */
vorbis_info_init(&vi);
- if(!opt->managed)
- {
- if(vorbis_encode_init_vbr(&vi, opt->channels, opt->rate, opt->quality))
+ if(opt->bitrate < 0 && opt->min_bitrate < 0 && opt->max_bitrate < 0)
+ {
+ if(vorbis_encode_setup_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
- {
- if(vorbis_encode_init(&vi, opt->channels, opt->rate,
+ }
+ }
+ else
+ {
+ if(vorbis_encode_setup_managed(&vi, opt->channels, opt->rate,
opt->max_bitrate>0?opt->max_bitrate*1000:-1,
opt->bitrate*1000,
opt->min_bitrate>0?opt->min_bitrate*1000:-1))
@@ -75,8 +75,20 @@
vorbis_info_clear(&vi);
return 1;
}
+ }
+
+ if(opt->managed && opt->bitrate < 0)
+ {
+ vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_AVG, NULL);
+ }
+ else if(!opt->managed)
+ {
+ /* Turn off management entirely (if it was turned on). */
+ vorbis_encode_ctl(&vi, OV_ECTL_RATEMANAGE_SET, NULL);
}
+ vorbis_encode_setup_init(&vi);
+
/* Now, set up the analysis engine, stream encoder, and other
preparation before the encoding begins.
*/
@@ -289,15 +301,20 @@
void start_encode_full(char *fn, char *outfn, int bitrate, float quality,
int managed)
{
- if(!managed)
- fprintf(stderr, _("Encoding %s%s%s to \n %s%s%s at quality %2.2f\n"),
+ if(bitrate > 0 && !managed)
+ fprintf(stderr, _("Encoding %s%s%s to \n %s%s%s \nat approximate bitrate %d kbps (VBR encoding enabled)\n"),
+ fn?"\"":"", fn?fn:_("standard input"), fn?"\"":"",
+ outfn?"\"":"", outfn?outfn:_("standard output"), outfn?"\"":"",
+ bitrate);
+ else if(!managed)
+ fprintf(stderr, _("Encoding %s%s%s to \n %s%s%s \nat 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"
- "using full bitrate management engine\n"),
+ "%s%s%s \nat bitrate %d kbps, "
+ "using bitrate management engine\n"),
fn?"\"":"", fn?fn:_("standard input"), fn?"\"":"",
outfn?"\"":"", outfn?outfn:_("standard output"), outfn?"\"":"",
bitrate);
<p><p>1.19 +0 -1 vorbis-tools/oggenc/encode.h
Index: encode.h
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/encode.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- encode.h 2002/05/30 12:13:22 1.18
+++ encode.h 2002/06/30 08:51:36 1.19
@@ -4,7 +4,6 @@
#include <stdio.h>
#include <vorbis/codec.h>
-
typedef void TIMER;
typedef long (*audio_read_func)(void *src, float **buffer, int samples);
typedef void (*progress_func)(char *fn, long totalsamples,
<p><p>1.59 +1 -28 vorbis-tools/oggenc/oggenc.c
Index: oggenc.c
===================================================================
RCS file: /usr/local/cvsroot/vorbis-tools/oggenc/oggenc.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- oggenc.c 2002/06/23 13:29:46 1.58
+++ oggenc.c 2002/06/30 08:51:36 1.59
@@ -75,7 +75,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, 0, NULL,DEFAULT_NAMEFMT_REMOVE,
- DEFAULT_NAMEFMT_REPLACE, NULL, 0, -1,128,-1,0.3,0, 0,0};
+ DEFAULT_NAMEFMT_REPLACE, NULL, 0, -1,-1,-1,0.3,0, 0,0};
int i;
char **infiles;
@@ -353,18 +353,6 @@
}
-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\n"));
-}
-
static void usage(void)
{
fprintf(stdout,
@@ -634,11 +622,6 @@
opt->title[opt->title_count - 1] = strdup(optarg);
break;
case 'b':
- if(!opt->managed) {
- print_deprecated_message();
- exit(1);
- }
-
if(sscanf(optarg, "%d", &opt->nominal_bitrate)
!= 1) {
fprintf(stderr, _("Warning: nominal bitrate \"%s\" not recognised\n"), optarg);
@@ -647,11 +630,6 @@
break;
case 'm':
- if(!opt->managed) {
- print_deprecated_message();
- exit(1);
- }
-
if(sscanf(optarg, "%d", &opt->min_bitrate)
!= 1) {
fprintf(stderr, _("Warning: minimum bitrate \"%s\" not recognised\n"), optarg);
@@ -659,11 +637,6 @@
}
break;
case 'M':
- if(!opt->managed) {
- print_deprecated_message();
- exit(1);
- }
-
if(sscanf(optarg, "%d", &opt->max_bitrate)
!= 1) {
fprintf(stderr, _("Warning: maximum bitrate \"%s\" not recognised\n"), optarg);
<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