[FFmpeg-cvslog] avfilter/asrc_sinc: check return code of tx_init()
Paul B Mahol
git at videolan.org
Sun Sep 3 10:43:58 EEST 2023
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Sun Sep 3 09:33:26 2023 +0200| [a469186b8a841293d1d1ca7cad95fb5043e901dc] | committer: Paul B Mahol
avfilter/asrc_sinc: check return code of tx_init()
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a469186b8a841293d1d1ca7cad95fb5043e901dc
---
libavfilter/asrc_sinc.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/libavfilter/asrc_sinc.c b/libavfilter/asrc_sinc.c
index 16e587f1b9..6366fb802b 100644
--- a/libavfilter/asrc_sinc.c
+++ b/libavfilter/asrc_sinc.c
@@ -202,7 +202,7 @@ static float safe_log(float x)
static int fir_to_phase(SincContext *s, float **h, int *len, int *post_len, float phase)
{
float *pi_wraps, *work, phase1 = (phase > 50.f ? 100.f - phase : phase) / 50.f;
- int i, work_len, begin, end, imp_peak = 0, peak = 0;
+ int i, work_len, begin, end, imp_peak = 0, peak = 0, ret;
float imp_sum = 0, peak_imp_sum = 0, scale = 1.f;
float prev_angle2 = 0, cum_2pi = 0, prev_angle1 = 0, cum_1pi = 0;
@@ -218,12 +218,12 @@ static int fir_to_phase(SincContext *s, float **h, int *len, int *post_len, floa
av_tx_uninit(&s->tx);
av_tx_uninit(&s->itx);
- av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_RDFT, 0, work_len, &scale, AV_TX_INPLACE);
- av_tx_init(&s->itx, &s->itx_fn, AV_TX_FLOAT_RDFT, 1, work_len, &scale, AV_TX_INPLACE);
- if (!s->tx || !s->itx) {
- av_free(work);
- return AVERROR(ENOMEM);
- }
+ ret = av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_RDFT, 0, work_len, &scale, AV_TX_INPLACE);
+ if (ret < 0)
+ goto fail;
+ ret = av_tx_init(&s->itx, &s->itx_fn, AV_TX_FLOAT_RDFT, 1, work_len, &scale, AV_TX_INPLACE);
+ if (ret < 0)
+ goto fail;
s->tx_fn(s->tx, work, work, sizeof(float)); /* Cepstral: */
@@ -315,9 +315,10 @@ static int fir_to_phase(SincContext *s, float **h, int *len, int *post_len, floa
work_len, pi_wraps[work_len >> 1] / M_PI, peak, peak_imp_sum, imp_peak,
work[imp_peak], *len, *post_len, 100.f - 100.f * *post_len / (*len - 1));
+fail:
av_free(work);
- return 0;
+ return ret;
}
static int config_output(AVFilterLink *outlink)
More information about the ffmpeg-cvslog
mailing list