summaryrefslogtreecommitdiff
path: root/libavfilter/vf_waveform.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2019-10-11 12:07:10 +0200
committerPaul B Mahol <onemda@gmail.com>2019-10-11 12:07:54 +0200
commit7ad69a73f3d9d0e4575ef40e746a974989b3d3eb (patch)
tree5f0498ab5f7537a63a35fd59f0b451495eb5d307 /libavfilter/vf_waveform.c
parente787f8fd7ee99ba0c3e0f086ce2ce59eea7ed86c (diff)
downloadffmpeg-7ad69a73f3d9d0e4575ef40e746a974989b3d3eb.tar.gz
avfilter/vf_waveform: better guard against picking wrong pixel format
Fixes #8252
Diffstat (limited to 'libavfilter/vf_waveform.c')
-rw-r--r--libavfilter/vf_waveform.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/libavfilter/vf_waveform.c b/libavfilter/vf_waveform.c
index 8033628407..fe2fc76359 100644
--- a/libavfilter/vf_waveform.c
+++ b/libavfilter/vf_waveform.c
@@ -290,9 +290,9 @@ static int query_formats(AVFilterContext *ctx)
WaveformContext *s = ctx->priv;
const enum AVPixelFormat *out_pix_fmts;
const enum AVPixelFormat *in_pix_fmts;
- const AVPixFmtDescriptor *desc;
- AVFilterFormats *avff;
- int depth, rgb, i, ret, ncomp;
+ const AVPixFmtDescriptor *desc, *desc2;
+ AVFilterFormats *avff, *avff2;
+ int depth, depth2, rgb, i, ret, ncomp, ncomp2;
if (!ctx->inputs[0]->in_formats ||
!ctx->inputs[0]->in_formats->nb_formats) {
@@ -316,10 +316,16 @@ static int query_formats(AVFilterContext *ctx)
}
avff = ctx->inputs[0]->in_formats;
+ avff2 = ctx->inputs[0]->out_formats;
desc = av_pix_fmt_desc_get(avff->formats[0]);
+ desc2 = av_pix_fmt_desc_get(avff2->formats[0]);
ncomp = desc->nb_components;
+ ncomp2 = desc2->nb_components;
rgb = desc->flags & AV_PIX_FMT_FLAG_RGB;
depth = desc->comp[0].depth;
+ depth2 = desc2->comp[0].depth;
+ if (ncomp != ncomp2 || depth != depth2)
+ return AVERROR(EAGAIN);
for (i = 1; i < avff->nb_formats; i++) {
desc = av_pix_fmt_desc_get(avff->formats[i]);
if (rgb != (desc->flags & AV_PIX_FMT_FLAG_RGB) ||