From f342d63431fc0784adc08648f17a6bbad934743f Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Mon, 18 Aug 2014 18:31:38 -0400 Subject: IMAGE: Allow for choosing dither type --- image/codecs/cinepak.cpp | 8 ++++---- image/codecs/cinepak.h | 4 ++-- image/codecs/codec.h | 19 +++++++++++++------ video/avi_decoder.cpp | 4 ++-- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/image/codecs/cinepak.cpp b/image/codecs/cinepak.cpp index 9760b5b2a4..de5198812b 100644 --- a/image/codecs/cinepak.cpp +++ b/image/codecs/cinepak.cpp @@ -320,12 +320,12 @@ void CinepakDecoder::decodeVectors(Common::SeekableReadStream &stream, uint16 st } } -bool CinepakDecoder::canDither() const { - return _bitsPerPixel == 24; +bool CinepakDecoder::canDither(DitherType type) const { + return type == kDitherTypeVFW && _bitsPerPixel == 24; } -void CinepakDecoder::setDither(const byte *palette) { - assert(canDither()); +void CinepakDecoder::setDither(DitherType type, const byte *palette) { + assert(canDither(type)); delete[] _colorMap; delete[] _ditherPalette; diff --git a/image/codecs/cinepak.h b/image/codecs/cinepak.h index ce8451bf9a..ccdad0877c 100644 --- a/image/codecs/cinepak.h +++ b/image/codecs/cinepak.h @@ -75,8 +75,8 @@ public: bool containsPalette() const { return _ditherPalette != 0; } const byte *getPalette() { _dirtyPalette = false; return _ditherPalette; } bool hasDirtyPalette() const { return _dirtyPalette; } - bool canDither() const; - void setDither(const byte *palette); + bool canDither(DitherType type) const; + void setDither(DitherType type, const byte *palette); private: CinepakFrame _curFrame; diff --git a/image/codecs/codec.h b/image/codecs/codec.h index 3a2da9ff1e..9abbb3d183 100644 --- a/image/codecs/codec.h +++ b/image/codecs/codec.h @@ -58,6 +58,17 @@ public: Codec() {} virtual ~Codec() {} + /** + * A type of dithering. + */ + enum DitherType { + /** Video for Windows dithering */ + kDitherTypeVFW, + + /** QuickTime dithering */ + kDitherTypeQT + }; + /** * Decode the frame for the given data and return a pointer to a surface * containing the decoded frame. @@ -89,17 +100,13 @@ public: /** * Can the codec dither down to 8bpp? - * - * @note This should only be used for VFW codecs */ - virtual bool canDither() const { return false; } + virtual bool canDither(DitherType type) const { return false; } /** * Activate dithering mode with a palette - * - * @note This should only be used for VFW codecs */ - virtual void setDither(const byte *palette) {} + virtual void setDither(DitherType type, const byte *palette) {} }; /** diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 72892534fb..700975d9a2 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -831,12 +831,12 @@ bool AVIDecoder::AVIVideoTrack::hasDirtyPalette() const { } bool AVIDecoder::AVIVideoTrack::canDither() const { - return _videoCodec && _videoCodec->canDither(); + return _videoCodec && _videoCodec->canDither(Image::Codec::kDitherTypeVFW); } void AVIDecoder::AVIVideoTrack::setDither(const byte *palette) { assert(_videoCodec); - _videoCodec->setDither(palette); + _videoCodec->setDither(Image::Codec::kDitherTypeVFW, palette); } AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) -- cgit v1.2.3