diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2014-07-28 07:16:03 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2014-07-28 07:16:03 +0400 |
commit | a06c14a48ee9af91e4146f26a578d99d3494d0eb (patch) | |
tree | 64a9462c09dd3c4f740e86036d5ce031182e59cf /libavfilter/vf_spp.c | |
parent | cab8fc624b401624be938c59b23c23136d5c5cb5 (diff) |
avfilter/vf_spp: support setting dct avoptions from the filter graph string
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavfilter/vf_spp.c')
-rw-r--r-- | libavfilter/vf_spp.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/libavfilter/vf_spp.c b/libavfilter/vf_spp.c index 3ce77cf6cc..bcaf2c920f 100644 --- a/libavfilter/vf_spp.c +++ b/libavfilter/vf_spp.c @@ -44,6 +44,17 @@ enum mode { NB_MODES }; +static const AVClass *child_class_next(const AVClass *prev) +{ + return prev ? NULL : avcodec_dct_get_class(); +} + +static void *child_next(void *obj, void *prev) +{ + SPPContext *s = obj; + return prev ? NULL : s->dct; +} + #define OFFSET(x) offsetof(SPPContext, x) #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM static const AVOption spp_options[] = { @@ -56,7 +67,15 @@ static const AVOption spp_options[] = { { NULL } }; -AVFILTER_DEFINE_CLASS(spp); +static const AVClass spp_class = { + .class_name = "spp", + .item_name = av_default_item_name, + .option = spp_options, + .version = LIBAVUTIL_VERSION_INT, + .category = AV_CLASS_CATEGORY_FILTER, + .child_class_next = child_class_next, + .child_next = child_next, +}; // XXX: share between filters? DECLARE_ALIGNED(8, static const uint8_t, ldither)[8][8] = { @@ -372,15 +391,27 @@ static int process_command(AVFilterContext *ctx, const char *cmd, const char *ar return AVERROR(ENOSYS); } -static av_cold int init(AVFilterContext *ctx) +static av_cold int init_dict(AVFilterContext *ctx, AVDictionary **opts) { SPPContext *spp = ctx->priv; + int ret; spp->avctx = avcodec_alloc_context3(NULL); spp->dct = avcodec_dct_alloc(); if (!spp->avctx || !spp->dct) return AVERROR(ENOMEM); ff_pixblockdsp_init(&spp->pdsp, spp->avctx); + + if (opts) { + AVDictionaryEntry *e = NULL; + + while ((e = av_dict_get(*opts, "", e, AV_DICT_IGNORE_SUFFIX))) { + if ((ret = av_opt_set(spp->dct, e->key, e->value, 0)) < 0) + return ret; + } + av_dict_free(opts); + } + avcodec_dct_init(spp->dct); spp->store_slice = store_slice_c; switch (spp->mode) { @@ -428,7 +459,7 @@ AVFilter ff_vf_spp = { .name = "spp", .description = NULL_IF_CONFIG_SMALL("Apply a simple post processing filter."), .priv_size = sizeof(SPPContext), - .init = init, + .init_dict = init_dict, .uninit = uninit, .query_formats = query_formats, .inputs = spp_inputs, |