[FFmpeg-cvslog] avfilter/vf_zscale: do not attempt to continue filtering if there is no graph
Paul B Mahol
git at videolan.org
Fri Mar 11 10:33:04 EET 2022
ffmpeg | branch: master | Paul B Mahol <onemda at gmail.com> | Fri Mar 11 09:32:34 2022 +0100| [a0724328a82ed1ea89b86c1414ba1d4dd12c760f] | committer: Paul B Mahol
avfilter/vf_zscale: do not attempt to continue filtering if there is no graph
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a0724328a82ed1ea89b86c1414ba1d4dd12c760f
---
libavfilter/vf_zscale.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 649ef7f6bb..bb457423b3 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -627,7 +627,7 @@ static int graphs_build(AVFrame *in, AVFrame *out, const AVPixFmtDescriptor *des
s->alpha_graph[job_nr] = zimg_filter_graph_build(&alpha_src_format, &alpha_dst_format, &s->alpha_params);
if (!s->alpha_graph[job_nr])
return print_zimg_error(ctx);
- }
+ }
return 0;
}
@@ -728,9 +728,11 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs
dst_buf.plane[i].stride = td->out->linesize[p];
dst_buf.plane[i].mask = -1;
}
+ if (!s->graph[job_nr])
+ return AVERROR(EINVAL);
ret = zimg_filter_graph_process(s->graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
if (ret)
- return print_zimg_error(ctx);
+ return print_zimg_error(ctx);
if (td->desc->flags & AV_PIX_FMT_FLAG_ALPHA && td->odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
src_buf.plane[0].data = td->in->data[3];
@@ -741,6 +743,8 @@ static int filter_slice(AVFilterContext *ctx, void *data, int job_nr, int n_jobs
dst_buf.plane[0].stride = td->out->linesize[3];
dst_buf.plane[0].mask = -1;
+ if (!s->alpha_graph[job_nr])
+ return AVERROR(EINVAL);
ret = zimg_filter_graph_process(s->alpha_graph[job_nr], &src_buf, &dst_buf, s->tmp[job_nr], 0, 0, 0, 0);
if (ret)
return print_zimg_error(ctx);
@@ -854,7 +858,14 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
td.desc = desc;
td.odesc = odesc;
- ff_filter_execute(ctx, filter_slice, &td, NULL, s->nb_threads);
+ ret = ff_filter_execute(ctx, filter_slice, &td, NULL, s->nb_threads);
+ if (ret < 0 || !s->graph[0]) {
+ av_frame_free(&in);
+ av_frame_free(&out);
+ if (ret >= 0)
+ ret = AVERROR(EINVAL);
+ return ret;
+ }
s->src_format_tmp = s->src_format;
s->dst_format_tmp = s->dst_format;
@@ -899,8 +910,14 @@ static av_cold void uninit(AVFilterContext *ctx)
for (int i = 0; i < s->nb_threads; i++) {
av_freep(&s->tmp[i]);
- zimg_filter_graph_free(s->graph[i]);
- zimg_filter_graph_free(s->alpha_graph[i]);
+ if (s->graph[i]) {
+ zimg_filter_graph_free(s->graph[i]);
+ s->graph[i] = NULL;
+ }
+ if (s->alpha_graph[i]) {
+ zimg_filter_graph_free(s->alpha_graph[i]);
+ s->alpha_graph[i] = NULL;
+ }
}
}
More information about the ffmpeg-cvslog
mailing list