]> git.sesse.net Git - ffmpeg/blobdiff - libavfilter/af_aformat.c
decode: add a per-frame private data for hwaccel use
[ffmpeg] / libavfilter / af_aformat.c
index 5b00d7de9c71beafc5502773238efb6c5845d3cf..f0746737dc7f297f5ea593372709ddf0c676c163 100644 (file)
@@ -23,8 +23,9 @@
  * format audio filter
  */
 
-#include "libavutil/audioconvert.h"
 #include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
 #include "libavutil/opt.h"
 
 #include "audio.h"
@@ -62,17 +63,24 @@ static const AVClass aformat_class = {
 
 #define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc)    \
 do {                                                                        \
-    char *next, *cur = str;                                                 \
+    char *next, *cur = str, sep;                                            \
+                                                                            \
+    if (str && strchr(str, ',')) {                                          \
+        av_log(ctx, AV_LOG_WARNING, "This syntax is deprecated, use '|' to "\
+               "separate %s.\n", desc);                                     \
+        sep = ',';                                                          \
+    } else                                                                  \
+        sep = '|';                                                          \
+                                                                            \
     while (cur) {                                                           \
         type fmt;                                                           \
-        next = strchr(cur, ',');                                            \
+        next = strchr(cur, sep);                                            \
         if (next)                                                           \
             *next++ = 0;                                                    \
                                                                             \
         if ((fmt = get_fmt(cur)) == none) {                                 \
             av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\
-            ret = AVERROR(EINVAL);                                          \
-            goto fail;                                                      \
+            return AVERROR(EINVAL);                                         \
         }                                                                   \
         add_to_list(&list, fmt);                                            \
                                                                             \
@@ -86,23 +94,9 @@ static int get_sample_rate(const char *samplerate)
     return FFMAX(ret, 0);
 }
 
-static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
+static av_cold int init(AVFilterContext *ctx)
 {
     AFormatContext *s = ctx->priv;
-    int ret;
-
-    if (!args) {
-        av_log(ctx, AV_LOG_ERROR, "No parameters supplied.\n");
-        return AVERROR(EINVAL);
-    }
-
-    s->class = &aformat_class;
-    av_opt_set_defaults(s);
-
-    if ((ret = av_set_options_string(s, args, "=", ":")) < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Error parsing options string '%s'.\n", args);
-        return ret;
-    }
 
     PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats,
                   ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format");
@@ -112,9 +106,7 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
                   ff_add_channel_layout, av_get_channel_layout, 0,
                   "channel layout");
 
-fail:
-    av_opt_free(s);
-    return ret;
+    return 0;
 }
 
 static int query_formats(AVFilterContext *ctx)
@@ -122,7 +114,7 @@ static int query_formats(AVFilterContext *ctx)
     AFormatContext *s = ctx->priv;
 
     ff_set_common_formats(ctx, s->formats ? s->formats :
-                                                  ff_all_formats(AVMEDIA_TYPE_AUDIO));
+                                            ff_all_formats(AVMEDIA_TYPE_AUDIO));
     ff_set_common_samplerates(ctx, s->sample_rates ? s->sample_rates :
                                                      ff_all_samplerates());
     ff_set_common_channel_layouts(ctx, s->channel_layouts ? s->channel_layouts :
@@ -131,17 +123,30 @@ static int query_formats(AVFilterContext *ctx)
     return 0;
 }
 
-AVFilter avfilter_af_aformat = {
+static const AVFilterPad avfilter_af_aformat_inputs[] = {
+    {
+        .name = "default",
+        .type = AVMEDIA_TYPE_AUDIO,
+    },
+    { NULL }
+};
+
+static const AVFilterPad avfilter_af_aformat_outputs[] = {
+    {
+        .name = "default",
+        .type = AVMEDIA_TYPE_AUDIO
+    },
+    { NULL }
+};
+
+AVFilter ff_af_aformat = {
     .name          = "aformat",
     .description   = NULL_IF_CONFIG_SMALL("Convert the input audio to one of the specified formats."),
     .init          = init,
     .query_formats = query_formats,
     .priv_size     = sizeof(AFormatContext),
+    .priv_class    = &aformat_class,
 
-    .inputs        = (AVFilterPad[]) {{ .name            = "default",
-                                        .type            = AVMEDIA_TYPE_AUDIO, },
-                                      { .name = NULL}},
-    .outputs       = (AVFilterPad[]) {{ .name            = "default",
-                                        .type            = AVMEDIA_TYPE_AUDIO},
-                                      { .name = NULL}},
+    .inputs        = avfilter_af_aformat_inputs,
+    .outputs       = avfilter_af_aformat_outputs,
 };