diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 872b5370414..71b581edc68 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -345,7 +345,7 @@ void AVIDecoder::handleStreamHeader(uint32 size) { } } - AVIVideoTrack *track = new AVIVideoTrack(_header.totalFrames, sHeader, bmInfo, initialPalette); + AVIVideoTrack *track = new AVIVideoTrack(_header.totalFrames, sHeader, bmInfo, initialPalette, _videoCodecAccuracy); if (track->isValid()) addTrack(track); else @@ -945,8 +945,8 @@ VideoDecoder::AudioTrack *AVIDecoder::getAudioTrack(int index) { return (AudioTrack *)track; } -AVIDecoder::AVIVideoTrack::AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader, byte *initialPalette) - : _frameCount(frameCount), _vidsHeader(streamHeader), _bmInfo(bitmapInfoHeader), _initialPalette(initialPalette) { +AVIDecoder::AVIVideoTrack::AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader, byte *initialPalette, Image::CodecAccuracy accuracy) + : _frameCount(frameCount), _vidsHeader(streamHeader), _bmInfo(bitmapInfoHeader), _initialPalette(initialPalette), _accuracy(accuracy) { _videoCodec = createCodec(); _lastFrame = 0; _curFrame = -1; @@ -1041,7 +1041,7 @@ void AVIDecoder::AVIVideoTrack::forceDimensions(uint16 width, uint16 height) { bool AVIDecoder::AVIVideoTrack::rewind() { _curFrame = -1; - + useInitialPalette(); delete _videoCodec; @@ -1051,8 +1051,12 @@ bool AVIDecoder::AVIVideoTrack::rewind() { } Image::Codec *AVIDecoder::AVIVideoTrack::createCodec() { - return Image::createBitmapCodec(_bmInfo.compression, _vidsHeader.streamHandler, _bmInfo.width, + Image::Codec *codec = Image::createBitmapCodec(_bmInfo.compression, _vidsHeader.streamHandler, _bmInfo.width, _bmInfo.height, _bmInfo.bitCount); + + codec->setCodecAccuracy(_accuracy); + + return codec; } void AVIDecoder::AVIVideoTrack::forceTrackEnd() { @@ -1100,6 +1104,15 @@ void AVIDecoder::AVIVideoTrack::setDither(const byte *palette) { _videoCodec->setDither(Image::Codec::kDitherTypeVFW, palette); } +void AVIDecoder::AVIVideoTrack::setCodecAccuracy(Image::CodecAccuracy accuracy) { + if (_accuracy != accuracy) { + _accuracy = accuracy; + + if (_videoCodec) + _videoCodec->setCodecAccuracy(accuracy); + } +} + AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : AudioTrack(soundType), _audsHeader(streamHeader), diff --git a/video/avi_decoder.h b/video/avi_decoder.h index 1e3f00693f2..b564cd4e678 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -202,7 +202,7 @@ protected: class AVIVideoTrack : public FixedRateVideoTrack { public: - AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader, byte *initialPalette = 0); + AVIVideoTrack(int frameCount, const AVIStreamHeader &streamHeader, const BitmapInfoHeader &bitmapInfoHeader, byte *initialPalette, Image::CodecAccuracy accuracy); ~AVIVideoTrack(); void decodeFrame(Common::SeekableReadStream *stream); @@ -213,6 +213,7 @@ protected: uint16 getBitCount() const { return _bmInfo.bitCount; } Graphics::PixelFormat getPixelFormat() const; bool setOutputPixelFormat(const Graphics::PixelFormat &format); + void setCodecAccuracy(Image::CodecAccuracy accuracy); int getCurFrame() const { return _curFrame; } int getFrameCount() const { return _frameCount; } Common::String &getName() { return _vidsHeader.name; } @@ -277,6 +278,8 @@ protected: Image::Codec *_videoCodec; const Graphics::Surface *_lastFrame; + Image::CodecAccuracy _accuracy; + Image::Codec *createCodec(); }; @@ -353,6 +356,7 @@ protected: Common::Array _videoTracks, _audioTracks; TrackStatus _transparencyTrack; + public: virtual AVIAudioTrack *createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo); diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index a4e9cc85e63..9029143074c 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -47,6 +47,7 @@ VideoDecoder::VideoDecoder() { _mainAudioTrack = 0; _canSetDither = true; _canSetDefaultFormat = true; + _videoCodecAccuracy = Image::CodecAccuracy::Default; } void VideoDecoder::close() { @@ -567,6 +568,15 @@ bool VideoDecoder::setOutputPixelFormat(const Graphics::PixelFormat &format) { return result; } +void VideoDecoder::setVideoCodecAccuracy(Image::CodecAccuracy accuracy) { + _videoCodecAccuracy = accuracy; + + for (Track *track : _tracks) { + if (track->getTrackType() == Track::kTrackTypeVideo) + static_cast(track)->setCodecAccuracy(accuracy); + } +} + VideoDecoder::Track::Track() { _paused = false; } diff --git a/video/video_decoder.h b/video/video_decoder.h index b2b3aca94f3..036c4e28dc0 100644 --- a/video/video_decoder.h +++ b/video/video_decoder.h @@ -29,6 +29,7 @@ #include "common/rational.h" #include "common/str.h" #include "graphics/pixelformat.h" +#include "image/codec-options.h" namespace Audio { class AudioStream; @@ -406,6 +407,11 @@ public: */ bool setOutputPixelFormat(const Graphics::PixelFormat &format); + /** + * Set the accuracy of the video decoder + */ + virtual void setVideoCodecAccuracy(Image::CodecAccuracy accuracy); + ///////////////////////////////////////// // Audio Control ///////////////////////////////////////// @@ -596,6 +602,11 @@ protected: */ virtual bool setOutputPixelFormat(const Graphics::PixelFormat &format) { return false; } + /** + * Set the image codec accuracy + */ + virtual void setCodecAccuracy(Image::CodecAccuracy accuracy) {} + /** * Get the current frame of this track * @@ -1003,6 +1014,8 @@ protected: VideoTrack *_nextVideoTrack; + Image::CodecAccuracy _videoCodecAccuracy; + private: uint32 _pauseLevel; uint32 _pauseStartTime;