changeset 934:159333d9297e libavcodec

fixes crash patch by (Mark Hills <mark at pogo dot org dot uk>)
author michaelni
date Sat, 21 Dec 2002 15:54:21 +0000
parents 8254eac24488
children c9bbd35064b6
files oggvorbis.c
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/oggvorbis.c	Thu Dec 19 18:59:45 2002 +0000
+++ b/oggvorbis.c	Sat Dec 21 15:54:21 2002 +0000
@@ -24,12 +24,20 @@
 
 
 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
 }