Просмотр исходного кода

lavfi: define macro AVFILTER_DEFINE_CLASS

The macro can be used to define consistently the internal class of a
filter, save some typing and factorize.
Stefano Sabatini 12 лет назад
Родитель
Сommit
c17808cebd

+ 2 - 8
libavfilter/af_aformat.c

@@ -46,20 +46,14 @@ typedef struct AFormatContext {
 
 #define OFFSET(x) offsetof(AFormatContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
-static const AVOption options[] = {
+static const AVOption aformat_options[] = {
     { "sample_fmts",     "A comma-separated list of sample formats.",  OFFSET(formats_str),         AV_OPT_TYPE_STRING, .flags = A },
     { "sample_rates",    "A comma-separated list of sample rates.",    OFFSET(sample_rates_str),    AV_OPT_TYPE_STRING, .flags = A },
     { "channel_layouts", "A comma-separated list of channel layouts.", OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A },
     { NULL },
 };
 
-static const AVClass aformat_class = {
-    .class_name = "aformat",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(aformat);
 
 #define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc)    \
 do {                                                                        \

+ 1 - 7
libavfilter/af_amerge.c

@@ -52,13 +52,7 @@ static const AVOption amerge_options[] = {
     {0}
 };
 
-static const AVClass amerge_class = {
-    .class_name = "amerge",
-    .item_name  = av_default_item_name,
-    .option     = amerge_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(amerge);
 
 static av_cold void uninit(AVFilterContext *ctx)
 {

+ 2 - 9
libavfilter/af_amix.c

@@ -173,7 +173,7 @@ typedef struct MixContext {
 
 #define OFFSET(x) offsetof(MixContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
-static const AVOption options[] = {
+static const AVOption amix_options[] = {
     { "inputs", "Number of inputs.",
             OFFSET(nb_inputs), AV_OPT_TYPE_INT, { 2 }, 1, 32, A },
     { "duration", "How to determine the end-of-stream.",
@@ -187,14 +187,7 @@ static const AVOption options[] = {
     { NULL },
 };
 
-static const AVClass amix_class = {
-    .class_name = "amix",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
-
+AVFILTER_DEFINE_CLASS(amix);
 
 /**
  * Update the scaling factors to apply to each input during mixing.

+ 4 - 9
libavfilter/af_asetnsamples.c

@@ -29,6 +29,7 @@
 #include "libavutil/opt.h"
 #include "avfilter.h"
 #include "audio.h"
+#include "internal.h"
 #include "formats.h"
 
 typedef struct {
@@ -42,7 +43,7 @@ typedef struct {
 
 #define OFFSET(x) offsetof(ASNSContext, x)
 
-static const AVOption asns_options[] = {
+static const AVOption asetnsamples_options[] = {
 { "pad", "pad last frame with zeros", OFFSET(pad), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
 { "p",   "pad last frame with zeros", OFFSET(pad), AV_OPT_TYPE_INT, {.dbl=1}, 0, 1 },
 { "nb_out_samples", "set the number of per-frame output samples", OFFSET(nb_out_samples), AV_OPT_TYPE_INT, {.dbl=1024}, 1, INT_MAX },
@@ -50,20 +51,14 @@ static const AVOption asns_options[] = {
 { NULL }
 };
 
-static const AVClass asns_class = {
-    .class_name = "asetnsamples",
-    .item_name  = av_default_item_name,
-    .option     = asns_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(asetnsamples);
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     ASNSContext *asns = ctx->priv;
     int err;
 
-    asns->class = &asns_class;
+    asns->class = &asetnsamples_class;
     av_opt_set_defaults(asns);
 
     if ((err = av_set_options_string(asns, args, "=", ":")) < 0) {

+ 3 - 9
libavfilter/af_asyncts.c

@@ -41,7 +41,7 @@ typedef struct ASyncContext {
 
 #define OFFSET(x) offsetof(ASyncContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
-static const AVOption options[] = {
+static const AVOption asyncts_options[] = {
     { "compensate", "Stretch/squeeze the data to make it match the timestamps", OFFSET(resample),      AV_OPT_TYPE_INT,   { 0 },   0, 1,       A },
     { "min_delta",  "Minimum difference between timestamps and audio data "
                     "(in seconds) to trigger padding/trimmin the data.",        OFFSET(min_delta_sec), AV_OPT_TYPE_FLOAT, { 0.1 }, 0, INT_MAX, A },
@@ -49,20 +49,14 @@ static const AVOption options[] = {
     { NULL },
 };
 
-static const AVClass async_class = {
-    .class_name = "asyncts",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(asyncts);
 
 static int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
     ASyncContext *s = ctx->priv;
     int ret;
 
-    s->class = &async_class;
+    s->class = &asyncts_class;
     av_opt_set_defaults(s);
 
     if ((ret = av_set_options_string(s, args, "=", ":")) < 0) {

+ 2 - 8
libavfilter/af_channelsplit.c

@@ -40,18 +40,12 @@ typedef struct ChannelSplitContext {
 
 #define OFFSET(x) offsetof(ChannelSplitContext, x)
 #define A AV_OPT_FLAG_AUDIO_PARAM
-static const AVOption options[] = {
+static const AVOption channelsplit_options[] = {
     { "channel_layout", "Input channel layout.", OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, { .str = "stereo" }, .flags = A },
     { NULL },
 };
 
-static const AVClass channelsplit_class = {
-    .class_name = "channelsplit",
-    .item_name  = av_default_item_name,
-    .option     = options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(channelsplit);
 
 static int init(AVFilterContext *ctx, const char *arg, void *opaque)
 {

+ 2 - 7
libavfilter/af_silencedetect.c

@@ -28,6 +28,7 @@
 #include "audio.h"
 #include "formats.h"
 #include "avfilter.h"
+#include "internal.h"
 
 typedef struct {
     const AVClass *class;
@@ -48,13 +49,7 @@ static const AVOption silencedetect_options[] = {
     { NULL },
 };
 
-static const AVClass silencedetect_class = {
-    .class_name = "silencedetect",
-    .item_name  = av_default_item_name,
-    .option     = silencedetect_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(silencedetect);
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 {

+ 3 - 9
libavfilter/asrc_aevalsrc.c

@@ -66,7 +66,7 @@ typedef struct {
 
 #define OFFSET(x) offsetof(EvalContext, x)
 
-static const AVOption eval_options[]= {
+static const AVOption aevalsrc_options[]= {
     { "nb_samples",  "set the number of samples per requested frame", OFFSET(nb_samples),      AV_OPT_TYPE_INT,    {.dbl = 1024},    0,        INT_MAX },
     { "n",           "set the number of samples per requested frame", OFFSET(nb_samples),      AV_OPT_TYPE_INT,    {.dbl = 1024},    0,        INT_MAX },
     { "sample_rate", "set the sample rate",                           OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, CHAR_MIN, CHAR_MAX },
@@ -78,13 +78,7 @@ static const AVOption eval_options[]= {
 {NULL},
 };
 
-static const AVClass eval_class = {
-    .class_name = "aevalsrc",
-    .item_name  = av_default_item_name,
-    .option     = eval_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(aevalsrc);
 
 static int init(AVFilterContext *ctx, const char *args, void *opaque)
 {
@@ -93,7 +87,7 @@ static int init(AVFilterContext *ctx, const char *args, void *opaque)
     char *expr, *buf, *bufptr;
     int ret, i;
 
-    eval->class = &eval_class;
+    eval->class = &aevalsrc_class;
     av_opt_set_defaults(eval);
 
     /* parse expressions */

+ 1 - 7
libavfilter/asrc_anullsrc.c

@@ -54,13 +54,7 @@ static const AVOption anullsrc_options[]= {
     { NULL },
 };
 
-static const AVClass anullsrc_class = {
-    .class_name = "anullsrc",
-    .item_name  = av_default_item_name,
-    .option     = anullsrc_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(anullsrc);
 
 static int init(AVFilterContext *ctx, const char *args, void *opaque)
 {

+ 2 - 7
libavfilter/avf_showwaves.c

@@ -30,6 +30,7 @@
 #include "formats.h"
 #include "audio.h"
 #include "video.h"
+#include "internal.h"
 
 typedef struct {
     const AVClass *class;
@@ -54,13 +55,7 @@ static const AVOption showwaves_options[] = {
     { NULL },
 };
 
-static const AVClass showwaves_class = {
-    .class_name = "showwaves",
-    .item_name  = av_default_item_name,
-    .option     = showwaves_options,
-    .version    = LIBAVUTIL_VERSION_INT,
-    .category   = AV_CLASS_CATEGORY_FILTER,
-};
+AVFILTER_DEFINE_CLASS(showwaves);
 
 static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
 {

Некоторые файлы не были показаны из-за большого количества измененных файлов