libavfilter/vf_v360: fix operator precedence in stereo loop condition

The loop condition in the DEFINE_REMAP macro:

  stereo < 1 + s->out_stereo > STEREO_2D

is parsed by C as:

  (stereo < (1 + s->out_stereo)) > STEREO_2D

Since STEREO_2D is 0 and relational operators return 0 or 1, the
outer comparison against 0 is a no-op for STEREO_2D and STEREO_SBS.
But for STEREO_TB (value 2) the loop runs 3 iterations instead of 2,
producing an out-of-bounds stereo pass.

Add parentheses so the comparison is evaluated first:

  stereo < 1 + (s->out_stereo > STEREO_2D)

This gives 1 iteration for 2D and 2 for any stereo format (SBS or TB),
matching the actual number of stereo views.

Signed-off-by: marcos ashton <marcosashiglesias@gmail.com>
(cherry picked from commit 9559a6036d)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
marcos ashton
2026-03-23 14:08:35 +00:00
committed by Michael Niedermayer
parent daf2cb8bfd
commit 520a3042d2
+2 -1
View File
@@ -284,7 +284,8 @@ static int remap##ws##_##bits##bit_slice(AVFilterContext *ctx, void *arg, int jo
const AVFrame *in = td->in; \
AVFrame *out = td->out; \
\
for (int stereo = 0; stereo < 1 + s->out_stereo > STEREO_2D; stereo++) { \
\
for (int stereo = 0; stereo < 1 + (s->out_stereo > STEREO_2D); stereo++) { \
for (int plane = 0; plane < s->nb_planes; plane++) { \
const unsigned map = s->map[plane]; \
const int in_linesize = in->linesize[plane]; \