]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '88fd836a015a5f3380df74592e440e7d1e5b8000'
authorJames Almer <jamrial@gmail.com>
Sat, 21 Oct 2017 18:27:03 +0000 (15:27 -0300)
committerJames Almer <jamrial@gmail.com>
Sat, 21 Oct 2017 18:27:03 +0000 (15:27 -0300)
* commit '88fd836a015a5f3380df74592e440e7d1e5b8000':
  lavfi: Drop deprecated way of passing options for a few filters

Merged-by: James Almer <jamrial@gmail.com>
1  2 
libavfilter/af_channelmap.c
libavfilter/af_join.c
libavfilter/avfilter.c
libavfilter/buffersrc.c
libavfilter/version.h
libavfilter/vf_aspect.c

Simple merge
Simple merge
index f0f849b32616485ffcda2c53497bf0e3b23d6bd3,d9c204e7660f518df294423978caddbb0ea31cb1..a08895dacf9241b0ccd90ae06ab47e1b64f068c5
@@@ -996,91 -624,13 +996,82 @@@ int avfilter_init_str(AVFilterContext *
              return AVERROR(EINVAL);
          }
  
- #if FF_API_OLD_FILTER_OPTS || FF_API_OLD_FILTER_OPTS_ERROR
 -        if (strchr(args, '=')) {
 -            /* assume a list of key1=value1:key2=value2:... */
 -            ret = av_dict_parse_string(&options, args, "=", ":", 0);
++#if FF_API_OLD_FILTER_OPTS_ERROR
 +            if (   !strcmp(filter->filter->name, "format")     ||
 +                   !strcmp(filter->filter->name, "noformat")   ||
 +                   !strcmp(filter->filter->name, "frei0r")     ||
 +                   !strcmp(filter->filter->name, "frei0r_src") ||
 +                   !strcmp(filter->filter->name, "ocv")        ||
 +                   !strcmp(filter->filter->name, "pan")        ||
 +                   !strcmp(filter->filter->name, "pp")         ||
 +                   !strcmp(filter->filter->name, "aevalsrc")) {
 +            /* a hack for compatibility with the old syntax
 +             * replace colons with |s */
 +            char *copy = av_strdup(args);
 +            char *p    = copy;
 +            int nb_leading = 0; // number of leading colons to skip
 +            int deprecated = 0;
 +
 +            if (!copy) {
 +                ret = AVERROR(ENOMEM);
 +                goto fail;
 +            }
 +
 +            if (!strcmp(filter->filter->name, "frei0r") ||
 +                !strcmp(filter->filter->name, "ocv"))
 +                nb_leading = 1;
 +            else if (!strcmp(filter->filter->name, "frei0r_src"))
 +                nb_leading = 3;
 +
 +            while (nb_leading--) {
 +                p = strchr(p, ':');
 +                if (!p) {
 +                    p = copy + strlen(copy);
 +                    break;
 +                }
 +                p++;
 +            }
 +
 +            deprecated = strchr(p, ':') != NULL;
 +
 +            if (!strcmp(filter->filter->name, "aevalsrc")) {
 +                deprecated = 0;
 +                while ((p = strchr(p, ':')) && p[1] != ':') {
 +                    const char *epos = strchr(p + 1, '=');
 +                    const char *spos = strchr(p + 1, ':');
 +                    const int next_token_is_opt = epos && (!spos || epos < spos);
 +                    if (next_token_is_opt) {
 +                        p++;
 +                        break;
 +                    }
 +                    /* next token does not contain a '=', assume a channel expression */
 +                    deprecated = 1;
 +                    *p++ = '|';
 +                }
 +                if (p && *p == ':') { // double sep '::' found
 +                    deprecated = 1;
 +                    memmove(p, p + 1, strlen(p));
 +                }
 +            } else
 +            while ((p = strchr(p, ':')))
 +                *p++ = '|';
 +
- #if FF_API_OLD_FILTER_OPTS
-             if (deprecated)
-                 av_log(filter, AV_LOG_WARNING, "This syntax is deprecated. Use "
-                        "'|' to separate the list items.\n");
-             av_log(filter, AV_LOG_DEBUG, "compat: called with args=[%s]\n", copy);
-             ret = process_options(filter, &options, copy);
- #else
 +            if (deprecated) {
 +                av_log(filter, AV_LOG_ERROR, "This syntax is deprecated. Use "
 +                       "'|' to separate the list items ('%s' instead of '%s')\n",
 +                       copy, args);
 +                ret = AVERROR(EINVAL);
 +            } else {
 +                ret = process_options(filter, &options, copy);
 +            }
- #endif
 +            av_freep(&copy);
 +
              if (ret < 0)
                  goto fail;
 -        } else {
 -            ret = process_unnamed_options(filter, &options, args);
 +        } else
 +#endif
 +        {
 +            ret = process_options(filter, &options, args);
              if (ret < 0)
                  goto fail;
          }
index ad5aedd5f7de937c6b4db64683ef612db690ef6f,df0097151479df539197bc9b5a4535b7a0aae3e6..cd56f8ca457e4c2b3d6a75e00728eed2e12a7589
@@@ -290,33 -236,17 +290,25 @@@ static av_cold int init_video(AVFilterC
      return 0;
  }
  
 +unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
 +{
 +    return ((BufferSourceContext *)buffer_src->priv)->nb_failed_requests;
 +}
 +
  #define OFFSET(x) offsetof(BufferSourceContext, x)
 -#define A AV_OPT_FLAG_AUDIO_PARAM
 -#define V AV_OPT_FLAG_VIDEO_PARAM
 +#define A AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_AUDIO_PARAM
 +#define V AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
  
 -static const AVOption video_options[] = {
 +static const AVOption buffer_options[] = {
      { "width",         NULL,                     OFFSET(w),                AV_OPT_TYPE_INT,      { .i64 = 0 }, 0, INT_MAX, V },
 +    { "video_size",    NULL,                     OFFSET(w),                AV_OPT_TYPE_IMAGE_SIZE,                .flags = V },
      { "height",        NULL,                     OFFSET(h),                AV_OPT_TYPE_INT,      { .i64 = 0 }, 0, INT_MAX, V },
 -    { "pix_fmt",       NULL,                     OFFSET(pix_fmt_str),      AV_OPT_TYPE_STRING,                    .flags = V },
 +    { "pix_fmt",       NULL,                     OFFSET(pix_fmt),          AV_OPT_TYPE_PIXEL_FMT, { .i64 = AV_PIX_FMT_NONE }, .min = AV_PIX_FMT_NONE, .max = INT_MAX, .flags = V },
- #if FF_API_OLD_FILTER_OPTS
-     /* those 4 are for compatibility with the old option passing system where each filter
-      * did its own parsing */
-     { "time_base_num", "deprecated, do not use", OFFSET(time_base.num),    AV_OPT_TYPE_INT,      { .i64 = 0 }, 0, INT_MAX, V },
-     { "time_base_den", "deprecated, do not use", OFFSET(time_base.den),    AV_OPT_TYPE_INT,      { .i64 = 0 }, 0, INT_MAX, V },
-     { "sar_num",       "deprecated, do not use", OFFSET(pixel_aspect.num), AV_OPT_TYPE_INT,      { .i64 = 0 }, 0, INT_MAX, V },
-     { "sar_den",       "deprecated, do not use", OFFSET(pixel_aspect.den), AV_OPT_TYPE_INT,      { .i64 = 0 }, 0, INT_MAX, V },
- #endif
      { "sar",           "sample aspect ratio",    OFFSET(pixel_aspect),     AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 +    { "pixel_aspect",  "sample aspect ratio",    OFFSET(pixel_aspect),     AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
      { "time_base",     NULL,                     OFFSET(time_base),        AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
      { "frame_rate",    NULL,                     OFFSET(frame_rate),       AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, DBL_MAX, V },
 +    { "sws_param",     NULL,                     OFFSET(sws_param),        AV_OPT_TYPE_STRING,                    .flags = V },
      { NULL },
  };
  
index a350f476861a0fc156a115bf76f6e7c116e3a329,bb437efa02dd813f9ca2dc4f3d1c36f290943c16..e3bdd0253fdaf9546fe0e4f0117c1fc7ba798011
   * the public API and may change, break or disappear at any time.
   */
  
- #ifndef FF_API_OLD_FILTER_OPTS
- #define FF_API_OLD_FILTER_OPTS              (LIBAVFILTER_VERSION_MAJOR < 7)
- #endif
 +#ifndef FF_API_OLD_FILTER_OPTS_ERROR
 +#define FF_API_OLD_FILTER_OPTS_ERROR        (LIBAVFILTER_VERSION_MAJOR < 8)
 +#endif
  #ifndef FF_API_AVFILTER_OPEN
  #define FF_API_AVFILTER_OPEN                (LIBAVFILTER_VERSION_MAJOR < 7)
  #endif
index bf3082485169ff8515bc09369b0fb466fa8aa5cc,6a6430f2dbb59cb40b91226c8b3e12e4540d905d..4c9363955476563fb289ad5a3891789ac11f3bc0
@@@ -60,10 -66,6 +60,7 @@@ typedef struct AspectContext 
      const AVClass *class;
      AVRational dar;
      AVRational sar;
- #if FF_API_OLD_FILTER_OPTS
-     float aspect_den;
- #endif
 +    int max;
      char *ratio_expr;
  } AspectContext;
  
@@@ -155,18 -118,10 +129,12 @@@ static int setdar_config_props(AVFilter
  {
      AspectContext *s = inlink->dst->priv;
      AVRational dar;
 +    AVRational old_dar;
 +    AVRational old_sar = inlink->sample_aspect_ratio;
      int ret;
  
- #if FF_API_OLD_FILTER_OPTS
-     if (!(s->ratio_expr && s->aspect_den > 0)) {
- #endif
      if ((ret = get_aspect_ratio(inlink, &s->dar)))
          return ret;
- #if FF_API_OLD_FILTER_OPTS
-     }
- #endif
  
      if (s->dar.num && s->dar.den) {
          av_reduce(&s->sar.num, &s->sar.den,
  }
  
  static const AVOption setdar_options[] = {
 -    { "dar", "display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
 -    { NULL },
 +    { "dar",   "set display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
 +    { "ratio", "set display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
 +    { "r",     "set display aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
- #if FF_API_OLD_FILTER_OPTS
-     { "dar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
- #endif
 +    { "max",   "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS },
 +    { NULL }
  };
  
 -static const AVClass setdar_class = {
 -    .class_name = "setdar",
 -    .item_name  = av_default_item_name,
 -    .option     = setdar_options,
 -    .version    = LIBAVUTIL_VERSION_INT,
 -};
 +AVFILTER_DEFINE_CLASS(setdar);
  
  static const AVFilterPad avfilter_vf_setdar_inputs[] = {
      {
@@@ -219,15 -173,16 +184,14 @@@ static const AVFilterPad avfilter_vf_se
  };
  
  AVFilter ff_vf_setdar = {
 -    .name      = "setdar",
 +    .name        = "setdar",
      .description = NULL_IF_CONFIG_SMALL("Set the frame display aspect ratio."),
-     .init        = init,
 -
 -    .priv_size = sizeof(AspectContext),
 -    .priv_class = &setdar_class,
 -
 -    .inputs    = avfilter_vf_setdar_inputs,
 -
 -    .outputs   = avfilter_vf_setdar_outputs,
 +    .priv_size   = sizeof(AspectContext),
 +    .priv_class  = &setdar_class,
 +    .inputs      = avfilter_vf_setdar_inputs,
 +    .outputs     = avfilter_vf_setdar_outputs,
  };
 +
  #endif /* CONFIG_SETDAR_FILTER */
  
  #if CONFIG_SETSAR_FILTER
  static int setsar_config_props(AVFilterLink *inlink)
  {
      AspectContext *s = inlink->dst->priv;
 +    AVRational old_sar = inlink->sample_aspect_ratio;
 +    AVRational old_dar, dar;
      int ret;
  
- #if FF_API_OLD_FILTER_OPTS
-     if (!(s->ratio_expr && s->aspect_den > 0)) {
- #endif
      if ((ret = get_aspect_ratio(inlink, &s->sar)))
          return ret;
- #if FF_API_OLD_FILTER_OPTS
-     }
- #endif
  
      inlink->sample_aspect_ratio = s->sar;
  
  }
  
  static const AVOption setsar_options[] = {
 -    { "sar", "sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "1" }, .flags = FLAGS },
 -    { NULL },
 +    { "sar",   "set sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
 +    { "ratio", "set sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
 +    { "r",     "set sample (pixel) aspect ratio", OFFSET(ratio_expr), AV_OPT_TYPE_STRING, { .str = "0" }, .flags = FLAGS },
- #if FF_API_OLD_FILTER_OPTS
-     { "sar_den", NULL, OFFSET(aspect_den), AV_OPT_TYPE_FLOAT, { .dbl = 0 }, 0, FLT_MAX, FLAGS },
- #endif
 +    { "max",   "set max value for nominator or denominator in the ratio", OFFSET(max), AV_OPT_TYPE_INT, {.i64=100}, 1, INT_MAX, FLAGS },
 +    { NULL }
  };
  
 -static const AVClass setsar_class = {
 -    .class_name = "setsar",
 -    .item_name  = av_default_item_name,
 -    .option     = setsar_options,
 -    .version    = LIBAVUTIL_VERSION_INT,
 -};
 +AVFILTER_DEFINE_CLASS(setsar);
  
  static const AVFilterPad avfilter_vf_setsar_inputs[] = {
      {
@@@ -291,13 -232,14 +246,12 @@@ static const AVFilterPad avfilter_vf_se
  };
  
  AVFilter ff_vf_setsar = {
 -    .name      = "setsar",
 +    .name        = "setsar",
      .description = NULL_IF_CONFIG_SMALL("Set the pixel sample aspect ratio."),
-     .init        = init,
 -
 -    .priv_size = sizeof(AspectContext),
 -    .priv_class = &setsar_class,
 -
 -    .inputs    = avfilter_vf_setsar_inputs,
 -
 -    .outputs   = avfilter_vf_setsar_outputs,
 +    .priv_size   = sizeof(AspectContext),
 +    .priv_class  = &setsar_class,
 +    .inputs      = avfilter_vf_setsar_inputs,
 +    .outputs     = avfilter_vf_setsar_outputs,
  };
 +
  #endif /* CONFIG_SETSAR_FILTER */