[FFmpeg-devel] [PATCH] lavfi/aevalsrc: use AV_OPT_TYPE_CHANNEL_LAYOUT

Stefano Sabatini stefasab at gmail.com
Thu Dec 5 19:03:42 CET 2013


Simplify.
---
 libavfilter/asrc_aevalsrc.c | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/libavfilter/asrc_aevalsrc.c b/libavfilter/asrc_aevalsrc.c
index 41ad632..6b1eba0 100644
--- a/libavfilter/asrc_aevalsrc.c
+++ b/libavfilter/asrc_aevalsrc.c
@@ -52,7 +52,6 @@ typedef struct {
     char *sample_rate_str;
     int sample_rate;
     int64_t chlayout;
-    char *chlayout_str;
     int nb_channels;
     int64_t pts;
     AVExpr **expr;
@@ -74,8 +73,8 @@ static const AVOption aevalsrc_options[]= {
     { "s",           "set the sample rate",                           OFFSET(sample_rate_str), AV_OPT_TYPE_STRING, {.str = "44100"}, CHAR_MIN, CHAR_MAX, FLAGS },
     { "duration",    "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
     { "d",           "set audio duration", OFFSET(duration), AV_OPT_TYPE_DURATION, {.i64 = -1}, -1, INT64_MAX, FLAGS },
-    { "channel_layout", "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
-    { "c",              "set channel layout", OFFSET(chlayout_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, FLAGS },
+    { "channel_layout", "set channel layout", OFFSET(chlayout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.str = NULL}, 0, 0, FLAGS },
+    { "c",              "set channel layout", OFFSET(chlayout), AV_OPT_TYPE_CHANNEL_LAYOUT, {.str = NULL}, 0, 0, FLAGS },
     { NULL }
 };
 
@@ -108,18 +107,13 @@ static av_cold int init(AVFilterContext *ctx)
             goto end;
     }
 
-    if (eval->chlayout_str) {
-        int n;
-        ret = ff_parse_channel_layout(&eval->chlayout, NULL, eval->chlayout_str, ctx);
-        if (ret < 0)
-            goto end;
-
-        n = av_get_channel_layout_nb_channels(eval->chlayout);
+    if (eval->chlayout) {
+        int n = av_get_channel_layout_nb_channels(eval->chlayout);
         if (n != eval->nb_channels) {
             av_log(ctx, AV_LOG_ERROR,
-                   "Mismatch between the specified number of channels '%d' "
-                   "and the number of channels '%d' in the specified channel layout '%s'\n",
-                   eval->nb_channels, n, eval->chlayout_str);
+                   "Mismatch between the specified number of channel expressions '%d' "
+                   "and the number of output channels '%d' in the specified channel layout\n",
+                   eval->nb_channels, n);
             ret = AVERROR(EINVAL);
             goto end;
         }
-- 
1.8.1.2



More information about the ffmpeg-devel mailing list