mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-08-09 01:21:06 +00:00
avfilter/vf_v360: reject dimensions too small for the projection
Fixes: out of array read
Fixes: assertion failure
Fixes: mQzloVqnivHQ
Found-by: Anthony Hurtado
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit b3712addc9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
@@ -4309,6 +4309,20 @@ static int get_output_dimension(AVFilterContext *ctx, const char *name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void projection_min_size(int projection, int *min_w, int *min_h)
|
||||
{
|
||||
switch (projection) {
|
||||
case CUBEMAP_3_2: *min_w = 3; *min_h = 2; break;
|
||||
case CUBEMAP_1_6: *min_w = 1; *min_h = 6; break;
|
||||
case CUBEMAP_6_1: *min_w = 6; *min_h = 1; break;
|
||||
case EQUIANGULAR: *min_w = 5; *min_h = 9; break;
|
||||
case BARREL: *min_w = 5; *min_h = 2; break;
|
||||
case BARREL_SPLIT: *min_w = 3; *min_h = 4; break;
|
||||
case DUAL_FISHEYE: *min_w = 2; *min_h = 1; break;
|
||||
default: *min_w = 1; *min_h = 1; break;
|
||||
}
|
||||
}
|
||||
|
||||
static int config_output(AVFilterLink *outlink)
|
||||
{
|
||||
AVFilterContext *ctx = outlink->src;
|
||||
@@ -4489,6 +4503,22 @@ static int config_output(AVFilterLink *outlink)
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
|
||||
{
|
||||
int min_w, min_h;
|
||||
const int pw = s->in_transpose ? AV_CEIL_RSHIFT(h, desc->log2_chroma_h)
|
||||
: AV_CEIL_RSHIFT(w, desc->log2_chroma_w);
|
||||
const int ph = s->in_transpose ? AV_CEIL_RSHIFT(w, desc->log2_chroma_w)
|
||||
: AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
|
||||
|
||||
projection_min_size(s->in, &min_w, &min_h);
|
||||
if (pw < min_w || ph < min_h) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Input %dx%d is too small for the input projection "
|
||||
"(requires at least %dx%d per plane).\n", pw, ph, min_w, min_h);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
switch (s->in) {
|
||||
case EQUIRECTANGULAR:
|
||||
s->in_transform = xyz_to_equirect;
|
||||
@@ -4876,6 +4906,22 @@ static int config_output(AVFilterLink *outlink)
|
||||
|
||||
set_dimensions(s->pr_width, s->pr_height, w, h, desc);
|
||||
|
||||
{
|
||||
int min_w, min_h;
|
||||
const int pw = s->out_transpose ? AV_CEIL_RSHIFT(h, desc->log2_chroma_h)
|
||||
: AV_CEIL_RSHIFT(w, desc->log2_chroma_w);
|
||||
const int ph = s->out_transpose ? AV_CEIL_RSHIFT(w, desc->log2_chroma_w)
|
||||
: AV_CEIL_RSHIFT(h, desc->log2_chroma_h);
|
||||
|
||||
projection_min_size(s->out, &min_w, &min_h);
|
||||
if (pw < min_w || ph < min_h) {
|
||||
av_log(ctx, AV_LOG_ERROR,
|
||||
"Output %dx%d is too small for the output projection "
|
||||
"(requires at least %dx%d per plane).\n", pw, ph, min_w, min_h);
|
||||
return AVERROR(EINVAL);
|
||||
}
|
||||
}
|
||||
|
||||
switch (s->out_stereo) {
|
||||
case STEREO_2D:
|
||||
out_offset_w = out_offset_h = 0;
|
||||
|
||||
Reference in New Issue
Block a user