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@gmx.net>
Reviewed-by: James Almer <jamrial@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Moritz Barsnick 2019-09-12 11:23:04 +02:00 committed by Michael Niedermayer
parent e6018fda14
commit d214f21611

View File

@ -36,18 +36,37 @@ struct HashContext {
#define OFFSET(x) offsetof(struct HashContext, x) #define OFFSET(x) offsetof(struct HashContext, x)
#define ENC AV_OPT_FLAG_ENCODING_PARAM #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[] = { static const AVOption hash_options[] = {
{ "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = "sha256"}, 0, 0, ENC }, HASH_OPT("sha256"),
{ "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC },
{ NULL }, { NULL },
}; };
#endif #endif
#if CONFIG_MD5_MUXER || CONFIG_FRAMEMD5_MUXER #if CONFIG_FRAMEHASH_MUXER
static const AVOption framehash_options[] = {
HASH_OPT("sha256"),
FORMAT_VERSION_OPT,
{ NULL },
};
#endif
#if CONFIG_MD5_MUXER
static const AVOption md5_options[] = { static const AVOption md5_options[] = {
{ "hash", "set hash to use", OFFSET(hash_name), AV_OPT_TYPE_STRING, {.str = "md5"}, 0, 0, ENC }, HASH_OPT("md5"),
{ "format_version", "file format version", OFFSET(format_version), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 2, ENC }, { NULL },
};
#endif
#if CONFIG_FRAMEMD5_MUXER
static const AVOption framemd5_options[] = {
HASH_OPT("md5"),
FORMAT_VERSION_OPT,
{ NULL }, { NULL },
}; };
#endif #endif
@ -219,7 +238,7 @@ static int framehash_write_trailer(struct AVFormatContext *s)
static const AVClass framehash_class = { static const AVClass framehash_class = {
.class_name = "frame hash muxer", .class_name = "frame hash muxer",
.item_name = av_default_item_name, .item_name = av_default_item_name,
.option = hash_options, .option = framehash_options,
.version = LIBAVUTIL_VERSION_INT, .version = LIBAVUTIL_VERSION_INT,
}; };
@ -242,7 +261,7 @@ AVOutputFormat ff_framehash_muxer = {
static const AVClass framemd5_class = { static const AVClass framemd5_class = {
.class_name = "frame MD5 muxer", .class_name = "frame MD5 muxer",
.item_name = av_default_item_name, .item_name = av_default_item_name,
.option = md5_options, .option = framemd5_options,
.version = LIBAVUTIL_VERSION_INT, .version = LIBAVUTIL_VERSION_INT,
}; };