IMAGE: Respect specified bytesPerPixel in Indeo decoders

This commit is contained in:
Paul Gilbert 2016-11-18 20:55:37 -05:00
parent 5d8b0e478e
commit 7f4d93ed93
7 changed files with 25 additions and 10 deletions

View File

@ -213,7 +213,7 @@ Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) {
return new Indeo3Decoder(width, height);
case MKTAG('I', 'V', '4', '1'):
case MKTAG('I', 'V', '4', '2'):
return new Indeo4Decoder(width, height);
return new Indeo4Decoder(width, height, bitsPerPixel);
case MKTAG('I', 'V', '5', '0'):
return new Indeo5Decoder(width, height);
#ifdef IMAGE_CODECS_TRUEMOTION1_H

View File

@ -466,12 +466,25 @@ IVI45DecContext::IVI45DecContext() : _gb(nullptr), _frameNum(0), _frameType(0),
/*------------------------------------------------------------------------*/
IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height) : Codec() {
_pixelFormat = g_system->getScreenFormat();
assert(_pixelFormat.bytesPerPixel > 1);
IndeoDecoderBase::IndeoDecoderBase(uint16 width, uint16 height, uint bytesPerPixel) : Codec() {
switch (bytesPerPixel) {
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);
_surface->fillRect(Common::Rect(0, 0, width, height), 0);
_surface->fillRect(Common::Rect(0, 0, width, height), (bytesPerPixel == 4) ? 0xff : 0);
_ctx._bRefBuf = 3; // buffer 2 is used for scalability mode
}

View File

@ -574,7 +574,7 @@ protected:
*/
int scaleMV(int mv, int mvScale);
public:
IndeoDecoderBase(uint16 width, uint16 height);
IndeoDecoderBase(uint16 width, uint16 height, uint bytesPerPixel);
virtual ~IndeoDecoderBase();
};

View File

@ -37,7 +37,8 @@ namespace Image {
#define IVI4_PIC_SIZE_ESC 7
Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
Indeo4Decoder::Indeo4Decoder(uint16 width, uint16 height, uint bytesPerPixel) :
IndeoDecoderBase(width, height, bytesPerPixel) {
_ctx._isIndeo4 = true;
_ctx._refBuf = 1;
_ctx._bRefBuf = 3;

View File

@ -52,7 +52,7 @@ class Indeo4Decoder : public IndeoDecoderBase {
bool _is2dTrans;
};
public:
Indeo4Decoder(uint16 width, uint16 height);
Indeo4Decoder(uint16 width, uint16 height, uint bytesPerPixel = 2);
virtual ~Indeo4Decoder() {}
virtual const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);

View File

@ -48,7 +48,8 @@ enum {
#define IVI5_PIC_SIZE_ESC 15
Indeo5Decoder::Indeo5Decoder(uint16 width, uint16 height) : IndeoDecoderBase(width, height) {
Indeo5Decoder::Indeo5Decoder(uint16 width, uint16 height, uint bytesPerPixel) :
IndeoDecoderBase(width, height, bytesPerPixel) {
_ctx._isIndeo4 = false;
_ctx._refBuf = 1;
_ctx._bRefBuf = 3;

View File

@ -52,7 +52,7 @@ class Indeo5Decoder : public IndeoDecoderBase {
int is_2d_trans;
};
public:
Indeo5Decoder(uint16 width, uint16 height);
Indeo5Decoder(uint16 width, uint16 height, uint bytesPerPixel = 2);
virtual ~Indeo5Decoder() {}
virtual const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);