[FFmpeg-cvslog] avfilter/buffersink: simplify parsing the input channel layout string
James Almer
git at videolan.org
Tue Mar 15 19:31:03 EET 2022
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Tue Mar 15 14:18:24 2022 -0300| [f5d67469b0e15402a6323e2e657572db8d17f8fe] | committer: James Almer
avfilter/buffersink: simplify parsing the input channel layout string
And remove a stray comma in the list of supported separators.
Signed-off-by: James Almer <jamrial at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f5d67469b0e15402a6323e2e657572db8d17f8fe
---
libavfilter/buffersink.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c
index b989473719..e269cf72d1 100644
--- a/libavfilter/buffersink.c
+++ b/libavfilter/buffersink.c
@@ -330,24 +330,22 @@ static int asink_query_formats(AVFilterContext *ctx)
"Conflicting ch_layouts and list of channel_counts/channel_layouts. Ignoring the former\n");
else
#endif
- while (cur && *cur) {
- char *chl = av_get_token(&cur, "|,");
- if (!chl)
- return AVERROR(ENOMEM);
- if (*cur)
- cur++;
-
- ret = av_channel_layout_from_string(&layout, chl);
+ while (cur) {
+ char *next = strchr(cur, '|');
+ if (next)
+ *next++ = 0;
+
+ ret = av_channel_layout_from_string(&layout, cur);
if (ret < 0) {
- av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", chl);
- av_free(chl);
+ av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", cur);
return ret;
}
ret = ff_add_channel_layout(&layouts, &layout);
av_channel_layout_uninit(&layout);
- av_free(chl);
if (ret < 0)
return ret;
+
+ cur = next;
}
}
More information about the ffmpeg-cvslog
mailing list