fixes crash patch by (Mark Hills <mark at pogo dot org dot uk>)
authorMark Hills <mark@pogo.org.uk>
Sat, 21 Dec 2002 15:54:21 +0000 (15:54 +0000)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 21 Dec 2002 15:54:21 +0000 (15:54 +0000)
Originally committed as revision 1355 to svn://svn.ffmpeg.org/ffmpeg/trunk

libavcodec/oggvorbis.c

index e327e2fd3e0e33f6a39de8529d7b6d766b1166de..6e661926c62a5f0e5fe0b131003a03564b969162 100644 (file)
@@ -24,12 +24,20 @@ typedef struct OggVorbisContext {
 
 
 int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
-    if(avccontext->coded_frame->quality) /* VBR requested */
-       return vorbis_encode_init_vbr(vi, avccontext->channels,
-                 avccontext->sample_rate, (float)avccontext->coded_frame->quality / 1000) ;
+
+#ifdef OGGVORBIS_VBR_BY_ESTIMATE
+    /* variable bitrate by estimate */
+
+    return (vorbis_encode_setup_managed(vi, avccontext->channels,
+              avccontext->sample_rate, -1, avccontext->bit_rate, -1) ||
+           vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE_AVG, NULL) ||
+           vorbis_encode_setup_init(vi)) ;
+#else
+    /* constant bitrate */
 
     return vorbis_encode_init(vi, avccontext->channels,
                  avccontext->sample_rate, -1, avccontext->bit_rate, -1) ;
+#endif
 }