ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

cinepak.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef IMAGE_CODECS_CINEPAK_H
00024 #define IMAGE_CODECS_CINEPAK_H
00025 
00026 #include "common/scummsys.h"
00027 #include "common/rect.h"
00028 #include "graphics/pixelformat.h"
00029 
00030 #include "image/codecs/codec.h"
00031 
00032 namespace Common {
00033 class SeekableReadStream;
00034 }
00035 
00036 namespace Image {
00037 
00038 struct CinepakCodebook {
00039     // These are not in the normal YUV colorspace, but in the Cinepak YUV colorspace instead.
00040     byte y[4]; // [0, 255]
00041     int8 u, v; // [-128, 127]
00042 };
00043 
00044 struct CinepakStrip {
00045     uint16 id;
00046     uint16 length;
00047     Common::Rect rect;
00048     CinepakCodebook v1_codebook[256], v4_codebook[256];
00049     byte v1_dither[256 * 4 * 4 * 4], v4_dither[256 * 4 * 4 * 4];
00050 };
00051 
00052 struct CinepakFrame {
00053     byte flags;
00054     uint32 length;
00055     uint16 width;
00056     uint16 height;
00057     uint16 stripCount;
00058     CinepakStrip *strips;
00059 
00060     Graphics::Surface *surface;
00061 };
00062 
00071 class CinepakDecoder : public Codec {
00072 public:
00073     CinepakDecoder(int bitsPerPixel = 24);
00074     ~CinepakDecoder();
00075 
00076     const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
00077     Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
00078 
00079     bool containsPalette() const { return _ditherPalette != 0; }
00080     const byte *getPalette() { _dirtyPalette = false; return _ditherPalette; }
00081     bool hasDirtyPalette() const { return _dirtyPalette; }
00082     bool canDither(DitherType type) const;
00083     void setDither(DitherType type, const byte *palette);
00084 
00085 private:
00086     CinepakFrame _curFrame;
00087     int32 _y;
00088     int _bitsPerPixel;
00089     Graphics::PixelFormat _pixelFormat;
00090     byte *_clipTable, *_clipTableBuf;
00091 
00092     byte *_ditherPalette;
00093     bool _dirtyPalette;
00094     byte *_colorMap;
00095     DitherType _ditherType;
00096 
00097     void initializeCodebook(uint16 strip, byte codebookType);
00098     void loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize);
00099     void decodeVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
00100 
00101     byte findNearestRGB(int index) const;
00102     void ditherVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
00103     void ditherCodebookQT(uint16 strip, byte codebookType, uint16 codebookIndex);
00104 };
00105 
00106 } // End of namespace Image
00107 
00108 #endif


Generated on Sat Sep 14 2019 05:01:33 for ResidualVM by doxygen 1.7.1
curved edge   curved edge