summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <[email protected]>2025-01-01 21:41:45 -0300
committerJames Almer <[email protected]>2025-01-02 12:11:08 -0300
commitdd5696c19713096e72603de071eda3a67742c440 (patch)
tree3f5640457002ba5a6136444cb2759b1546a5dec0
parent0457aaf0d3a05331dc599bea573809fd0317c624 (diff)
avfilter/buffersrc: make channel_layout a CHLAYOUT type AVOption
The string type is a remnant of the old channel layout API implementation. Reviewed-by: Nicolas George <[email protected]> Signed-off-by: James Almer <[email protected]>
-rw-r--r--libavfilter/buffersrc.c14
1 files 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) {