[FFmpeg-cvslog] fftools/ffmpeg_filter: return error codes from set_channel_layout() instead of aborting
Anton Khirnov
git at videolan.org
Thu Jul 20 21:57:01 EEST 2023
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Jul 13 15:11:07 2023 +0200| [cb8242db8d0191fbb51f06eca6bee2c1a2c0c075] | committer: Anton Khirnov
fftools/ffmpeg_filter: return error codes from set_channel_layout() instead of aborting
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cb8242db8d0191fbb51f06eca6bee2c1a2c0c075
---
fftools/ffmpeg_filter.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 378a6c6871..b7fb66c047 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -583,7 +583,7 @@ static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
return 0;
}
-static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
+static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
{
const AVCodec *c = ost->enc_ctx->codec;
int i, err;
@@ -592,8 +592,8 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
/* Pass the layout through for all orders but UNSPEC */
err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
if (err < 0)
- report_and_exit(AVERROR(ENOMEM));
- return;
+ return err;
+ return 0;
}
/* Requested layout is of order UNSPEC */
@@ -601,7 +601,7 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
/* 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);
- return;
+ 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 */
@@ -613,12 +613,14 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
/* Use it if one is found */
err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]);
if (err < 0)
- report_and_exit(AVERROR(ENOMEM));
- return;
+ 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);
+
+ return 0;
}
int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
@@ -682,7 +684,9 @@ int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
ofp->sample_rates = c->supported_samplerates;
}
if (ost->enc_ctx->ch_layout.nb_channels) {
- set_channel_layout(ofp, ost);
+ int ret = set_channel_layout(ofp, ost);
+ if (ret < 0)
+ return ret;
} else if (c->ch_layouts) {
ofp->ch_layouts = c->ch_layouts;
}
More information about the ffmpeg-cvslog
mailing list