IMAGE: Return correct pixel format for Indeo3

This gives Indeo3 the same behavior as other codecs when
encapsulated in a container that provides bit depth information
(e.g. AVI).

Closes #888.
This commit is contained in:
Colin Snover 2017-01-08 23:12:05 -06:00
parent 68de00b367
commit 7b90f0693a
4 changed files with 18 additions and 5 deletions

View File

@ -210,7 +210,7 @@ Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) {
case MKTAG('c','v','i','d'):
return new CinepakDecoder(bitsPerPixel);
case MKTAG('I','V','3','2'):
return new Indeo3Decoder(width, height);
return new Indeo3Decoder(width, height, bitsPerPixel);
case MKTAG('I', 'V', '4', '1'):
case MKTAG('I', 'V', '4', '2'):
return new Indeo4Decoder(width, height, bitsPerPixel);

View File

@ -40,11 +40,24 @@
namespace Image {
Indeo3Decoder::Indeo3Decoder(uint16 width, uint16 height) : _ModPred(0), _corrector_type(0) {
Indeo3Decoder::Indeo3Decoder(uint16 width, uint16 height, uint bitsPerPixel) : _ModPred(0), _corrector_type(0) {
_iv_frame[0].the_buf = 0;
_iv_frame[1].the_buf = 0;
_pixelFormat = g_system->getScreenFormat();
switch (bitsPerPixel) {
case 16:
_pixelFormat = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
break;
case 24:
_pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 0, 16, 8, 0, 0);
break;
case 32:
_pixelFormat = Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0);
break;
default:
error("Invalid color depth");
break;
}
_surface = new Graphics::Surface;
_surface->create(width, height, _pixelFormat);

View File

@ -46,7 +46,7 @@ namespace Image {
*/
class Indeo3Decoder : public Codec {
public:
Indeo3Decoder(uint16 width, uint16 height);
Indeo3Decoder(uint16 width, uint16 height, uint bitsPerPixel = 24);
~Indeo3Decoder();
const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);

View File

@ -1691,7 +1691,7 @@ bool VMDDecoder::openExternalCodec() {
if (_videoCodec == kVideoCodecIndeo3) {
_isPaletted = false;
_codec = new Image::Indeo3Decoder(_width, _height);
_codec = new Image::Indeo3Decoder(_width, _height, g_system->getScreenFormat().bpp());
} else {
warning("VMDDecoder::openExternalCodec(): Unknown video codec FourCC \"%s\"",