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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "common/scummsys.h"
24 
25 /* Intel Indeo 3 decompressor, derived from ffmpeg.
26  *
27  * Original copyright note:
28  * Intel Indeo 3 (IV31, IV32, etc.) video decoder for ffmpeg
29  * written, produced, and directed by Alan Smithee
30  */
31 
32 #ifndef IMAGE_CODECS_INDEO3_H
33 #define IMAGE_CODECS_INDEO3_H
34 
35 #include "image/codecs/codec.h"
36 
37 namespace Image {
38 
39 /**
40  * Intel Indeo 3 decoder.
41  *
42  * Used by BMP/AVI.
43  *
44  * Used in video:
45  *  - VMDDecoder
46  */
47 class Indeo3Decoder : public Codec {
48 public:
49 	Indeo3Decoder(uint16 width, uint16 height, uint bitsPerPixel = 24);
50 	~Indeo3Decoder();
51 
52 	const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
53 	Graphics::PixelFormat getPixelFormat() const;
54 
55 	static bool isIndeo3(Common::SeekableReadStream &stream);
56 
57 private:
58 	Graphics::Surface *_surface;
59 
60 	Graphics::PixelFormat _pixelFormat;
61 
62 	static const int _corrector_type_0[24];
63 	static const int _corrector_type_2[8];
64 	static const uint32 correction[];
65 	static const uint32 correctionloworder[];
66 	static const uint32 correctionhighorder[];
67 
68 	struct YUVBufs {
69 		byte *Ybuf;
70 		byte *Ubuf;
71 		byte *Vbuf;
72 		byte *the_buf;
73 		uint32 the_buf_size;
74 		uint16 y_w, y_h;
75 		uint16 uv_w, uv_h;
76 	};
77 
78 	YUVBufs _iv_frame[2];
79 	YUVBufs *_cur_frame;
80 	YUVBufs *_ref_frame;
81 
82 	byte *_ModPred;
83 	uint16 *_corrector_type;
84 
85 	void buildModPred();
86 	void allocFrames();
87 
88 	void decodeChunk(byte *cur, byte *ref, int width, int height,
89 			const byte *buf1, uint32 fflags2, const byte *hdr,
90 			const byte *buf2, int min_width_160);
91 };
92 
93 } // End of namespace Image
94 
95 #endif
96