changeset 12509:7220936dc29c libavcodec

Deprecate av_opt_show() in favor of a new function av_opt_show2(), which allows to specify only a subset of all the options to show.
author stefano
date Fri, 24 Sep 2010 00:51:40 +0000
parents 750ff18b7394
children ef2f2db5b7be
files avcodec.h opt.c opt.h
diffstat 3 files changed, 37 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/avcodec.h	Thu Sep 23 21:33:29 2010 +0000
+++ b/avcodec.h	Fri Sep 24 00:51:40 2010 +0000
@@ -31,7 +31,7 @@
 #include "libavutil/cpu.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
-#define LIBAVCODEC_VERSION_MINOR 89
+#define LIBAVCODEC_VERSION_MINOR 90
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
@@ -54,6 +54,9 @@
 #ifndef FF_API_MM_FLAGS
 #define FF_API_MM_FLAGS         (LIBAVCODEC_VERSION_MAJOR < 53)
 #endif
+#ifndef FF_API_OPT_SHOW
+#define FF_API_OPT_SHOW         (LIBAVCODEC_VERSION_MAJOR < 53)
+#endif
 
 #define AV_NOPTS_VALUE          INT64_C(0x8000000000000000)
 #define AV_TIME_BASE            1000000
--- a/opt.c	Thu Sep 23 21:33:29 2010 +0000
+++ b/opt.c	Fri Sep 24 00:51:40 2010 +0000
@@ -319,12 +319,13 @@
     return num*intnum/den;
 }
 
-static void opt_list(void *obj, void *av_log_obj, const char *unit)
+static void opt_list(void *obj, void *av_log_obj, const char *unit,
+                     int req_flags, int rej_flags)
 {
     const AVOption *opt=NULL;
 
     while((opt= av_next_option(obj, opt))){
-        if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM)))
+        if (!(opt->flags & req_flags) || (opt->flags & rej_flags))
             continue;
 
         /* Don't print CONST's on level one.
@@ -383,22 +384,30 @@
             av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
         av_log(av_log_obj, AV_LOG_INFO, "\n");
         if (opt->unit && opt->type != FF_OPT_TYPE_CONST) {
-            opt_list(obj, av_log_obj, opt->unit);
+            opt_list(obj, av_log_obj, opt->unit, req_flags, rej_flags);
         }
     }
 }
 
-int av_opt_show(void *obj, void *av_log_obj){
+int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags)
+{
     if(!obj)
         return -1;
 
     av_log(av_log_obj, AV_LOG_INFO, "%s AVOptions:\n", (*(AVClass**)obj)->class_name);
 
-    opt_list(obj, av_log_obj, NULL);
+    opt_list(obj, av_log_obj, NULL, req_flags, rej_flags);
 
     return 0;
 }
 
+#if FF_API_OPT_SHOW
+int av_opt_show(void *obj, void *av_log_obj){
+    return av_opt_show2(obj, av_log_obj,
+                        AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM, 0);
+}
+#endif
+
 /** Set the values of the AVCodecContext or AVFormatContext structure.
  * They are set to the defaults specified in the according AVOption options
  * array default_val field.
--- a/opt.h	Thu Sep 23 21:33:29 2010 +0000
+++ b/opt.h	Fri Sep 24 00:51:40 2010 +0000
@@ -204,7 +204,25 @@
 int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
 const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
 const AVOption *av_next_option(void *obj, const AVOption *last);
-int av_opt_show(void *obj, void *av_log_obj);
+
+#if FF_API_OPT_SHOW
+/**
+ * @deprecated Use av_opt_show2() instead.
+ */
+attribute_deprecated int av_opt_show(void *obj, void *av_log_obj);
+#endif
+
+/**
+ * Show the obj options.
+ *
+ * @param req_flags requested flags for the options to show. Show only the
+ * options for which it is opt->flags & req_flags.
+ * @param rej_flags rejected flags for the options to show. Show only the
+ * options for which it is !(opt->flags & req_flags).
+ * @param av_log_obj log context to use for showing the options
+ */
+int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags);
+
 void av_opt_set_defaults(void *s);
 void av_opt_set_defaults2(void *s, int mask, int flags);