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

Janne Grunau janne-ffmpeg
Wed May 26 09:14:17 CEST 2010


On Wed, May 26, 2010 at 02:04:28AM +0200, Michael Niedermayer wrote:
> On Wed, May 26, 2010 at 12:39:28AM +0200, Janne Grunau wrote:
> > On Wed, May 26, 2010 at 12:15:32AM +0200, Janne Grunau wrote:
> > > On Sun, May 23, 2010 at 03:04:01PM -0700, Baptiste Coudurier wrote:
> > > > On 5/23/10 2:59 PM, Janne Grunau wrote:
> > > > > On Sun, May 23, 2010 at 06:41:35PM +0200, Michael Niedermayer wrote:
> > > > >
> > > > >> the rest of the patch is ok with me
> > > > 
> > > > Humm won't this have side effects for decoder developpers ?
> > > > 
> > > > Manually selecting encoders is easy, but not decoders.
> > > > 
> > > > For encoders I think I'm ok.
> > > 
> > > see attached patch
> > 
> > 10l wrong patch, sorry
> 
> >  avcodec.h |    5 +++++
> >  utils.c   |   12 ++++++++----
> >  2 files changed, 13 insertions(+), 4 deletions(-)
> > 60c66792aeb93313fedc90c773a48572a01cb9b6  avoid_experimental_encoders2.diff
> > commit 2e69c61f56088207757759f96a071d1b12161407
> > Author: Janne Grunau <janne at grunau.be>
> > Date:   Sat May 22 02:19:30 2010 +0200
> > 
> >     add CODEC_CAP_EXPERIMENTAL and prefer encoders without it
> >     
> >     avcodec_find_encoder returns only imidiately if CODEC_CAP_EXPERIMENTAL
> >     is not set. The first experimental codec is saved and returned if no
> >     non-experimental encoder was found.
> [...]
> 
> > diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> > index 56d4dbd..9d823aa 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
> 
> if{}else
> patcheck should have told you

indeed, sorry.

> patch ok otherwise

final patch attached

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

    add CODEC_CAP_EXPERIMENTAL and prefer encoders without it
    
    avcodec_find_encoder returns only imidiately if CODEC_CAP_EXPERIMENTAL
    is not set. The first experimental codec is saved and returned if no
    non-experimental encoder was found.

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 435b0fb..a1728b9 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -645,6 +645,11 @@ typedef struct RcOverride{
  * as a last resort.
  */
 #define CODEC_CAP_SUBFRAMES        0x0100
+/**
+ * Codec is experimental and is thus avoided in favor of non experimental
+ * encoders
+ */
+#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..54db3da 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)



More information about the ffmpeg-devel mailing list