[FFmpeg-devel] [PATCH] avfilter/buffersrc: make channel_layout a CHLAYOUT type AVOption
James Almer
jamrial at gmail.com
Thu Jan 2 16:56:06 EET 2025
The string type is a remnant of the old channel layout API implementation.
Signed-off-by: James Almer <jamrial at gmail.com>
---
libavfilter/buffersrc.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c
index c921803c67..117ac0cfa2 100644
--- a/libavfilter/buffersrc.c
+++ b/libavfilter/buffersrc.c
@@ -60,7 +60,6 @@ typedef struct BufferSourceContext {
int sample_rate;
enum AVSampleFormat sample_fmt;
int channels;
- char *channel_layout_str;
AVChannelLayout ch_layout;
int eof;
@@ -370,7 +369,7 @@ static const AVOption abuffer_options[] = {
{ "time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, { .dbl = 0 }, 0, INT_MAX, A },
{ "sample_rate", NULL, OFFSET(sample_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
{ "sample_fmt", NULL, OFFSET(sample_fmt), AV_OPT_TYPE_SAMPLE_FMT, { .i64 = AV_SAMPLE_FMT_NONE }, .min = AV_SAMPLE_FMT_NONE, .max = INT_MAX, .flags = A },
- { "channel_layout", NULL, OFFSET(channel_layout_str), AV_OPT_TYPE_STRING, .flags = A },
+ { "channel_layout", NULL, OFFSET(ch_layout), AV_OPT_TYPE_CHLAYOUT, .flags = A },
{ "channels", NULL, OFFSET(channels), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, A },
{ NULL },
};
@@ -388,18 +387,9 @@ static av_cold int init_audio(AVFilterContext *ctx)
return AVERROR(EINVAL);
}
- if (s->channel_layout_str || s->ch_layout.nb_channels) {
+ if (av_channel_layout_check(&s->ch_layout)) {
int n;
- if (!s->ch_layout.nb_channels) {
- ret = av_channel_layout_from_string(&s->ch_layout, s->channel_layout_str);
- if (ret < 0) {
- av_log(ctx, AV_LOG_ERROR, "Invalid channel layout %s.\n",
- s->channel_layout_str);
- return AVERROR(EINVAL);
- }
- }
-
n = s->ch_layout.nb_channels;
av_channel_layout_describe(&s->ch_layout, buf, sizeof(buf));
if (s->channels) {
--
2.47.1
More information about the ffmpeg-devel
mailing list