From ec38016044e674fadc0e8b370afd5cd25110b392 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 26 May 2014 11:01:11 -0400 Subject: IMAGE: Fix compiling in truemotion --- image/codecs/codec.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'image') diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp index 530fb3b836..64acf3f169 100644 --- a/image/codecs/codec.cpp +++ b/image/codecs/codec.cpp @@ -58,7 +58,7 @@ Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) { return new CinepakDecoder(bitsPerPixel); case MKTAG('I','V','3','2'): return new Indeo3Decoder(width, height); -#ifdef VIDEO_CODECS_TRUEMOTION1_H +#ifdef IMAGE_CODECS_TRUEMOTION1_H case MKTAG('D','U','C','K'): case MKTAG('d','u','c','k'): return new TrueMotion1Decoder(width, height); -- cgit v1.2.3 From 9fc10d9739217024e2435bcf1466b101163a2e56 Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 26 May 2014 17:49:53 -0400 Subject: IMAGE: Limit truemotion to decoding within its boundaries, not AVI's --- image/codecs/truemotion1.cpp | 31 ++++++++++++++++--------------- image/codecs/truemotion1.h | 1 - 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'image') diff --git a/image/codecs/truemotion1.cpp b/image/codecs/truemotion1.cpp index 1302d72e2f..b5f7c76f6b 100644 --- a/image/codecs/truemotion1.cpp +++ b/image/codecs/truemotion1.cpp @@ -90,14 +90,9 @@ static const CompressionType compressionTypes[17] = { TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) { _surface = new Graphics::Surface(); - _width = width; - _height = height; - _surface->create(width, height, getPixelFormat()); - // there is a vertical predictor for each pixel in a line; each vertical - // predictor is 0 to start with - _vertPred = new uint32[_width]; + _vertPred = 0; _buf = _mbChangeBits = _indexStream = 0; _lastDeltaset = _lastVectable = -1; @@ -170,11 +165,6 @@ void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream &stream) { byte headerBuffer[128]; // logical maximum size of the header const byte *selVectorTable; - // There is 1 change bit per 4 pixels, so each change byte represents - // 32 pixels; divide width by 4 to obtain the number of change bits and - // then round up to the nearest byte. - _mbChangeBitsRowSize = ((_width >> 2) + 7) >> 3; - _header.headerSize = ((_buf[0] >> 5) | (_buf[0] << 3)) & 0x7f; if (_buf[0] < 0x10) @@ -196,6 +186,17 @@ void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream &stream) { _header.flags = headerBuffer[11]; _header.control = headerBuffer[12]; + if (!_vertPred) { + // there is a vertical predictor for each pixel in a line; each vertical + // predictor is 0 to start with + _vertPred = new uint32[_header.xsize]; + } + + // There is 1 change bit per 4 pixels, so each change byte represents + // 32 pixels; divide width by 4 to obtain the number of change bits and + // then round up to the nearest byte. + _mbChangeBitsRowSize = ((_header.xsize >> 2) + 7) >> 3; + // Version 2 if (_header.version >= 2) { if (_header.headerType > 3) { @@ -240,7 +241,7 @@ void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream &stream) { _indexStream = _mbChangeBits; } else { // one change bit per 4x4 block - _indexStream = _mbChangeBits + _mbChangeBitsRowSize * (_height >> 2); + _indexStream = _mbChangeBits + _mbChangeBitsRowSize * (_header.ysize >> 2); } _indexStreamSize = stream.size() - (_indexStream - _buf); @@ -306,11 +307,11 @@ void TrueMotion1Decoder::decode16() { int index; // clean out the line buffer - memset(_vertPred, 0, _width * 4); + memset(_vertPred, 0, _header.xsize * 4); GET_NEXT_INDEX(); - for (int y = 0; y < _height; y++) { + for (int y = 0; y < _header.ysize; y++) { // re-init variables for the next line iteration uint32 horizPred = 0; uint32 *currentPixelPair = (uint32 *)_surface->getBasePtr(0, y); @@ -319,7 +320,7 @@ void TrueMotion1Decoder::decode16() { byte mbChangeByte = _mbChangeBits[mbChangeIndex++]; byte mbChangeByteMask = 1; - for (int pixelsLeft = _width; pixelsLeft > 0; pixelsLeft -= 4) { + for (int pixelsLeft = _header.xsize; pixelsLeft > 0; pixelsLeft -= 4) { if (keyframe || (mbChangeByte & mbChangeByteMask) == 0) { switch (y & 3) { case 0: diff --git a/image/codecs/truemotion1.h b/image/codecs/truemotion1.h index 12570f066c..bbbcd6d6be 100644 --- a/image/codecs/truemotion1.h +++ b/image/codecs/truemotion1.h @@ -54,7 +54,6 @@ private: byte *_buf, *_mbChangeBits, *_indexStream; int _indexStreamSize; - uint16 _width, _height; int _flags; struct PredictorTableEntry { -- cgit v1.2.3 From 8c3e8624f04621d947f94bad6f19b55ad961530a Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 26 May 2014 17:55:39 -0400 Subject: IMAGE: Ensure the truemotion surface is cleared to black before decoding --- image/codecs/truemotion1.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'image') diff --git a/image/codecs/truemotion1.cpp b/image/codecs/truemotion1.cpp index b5f7c76f6b..741b9d51eb 100644 --- a/image/codecs/truemotion1.cpp +++ b/image/codecs/truemotion1.cpp @@ -30,6 +30,7 @@ #include "image/codecs/truemotion1data.h" #include "common/stream.h" #include "common/textconsole.h" +#include "common/rect.h" #include "common/util.h" namespace Image { @@ -91,6 +92,7 @@ static const CompressionType compressionTypes[17] = { TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) { _surface = new Graphics::Surface(); _surface->create(width, height, getPixelFormat()); + _surface->fillRect(Common::Rect(width, height), getPixelFormat().RGBToColor(0, 0, 0)); _vertPred = 0; -- cgit v1.2.3 From 5891ef4d89936917aaa7edf06f5d1fbc06a1271f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Tue, 27 May 2014 00:09:11 -0400 Subject: VIDEO: Handle Truemotion dimensions specially Truemotion uses its own demuxer and seems to follow its own AVI rules. Work around it by coercing the video's dimensions to use the codec's internal dimensions. --- image/codecs/codec.cpp | 2 +- image/codecs/truemotion1.cpp | 19 ++++++++++++------- image/codecs/truemotion1.h | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) (limited to 'image') diff --git a/image/codecs/codec.cpp b/image/codecs/codec.cpp index 64acf3f169..6b0c7ebcfb 100644 --- a/image/codecs/codec.cpp +++ b/image/codecs/codec.cpp @@ -61,7 +61,7 @@ Codec *createBitmapCodec(uint32 tag, int width, int height, int bitsPerPixel) { #ifdef IMAGE_CODECS_TRUEMOTION1_H case MKTAG('D','U','C','K'): case MKTAG('d','u','c','k'): - return new TrueMotion1Decoder(width, height); + return new TrueMotion1Decoder(); #endif #ifdef USE_MPEG2 case MKTAG('m','p','g','2'): diff --git a/image/codecs/truemotion1.cpp b/image/codecs/truemotion1.cpp index 741b9d51eb..e60ec6c72e 100644 --- a/image/codecs/truemotion1.cpp +++ b/image/codecs/truemotion1.cpp @@ -89,11 +89,8 @@ static const CompressionType compressionTypes[17] = { { ALGO_RGB24H, 2, 2, BLOCK_2x2 } }; -TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) { - _surface = new Graphics::Surface(); - _surface->create(width, height, getPixelFormat()); - _surface->fillRect(Common::Rect(width, height), getPixelFormat().RGBToColor(0, 0, 0)); - +TrueMotion1Decoder::TrueMotion1Decoder() { + _surface = 0; _vertPred = 0; _buf = _mbChangeBits = _indexStream = 0; @@ -101,8 +98,11 @@ TrueMotion1Decoder::TrueMotion1Decoder(uint16 width, uint16 height) { } TrueMotion1Decoder::~TrueMotion1Decoder() { - _surface->free(); - delete _surface; + if (_surface) { + _surface->free(); + delete _surface; + } + delete[] _vertPred; } @@ -194,6 +194,11 @@ void TrueMotion1Decoder::decodeHeader(Common::SeekableReadStream &stream) { _vertPred = new uint32[_header.xsize]; } + if (!_surface) { + _surface = new Graphics::Surface(); + _surface->create(_header.xsize, _header.ysize, getPixelFormat()); + } + // There is 1 change bit per 4 pixels, so each change byte represents // 32 pixels; divide width by 4 to obtain the number of change bits and // then round up to the nearest byte. diff --git a/image/codecs/truemotion1.h b/image/codecs/truemotion1.h index bbbcd6d6be..51daf607d2 100644 --- a/image/codecs/truemotion1.h +++ b/image/codecs/truemotion1.h @@ -39,7 +39,7 @@ namespace Image { */ class TrueMotion1Decoder : public Codec { public: - TrueMotion1Decoder(uint16 width, uint16 height); + TrueMotion1Decoder(); ~TrueMotion1Decoder(); const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream); -- cgit v1.2.3