ref: db7bbf53eac7b4e3f7c65dcb22afc7e20eaa1dfc
parent: 6f88f59204a99d07fa3646f1141ece17b7c2660a
author: Gregory Maxwell <greg@xiph.org>
date: Sat Nov 3 09:28:30 EDT 2012
Lower default bitrates for sampling rates <44.1k. Fix status output. Getting 64kbit/sec output for a mono 8kHz stream is somewhat surprising. Instead lower the default rate by a factor of (rate+16000)/64000 for rates under 44.1kHz. This gives mono 8kHz a more respectable 24kbit/sec rate. In opusenc the "encoding complete" was incompletely overwriting the last status line. Now it takes care to overwrite it all the way.
--- a/man/opusenc.1
+++ b/man/opusenc.1
@@ -92,7 +92,7 @@
.IP "--bitrate N.nnn"
Encoding bitrate in kbit/sec (6-256 per channel)
.br
-Default is 64kbps per mono stream, 96kbps per coupled pair.
+Default for >=44.1kHz input is 64kbps per mono stream, 96kbps per coupled pair.
.IP "--vbr"
Use variable bitrate encoding (default)
.IP "--cvbr"
--- a/src/opusenc.c
+++ b/src/opusenc.c
@@ -584,7 +584,11 @@
}
}
- bitrate=bitrate>0?bitrate:64000*header.nb_streams+32000*header.nb_coupled;
+ if(bitrate<0){
+ /*Lower default rate for sampling rates [8000-44100) by a factor of (rate+16k)/(64k)*/
+ bitrate=((64000*header.nb_streams+32000*header.nb_coupled)*
+ (IMIN(48,IMAX(8,((rate<44100?rate:48000)+1000)/1000))+16)+32)>>6;
+ }
if(bitrate>(1024000*chan)||bitrate<500){
fprintf(stderr,"Error: Bitrate %d bits/sec is insane.\nDid you mistake bits for kilobits?\n",bitrate);
@@ -932,7 +936,7 @@
if(!quiet){
double coded_seconds=nb_encoded/(double)coding_rate;
double wall_time=(stop_time-start_time)+1e-6;
- fprintf(stderr,"Encoding complete\n");
+ fprintf(stderr,"Encoding complete \n");
fprintf(stderr,"-----------------------------------------------------\n");
fprintf(stderr," Encoded:");
print_time(coded_seconds);