changeset 3058:8936371f5a5c libavcodec

Implement audio cutoff frequency to the vorbis encoder. Patch by Justin Ruggles jruggle earthlink net.
author banan
date Sat, 21 Jan 2006 17:09:23 +0000
parents 8f78b00d1252
children 61b4cc042988
files oggvorbis.c
diffstat 1 files changed, 24 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/oggvorbis.c	Sat Jan 21 02:35:03 2006 +0000
+++ b/oggvorbis.c	Sat Jan 21 17:09:23 2006 +0000
@@ -29,25 +29,35 @@
 
 
 static int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext *avccontext) {
+    double cfreq;
 
     if(avccontext->flags & CODEC_FLAG_QSCALE) {
-        return vorbis_encode_init_vbr(vi, avccontext->channels,
+        /* variable bitrate */
+        if(vorbis_encode_setup_vbr(vi, avccontext->channels,
                 avccontext->sample_rate,
-                avccontext->global_quality / (float)FF_QP2LAMBDA);
-    }
-#ifdef OGGVORBIS_VBR_BY_ESTIMATE
-    /* variable bitrate by estimate */
+                avccontext->global_quality / (float)FF_QP2LAMBDA))
+            return -1;
+    } else {
+        /* constant bitrate */
+        if(vorbis_encode_setup_managed(vi, avccontext->channels,
+                avccontext->sample_rate, -1, avccontext->bit_rate, -1))
+            return -1;
 
-    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 */
+#ifdef OGGVORBIS_VBR_BY_ESTIMATE
+        /* variable bitrate by estimate */
+        if(vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE_AVG, NULL))
+            return -1;
+#endif
+    }
 
-    return vorbis_encode_init(vi, avccontext->channels,
-                  avccontext->sample_rate, -1, avccontext->bit_rate, -1) ;
-#endif
+    /* cutoff frequency */
+    if(avccontext->cutoff > 0) {
+        cfreq = avccontext->cutoff / 1000.0;
+        if(vorbis_encode_ctl(vi, OV_ECTL_LOWPASS_SET, &cfreq))
+            return -1;
+    }
+
+    return vorbis_encode_setup_init(vi);
 }
 
 static int oggvorbis_encode_init(AVCodecContext *avccontext) {