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.
This commit is contained in:
Colin Snover 2017-09-11 00:45:14 -05:00
parent 2228ae255c
commit 533bb5b257

View File

@ -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<Graphics::PixelFormat> outFormats = g_system->getSupportedFormats();
Graphics::PixelFormat inFormat = _decoder->getPixelFormat();
Graphics::PixelFormat bestFormat = outFormats.front();
Common::List<Graphics::PixelFormat>::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;