Merge commit '5c439b41d0489412c0a4cf6dfb98915251677b8e'
authorMichael Niedermayer <michaelni@gmx.at>
Mon, 28 Oct 2013 12:07:05 +0000 (13:07 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Mon, 28 Oct 2013 12:07:05 +0000 (13:07 +0100)
* commit '5c439b41d0489412c0a4cf6dfb98915251677b8e':
  avfilter: have avfilter_get_by_name return const for next bump

Conflicts:
libavfilter/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavfilter/avfilter.c
libavfilter/avfilter.h
libavfilter/version.h

@@@ -381,85 -270,14 +381,88 @@@ int ff_poll_frame(AVFilterLink *link
      return min;
  }
  
 +static const char *const var_names[] = {   "t",   "n",   "pos",        NULL };
 +enum                                   { VAR_T, VAR_N, VAR_POS, 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 = 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;
  
+ #if !FF_API_NOCONST_GET_NAME
+ const
+ #endif
  AVFilter *avfilter_get_by_name(const char *name)
  {
 -    AVFilter *f = NULL;
 +    const AVFilter *f = NULL;
  
      if (!name)
          return NULL;
Simple merge
  #ifndef FF_API_OLD_FILTER_REGISTER
  #define FF_API_OLD_FILTER_REGISTER          (LIBAVFILTER_VERSION_MAJOR < 4)
  #endif
 +#ifndef FF_API_OLD_GRAPH_PARSE
 +#define FF_API_OLD_GRAPH_PARSE              (LIBAVFILTER_VERSION_MAJOR < 4)
 +#endif
 +#ifndef FF_API_DRAWTEXT_OLD_TIMELINE
 +#define FF_API_DRAWTEXT_OLD_TIMELINE        (LIBAVFILTER_VERSION_MAJOR < 4)
 +#endif
+ #ifndef FF_API_NOCONST_GET_NAME
+ #define FF_API_NOCONST_GET_NAME             (LIBAVFILTER_VERSION_MAJOR < 4)
+ #endif
  
  #endif /* AVFILTER_VERSION_H */