aboutsummaryrefslogtreecommitdiff
path: root/engines/cryo/video.h
blob: 2c55baa5d9883268bd42de61b26a7edfb5abec78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef CRYO_VIDEO_H
#define CRYO_VIDEO_H

namespace Cryo {

class CryoEngine;

class HnmPlayer {
public:
	Common::File *_file;
	HNMHeader     _header;

private:
	CryoEngine *_vm;

	void resetInternalTimer();
	void wantsSound(bool sound);
	void decompADPCM(byte *buffer, int16 *output, int size);
	void loadDecompTable(int16 *buffer);
	bool loadFrame();
	void tryRead(int size);
	void changePalette();
	void selectBuffers();
	void decompLempelZiv(byte *buffer, byte *output);
	void desentrelace320(byte *frame_buffer, byte *final_buffer, uint16 height);
	void desentrelace();
	void decompUBA(byte *output, byte *curr_buffer, byte *prev_buffer, byte *input, int width, char flags);
	void setupSoundADPCM(int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode);
	void init();

	// Unused
	void done();
	void canLoop(bool canLoop);
	void soundInADPCM(bool is_adpcm);
	void soundMono(bool is_mono);
	//

	bool _soundStarted;
	int16 _pendingSounds;
	float _timeDrift;
	float _nextFrameTime;
	float _expectedFrameTime;
	float _rate;
	bool _useSoundSync;
	bool _useSound;
	int16 _prevRight;
	int16 _prevLeft;
	bool _useAdpcm;
	bool _useMono;
	bool _preserveColor0;
	int16 decompTable[256];
	bool _safePalette;
	int     _frameNum;
	byte   *_tmpBuffer[2];
	byte   *_finalBuffer;
	byte   *_newFrameBuffer;
	byte   *_oldFrameBuffer;
	byte   *_readBuffer;
	byte   *_dataPtr;
	color_t _palette[256];
	bool    _canLoop;
	int16   _chunkId;
	int     _totalRead;

	void (*_customChunkHandler)(byte *buffer, int size, int16 id, char h6, char h7);

	SoundChannel *_soundChannel;
	SoundGroup *_soundGroup;
	SoundChannel *_soundChannelAdpcm;
	SoundGroup *_soundGroupAdpcm;

public:
	uint16 _curVideoNum;

	HnmPlayer(CryoEngine *vm);

	void allocMemory();
	void closeSound();
	void deallocMemory();
	int getFrameNum();
	SoundChannel *getSoundChannel();
	int16 getVersion();
	bool nextElement();
	void reset();
	void readHeader();
	void resetInternals();
	void setFile(Common::File *file);
	void setFinalBuffer(byte *buffer);
	void setForceZero2Black(bool forceblack);
	void setupSound(int16 numSounds, int16 length, int16 sampleSize, float rate, int16 mode);
	void setupTimer(float rate);
	void waitLoop();
};

} // End of namespace Cryo

#endif