avcodec/snowenc: fix SIGFPE in get_dc() when a block lies outside the plane
authorBogdan Lisman <bogdan@pydevsolutions.com>
Mon, 15 Jun 2026 00:24:14 +0000 (03:24 +0300)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 18 Jun 2026 02:03:05 +0000 (04:03 +0200)
get_dc() divides the accumulated, OBMC-weighted DC by aa, the sum of the
squared OBMC weights taken over the in-plane pixels.  When an OBMC block
falls entirely outside the plane - e.g. a tiny chroma plane after mcdeint
splits a frame into fields - no pixel contributes, aa stays 0 and the
ROUNDED_DIV() divides by zero (SIGFPE).  ab is 0 in exactly the same case,
so the result degenerates to 0; return it directly.

Reproducible with the GPL mcdeint filter in slow/extra_slow mode, e.g.

    ffmpeg -f lavfi -i testsrc=s=128x2 -vf mcdeint=mode=slow -f null -

Add a self-contained lavfi-based FATE regression test for the slow mode,
which previously crashed and is therefore not covered by the existing
sample-based fast/medium tests.

Fixes trac ticket #7779.

Signed-off-by: Bogdan Lisman <bogdan@pydevsolutions.com>
(cherry picked from commit a62d99692780431aeb8cc96665434d5ec3210985)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/snowenc.c

index 65363e20dde4223249ea1b07fd3d252e1bfbaa4a..bb387abe1c2667353b3fdbdca6e59caa88b9ef25 100644 (file)
@@ -720,6 +720,9 @@ static int get_dc(SnowEncContext *enc, int mb_x, int mb_y, int plane_index)
     }
     *b= backup;
 
+    if (!aa)
+        return 0;
+
     return av_clip_uint8( ROUNDED_DIV((int64_t)ab<<LOG2_OBMC_MAX, aa) ); //FIXME we should not need clipping
 }