ScummVM API documentation
movie_decoder.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 ACCESS_VIDEO_MOVIE_DECODER_H
23 #define ACCESS_VIDEO_MOVIE_DECODER_H
24 
25 #include "video/video_decoder.h"
26 #include "audio/audiostream.h"
27 
28 namespace Common {
29 class SeekableReadStream;
30 }
31 
32 namespace Image {
33 class Codec;
34 }
35 
36 namespace Access {
37 
38 enum kDebugLevels {
39  kVIDMovieChunkId_FullFrame = 0x00,
40  kVIDMovieChunkId_FullFrameCompressed = 0x01,
41  kVIDMovieChunkId_Palette = 0x02,
42  kVIDMovieChunkId_FullFrameCompressedFill = 0x03,
43  kVIDMovieChunkId_PartialFrameCompressed = 0x04,
44  kVIDMovieChunkId_EndOfFile = 0x14,
45  kVIDMovieChunkId_AudioFirstChunk = 0x7C,
46  kVIDMovieChunkId_Audio = 0x7D
47 };
48 
49 // This video format is used in at least the following Access engine games:
50 // - Noctropolis
51 // - Synnergist
52 
54 public:
56  ~AccessVIDMovieDecoder() override;
57 
58  bool loadStream(Common::SeekableReadStream *stream) override;
59  void close() override;
60 
61 protected:
62  void readNextPacket() override;
63 
64 private:
65  bool streamSkipFullFrameCompressedFill();
66 
67 private:
68  int32 _streamSeekOffset; /* current stream offset, pointing to not-yet-indexed stream position */
69  uint32 _streamVideoIndex; /* current stream index for video decoding */
70  uint32 _streamAudioIndex; /* current stream index for audio decoding */
71 
72  struct IndexCacheEntry {
73  byte chunkId;
74  int32 offset;
75  };
76 
77  Common::Array<IndexCacheEntry> _indexCacheTable;
78 
79 private:
80  class StreamVideoTrack : public VideoTrack {
81  public:
82  StreamVideoTrack(uint32 width, uint32 height, uint16 regularFrameDelay);
83  ~StreamVideoTrack() override;
84 
85  bool endOfTrack() const override;
86 
87  uint16 getWidth() const override { return _width; }
88  uint16 getHeight() const override { return _height; }
89  Graphics::PixelFormat getPixelFormat() const override;
90  int getCurFrame() const override { return _curFrame; }
91  void setNextFrameStartTime(uint32 nextFrameStartTime) { _nextFrameStartTime = nextFrameStartTime; }
92  uint32 getNextFrameStartTime() const override { return _nextFrameStartTime; }
93  const Graphics::Surface *decodeNextFrame() override { return _surface; }
94 
95  const byte *getPalette() const override;
96  bool hasDirtyPalette() const override;
97 
98  void decodePalette(Common::SeekableReadStream *stream);
99  void decodeFrame(Common::SeekableReadStream *stream, byte chunkId);
100  bool skipOverFrame(Common::SeekableReadStream *stream, byte chunkId);
101  bool skipOverPalette(Common::SeekableReadStream *stream);
102 
103  void setEndOfTrack() { _endOfTrack = true; }
104 
105  private:
106  Graphics::Surface *_surface;
107 
108  int _curFrame;
109  uint32 _nextFrameStartTime;
110 
111  byte _palette[3 * 256];
112  mutable bool _dirtyPalette;
113  uint16 _width, _height;
114 
115  uint16 _regularFrameDelay; // delay between frames (1 = 1/60 of a second)
116  bool _endOfTrack;
117  };
118 
119  class StreamAudioTrack : public AudioTrack {
120  public:
121  StreamAudioTrack(uint32 sampleRate, Audio::Mixer::SoundType soundType);
122  ~StreamAudioTrack() override;
123 
124  void queueAudio(Common::SeekableReadStream *stream, byte chunkId);
125  bool skipOverAudio(Common::SeekableReadStream *stream, byte chunkId);
126 
127  protected:
128  Audio::AudioStream *getAudioStream() const override;
129 
130  private:
131  Audio::QueuingAudioStream *_audioStream;
132  uint32 _totalAudioQueued; /* total amount of milliseconds of audio, that we queued up already */
133 
134  public:
135  uint32 getTotalAudioQueued() const { return _totalAudioQueued; }
136 
137  private:
138  int16 decodeSample(uint8 dataNibble);
139 
140  uint16 _sampleRate;
141  bool _stereo;
142  };
143 
145  StreamVideoTrack *_videoTrack;
146  StreamAudioTrack *_audioTrack;
147 };
148 
149 } // End of namespace Access
150 
151 #endif
Definition: surface.h:67
Definition: pixelformat.h:138
Definition: video_decoder.h:700
Definition: stream.h:745
SoundType
Definition: mixer.h:62
Definition: video_decoder.h:52
Definition: algorithm.h:29
Definition: audiostream.h:50
Definition: audiostream.h:370
Definition: access.h:62
Definition: movie_decoder.h:32
Definition: movie_decoder.h:53
Definition: video_decoder.h:571