ScummVM API documentation
truemotion1.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 // Based on the TrueMotion 1 decoder by Alex Beregszaszi & Mike Melanson in FFmpeg
23 
24 // Only compile if SCI32 is enabled, TESTBED is enabled, ZVISION is enabled, or if we're building dynamic modules
25 #if defined(ENABLE_SCI32) || defined(ENABLE_TESTBED) || defined(ENABLE_ZVISION) || defined(DYNAMIC_MODULES)
26 
27 #ifndef IMAGE_CODECS_TRUEMOTION1_H
28 #define IMAGE_CODECS_TRUEMOTION1_H
29 
30 #include "image/codecs/codec.h"
31 
32 namespace Image {
33 
39 class TrueMotion1Decoder : public Codec {
40 public:
41  TrueMotion1Decoder();
42  ~TrueMotion1Decoder() override;
43 
44  const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream) override;
45 
46  // Always return RGB565
47  Graphics::PixelFormat getPixelFormat() const override { return Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0); }
48 
49 private:
50  Graphics::Surface *_surface;
51 
52  int _mbChangeBitsRowSize;
53  byte *_buf, *_mbChangeBits, *_indexStream;
54  int _indexStreamSize;
55 
56  int _flags;
57 
58  struct PredictorTableEntry {
59  uint32 color;
60  bool getNextIndex;
61  };
62 
63  PredictorTableEntry _yPredictorTable[1024];
64  PredictorTableEntry _cPredictorTable[1024];
65 
66  int _blockType;
67  int _blockWidth;
68  int _blockHeight;
69 
70  int16 _ydt[8];
71  int16 _cdt[8];
72 
73  int _lastDeltaset, _lastVectable;
74 
75  uint32 *_vertPred;
76 
77  struct {
78  byte headerSize;
79  byte compression;
80  byte deltaset;
81  byte vectable;
82  uint16 ysize;
83  uint16 xsize;
84  uint16 checksum;
85  byte version;
86  byte headerType;
87  byte flags;
88  byte control;
89  uint16 xoffset;
90  uint16 yoffset;
91  uint16 width;
92  uint16 height;
93  } _header;
94 
95  void selectDeltaTables(int deltaTableIndex);
96  void decodeHeader(Common::SeekableReadStream &stream);
97  void decode16();
98  int makeYdt16Entry(int p1, int p2);
99  int makeCdt16Entry(int p1, int p2);
100  void genVectorTable16(const byte *selVectorTable);
101 };
102 
103 } // End of namespace Image
104 
105 #endif // IMAGE_CODECS_TRUEMOTION1_H
106 #endif // SCI32/Plugins guard
Definition: surface.h:67
Definition: pixelformat.h:138
Definition: stream.h:745
Definition: movie_decoder.h:32