[FFmpeg-cvslog] lavc: add support for codec-specific defaults.

Anton Khirnov git at videolan.org
Mon Jul 11 05:52:40 CEST 2011


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Wed Jun  8 08:27:53 2011 +0200| [84626b364babc27c5a3db454ebf6a02aeaa186fe] | committer: Anton Khirnov

lavc: add support for codec-specific defaults.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=84626b364babc27c5a3db454ebf6a02aeaa186fe
---

 libavcodec/avcodec.h  |    7 +++++++
 libavcodec/internal.h |    5 +++++
 libavcodec/options.c  |   11 +++++++++++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 3f01680..ba6342a 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2860,6 +2860,8 @@ typedef struct AVProfile {
     const char *name; ///< short name for the profile
 } AVProfile;
 
+typedef struct AVCodecDefault AVCodecDefault;
+
 /**
  * AVCodec.
  */
@@ -2922,6 +2924,11 @@ typedef struct AVCodec {
      */
     int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src);
     /** @} */
+
+    /**
+     * Private codec-specific defaults.
+     */
+    const AVCodecDefault *defaults;
 } AVCodec;
 
 /**
diff --git a/libavcodec/internal.h b/libavcodec/internal.h
index fe853ab..9a444fc 100644
--- a/libavcodec/internal.h
+++ b/libavcodec/internal.h
@@ -27,6 +27,11 @@
 #include <stdint.h>
 #include "avcodec.h"
 
+struct AVCodecDefault {
+    const uint8_t *key;
+    const uint8_t *value;
+};
+
 /**
  * Determine whether pix_fmt is a hardware accelerated format.
  */
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 1e7fe52..4869046 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -25,6 +25,8 @@
  */
 
 #include "avcodec.h"
+#include "internal.h"
+#include "libavutil/avassert.h"
 #include "libavutil/opt.h"
 #include <float.h>              /* FLT_MIN, FLT_MAX */
 
@@ -524,6 +526,15 @@ int avcodec_get_context_defaults3(AVCodecContext *s, AVCodec *codec){
             av_opt_set_defaults(s->priv_data);
         }
     }
+    if (codec && codec->defaults) {
+        int ret;
+        AVCodecDefault *d = codec->defaults;
+        while (d->key) {
+            ret = av_set_string3(s, d->key, d->value, 0, NULL);
+            av_assert0(ret >= 0);
+            d++;
+        }
+    }
     return 0;
 }
 



More information about the ffmpeg-cvslog mailing list