aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_filter.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-03-29 10:15:49 +0100
committerAnton Khirnov <anton@khirnov.net>2024-04-09 10:34:18 +0200
commit8c330853131e1d1f75c6238784596235af2e9603 (patch)
tree4c440c4e2b25d000a15da8ad83e60dab7497b483 /fftools/ffmpeg_filter.c
parentd7cde009ce7884995bb38505a26e819b9f57a3d2 (diff)
downloadffmpeg-8c330853131e1d1f75c6238784596235af2e9603.tar.gz
fftools/ffmpeg_filter: do not pass OutputStream to set_channel_layout()
It only needs a list of allowed layouts and the requested layout.
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r--fftools/ffmpeg_filter.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 2308abf82a..ba6c6c7673 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -722,42 +722,42 @@ static int ifilter_bind_dec(InputFilterPriv *ifp, Decoder *dec)
return 0;
}
-static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
+static int set_channel_layout(OutputFilterPriv *f, const AVChannelLayout *layouts_allowed,
+ const AVChannelLayout *layout_requested)
{
- const AVCodec *c = ost->enc_ctx->codec;
int i, err;
- if (ost->enc_ctx->ch_layout.order != AV_CHANNEL_ORDER_UNSPEC) {
+ if (layout_requested->order != AV_CHANNEL_ORDER_UNSPEC) {
/* Pass the layout through for all orders but UNSPEC */
- err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
+ err = av_channel_layout_copy(&f->ch_layout, layout_requested);
if (err < 0)
return err;
return 0;
}
/* Requested layout is of order UNSPEC */
- if (!c->ch_layouts) {
+ if (!layouts_allowed) {
/* Use the default native layout for the requested amount of channels when the
encoder doesn't have a list of supported layouts */
- av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
+ av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels);
return 0;
}
/* Encoder has a list of supported layouts. Pick the first layout in it with the
same amount of channels as the requested layout */
- for (i = 0; c->ch_layouts[i].nb_channels; i++) {
- if (c->ch_layouts[i].nb_channels == ost->enc_ctx->ch_layout.nb_channels)
+ for (i = 0; layouts_allowed[i].nb_channels; i++) {
+ if (layouts_allowed[i].nb_channels == layout_requested->nb_channels)
break;
}
- if (c->ch_layouts[i].nb_channels) {
+ if (layouts_allowed[i].nb_channels) {
/* Use it if one is found */
- err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]);
+ err = av_channel_layout_copy(&f->ch_layout, &layouts_allowed[i]);
if (err < 0)
return err;
return 0;
}
/* If no layout for the amount of channels requested was found, use the default
native layout for it. */
- av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
+ av_channel_layout_default(&f->ch_layout, layout_requested->nb_channels);
return 0;
}
@@ -844,7 +844,7 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost,
ofp->sample_rates = c->supported_samplerates;
}
if (ost->enc_ctx->ch_layout.nb_channels) {
- int ret = set_channel_layout(ofp, ost);
+ int ret = set_channel_layout(ofp, c->ch_layouts, &ost->enc_ctx->ch_layout);
if (ret < 0)
return ret;
} else if (c->ch_layouts) {