Module: libav
Branch: release/0.8
Commit: 24025cc0b972a8c2e8b3018cb7c53c1f55fe5fbb

Author:    Justin Ruggles <[email protected]>
Committer: Anton Khirnov <[email protected]>
Date:      Tue Feb 28 19:33:07 2012 -0500

libvorbis: use VBR by default, with default quality of 3

(cherry picked from commit 147ff24a0e8d819615a0f596df3ea47dddd79fdc)

Conflicts:
        libavcodec/libvorbis.c

Fixes a part of Bug 277

Signed-off-by: Anton Khirnov <[email protected]>

---

 libavcodec/libvorbis.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
index c790ff0..60235d7 100644
--- a/libavcodec/libvorbis.c
+++ b/libavcodec/libvorbis.c
@@ -29,6 +29,7 @@
 #include "libavutil/opt.h"
 #include "avcodec.h"
 #include "bytestream.h"
+#include "internal.h"
 #include "vorbis.h"
 #include "libavutil/mathematics.h"
 
@@ -59,6 +60,12 @@ static const AVOption options[] = {
     { "iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, 
iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | 
AV_OPT_FLAG_ENCODING_PARAM },
     { NULL }
 };
+
+static const AVCodecDefault defaults[] = {
+    { "b",  "0" },
+    { NULL },
+};
+
 static const AVClass class = { "libvorbis", av_default_item_name, options, 
LIBAVUTIL_VERSION_INT };
 
 static av_cold int oggvorbis_init_encoder(vorbis_info *vi, AVCodecContext 
*avccontext)
@@ -66,11 +73,18 @@ static av_cold int oggvorbis_init_encoder(vorbis_info *vi, 
AVCodecContext *avcco
     OggVorbisContext *context = avccontext->priv_data;
     double cfreq;
 
-    if (avccontext->flags & CODEC_FLAG_QSCALE) {
-        /* variable bitrate */
+    if (avccontext->flags & CODEC_FLAG_QSCALE || !avccontext->bit_rate) {
+        /* variable bitrate
+         * NOTE: we use the oggenc range of -1 to 10 for global_quality for
+         *       user convenience, but libvorbis uses -0.1 to 1.0.
+         */
+        float q = avccontext->global_quality / (float)FF_QP2LAMBDA;
+        /* default to 3 if the user did not set quality or bitrate */
+        if (!(avccontext->flags & CODEC_FLAG_QSCALE))
+            q = 3.0;
         if (vorbis_encode_setup_vbr(vi, avccontext->channels,
                                     avccontext->sample_rate,
-                                    avccontext->global_quality / 
(float)FF_QP2LAMBDA / 10.0))
+                                    q / 10.0))
             return -1;
     } else {
         int minrate = avccontext->rc_min_rate > 0 ? avccontext->rc_min_rate : 
-1;
@@ -262,4 +276,5 @@ AVCodec ff_libvorbis_encoder = {
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, 
AV_SAMPLE_FMT_NONE },
     .long_name      = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
     .priv_class     = &class,
+    .defaults       = defaults,
 };

_______________________________________________
libav-commits mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-commits

Reply via email to