[FFmpeg-cvslog] avprobe: Get rid of ugly casts in the options table

Martin Storsjö git at videolan.org
Tue Aug 28 16:33:22 CEST 2012


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Mon Aug 27 14:07:12 2012 +0300| [b42be2d56a5abbc8645eac7d4d30f9e3b486dcc0] | committer: Martin Storsjö

avprobe: Get rid of ugly casts in the options table

This also makes sure the function pointers are stored via the same
union member as they are accessed via.

Signed-off-by: Martin Storsjö <martin at martin.st>

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

 avprobe.c |   27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/avprobe.c b/avprobe.c
index 00e0ad0..cb610d8 100644
--- a/avprobe.c
+++ b/avprobe.c
@@ -877,34 +877,35 @@ void show_help_default(const char *opt, const char *arg)
     show_help_children(avformat_get_class(), AV_OPT_FLAG_DECODING_PARAM);
 }
 
-static void opt_pretty(void)
+static int opt_pretty(const char *opt, const char *arg)
 {
     show_value_unit              = 1;
     use_value_prefix             = 1;
     use_byte_value_binary_prefix = 1;
     use_value_sexagesimal_format = 1;
+    return 0;
 }
 
 static const OptionDef real_options[] = {
 #include "cmdutils_common_opts.h"
-    { "f", HAS_ARG, {(void*)opt_format}, "force format", "format" },
-    { "of", HAS_ARG, {(void*)&opt_output_format}, "output the document either as ini or json", "output_format" },
-    { "unit", OPT_BOOL, {(void*)&show_value_unit},
+    { "f", HAS_ARG, {.func_arg = opt_format}, "force format", "format" },
+    { "of", HAS_ARG, {.func_arg = opt_output_format}, "output the document either as ini or json", "output_format" },
+    { "unit", OPT_BOOL, {&show_value_unit},
       "show unit of the displayed values" },
-    { "prefix", OPT_BOOL, {(void*)&use_value_prefix},
+    { "prefix", OPT_BOOL, {&use_value_prefix},
       "use SI prefixes for the displayed values" },
-    { "byte_binary_prefix", OPT_BOOL, {(void*)&use_byte_value_binary_prefix},
+    { "byte_binary_prefix", OPT_BOOL, {&use_byte_value_binary_prefix},
       "use binary prefixes for byte units" },
-    { "sexagesimal", OPT_BOOL,  {(void*)&use_value_sexagesimal_format},
+    { "sexagesimal", OPT_BOOL,  {&use_value_sexagesimal_format},
       "use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units" },
-    { "pretty", 0, {(void*)&opt_pretty},
+    { "pretty", 0, {.func_arg = opt_pretty},
       "prettify the format of displayed values, make it more human readable" },
-    { "show_format",  OPT_BOOL, {(void*)&do_show_format} , "show format/container info" },
-    { "show_format_entry", HAS_ARG, {(void*)opt_show_format_entry},
+    { "show_format",  OPT_BOOL, {&do_show_format} , "show format/container info" },
+    { "show_format_entry", HAS_ARG, {.func_arg = opt_show_format_entry},
       "show a particular entry from the format/container info", "entry" },
-    { "show_packets", OPT_BOOL, {(void*)&do_show_packets}, "show packets info" },
-    { "show_streams", OPT_BOOL, {(void*)&do_show_streams}, "show streams info" },
-    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default},
+    { "show_packets", OPT_BOOL, {&do_show_packets}, "show packets info" },
+    { "show_streams", OPT_BOOL, {&do_show_streams}, "show streams info" },
+    { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = opt_default},
       "generic catch all option", "" },
     { NULL, },
 };



More information about the ffmpeg-cvslog mailing list