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 #ifdef USE_MPEG2
24 
25 #ifndef IMAGE_CODECS_MPEG_H
26 #define IMAGE_CODECS_MPEG_H
27 
28 #include "image/codecs/codec.h"
29 #include "graphics/pixelformat.h"
30 
31 #if defined(__PLAYSTATION2__)
32 	typedef uint8 uint8_t;
33 	typedef uint16 uint16_t;
34 	typedef uint32 uint32_t;
35 #elif defined(_WIN32_WCE)
36 	typedef signed char int8_t;
37 	typedef signed short int16_t;
38 	typedef unsigned char uint8_t;
39 	typedef unsigned short uint16_t;
40 #elif defined(_MSC_VER) || defined (__SYMBIAN32__)
41 	typedef signed char int8_t;
42 	typedef signed short int16_t;
43 	typedef unsigned char uint8_t;
44 	typedef unsigned short uint16_t;
45 	#if !defined(SDL_COMPILEDVERSION) || (SDL_COMPILEDVERSION < 1210)
46 	typedef signed long int32_t;
47 	typedef unsigned long uint32_t;
48 	#endif
49 #else
50 #	include <inttypes.h>
51 #endif
52 
53 extern "C" {
54 	#include <mpeg2dec/mpeg2.h>
55 }
56 
57 namespace Common {
58 class SeekableReadStream;
59 }
60 
61 namespace Graphics {
62 struct Surface;
63 }
64 
65 namespace Image {
66 
67 /**
68  * MPEG 1/2 video decoder.
69  *
70  * Used by BMP/AVI.
71  */
72 class MPEGDecoder : public Codec {
73 public:
74 	MPEGDecoder();
75 	~MPEGDecoder();
76 
77 	// Codec interface
78 	const Graphics::Surface *decodeFrame(Common::SeekableReadStream &stream);
getPixelFormat()79 	Graphics::PixelFormat getPixelFormat() const { return _pixelFormat; }
80 
81 	// MPEGPSDecoder call
82 	bool decodePacket(Common::SeekableReadStream &packet, uint32 &framePeriod, Graphics::Surface *dst = 0);
83 
84 private:
85 	Graphics::PixelFormat _pixelFormat;
86 	Graphics::Surface *_surface;
87 
88 	enum {
89 		BUFFER_SIZE = 4096
90 	};
91 
92 	byte _buffer[BUFFER_SIZE];
93 	mpeg2dec_t *_mpegDecoder;
94 	const mpeg2_info_t *_mpegInfo;
95 };
96 
97 } // End of namespace Image
98 
99 #endif // IMAGE_CODECS_MPEG_H
100 
101 #endif // USE_MPEG2
102