29#if !(defined(ENABLE_GOB) || defined(ENABLE_SCI32) || defined(DYNAMIC_MODULES))
35#ifndef VIDEO_COKTELDECODER_H
36#define VIDEO_COKTELDECODER_H
38#include "common/list.h"
39#include "common/array.h"
40#include "common/rational.h"
41#include "common/str.h"
43#include "graphics/palette.h"
44#include "graphics/surface.h"
46#include "video/video_decoder.h"
48#include "audio/mixer.h"
52class MemoryReadWriteStream;
53class SeekableReadStream;
56class QueuingAudioStream;
89 virtual ~CoktelDecoder();
94 virtual bool seek(int32 frame,
int whence = SEEK_SET,
bool restart =
false) = 0;
97 void setSurfaceMemory(
void *mem, uint16 width, uint16 height, uint8 bpp);
99 void setSurfaceMemory();
104 virtual void setXY(uint16 x, uint16 y);
114 uint16 getDefaultX()
const;
116 uint16 getDefaultY()
const;
121 bool hasPalette()
const;
122 virtual bool hasVideo()
const;
123 virtual bool hasVideoData()
const;
125 bool hasSound()
const;
126 bool isSoundEnabled()
const;
127 bool isSoundPlaying()
const;
133 virtual void colorModeChanged();
136 virtual bool getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height);
139 virtual bool hasEmbeddedFiles()
const;
142 virtual bool hasEmbeddedFile(
const Common::String &fileName)
const;
148 virtual int32 getSubtitleIndex()
const;
151 virtual bool isPaletted()
const;
153 virtual uint32 getVideoBufferSize()
const = 0;
159 int getCurFrame()
const;
160 int getNbFramesPastEnd()
const;
175 virtual bool isVideoLoaded()
const = 0;
178 bool endOfVideo()
const;
188 uint16 getWidth()
const;
189 uint16 getHeight()
const;
190 virtual uint32 getFlags()
const = 0;
191 virtual uint16 getSoundFlags()
const = 0;
194 uint32 getFrameCount()
const;
196 const byte *getPalette();
197 bool hasDirtyPalette()
const;
199 uint32 getTimeToNextFrame()
const;
200 uint32 getStaticTimeToNextFrame()
const;
201 int32 getExpectedFrameFromCurrentTime()
const;
203 void pauseVideo(
bool pause);
214 kFeaturesNone = 0x0000,
215 kFeaturesPalette = 0x0008,
216 kFeaturesDataSize = 0x0020,
217 kFeaturesSound = 0x0040,
218 kFeaturesFrameCoords = 0x0080,
219 kFeaturesStdCoords = 0x0100,
220 kFeaturesFramePos = 0x0200,
221 kFeaturesVideo = 0x0400
239 int32 _nbFramesPastEnd;
257 SoundStage _soundStage;
262 bool evaluateSeekFrame(int32 &frame,
int whence)
const;
266 void createSurface();
270 uint32 deLZ77(
byte *dest,
const byte *src, uint32 srcSize, uint32 destSize);
271 void deRLE(
byte *&destPtr,
const byte *&srcPtr, int16 destLen, int16 srcLen);
282 inline void unsignedToSigned(
byte *buffer,
int length);
285 uint32 _pauseStartTime;
289class PreIMDDecoder :
public CoktelDecoder {
291 PreIMDDecoder(uint16 width, uint16 height,
Audio::Mixer *mixer,
297 bool seek(int32 frame,
int whence = SEEK_SET,
bool restart =
false)
override;
302 bool isVideoLoaded()
const override;
306 uint32 getFlags()
const override;
307 uint16 getSoundFlags()
const override;
308 uint32 getVideoBufferSize()
const override;
317 uint32 _videoBufferSize;
324class IMDDecoder :
public CoktelDecoder {
331 bool seek(int32 frame,
int whence = SEEK_SET,
bool restart =
false)
override;
333 void setXY(uint16 x, uint16 y)
override;
338 bool isVideoLoaded()
const override;
342 uint32 getFlags()
const override;
343 uint16 getSoundFlags()
const override;
344 uint32 getVideoBufferSize()
const override;
350 kCommandNextSound = 0xFF00,
351 kCommandStartSound = 0xFF01,
353 kCommandBreak = 0xFFF0,
354 kCommandBreakSkip0 = 0xFFF1,
355 kCommandBreakSkip16 = 0xFFF2,
356 kCommandBreakSkip32 = 0xFFF3,
357 kCommandBreakMask = 0xFFF8,
359 kCommandPalette = 0xFFF4,
360 kCommandVideoData = 0xFFFC,
362 kCommandJump = 0xFFFD
384 uint32 _firstFramePos;
388 uint32 _videoBufferSize;
389 byte *_videoBuffer[2];
390 uint32 _videoBufferLen[2];
395 int16 _soundSliceSize;
396 int16 _soundSlicesCount;
399 bool loadCoordinates();
400 bool loadFrameTableOffsets(uint32 &framePosPos, uint32 &frameCoordsPos);
401 bool assessVideoProperties();
402 bool assessAudioProperties();
403 bool loadFrameTables(uint32 framePosPos, uint32 frameCoordsPos);
413 void nextSoundSlice(
bool hasNextCmd);
414 bool initialSoundSlice(
bool hasNextCmd);
415 void emptySoundSlice(
bool hasNextCmd);
418class VMDDecoder :
public CoktelDecoder {
419friend class AdvancedVMDDecoder;
427 bool seek(int32 frame,
int whence = SEEK_SET,
bool restart =
false)
override;
429 void setXY(uint16 x, uint16 y)
override;
431 void colorModeChanged()
override;
433 bool getFrameCoords(int16 frame, int16 &x, int16 &y, int16 &width, int16 &height)
override;
435 bool hasEmbeddedFiles()
const override;
436 bool hasEmbeddedFile(
const Common::String &fileName)
const override;
439 int32 getSubtitleIndex()
const override;
441 bool hasVideo()
const override;
442 bool hasVideoData()
const override;
443 bool isPaletted()
const override;
448 bool isVideoLoaded()
const override;
452 uint32 getFlags()
const override;
453 uint16 getSoundFlags()
const override;
454 uint32 getVideoBufferSize()
const override;
459 void setAutoStartSound(
bool autoStartSound);
463 kPartTypeSeparator = 0,
468 kPartTypeSubtitle = 5
472 kAudioFormat8bitRaw = 0,
473 kAudioFormat16bitDPCM = 1,
474 kAudioFormat16bitADPCM = 2
515 uint32 _frameInfoOffset;
516 uint16 _partsPerFrame;
524 int16 _soundSliceSize;
525 int16 _soundSlicesCount;
526 byte _soundBytesPerSample;
528 uint32 _soundHeaderSize;
529 uint32 _soundDataSize;
530 uint32 _soundLastFilledFrame;
531 AudioFormat _audioFormat;
532 bool _autoStartSound;
552 uint32 _firstFramePos;
554 uint32 _videoBufferSize;
555 byte *_videoBuffer[3];
556 uint32 _videoBufferLen[3];
568 bool assessVideoProperties();
569 bool assessAudioProperties();
570 bool openExternalCodec();
571 bool readFrameTable(
int &numFiles);
585 void emptySoundSlice (uint32 size);
586 void filledSoundSlice (uint32 size);
587 void filledSoundSlices(uint32 size, uint32 mask);
588 void createAudioStream();
590 uint8 evaluateMask(uint32 mask,
bool *fillInfo, uint8 &max);
597 bool getPartCoords(int16 frame, PartType type, int16 &x, int16 &y, int16 &width, int16 &height);
604class AdvancedVMDDecoder :
public VideoDecoder {
607 ~AdvancedVMDDecoder();
610 void close()
override;
612 void setSurfaceMemory(
void *mem, uint16 width, uint16 height, uint8 bpp);
615 class VMDVideoTrack :
public FixedRateVideoTrack {
617 VMDVideoTrack(VMDDecoder *decoder);
619 uint16 getWidth()
const override;
620 uint16 getHeight()
const override;
622 int getCurFrame()
const override;
623 int getFrameCount()
const override;
625 const byte *getPalette()
const override;
626 bool hasDirtyPalette()
const override;
632 VMDDecoder *_decoder;
635 class VMDAudioTrack :
public AudioTrack {
637 VMDAudioTrack(VMDDecoder *decoder);
643 VMDDecoder *_decoder;
646 VMDDecoder *_decoder;
647 VMDVideoTrack *_videoTrack;
648 VMDAudioTrack *_audioTrack;
Definition: audiostream.h:50
SoundType
Definition: mixer.h:73
@ kPlainSoundType
Definition: mixer.h:74
Definition: audiostream.h:370
Definition: memstream.h:283
Definition: rational.h:40
Simple class for handling a palette data.
Definition: palette.h:61
Definition: algorithm.h:29
Definition: formatinfo.h:28