[FFmpeg-cvslog] avformat/hashenc: rearrange options definition

Moritz Barsnick git at videolan.org
Sat Sep 21 00:29:44 EEST 2019


ffmpeg | branch: master | Moritz Barsnick <barsnick at gmx.net> | Thu Sep 12 11:23:04 2019 +0200| [d214f216110f3af9be3b6af2ed5ca285ffe3bda3] | committer: Michael Niedermayer

avformat/hashenc: rearrange options definition

Only the frame* muxers support the format_version option.
Use macros to ease the proliferation of identical options to
coming muxers as well.

Signed-off-by: Moritz Barsnick <barsnick at gmx.net>
Reviewed-by: James Almer <jamrial at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavformat/hashenc.c | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/libavformat/hashenc.c b/libavformat/hashenc.c
index 06fc085d18..210bfdea0e 100644
--- a/libavformat/hashenc.c
+++ b/libavformat/hashenc.c
@@ -36,18 +36,37 @@ struct HashContext {
 
 #define OFFSET(x) offsetof(struct HashContext, x)
 #define ENC AV_OPT_FLAG_ENCODING_PARAM
-#if CONFIG_HASH_MUXER || CONFIG_FRAMEHASH_MUXER
+#define HASH_OPT(defaulttype) \
+    { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = defaulttype}, 0, 0, ENC }
+#define FORMAT_VERSION_OPT \
+    { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }
+
+#if CONFIG_HASH_MUXER
 static const AVOption hash_options[] = {
-    { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = "sha256"}, 0, 0, ENC },
-    { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC },
+    HASH_OPT("sha256"),
+    { NULL },
+};
+#endif
+
+#if CONFIG_FRAMEHASH_MUXER
+static const AVOption framehash_options[] = {
+    HASH_OPT("sha256"),
+    FORMAT_VERSION_OPT,
     { NULL },
 };
 #endif
 
-#if CONFIG_MD5_MUXER || CONFIG_FRAMEMD5_MUXER
+#if CONFIG_MD5_MUXER
 static const AVOption md5_options[] = {
-    { "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = "md5"}, 0, 0, ENC },
-    { "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC },
+    HASH_OPT("md5"),
+    { NULL },
+};
+#endif
+
+#if CONFIG_FRAMEMD5_MUXER
+static const AVOption framemd5_options[] = {
+    HASH_OPT("md5"),
+    FORMAT_VERSION_OPT,
     { NULL },
 };
 #endif
@@ -219,7 +238,7 @@ static int framehash_write_trailer(struct AVFormatContext *s)
 static const AVClass framehash_class = {
     .class_name = "frame hash muxer",
     .item_name  = av_default_item_name,
-    .option     = hash_options,
+    .option     = framehash_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 
@@ -242,7 +261,7 @@ AVOutputFormat ff_framehash_muxer = {
 static const AVClass framemd5_class = {
     .class_name = "frame MD5 muxer",
     .item_name  = av_default_item_name,
-    .option     = md5_options,
+    .option     = framemd5_options,
     .version    = LIBAVUTIL_VERSION_INT,
 };
 



More information about the ffmpeg-cvslog mailing list