ScummVM API documentation
cinepak.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef IMAGE_CODECS_CINEPAK_H
23#define IMAGE_CODECS_CINEPAK_H
24
25#include "common/scummsys.h"
26#include "common/rect.h"
27#include "graphics/pixelformat.h"
28#include "graphics/palette.h"
29
30#include "image/codecs/codec.h"
31
32namespace Common {
33class SeekableReadStream;
34}
35
36namespace Image {
37
39 // These are not in the normal YUV colorspace, but in the Cinepak YUV colorspace instead.
40 byte y[4]; // [0, 255]
41 int8 u, v; // [-128, 127]
42};
43
45 uint16 id;
46 uint16 length;
47 Common::Rect rect;
48 CinepakCodebook v1_codebook[256], v4_codebook[256];
49 uint32 v1_dither[256 * 4 * 4], v4_dither[256 * 4 * 4];
50};
51
53 byte flags;
54 uint32 length;
55 uint16 width;
56 uint16 height;
57 uint16 stripCount;
58 CinepakStrip *strips;
59
60 Graphics::Surface *surface;
61};
62
71class CinepakDecoder : public Codec {
72public:
73 CinepakDecoder(int bitsPerPixel = 24);
74 ~CinepakDecoder() override;
75
77 Graphics::PixelFormat getPixelFormat() const override { return _pixelFormat; }
78 bool setOutputPixelFormat(const Graphics::PixelFormat &format) override;
79
80 bool containsPalette() const override { return _ditherPalette != 0; }
81 const byte *getPalette() override { _dirtyPalette = false; return _ditherPalette.data(); }
82 bool hasDirtyPalette() const override { return _dirtyPalette; }
83 bool canDither(DitherType type) const override;
84 void setDither(DitherType type, const byte *palette) override;
85
86private:
87 CinepakFrame _curFrame;
88 int32 _y;
89 int _bitsPerPixel;
90 Graphics::PixelFormat _pixelFormat;
91 byte *_clipTable, *_clipTableBuf;
92
93 Graphics::Palette _ditherPalette;
94 bool _dirtyPalette;
95 byte *_colorMap;
96 DitherType _ditherType;
97
98 void initializeCodebook(uint16 strip, byte codebookType);
99 void loadCodebook(Common::SeekableReadStream &stream, uint16 strip, byte codebookType, byte chunkID, uint32 chunkSize);
100 void decodeVectors8(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
101 void decodeVectors24(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
102
103 byte findNearestRGB(int index) const;
104 void ditherVectors(Common::SeekableReadStream &stream, uint16 strip, byte chunkID, uint32 chunkSize);
105 void ditherCodebookQT(uint16 strip, byte codebookType, uint16 codebookIndex);
106 void ditherCodebookVFW(uint16 strip, byte codebookType, uint16 codebookIndex);
107};
108
109} // End of namespace Image
110
111#endif
Definition: stream.h:745
Simple class for handling a palette data.
Definition: palette.h:61
Definition: cinepak.h:71
bool hasDirtyPalette() const override
Definition: cinepak.h:82
bool setOutputPixelFormat(const Graphics::PixelFormat &format) override
bool containsPalette() const override
Definition: cinepak.h:80
void setDither(DitherType type, const byte *palette) override
const byte * getPalette() override
Definition: cinepak.h:81
bool canDither(DitherType type) const override
Graphics::PixelFormat getPixelFormat() const override
Definition: cinepak.h:77
const Graphics::Surface * decodeFrame(Common::SeekableReadStream &stream) override
Definition: codec.h:57
DitherType
Definition: codec.h:65
Definition: algorithm.h:29
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: surface.h:67
Definition: cinepak.h:38
Definition: cinepak.h:52
Definition: cinepak.h:44