[FFmpeg-devel] runtime-cpu-detect bug in swscale

Josh Harris qt at tateu.net
Thu Apr 21 16:24:52 CEST 2011

On 3/4/2011 2:15 PM, Darren Horrocks wrote:
> swscale doesnt ever actually do any runtime detection at all when
> runtime cpu detection is enabled, it simply passes whatever is passed
> to -sws_flags, which could be nothing at all making swscale default to
> the C implementation.

> could anyone else test this patch and submit it to trunk if its usable?

The patch has been causing purple and green bars/rectangles with a 32bit
build of ffmpeg on Windows when my source is RGB and the output is not
RGB.  See this bug report (the title is "mjpeg decoder is broken" but, I
believe it is a libswscale bug caused by this patch):

As posted there:
With --enable-runtime-cpudetect and this patch applied, ff_getSwsFunc
from swscale.c calls av_get_cpu_flags() and applies runtime detected CPU
flags so that the correct version of sws_init_swScale_* gets called. 
The problem appears to be that sws_rgb2rgb_init from rgb2rgb.c has
already been called and it does not perform any runtime CPU detection so
the C version of rgb2rgb_init_* is always called.

I posted a patch to
which fixes the issue for me.  I added a test for AV_CPU_FLAG_SSE2 since
there is an rgb2rgb_init_SSE2() function but I am not 100% sure that it
should be there.

More information about the ffmpeg-devel mailing list