22 #ifndef SCI_VIDEO_DECODERS_ROBOT_H 23 #define SCI_VIDEO_DECODERS_ROBOT_H 25 #include "audio/audiostream.h" 26 #include "audio/rate.h" 27 #include "common/array.h" 28 #include "common/mutex.h" 29 #include "common/rect.h" 30 #include "common/scummsys.h" 31 #include "sci/engine/vm_types.h" 32 #include "sci/graphics/helpers.h" 33 #include "sci/graphics/screen_item32.h" 35 namespace Common {
class SeekableReadStreamEndian; }
256 #pragma mark RobotAudioStream 268 kRobotSampleRate = 22050,
318 data(data_), dataSize(dataSize_), position(position_) {}
353 int32 _loopBufferSize;
402 int32 _firstPacketPosition;
408 byte *_decompressionBuffer;
413 int32 _decompressionBufferSize;
420 int32 _decompressionBufferPosition;
425 void fillRobotBuffer(
const RobotAudioPacket &packet,
const int8 bufferIndex);
431 void interpolateMissingSamples(
const int32 numSamples);
434 #pragma mark RobotAudioStream - AudioStream implementation 436 int readBuffer(Audio::st_sample_t *outBuffer,
int numSamples)
override;
438 int getRate()
const override {
return 22050; };
441 return _readHeadAbs >= _writeHeadAbs;
445 return _finished && endOfData();
450 #pragma mark RobotDecoder 460 GuiResourceId getResourceId()
const {
470 GuiResourceId _robotId;
472 #pragma mark Constants 478 kRobotStatusUninitialized = 0,
479 kRobotStatusPlaying = 1,
481 kRobotStatusPaused = 3
495 kScreenItemListSize = 10,
516 kFixedCelListSize = 4,
521 kRawPaletteSize = 1200,
528 kRobotFrameSize = 2048,
534 kRobotZeroCompressSize = 2048,
541 kAudioBlockHeaderSize = 8,
552 kMaxFrameRateDrift = 1
569 #pragma mark Initialisation 574 void initStream(
const GuiResourceId robotId);
589 void initVideo(
const int16 x,
const int16 y,
const int16
scale,
const reg_t plane,
const bool hasPalette,
const uint16 paletteSize);
594 void initRecordAndCuePositions();
597 #pragma mark Playback 603 void open(
const GuiResourceId robotId,
const reg_t plane,
const int16 priority,
const int16 x,
const int16 y,
const int16 scale);
626 void showFrame(
const uint16 frameNo,
const uint16 newX,
const uint16 newY,
const uint16 newPriority);
631 int16 getCue()
const;
636 int16 getFrameNo()
const;
659 PositionList _recordPositions;
670 mutable int32 _cueTimes[kCueListSize];
675 int32 _masterCueTimes[kCueListSize];
680 int32 _cueValues[kCueListSize];
690 int16 _normalFrameRate;
708 int16 _maxSkippablePackets;
718 int _previousFrameNo;
733 int32 _startingFrameNo;
738 bool seekToFrame(
const int frameNo);
744 void setRobotTime(
const int frameNo);
772 bool timingInProgress()
const;
778 int predictedTicks()
const;
796 int _delays[kDelayListSize];
803 uint _timestamps[kDelayListSize];
808 uint _oldestTimestamp;
813 uint _newestTimestamp;
825 uint16 calculateNextFrameNo(
const uint32 extraTicks = 0)
const;
831 uint32 ticksToFrames(
const uint32 ticks)
const;
836 uint32 getTickCount()
const;
841 DelayTime _delayTime;
850 kAudioSyncCheckInterval = 5 * 60
856 enum RobotAudioStatus {
857 kRobotAudioReady = 1,
858 kRobotAudioStopped = 2,
859 kRobotAudioPlaying = 3,
860 kRobotAudioPaused = 4,
861 kRobotAudioStopping = 5
865 #pragma mark Audio - AudioList 877 void startAudioNow();
893 void submitDriverMax();
904 void addBlock(
const int position,
const int size,
const byte *buffer);
916 void prepareForPrimer();
922 void setAudioOffset(
const int offset);
925 #pragma mark Audio - AudioList - AudioBlock 933 AudioBlock(
const int position,
const int size,
const byte *
const data);
941 bool submit(
const int startOffset);
964 AudioBlock *_blocks[kAudioListSize];
974 uint8 _oldestBlockIndex;
979 uint8 _newestBlockIndex;
989 RobotAudioStatus _status;
994 void freeAudioBlocks();
1006 AudioList _audioList;
1012 uint16 _audioBlockSize;
1018 int16 _expectedAudioBlockSize;
1024 int16 _audioRecordInterval;
1030 uint16 _primerZeroCompressFlag;
1036 uint16 _primerReservedSize;
1041 int32 _totalPrimerSize;
1046 int32 _primerPosition;
1051 int32 _evenPrimerSize;
1056 int32 _oddPrimerSize;
1061 int32 _firstAudioRecordPosition;
1073 uint32 _checkAudioSyncTime;
1080 bool primeAudio(
const uint32 startTick);
1086 bool readPrimerData(byte *outEvenBuffer, byte *outOddBuffer);
1095 bool readAudioDataFromRecord(
const int frameNo, byte *outBuffer,
int &outAudioPosition,
int &outAudioSize);
1101 bool readPartialAudioRecordAndSubmit(
const int startFrame,
const int startPosition);
1104 #pragma mark Rendering 1124 return _scaleInfo.x;
1144 void frameAlmostVisible();
1150 void frameNowVisible();
1156 void expandCel(byte *target,
const byte* source,
const int16 celWidth,
const int16 celHeight)
const;
1158 int16 getPriority()
const;
1164 void setPriority(
const int16 newPriority);
1167 enum CompressionType {
1168 kCompressionLZS = 0,
1169 kCompressionNone = 2
1175 struct CelHandleInfo {
1179 enum CelHandleLifetime {
1194 CelHandleLifetime status;
1201 CelHandleInfo() : bitmapId(NULL_REG), status(kNoCel), area(0) {}
1215 void doVersion5(
const bool shouldSubmitAudio =
true);
1220 void createCels5(
const byte *rawVideoData,
const int16 numCels,
const bool usePalette);
1227 uint32 createCel5(
const byte *rawVideoData,
const int16 screenItemIndex,
const bool usePalette);
1232 void preallocateCelMemory(
const byte *rawVideoData,
const int16 numCels);
1237 DecompressorLZS _decompressor;
1257 int16 _xResolution, _yResolution;
1268 int16 _maxCelsPerFrame;
1274 MaxCelAreaList _maxCelArea;
1286 VideoSizeList _videoSizes;
1292 FixedCelsList _fixedCels;
1297 CelHandleList _celHandles;
1303 ScratchMemory _celDecompressionBuffer;
1308 int _celDecompressionArea;
1320 ScratchMemory _doVersion5Scratch;
1327 mutable int _cueForceShowFrame;
1337 RobotScreenItemList _screenItemList;
1354 uint16 _numFramesTotal;
1368 uint8 _verticalScaleFactor;
1373 #endif // SCI_VIDEO_DECODERS_ROBOT_H Definition: robot_decoder.h:280
uint8 bits
Definition: robot_decoder.h:294
bool endOfData() const override
Definition: robot_decoder.h:439
bool isStereo() const override
Definition: robot_decoder.h:437
byte * data
Definition: robot_decoder.h:304
RobotStatus
Definition: robot_decoder.h:477
uint16 rate
Definition: robot_decoder.h:289
const reg_t getPlaneId() const
Definition: robot_decoder.h:1109
int getRate() const override
Definition: robot_decoder.h:438
Definition: plane32.h:103
Definition: robot_decoder.h:262
int bytesPlaying
Definition: robot_decoder.h:284
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: screen_item32.h:37
Definition: algorithm.h:29
Definition: audiostream.h:50
bool endOfStream() const override
Definition: robot_decoder.h:443
int dataSize
Definition: robot_decoder.h:310
Definition: seg_manager.h:48
int position
Definition: robot_decoder.h:315
Definition: robot_decoder.h:300
int16 getScale() const
Definition: robot_decoder.h:1123
Definition: vm_types.h:39
Definition: robot_decoder.h:455
Common::Point getPosition() const
Definition: robot_decoder.h:1116