2015-06-03 11:11:09 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2015-06-03 11:11:09 +00:00
|
|
|
*
|
|
|
|
* 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
|
2021-12-26 17:47:58 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2015-06-03 11:11:09 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SHERLOCK_SCALPEL_3DO_MOVIE_DECODER_H
|
|
|
|
#define SHERLOCK_SCALPEL_3DO_MOVIE_DECODER_H
|
|
|
|
|
2015-06-08 19:01:07 +00:00
|
|
|
#include "common/rect.h"
|
2015-06-03 11:11:09 +00:00
|
|
|
#include "video/video_decoder.h"
|
2015-06-04 13:53:54 +00:00
|
|
|
#include "audio/decoders/3do.h"
|
2015-06-03 11:11:09 +00:00
|
|
|
|
|
|
|
namespace Audio {
|
|
|
|
class QueuingAudioStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class SeekableReadStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace Image {
|
|
|
|
class Codec;
|
|
|
|
}
|
|
|
|
|
2020-10-20 21:12:11 +00:00
|
|
|
namespace Video {
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2020-10-20 21:12:11 +00:00
|
|
|
/**
|
|
|
|
* Decoder for 3DO videos.
|
|
|
|
*
|
|
|
|
* Video decoder used in engines:
|
|
|
|
* - sherlock
|
|
|
|
* - plumbers
|
|
|
|
*/
|
|
|
|
class ThreeDOMovieDecoder : public Video::VideoDecoder {
|
2015-06-03 11:11:09 +00:00
|
|
|
public:
|
2020-10-20 21:12:11 +00:00
|
|
|
ThreeDOMovieDecoder();
|
|
|
|
~ThreeDOMovieDecoder() override;
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2020-02-09 11:05:32 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream) override;
|
|
|
|
void close() override;
|
2015-06-03 11:11:09 +00:00
|
|
|
|
|
|
|
protected:
|
2020-02-09 11:05:32 +00:00
|
|
|
void readNextPacket() override;
|
2020-10-20 22:12:10 +00:00
|
|
|
bool supportsAudioTrackSwitching() const override { return true; }
|
|
|
|
AudioTrack *getAudioTrack(int index) override;
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2015-06-04 13:53:54 +00:00
|
|
|
private:
|
|
|
|
int32 _streamVideoOffset; /* current stream offset for video decoding */
|
|
|
|
int32 _streamAudioOffset; /* current stream offset for audio decoding */
|
|
|
|
|
2015-06-03 11:11:09 +00:00
|
|
|
private:
|
2015-06-03 17:47:01 +00:00
|
|
|
class StreamVideoTrack : public VideoTrack {
|
2015-06-03 11:11:09 +00:00
|
|
|
public:
|
2015-06-03 17:47:01 +00:00
|
|
|
StreamVideoTrack(uint32 width, uint32 height, uint32 codecTag, uint32 frameCount);
|
2020-02-09 11:05:32 +00:00
|
|
|
~StreamVideoTrack() override;
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2020-02-09 11:05:32 +00:00
|
|
|
bool endOfTrack() const override;
|
2015-06-03 17:47:01 +00:00
|
|
|
|
2020-02-09 11:05:32 +00:00
|
|
|
uint16 getWidth() const override { return _width; }
|
|
|
|
uint16 getHeight() const override { return _height; }
|
|
|
|
Graphics::PixelFormat getPixelFormat() const override;
|
2023-04-05 21:23:18 +00:00
|
|
|
bool setOutputPixelFormat(const Graphics::PixelFormat &format) override;
|
2020-02-09 11:05:32 +00:00
|
|
|
int getCurFrame() const override { return _curFrame; }
|
|
|
|
int getFrameCount() const override { return _frameCount; }
|
2015-06-04 13:53:54 +00:00
|
|
|
void setNextFrameStartTime(uint32 nextFrameStartTime) { _nextFrameStartTime = nextFrameStartTime; }
|
2020-02-09 11:05:32 +00:00
|
|
|
uint32 getNextFrameStartTime() const override { return _nextFrameStartTime; }
|
|
|
|
const Graphics::Surface *decodeNextFrame() override { return _surface; }
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2015-06-03 17:47:01 +00:00
|
|
|
void decodeFrame(Common::SeekableReadStream *stream, uint32 videoTimeStamp);
|
2015-06-03 11:11:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const Graphics::Surface *_surface;
|
|
|
|
|
2015-06-03 17:47:01 +00:00
|
|
|
int _curFrame;
|
2015-06-03 11:11:09 +00:00
|
|
|
uint32 _frameCount;
|
2015-06-03 17:47:01 +00:00
|
|
|
uint32 _nextFrameStartTime;
|
|
|
|
|
2015-06-03 11:11:09 +00:00
|
|
|
Image::Codec *_codec;
|
|
|
|
uint16 _width, _height;
|
|
|
|
};
|
|
|
|
|
|
|
|
class StreamAudioTrack : public AudioTrack {
|
|
|
|
public:
|
2020-10-20 22:12:10 +00:00
|
|
|
StreamAudioTrack(uint32 codecTag, uint32 sampleRate, uint32 channels, Audio::Mixer::SoundType soundType, uint32 trackId);
|
2020-02-09 11:05:32 +00:00
|
|
|
~StreamAudioTrack() override;
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2015-06-04 13:53:54 +00:00
|
|
|
void queueAudio(Common::SeekableReadStream *stream, uint32 size);
|
2015-06-03 11:11:09 +00:00
|
|
|
|
2020-10-20 22:12:10 +00:00
|
|
|
bool matchesId(uint trackId);
|
|
|
|
|
2015-06-03 11:11:09 +00:00
|
|
|
protected:
|
2020-02-09 11:05:32 +00:00
|
|
|
Audio::AudioStream *getAudioStream() const override;
|
2015-06-03 11:11:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
Audio::QueuingAudioStream *_audioStream;
|
2015-06-04 13:53:54 +00:00
|
|
|
uint32 _totalAudioQueued; /* total amount of milliseconds of audio, that we queued up already */
|
|
|
|
|
|
|
|
public:
|
|
|
|
uint32 getTotalAudioQueued() const { return _totalAudioQueued; }
|
2015-06-03 11:11:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
int16 decodeSample(uint8 dataNibble);
|
|
|
|
|
2015-06-04 13:53:54 +00:00
|
|
|
uint32 _codecTag;
|
|
|
|
uint16 _sampleRate;
|
2015-06-06 20:50:36 +00:00
|
|
|
bool _stereo;
|
2020-10-20 22:12:10 +00:00
|
|
|
uint32 _trackId;
|
2015-06-04 13:53:54 +00:00
|
|
|
|
|
|
|
Audio::audio_3DO_ADP4_PersistentSpace _ADP4_PersistentSpace;
|
|
|
|
Audio::audio_3DO_SDX2_PersistentSpace _SDX2_PersistentSpace;
|
2015-06-03 11:11:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Common::SeekableReadStream *_stream;
|
|
|
|
StreamVideoTrack *_videoTrack;
|
2020-10-20 22:12:10 +00:00
|
|
|
Common::Array<StreamAudioTrack *> _audioTracks;
|
2015-06-03 11:11:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Sherlock
|
|
|
|
|
|
|
|
#endif
|