diff options
author | Matthew Hoops | 2010-09-06 15:15:59 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-09-06 15:15:59 +0000 |
commit | c54a97005f3c03a6ab8585f7c4fb7d7a6912918e (patch) | |
tree | 9cefe3d1f46655568bfbf6a151adba5cfa97fff2 /graphics/video | |
parent | df7158c0ee9cd6fde0183b2841d1c918f5c8ab7b (diff) | |
download | scummvm-rg350-c54a97005f3c03a6ab8585f7c4fb7d7a6912918e.tar.gz scummvm-rg350-c54a97005f3c03a6ab8585f7c4fb7d7a6912918e.tar.bz2 scummvm-rg350-c54a97005f3c03a6ab8585f7c4fb7d7a6912918e.zip |
VIDEO: Apply patch #3057924 with some changes
Patch #3057924 is "QuickTimeDecoder: Scaling x and y separately". Thanks to kreegee for the patch and fuzzie for fixing a couple bugs with it.
svn-id: r52594
Diffstat (limited to 'graphics/video')
-rw-r--r-- | graphics/video/qt_decoder.cpp | 57 | ||||
-rw-r--r-- | graphics/video/qt_decoder.h | 15 |
2 files changed, 34 insertions, 38 deletions
diff --git a/graphics/video/qt_decoder.cpp b/graphics/video/qt_decoder.cpp index 470441dab8..3cdb82fb10 100644 --- a/graphics/video/qt_decoder.cpp +++ b/graphics/video/qt_decoder.cpp @@ -67,6 +67,8 @@ QuickTimeDecoder::QuickTimeDecoder() : VideoDecoder() { _numStreams = 0; _fd = 0; _scaledSurface = 0; + _scaleFactorX = 1; + _scaleFactorY = 1; _dirtyPalette = false; _resFork = new Common::MacResManager(); @@ -82,14 +84,14 @@ uint16 QuickTimeDecoder::getWidth() const { if (_videoStreamIndex < 0) return 0; - return _streams[_videoStreamIndex]->width / getScaleMode(); + return (Common::Rational(_streams[_videoStreamIndex]->width) / getScaleFactorX()).toInt(); } uint16 QuickTimeDecoder::getHeight() const { if (_videoStreamIndex < 0) return 0; - return _streams[_videoStreamIndex]->height / getScaleMode(); + return (Common::Rational(_streams[_videoStreamIndex]->height) / getScaleFactorY()).toInt(); } uint32 QuickTimeDecoder::getFrameCount() const { @@ -113,11 +115,18 @@ uint32 QuickTimeDecoder::getCodecTag() { return _streams[_videoStreamIndex]->codec_tag; } -ScaleMode QuickTimeDecoder::getScaleMode() const { +Common::Rational QuickTimeDecoder::getScaleFactorX() const { if (_videoStreamIndex < 0) - return kScaleNormal; + return 1; - return (ScaleMode)(_scaleMode * _streams[_videoStreamIndex]->scaleMode); + return (_scaleFactorX * _streams[_videoStreamIndex]->scaleFactorX); +} + +Common::Rational QuickTimeDecoder::getScaleFactorY() const { + if (_videoStreamIndex < 0) + return 1; + + return (_scaleFactorY * _streams[_videoStreamIndex]->scaleFactorY); } uint32 QuickTimeDecoder::getFrameDuration() { @@ -231,14 +240,14 @@ Surface *QuickTimeDecoder::decodeNextFrame() { } Surface *QuickTimeDecoder::scaleSurface(Surface *frame) { - if (getScaleMode() == kScaleNormal) + if (getScaleFactorX() == 1 && getScaleFactorY() == 1) return frame; assert(_scaledSurface); - for (uint32 j = 0; j < _scaledSurface->h; j++) - for (uint32 k = 0; k < _scaledSurface->w; k++) - memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr(k * getScaleMode(), j * getScaleMode()), frame->bytesPerPixel); + for (int32 j = 0; j < _scaledSurface->h; j++) + for (int32 k = 0; k < _scaledSurface->w; k++) + memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr((k * getScaleFactorX()).toInt() , (j * getScaleFactorY()).toInt()), frame->bytesPerPixel); return _scaledSurface; } @@ -376,7 +385,7 @@ void QuickTimeDecoder::init() { if (_videoStreamIndex >= 0) { _videoCodec = createCodec(getCodecTag(), getBitsPerPixel()); - if (getScaleMode() != kScaleNormal) { + if (getScaleFactorX() != 1 || getScaleFactorY() != 1) { // We have to initialize the scaled surface _scaledSurface = new Surface(); _scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel); @@ -593,17 +602,11 @@ int QuickTimeDecoder::readMVHD(MOVatom atom) { uint32 yMod = _fd->readUint32BE(); _fd->skip(16); - if (xMod != yMod) - error("X and Y resolution modifiers differ"); + _scaleFactorX = Common::Rational(0x10000, xMod); + _scaleFactorY = Common::Rational(0x10000, yMod); - if (xMod == 0x8000) - _scaleMode = kScaleHalf; - else if (xMod == 0x4000) - _scaleMode = kScaleQuarter; - else - _scaleMode = kScaleNormal; - - debug(1, "readMVHD(): scaleMode = %d", (int)_scaleMode); + _scaleFactorX.debugPrint(1, "readMVHD(): scaleFactorX ="); + _scaleFactorY.debugPrint(1, "readMVHD(): scaleFactorY ="); _fd->readUint32BE(); // preview time _fd->readUint32BE(); // preview duration @@ -688,17 +691,11 @@ int QuickTimeDecoder::readTKHD(MOVatom atom) { uint32 yMod = _fd->readUint32BE(); _fd->skip(16); - if (xMod != yMod) - error("X and Y resolution modifiers differ"); - - if (xMod == 0x8000) - st->scaleMode = kScaleHalf; - else if (xMod == 0x4000) - st->scaleMode = kScaleQuarter; - else - st->scaleMode = kScaleNormal; + st->scaleFactorX = Common::Rational(0x10000, xMod); + st->scaleFactorY = Common::Rational(0x10000, yMod); - debug(1, "readTKHD(): scaleMode = %d", (int)_scaleMode); + st->scaleFactorX.debugPrint(1, "readTKHD(): scaleFactorX ="); + st->scaleFactorY.debugPrint(1, "readTKHD(): scaleFactorY ="); // these are fixed-point, 16:16 // uint32 tkWidth = _fd->readUint32BE() >> 16; // track width diff --git a/graphics/video/qt_decoder.h b/graphics/video/qt_decoder.h index 196d4c02cb..6dcfc0944d 100644 --- a/graphics/video/qt_decoder.h +++ b/graphics/video/qt_decoder.h @@ -36,6 +36,7 @@ #include "common/scummsys.h" #include "common/queue.h" +#include "common/rational.h" #include "graphics/video/video_decoder.h" #include "graphics/video/codecs/codec.h" @@ -50,11 +51,6 @@ namespace Common { namespace Graphics { -enum ScaleMode { - kScaleNormal = 1, - kScaleHalf = 2, - kScaleQuarter = 4 -}; class QuickTimeDecoder : public RewindableVideoDecoder { public: @@ -217,7 +213,8 @@ protected: uint32 nb_frames; uint32 duration; uint32 start_time; - ScaleMode scaleMode; + Common::Rational scaleFactorX; + Common::Rational scaleFactorY; }; const ParseTable *_parseTable; @@ -230,7 +227,8 @@ protected: MOVStreamContext *_partial; uint32 _numStreams; int _ni; - ScaleMode _scaleMode; + Common::Rational _scaleFactorX; + Common::Rational _scaleFactorY; MOVStreamContext *_streams[20]; byte _palette[256 * 3]; bool _dirtyPalette; @@ -260,7 +258,8 @@ protected: Surface *_scaledSurface; Surface *scaleSurface(Surface *frame); - ScaleMode getScaleMode() const; + Common::Rational getScaleFactorX() const; + Common::Rational getScaleFactorY() const; void pauseVideoIntern(bool pause); |