diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-07-13 15:11:07 +0200 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-07-20 20:40:26 +0200 |
commit | cb8242db8d0191fbb51f06eca6bee2c1a2c0c075 (patch) | |
tree | e7f41b9d6ab2da7731df09503f7dc91e99322678 /fftools | |
parent | 5ba7aa2ce821b39b665fd0ef1e1c236814f3438a (diff) | |
download | ffmpeg-cb8242db8d0191fbb51f06eca6bee2c1a2c0c075.tar.gz |
fftools/ffmpeg_filter: return error codes from set_channel_layout() instead of aborting
Diffstat (limited to 'fftools')
-rw-r--r-- | fftools/ffmpeg_filter.c | 18 |
1 files 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; } |