ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Sat Oct 21 15:40:14 2017 -0300| [d1b1a65662e3657ba05aa76023dde19712470f58] | committer: James Almer
Merge commit '96a47364d1cf346a5d0437e054b1b10d44d8d969' * commit '96a47364d1cf346a5d0437e054b1b10d44d8d969': lavfi: Drop deprecated non-const filter retrieval Merged-by: James Almer <jamr...@gmail.com> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d1b1a65662e3657ba05aa76023dde19712470f58 --- libavfilter/avfilter.c | 5 +---- libavfilter/avfilter.h | 5 +---- libavfilter/avfiltergraph.c | 4 ++-- libavfilter/version.h | 3 --- 4 files changed, 4 insertions(+), 13 deletions(-) diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index 6740cd3755..bc9e60bb85 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -576,10 +576,7 @@ int avfilter_process_command(AVFilterContext *filter, const char *cmd, const cha static AVFilter *first_filter; static AVFilter **last_filter = &first_filter; -#if !FF_API_NOCONST_GET_NAME -const -#endif -AVFilter *avfilter_get_by_name(const char *name) +const AVFilter *avfilter_get_by_name(const char *name) { const AVFilter *f = NULL; diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 6be7625676..47546c15e5 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -699,10 +699,7 @@ int avfilter_register(AVFilter *filter); * @return the filter definition, if any matching one is registered. * NULL if none found. */ -#if !FF_API_NOCONST_GET_NAME -const -#endif -AVFilter *avfilter_get_by_name(const char *name); +const AVFilter *avfilter_get_by_name(const char *name); /** * Iterate over all registered filters. diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 76a3a2b8ed..69cf26896d 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -492,7 +492,7 @@ static int query_formats(AVFilterGraph *graph, AVClass *log_ctx) if (convert_needed) { AVFilterContext *convert; - AVFilter *filter; + const AVFilter *filter; AVFilterLink *inlink, *outlink; char scale_args[256]; char inst_name[30]; @@ -1218,7 +1218,7 @@ static int graph_insert_fifos(AVFilterGraph *graph, AVClass *log_ctx) for (j = 0; j < f->nb_inputs; j++) { AVFilterLink *link = f->inputs[j]; AVFilterContext *fifo_ctx; - AVFilter *fifo; + const AVFilter *fifo; char name[32]; if (!link->dstpad->needs_fifo) diff --git a/libavfilter/version.h b/libavfilter/version.h index 2d5caa8105..5bcf9b4df0 100644 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@ -52,9 +52,6 @@ #ifndef FF_API_OLD_FILTER_OPTS_ERROR #define FF_API_OLD_FILTER_OPTS_ERROR (LIBAVFILTER_VERSION_MAJOR < 8) #endif -#ifndef FF_API_NOCONST_GET_NAME -#define FF_API_NOCONST_GET_NAME (LIBAVFILTER_VERSION_MAJOR < 7) -#endif #ifndef FF_API_LAVR_OPTS #define FF_API_LAVR_OPTS (LIBAVFILTER_VERSION_MAJOR < 8) #endif ====================================================================== diff --cc libavfilter/avfilter.c index 6740cd3755,83c1a7c20d..bc9e60bb85 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@@ -483,103 -290,9 +483,100 @@@ int ff_poll_frame(AVFilterLink *link return min; } +static const char *const var_names[] = { + "t", + "n", + "pos", + "w", + "h", + NULL +}; + +enum { + VAR_T, + VAR_N, + VAR_POS, + VAR_W, + VAR_H, + VAR_VARS_NB +}; + +static int set_enable_expr(AVFilterContext *ctx, const char *expr) +{ + int ret; + char *expr_dup; + AVExpr *old = ctx->enable; + + if (!(ctx->filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)) { + av_log(ctx, AV_LOG_ERROR, "Timeline ('enable' option) not supported " + "with filter '%s'\n", ctx->filter->name); + return AVERROR_PATCHWELCOME; + } + + expr_dup = av_strdup(expr); + if (!expr_dup) + return AVERROR(ENOMEM); + + if (!ctx->var_values) { + ctx->var_values = av_calloc(VAR_VARS_NB, sizeof(*ctx->var_values)); + if (!ctx->var_values) { + av_free(expr_dup); + return AVERROR(ENOMEM); + } + } + + ret = av_expr_parse((AVExpr**)&ctx->enable, expr_dup, var_names, + NULL, NULL, NULL, NULL, 0, ctx->priv); + if (ret < 0) { + av_log(ctx->priv, AV_LOG_ERROR, + "Error when evaluating the expression '%s' for enable\n", + expr_dup); + av_free(expr_dup); + return ret; + } + + av_expr_free(old); + av_free(ctx->enable_str); + ctx->enable_str = expr_dup; + return 0; +} + +void ff_update_link_current_pts(AVFilterLink *link, int64_t pts) +{ + if (pts == AV_NOPTS_VALUE) + return; + link->current_pts = pts; + link->current_pts_us = av_rescale_q(pts, link->time_base, AV_TIME_BASE_Q); + /* TODO use duration */ + if (link->graph && link->age_index >= 0) + ff_avfilter_graph_update_heap(link->graph, link); +} + +int avfilter_process_command(AVFilterContext *filter, const char *cmd, const char *arg, char *res, int res_len, int flags) +{ + if(!strcmp(cmd, "ping")){ + char local_res[256] = {0}; + + if (!res) { + res = local_res; + res_len = sizeof(local_res); + } + av_strlcatf(res, res_len, "pong from:%s %s\n", filter->filter->name, filter->name); + if (res == local_res) + av_log(filter, AV_LOG_INFO, "%s", res); + return 0; + }else if(!strcmp(cmd, "enable")) { + return set_enable_expr(filter, arg); + }else if(filter->filter->process_command) { + return filter->filter->process_command(filter, cmd, arg, res, res_len, flags); + } + return AVERROR(ENOSYS); +} + static AVFilter *first_filter; +static AVFilter **last_filter = &first_filter; - #if !FF_API_NOCONST_GET_NAME - const - #endif - AVFilter *avfilter_get_by_name(const char *name) + const AVFilter *avfilter_get_by_name(const char *name) { const AVFilter *f = NULL; diff --cc libavfilter/avfiltergraph.c index 76a3a2b8ed,a0f797e283..69cf26896d --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@@ -447,52 -276,24 +447,52 @@@ static int query_formats(AVFilterGraph if (!link) continue; - if (link->in_formats != link->out_formats && - !ff_merge_formats(link->in_formats, - link->out_formats)) - convert_needed = 1; - if (link->type == AVMEDIA_TYPE_AUDIO) { - if (link->in_channel_layouts != link->out_channel_layouts && - !ff_merge_channel_layouts(link->in_channel_layouts, - link->out_channel_layouts)) - convert_needed = 1; - if (link->in_samplerates != link->out_samplerates && - !ff_merge_samplerates(link->in_samplerates, - link->out_samplerates)) + if (link->in_formats != link->out_formats + && link->in_formats && link->out_formats) + if (!can_merge_formats(link->in_formats, link->out_formats, + link->type, 0)) convert_needed = 1; + if (link->type == AVMEDIA_TYPE_AUDIO) { + if (link->in_samplerates != link->out_samplerates + && link->in_samplerates && link->out_samplerates) + if (!can_merge_formats(link->in_samplerates, + link->out_samplerates, + 0, 1)) + convert_needed = 1; + } + +#define MERGE_DISPATCH(field, statement) \ + if (!(link->in_ ## field && link->out_ ## field)) { \ + count_delayed++; \ + } else if (link->in_ ## field == link->out_ ## field) { \ + count_already_merged++; \ + } else if (!convert_needed) { \ + count_merged++; \ + statement \ } + if (link->type == AVMEDIA_TYPE_AUDIO) { + MERGE_DISPATCH(channel_layouts, + if (!ff_merge_channel_layouts(link->in_channel_layouts, + link->out_channel_layouts)) + convert_needed = 1; + ) + MERGE_DISPATCH(samplerates, + if (!ff_merge_samplerates(link->in_samplerates, + link->out_samplerates)) + convert_needed = 1; + ) + } + MERGE_DISPATCH(formats, + if (!ff_merge_formats(link->in_formats, link->out_formats, + link->type)) + convert_needed = 1; + ) +#undef MERGE_DISPATCH + if (convert_needed) { AVFilterContext *convert; - AVFilter *filter; + const AVFilter *filter; AVFilterLink *inlink, *outlink; char scale_args[256]; char inst_name[30]; diff --cc libavfilter/version.h index 2d5caa8105,62fc97dd27..5bcf9b4df0 --- a/libavfilter/version.h +++ b/libavfilter/version.h @@@ -49,14 -49,4 +49,11 @@@ * the public API and may change, break or disappear at any time. */ +#ifndef FF_API_OLD_FILTER_OPTS_ERROR +#define FF_API_OLD_FILTER_OPTS_ERROR (LIBAVFILTER_VERSION_MAJOR < 8) +#endif - #ifndef FF_API_NOCONST_GET_NAME - #define FF_API_NOCONST_GET_NAME (LIBAVFILTER_VERSION_MAJOR < 7) - #endif +#ifndef FF_API_LAVR_OPTS +#define FF_API_LAVR_OPTS (LIBAVFILTER_VERSION_MAJOR < 8) +#endif + #endif /* AVFILTER_VERSION_H */ _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog