From 533bb5b257b7788b99b307381d96f8e54d9e9c75 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Mon, 11 Sep 2017 00:45:14 -0500 Subject: SCI32: Improve chance of rendering non-8bpp AVIs OpenGL backends don't always support the pixel format that is returned by the Indeo 3 decoder when playing the GK2A.AVI from the GK2 demo. If this happens, use the backend's preferred pixel format and convert in software. If a backend doesn't support any 16-bit or 32-bit format, the playback code will error out. This is probably fine, since there are not really any of those any more. Fixes Trac#9994. --- engines/sci/graphics/video32.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/engines/sci/graphics/video32.cpp b/engines/sci/graphics/video32.cpp index c9c48eb9fd..301092bf4e 100644 --- a/engines/sci/graphics/video32.cpp +++ b/engines/sci/graphics/video32.cpp @@ -408,7 +408,22 @@ AVIPlayer::IOStatus AVIPlayer::init(const bool doublePixels) { _drawRect.setHeight(height); if (!startHQVideo() && _decoder->getPixelFormat().bytesPerPixel != 1) { - g_sci->_gfxFrameout->setPixelFormat(_decoder->getPixelFormat()); + const Common::List outFormats = g_system->getSupportedFormats(); + Graphics::PixelFormat inFormat = _decoder->getPixelFormat(); + Graphics::PixelFormat bestFormat = outFormats.front(); + Common::List::const_iterator it; + for (it = outFormats.begin(); it != outFormats.end(); ++it) { + if (*it == inFormat) { + bestFormat = inFormat; + break; + } + } + + if (bestFormat.bytesPerPixel != 2 && bestFormat.bytesPerPixel != 4) { + error("Failed to find any valid output pixel format"); + } + + g_sci->_gfxFrameout->setPixelFormat(bestFormat); } return kIOSuccess; -- cgit v1.2.3