[FFmpeg-devel] [PATCH] Default to using libraries when enabled

Janne Grunau janne-ffmpeg
Sat May 22 12:48:02 CEST 2010


On Fri, May 21, 2010 at 03:05:50PM -0700, Baptiste Coudurier wrote:
> Hi guys,
> 
> On 05/20/2009 05:20 PM, David Conrad wrote:
> > Hi,
> >
> > This changes the order of initialization so that external libraries that
> > are enabled are used by default over native codecs. My main motivation
> > in moving these is to be able to have the ogg and mkv muxers default to
> > encoding via libvorbis if it's enabled; currently, specifying
> > CODEC_ID_VORBIS will use the native encoder regardless, which is much
> > worse quality.
> 
> I'd like to revive this thread.
> It's been more than a year, and nothing has been done on the native 
> vorbis encoder to improve it's quality.
> 
> While the patch is questionable for all codecs, I think it is not for 
> vorbis.
> 
> Can we please make everything so libvorbis is used by default when it is 
> compiled in ?

See attached patches for selections by codec id. Beside the aac and vorbis
encoder are there other codecs which should be considered experimental?
It's more tricky for selections by codec name since the names are unique.
The best solution is probably to fail in ffmpeg if the encoder is experimental
and -strict (or something else) is not set.

Janne
-------------- next part --------------
commit 75273f4917cf21fcab6da91c048fae5955012b68
Author: Janne Grunau <janne at grunau.be>
Date:   Sat May 22 02:19:30 2010 +0200

    add CODEC_CAP_EXPERIMENTAL and prefer codecs without this capability
    
    avcodec_find_{de|en}coder returns only imidiately if CODEC_CAP_EXPERIMENTAL
    is not set. The first experimental codec is saved and returned if no other
    codec was found.

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8781c0a..a0d6498 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -645,6 +645,10 @@ typedef struct RcOverride{
  * as a last resort.
  */
 #define CODEC_CAP_SUBFRAMES        0x0100
+/**
+ * Codec is experimental
+ */
+#define CODEC_CAP_EXPERIMENTAL     0x0200
 
 //The following defines may change, don't expect compatibility if you use them.
 #define MB_TYPE_INTRA4x4   0x0001
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 56d4dbd..978e4d3 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -725,14 +725,18 @@ av_cold int avcodec_close(AVCodecContext *avctx)
 
 AVCodec *avcodec_find_encoder(enum CodecID id)
 {
-    AVCodec *p;
+    AVCodec *p, *experimental=NULL;
     p = first_avcodec;
     while (p) {
-        if (p->encode != NULL && p->id == id)
-            return p;
+        if (p->encode != NULL && p->id == id) {
+            if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental)
+                experimental = p;
+            else
+                return p;
+        }
         p = p->next;
     }
-    return NULL;
+    return experimental;
 }
 
 AVCodec *avcodec_find_encoder_by_name(const char *name)
@@ -751,14 +755,18 @@ AVCodec *avcodec_find_encoder_by_name(const char *name)
 
 AVCodec *avcodec_find_decoder(enum CodecID id)
 {
-    AVCodec *p;
+    AVCodec *p, *experimental=NULL;
     p = first_avcodec;
     while (p) {
-        if (p->decode != NULL && p->id == id)
-            return p;
+        if (p->decode != NULL && p->id == id) {
+            if (p->capabilities & CODEC_CAP_EXPERIMENTAL && !experimental)
+                experimental = p;
+            else
+                return p;
+        }
         p = p->next;
     }
-    return NULL;
+    return experimental;
 }
 
 AVCodec *avcodec_find_decoder_by_name(const char *name)
-------------- next part --------------
commit 9380dcec565dfb369430ff0273f776d934d4d1c2
Author: Janne Grunau <janne at grunau.be>
Date:   Sat May 22 12:38:55 2010 +0200

    mark aac encoder as experimental

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 69eb51e..d5f8ebb 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -645,7 +645,7 @@ AVCodec aac_encoder = {
     aac_encode_init,
     aac_encode_frame,
     aac_encode_end,
-    .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY,
+    .capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
     .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
 };
-------------- next part --------------
commit 8cf883bcf25d06320f1c86c5e4b7f3e7cbcd6740
Author: Janne Grunau <janne at grunau.be>
Date:   Sat May 22 12:39:35 2010 +0200

    mark vorbis encoder as experimental

diff --git a/libavcodec/vorbis_enc.c b/libavcodec/vorbis_enc.c
index 2bc0a24..934463d 100644
--- a/libavcodec/vorbis_enc.c
+++ b/libavcodec/vorbis_enc.c
@@ -1099,7 +1099,7 @@ AVCodec vorbis_encoder = {
     vorbis_encode_init,
     vorbis_encode_frame,
     vorbis_encode_close,
-    .capabilities= CODEC_CAP_DELAY,
+    .capabilities= CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
     .sample_fmts = (const enum SampleFormat[]){SAMPLE_FMT_S16,SAMPLE_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("Vorbis"),
 };



More information about the ffmpeg-devel mailing list