Ticket #9205: qt_scaler_v2.diff
File qt_scaler_v2.diff, 5.4 KB (added by , 14 years ago) |
---|
-
video/qt_decoder.cpp
67 67 _numStreams = 0; 68 68 _fd = 0; 69 69 _scaledSurface = 0; 70 _scaleFactorX = 1; 71 _scaleFactorY = 1; 70 72 _dirtyPalette = false; 71 73 _resFork = new Common::MacResManager(); 72 74 … … 82 84 if (_videoStreamIndex < 0) 83 85 return 0; 84 86 85 return _streams[_videoStreamIndex]->width / getScaleMode();87 return Common::Rational(_streams[_videoStreamIndex]->width,getScaleFactorX()).toInt(); 86 88 } 87 89 88 90 uint16 QuickTimeDecoder::getHeight() const { 89 91 if (_videoStreamIndex < 0) 90 92 return 0; 91 92 return _streams[_videoStreamIndex]->height / getScaleMode();93 94 return Common::Rational(_streams[_videoStreamIndex]->height,getScaleFactorY()).toInt(); 93 95 } 94 96 95 97 uint32 QuickTimeDecoder::getFrameCount() const { … … 113 115 return _streams[_videoStreamIndex]->codec_tag; 114 116 } 115 117 116 ScaleMode QuickTimeDecoder::getScaleMode() const {118 Common::Rational QuickTimeDecoder::getScaleFactorX() const { 117 119 if (_videoStreamIndex < 0) 118 return kScaleNormal;120 return 1; 119 121 120 return ( ScaleMode)(_scaleMode * _streams[_videoStreamIndex]->scaleMode);122 return (_scaleFactorX * _streams[_videoStreamIndex]->scaleFactorX); 121 123 } 122 124 125 Common::Rational QuickTimeDecoder::getScaleFactorY() const { 126 if (_videoStreamIndex < 0) 127 return 1; 128 129 return (_scaleFactorY * _streams[_videoStreamIndex]->scaleFactorY); 130 } 131 123 132 uint32 QuickTimeDecoder::getFrameDuration() { 124 133 if (_videoStreamIndex < 0) 125 134 return 0; … … 231 240 } 232 241 233 242 Surface *QuickTimeDecoder::scaleSurface(Surface *frame) { 234 if (getScale Mode() == kScaleNormal)243 if (getScaleFactorX() == 1 && getScaleFactorY() == 1) 235 244 return frame; 236 245 237 246 assert(_scaledSurface); 238 247 239 for ( uint32 j = 0; j < _scaledSurface->h; j++)240 for ( uint32 k = 0; k < _scaledSurface->w; k++)241 memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr( k * getScaleMode(), j * getScaleMode()), frame->bytesPerPixel);248 for (int32 j = 0; j < _scaledSurface->h; j++) 249 for (int32 k = 0; k < _scaledSurface->w; k++) 250 memcpy(_scaledSurface->getBasePtr(k, j), frame->getBasePtr(int(getScaleFactorX() * k ) , int(getScaleFactorY() * j)), frame->bytesPerPixel); 242 251 243 252 return _scaledSurface; 244 253 } … … 376 385 if (_videoStreamIndex >= 0) { 377 386 _videoCodec = createCodec(getCodecTag(), getBitsPerPixel()); 378 387 379 if (getScale Mode() != kScaleNormal) {388 if (getScaleFactorX() != 1 || getScaleFactorY() != 1) { 380 389 // We have to initialize the scaled surface 381 390 _scaledSurface = new Surface(); 382 391 _scaledSurface->create(getWidth(), getHeight(), getPixelFormat().bytesPerPixel); … … 592 601 _fd->skip(12); 593 602 uint32 yMod = _fd->readUint32BE(); 594 603 _fd->skip(16); 604 605 _scaleFactorX = Common::Rational(65536, xMod); 606 _scaleFactorY = Common::Rational(65536, yMod); 595 607 596 if (xMod != yMod)597 error("X and Y resolution modifiers differ");608 debug(1, "readMVHD(): scaleFactorX = %f", double(_scaleFactorX)); 609 debug(1, "readMVHD(): scaleFactorY = %f", double(_scaleFactorY)); 598 610 599 if (xMod == 0x8000)600 _scaleMode = kScaleHalf;601 else if (xMod == 0x4000)602 _scaleMode = kScaleQuarter;603 else604 _scaleMode = kScaleNormal;605 606 debug(1, "readMVHD(): scaleMode = %d", (int)_scaleMode);607 608 611 _fd->readUint32BE(); // preview time 609 612 _fd->readUint32BE(); // preview duration 610 613 _fd->readUint32BE(); // poster time … … 687 690 _fd->skip(12); 688 691 uint32 yMod = _fd->readUint32BE(); 689 692 _fd->skip(16); 693 694 st->scaleFactorX = Common::Rational(65536, xMod); 695 st->scaleFactorY = Common::Rational(65536, yMod); 696 697 debug(1, "readTKHD(): scaleFactorX = %f", double(st->scaleFactorX)); 698 debug(1, "readTKHD(): scaleFactorY = %f", double(st->scaleFactorY)); 690 699 691 if (xMod != yMod)692 error("X and Y resolution modifiers differ");693 694 if (xMod == 0x8000)695 st->scaleMode = kScaleHalf;696 else if (xMod == 0x4000)697 st->scaleMode = kScaleQuarter;698 else699 st->scaleMode = kScaleNormal;700 701 debug(1, "readTKHD(): scaleMode = %d", (int)_scaleMode);702 703 700 // these are fixed-point, 16:16 704 701 // uint32 tkWidth = _fd->readUint32BE() >> 16; // track width 705 702 // uint32 tkHeight = _fd->readUint32BE() >> 16; // track height -
video/qt_decoder.h
36 36 37 37 #include "common/scummsys.h" 38 38 #include "common/queue.h" 39 #include "common/rational.h" 39 40 40 41 #include "graphics/video/video_decoder.h" 41 42 #include "graphics/video/codecs/codec.h" … … 50 51 51 52 namespace Graphics { 52 53 53 enum ScaleMode {54 kScaleNormal = 1,55 kScaleHalf = 2,56 kScaleQuarter = 457 };58 54 59 55 class QuickTimeDecoder : public RewindableVideoDecoder { 60 56 public: … … 217 213 uint32 nb_frames; 218 214 uint32 duration; 219 215 uint32 start_time; 220 ScaleMode scaleMode; 216 Common::Rational scaleFactorX; 217 Common::Rational scaleFactorY; 221 218 }; 222 219 223 220 const ParseTable *_parseTable; … … 230 227 MOVStreamContext *_partial; 231 228 uint32 _numStreams; 232 229 int _ni; 233 ScaleMode _scaleMode; 230 Common::Rational _scaleFactorX; 231 Common::Rational _scaleFactorY; 234 232 MOVStreamContext *_streams[20]; 235 233 byte _palette[256 * 3]; 236 234 bool _dirtyPalette; … … 260 258 261 259 Surface *_scaledSurface; 262 260 Surface *scaleSurface(Surface *frame); 263 ScaleMode getScaleMode() const; 261 Common::Rational getScaleFactorX() const; 262 Common::Rational getScaleFactorY() const; 264 263 265 264 void pauseVideoIntern(bool pause); 266 265