Message ID | 1572778204-165552-1-git-send-email-leozhang@qiyi.com |
---|---|
State | New |
Headers | show |
ping, at the beginning of the new week:) leozhang <leozhang@qiyi.com> 于2019年11月3日周日 下午6:50写道: > > Reviewed-by: Paul B Mahol <onemda@gmail.com> > Reviewed-by: Jun Zhao <mypopy@gmail.com> > Signed-off-by: leozhang <leozhang@qiyi.com> > --- > libavfilter/vf_bilateral.c | 39 ++++++++++++++++++++++++++++++++++----- > 1 file changed, 34 insertions(+), 5 deletions(-) > > diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c > index 3c9d800..ba3631c 100644 > --- a/libavfilter/vf_bilateral.c > +++ b/libavfilter/vf_bilateral.c > @@ -29,6 +29,8 @@ > #include "internal.h" > #include "video.h" > > +#include <float.h> > + > typedef struct BilateralContext { > const AVClass *class; > > @@ -54,7 +56,7 @@ typedef struct BilateralContext { > } BilateralContext; > > #define OFFSET(x) offsetof(BilateralContext, x) > -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM > > static const AVOption bilateral_options[] = { > { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 10, FLAGS }, > @@ -91,19 +93,27 @@ static int query_formats(AVFilterContext *ctx) > return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > } > > -static int config_input(AVFilterLink *inlink) > +static int init_lut(BilateralContext *s) > { > - BilateralContext *s = inlink->dst->priv; > - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > float inv_sigma_range; > > - s->depth = desc->comp[0].depth; > inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1)); > > //compute a lookup table > for (int i = 0; i < (1 << s->depth); i++) > s->range_table[i] = expf(-i * inv_sigma_range); > > + return 0; > +} > + > +static int config_input(AVFilterLink *inlink) > +{ > + BilateralContext *s = inlink->dst->priv; > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > + > + s->depth = desc->comp[0].depth; > + init_lut(s); > + > s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); > s->planewidth[0] = s->planewidth[3] = inlink->w; > s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); > @@ -325,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) > return ff_filter_frame(outlink, out); > } > > +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, > + char *res, int res_len, int flags) > +{ > + BilateralContext *s = ctx->priv; > + int ret; > + float old_sigmaR = s->sigmaR; > + > + if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags)) < 0) { > + return ret; > + } > + > + if (fabs(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < 0) { > + s->sigmaR = old_sigmaR; > + } > + > + return ret; > +} > + > static av_cold void uninit(AVFilterContext *ctx) > { > BilateralContext *s = ctx->priv; > @@ -367,4 +395,5 @@ AVFilter ff_vf_bilateral = { > .inputs = bilateral_inputs, > .outputs = bilateral_outputs, > .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, > + .process_command = process_command, > }; > -- > 1.8.3.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
I submit new patchset. Have separate functional and non-functional changes. Also updated doc, inspired by Paul's commit https://github.com/FFmpeg/FFmpeg/commit/45f03cdd20c3f9a83d4955fa32ffdc287229ccfd Tao Zhang <nowerzt@gmail.com> 于2019年11月11日周一 下午7:55写道: > > ping, at the beginning of the new week:) > > leozhang <leozhang@qiyi.com> 于2019年11月3日周日 下午6:50写道: > > > > > Reviewed-by: Paul B Mahol <onemda@gmail.com> > > Reviewed-by: Jun Zhao <mypopy@gmail.com> > > Signed-off-by: leozhang <leozhang@qiyi.com> > > --- > > libavfilter/vf_bilateral.c | 39 ++++++++++++++++++++++++++++++++++----- > > 1 file changed, 34 insertions(+), 5 deletions(-) > > > > diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c > > index 3c9d800..ba3631c 100644 > > --- a/libavfilter/vf_bilateral.c > > +++ b/libavfilter/vf_bilateral.c > > @@ -29,6 +29,8 @@ > > #include "internal.h" > > #include "video.h" > > > > +#include <float.h> > > + > > typedef struct BilateralContext { > > const AVClass *class; > > > > @@ -54,7 +56,7 @@ typedef struct BilateralContext { > > } BilateralContext; > > > > #define OFFSET(x) offsetof(BilateralContext, x) > > -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > > +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM > > > > static const AVOption bilateral_options[] = { > > { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 10, FLAGS }, > > @@ -91,19 +93,27 @@ static int query_formats(AVFilterContext *ctx) > > return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > > } > > > > -static int config_input(AVFilterLink *inlink) > > +static int init_lut(BilateralContext *s) > > { > > - BilateralContext *s = inlink->dst->priv; > > - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > > float inv_sigma_range; > > > > - s->depth = desc->comp[0].depth; > > inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1)); > > > > //compute a lookup table > > for (int i = 0; i < (1 << s->depth); i++) > > s->range_table[i] = expf(-i * inv_sigma_range); > > > > + return 0; > > +} > > + > > +static int config_input(AVFilterLink *inlink) > > +{ > > + BilateralContext *s = inlink->dst->priv; > > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > > + > > + s->depth = desc->comp[0].depth; > > + init_lut(s); > > + > > s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); > > s->planewidth[0] = s->planewidth[3] = inlink->w; > > s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); > > @@ -325,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) > > return ff_filter_frame(outlink, out); > > } > > > > +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, > > + char *res, int res_len, int flags) > > +{ > > + BilateralContext *s = ctx->priv; > > + int ret; > > + float old_sigmaR = s->sigmaR; > > + > > + if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags)) < 0) { > > + return ret; > > + } > > + > > + if (fabs(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < 0) { > > + s->sigmaR = old_sigmaR; > > + } > > + > > + return ret; > > +} > > + > > static av_cold void uninit(AVFilterContext *ctx) > > { > > BilateralContext *s = ctx->priv; > > @@ -367,4 +395,5 @@ AVFilter ff_vf_bilateral = { > > .inputs = bilateral_inputs, > > .outputs = bilateral_outputs, > > .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, > > + .process_command = process_command, > > }; > > -- > > 1.8.3.1 > > > > _______________________________________________ > > ffmpeg-devel mailing list > > ffmpeg-devel@ffmpeg.org > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > To unsubscribe, visit link above, or email > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
The new patchsets are https://patchwork.ffmpeg.org/patch/16279/ https://patchwork.ffmpeg.org/patch/16280/ Please review it, thx Tao Zhang <nowerzt@gmail.com> 于2019年11月15日周五 下午4:38写道: > > I submit new patchset. Have separate functional and non-functional > changes. Also updated doc, inspired by Paul's commit > https://github.com/FFmpeg/FFmpeg/commit/45f03cdd20c3f9a83d4955fa32ffdc287229ccfd > > Tao Zhang <nowerzt@gmail.com> 于2019年11月11日周一 下午7:55写道: > > > > ping, at the beginning of the new week:) > > > > leozhang <leozhang@qiyi.com> 于2019年11月3日周日 下午6:50写道: > > > > > > > > Reviewed-by: Paul B Mahol <onemda@gmail.com> > > > Reviewed-by: Jun Zhao <mypopy@gmail.com> > > > Signed-off-by: leozhang <leozhang@qiyi.com> > > > --- > > > libavfilter/vf_bilateral.c | 39 ++++++++++++++++++++++++++++++++++----- > > > 1 file changed, 34 insertions(+), 5 deletions(-) > > > > > > diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c > > > index 3c9d800..ba3631c 100644 > > > --- a/libavfilter/vf_bilateral.c > > > +++ b/libavfilter/vf_bilateral.c > > > @@ -29,6 +29,8 @@ > > > #include "internal.h" > > > #include "video.h" > > > > > > +#include <float.h> > > > + > > > typedef struct BilateralContext { > > > const AVClass *class; > > > > > > @@ -54,7 +56,7 @@ typedef struct BilateralContext { > > > } BilateralContext; > > > > > > #define OFFSET(x) offsetof(BilateralContext, x) > > > -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM > > > +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM > > > > > > static const AVOption bilateral_options[] = { > > > { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 10, FLAGS }, > > > @@ -91,19 +93,27 @@ static int query_formats(AVFilterContext *ctx) > > > return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); > > > } > > > > > > -static int config_input(AVFilterLink *inlink) > > > +static int init_lut(BilateralContext *s) > > > { > > > - BilateralContext *s = inlink->dst->priv; > > > - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > > > float inv_sigma_range; > > > > > > - s->depth = desc->comp[0].depth; > > > inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1)); > > > > > > //compute a lookup table > > > for (int i = 0; i < (1 << s->depth); i++) > > > s->range_table[i] = expf(-i * inv_sigma_range); > > > > > > + return 0; > > > +} > > > + > > > +static int config_input(AVFilterLink *inlink) > > > +{ > > > + BilateralContext *s = inlink->dst->priv; > > > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); > > > + > > > + s->depth = desc->comp[0].depth; > > > + init_lut(s); > > > + > > > s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); > > > s->planewidth[0] = s->planewidth[3] = inlink->w; > > > s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); > > > @@ -325,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) > > > return ff_filter_frame(outlink, out); > > > } > > > > > > +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, > > > + char *res, int res_len, int flags) > > > +{ > > > + BilateralContext *s = ctx->priv; > > > + int ret; > > > + float old_sigmaR = s->sigmaR; > > > + > > > + if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags)) < 0) { > > > + return ret; > > > + } > > > + > > > + if (fabs(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < 0) { > > > + s->sigmaR = old_sigmaR; > > > + } > > > + > > > + return ret; > > > +} > > > + > > > static av_cold void uninit(AVFilterContext *ctx) > > > { > > > BilateralContext *s = ctx->priv; > > > @@ -367,4 +395,5 @@ AVFilter ff_vf_bilateral = { > > > .inputs = bilateral_inputs, > > > .outputs = bilateral_outputs, > > > .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, > > > + .process_command = process_command, > > > }; > > > -- > > > 1.8.3.1 > > > > > > _______________________________________________ > > > ffmpeg-devel mailing list > > > ffmpeg-devel@ffmpeg.org > > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > > > > > To unsubscribe, visit link above, or email > > > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff --git a/libavfilter/vf_bilateral.c b/libavfilter/vf_bilateral.c index 3c9d800..ba3631c 100644 --- a/libavfilter/vf_bilateral.c +++ b/libavfilter/vf_bilateral.c @@ -29,6 +29,8 @@ #include "internal.h" #include "video.h" +#include <float.h> + typedef struct BilateralContext { const AVClass *class; @@ -54,7 +56,7 @@ typedef struct BilateralContext { } BilateralContext; #define OFFSET(x) offsetof(BilateralContext, x) -#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM +#define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_RUNTIME_PARAM static const AVOption bilateral_options[] = { { "sigmaS", "set spatial sigma", OFFSET(sigmaS), AV_OPT_TYPE_FLOAT, {.dbl=0.1}, 0.0, 10, FLAGS }, @@ -91,19 +93,27 @@ static int query_formats(AVFilterContext *ctx) return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts)); } -static int config_input(AVFilterLink *inlink) +static int init_lut(BilateralContext *s) { - BilateralContext *s = inlink->dst->priv; - const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); float inv_sigma_range; - s->depth = desc->comp[0].depth; inv_sigma_range = 1.0f / (s->sigmaR * ((1 << s->depth) - 1)); //compute a lookup table for (int i = 0; i < (1 << s->depth); i++) s->range_table[i] = expf(-i * inv_sigma_range); + return 0; +} + +static int config_input(AVFilterLink *inlink) +{ + BilateralContext *s = inlink->dst->priv; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + + s->depth = desc->comp[0].depth; + init_lut(s); + s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w); s->planewidth[0] = s->planewidth[3] = inlink->w; s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h); @@ -325,6 +335,24 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) return ff_filter_frame(outlink, out); } +static int process_command(AVFilterContext *ctx, const char *cmd, const char *args, + char *res, int res_len, int flags) +{ + BilateralContext *s = ctx->priv; + int ret; + float old_sigmaR = s->sigmaR; + + if ((ret = ff_filter_process_command(ctx, cmd, args, res, res_len, flags)) < 0) { + return ret; + } + + if (fabs(old_sigmaR - s->sigmaR) > FLT_EPSILON && (ret = init_lut(s)) < 0) { + s->sigmaR = old_sigmaR; + } + + return ret; +} + static av_cold void uninit(AVFilterContext *ctx) { BilateralContext *s = ctx->priv; @@ -367,4 +395,5 @@ AVFilter ff_vf_bilateral = { .inputs = bilateral_inputs, .outputs = bilateral_outputs, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, + .process_command = process_command, };