]> rtime.felk.cvut.cz Git - frescor/ffmpeg.git/commitdiff
Implement audio cutoff frequency to the vorbis encoder.
authorbanan <banan@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sat, 21 Jan 2006 17:09:23 +0000 (17:09 +0000)
committerbanan <banan@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
Sat, 21 Jan 2006 17:09:23 +0000 (17:09 +0000)
Patch by Justin Ruggles jruggle earthlink net.

git-svn-id: file:///var/local/repositories/ffmpeg/trunk@4877 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b

libavcodec/oggvorbis.c

index 80ed07db4f595e8c7f90ec2905819384ff1c646a..56fa247500f16af1cf4c7452d838ab2855b3b449 100644 (file)
@@ -29,25 +29,35 @@ typedef struct OggVorbisContext {
 
 
 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);
-    }
+                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;
+
 #ifdef OGGVORBIS_VBR_BY_ESTIMATE
-    /* variable bitrate by estimate */
+        /* variable bitrate by estimate */
+        if(vorbis_encode_ctl(vi, OV_ECTL_RATEMANAGE_AVG, NULL))
+            return -1;
+#endif
+    }
 
-    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 */
+    /* 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_init(vi, avccontext->channels,
-                  avccontext->sample_rate, -1, avccontext->bit_rate, -1) ;
-#endif
+    return vorbis_encode_setup_init(vi);
 }
 
 static int oggvorbis_encode_init(AVCodecContext *avccontext) {