mirror of
https://github.com/scummvm/scummvm.git
synced 2024-05-31 18:27:36 -04:00
VIDEO: Add setOutputPixelFormat() to the VideoDecoder interface
This commit is contained in:
parent
9a6897a852
commit
8a4a5bdc55
|
@ -396,6 +396,10 @@ Graphics::PixelFormat ThreeDOMovieDecoder::StreamVideoTrack::getPixelFormat() co
|
|||
return _codec->getPixelFormat();
|
||||
}
|
||||
|
||||
bool ThreeDOMovieDecoder::StreamVideoTrack::setOutputPixelFormat(const Graphics::PixelFormat &format) {
|
||||
return _codec->setOutputPixelFormat(format);
|
||||
}
|
||||
|
||||
void ThreeDOMovieDecoder::StreamVideoTrack::decodeFrame(Common::SeekableReadStream *stream, uint32 videoTimeStamp) {
|
||||
_surface = _codec->decodeFrame(*stream);
|
||||
_curFrame++;
|
||||
|
|
|
@ -75,6 +75,7 @@ private:
|
|||
uint16 getWidth() const override { return _width; }
|
||||
uint16 getHeight() const override { return _height; }
|
||||
Graphics::PixelFormat getPixelFormat() const override;
|
||||
bool setOutputPixelFormat(const Graphics::PixelFormat &format);
|
||||
int getCurFrame() const override { return _curFrame; }
|
||||
int getFrameCount() const override { return _frameCount; }
|
||||
void setNextFrameStartTime(uint32 nextFrameStartTime) { _nextFrameStartTime = nextFrameStartTime; }
|
||||
|
|
|
@ -985,6 +985,13 @@ Graphics::PixelFormat AVIDecoder::AVIVideoTrack::getPixelFormat() const {
|
|||
return Graphics::PixelFormat();
|
||||
}
|
||||
|
||||
bool AVIDecoder::AVIVideoTrack::setOutputPixelFormat(const Graphics::PixelFormat &format) {
|
||||
if (_videoCodec)
|
||||
return _videoCodec->setOutputPixelFormat(format);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AVIDecoder::AVIVideoTrack::loadPaletteFromChunkRaw(Common::SeekableReadStream *chunk, int firstEntry, int numEntries) {
|
||||
assert(chunk);
|
||||
assert(firstEntry >= 0);
|
||||
|
|
|
@ -212,6 +212,7 @@ protected:
|
|||
uint16 getHeight() const { return _bmInfo.height; }
|
||||
uint16 getBitCount() const { return _bmInfo.bitCount; }
|
||||
Graphics::PixelFormat getPixelFormat() const;
|
||||
bool setOutputPixelFormat(const Graphics::PixelFormat &format);
|
||||
int getCurFrame() const { return _curFrame; }
|
||||
int getFrameCount() const { return _frameCount; }
|
||||
Common::String &getName() { return _vidsHeader.name; }
|
||||
|
|
|
@ -1064,6 +1064,10 @@ Graphics::PixelFormat HNMDecoder::HNM6VideoTrack::getPixelFormat() const {
|
|||
return _decoder->getPixelFormat();
|
||||
}
|
||||
|
||||
bool HNMDecoder::HNM6VideoTrack::setOutputPixelFormat(const Graphics::PixelFormat &format) {
|
||||
return _decoder->setOutputPixelFormat(format);
|
||||
}
|
||||
|
||||
void HNMDecoder::HNM6VideoTrack::decodeChunk(byte *data, uint32 size,
|
||||
uint16 chunkType, uint16 flags) {
|
||||
if (chunkType == MKTAG16('I', 'X') ||
|
||||
|
|
|
@ -162,6 +162,7 @@ private:
|
|||
uint16 getWidth() const override;
|
||||
uint16 getHeight() const override;
|
||||
Graphics::PixelFormat getPixelFormat() const override;
|
||||
bool setOutputPixelFormat(const Graphics::PixelFormat &format) override;
|
||||
const Graphics::Surface *decodeNextFrame() override { return _surface; }
|
||||
|
||||
virtual void newFrame(uint32 frameDelay) override;
|
||||
|
|
|
@ -461,6 +461,13 @@ Graphics::PixelFormat QuickTimeDecoder::VideoTrackHandler::getPixelFormat() cons
|
|||
return ((VideoSampleDesc *)_parent->sampleDescs[0])->_videoCodec->getPixelFormat();
|
||||
}
|
||||
|
||||
bool QuickTimeDecoder::VideoTrackHandler::setOutputPixelFormat(const Graphics::PixelFormat &format) {
|
||||
if (_forcedDitherPalette)
|
||||
return false;
|
||||
|
||||
return ((VideoSampleDesc *)_parent->sampleDescs[0])->_videoCodec->setOutputPixelFormat(format);
|
||||
}
|
||||
|
||||
int QuickTimeDecoder::VideoTrackHandler::getFrameCount() const {
|
||||
return _parent->frameCount;
|
||||
}
|
||||
|
|
|
@ -135,6 +135,7 @@ private:
|
|||
uint16 getWidth() const;
|
||||
uint16 getHeight() const;
|
||||
Graphics::PixelFormat getPixelFormat() const;
|
||||
bool setOutputPixelFormat(const Graphics::PixelFormat &format);
|
||||
int getCurFrame() const { return _curFrame; }
|
||||
int getFrameCount() const;
|
||||
uint32 getNextFrameStartTime() const; // milliseconds
|
||||
|
|
|
@ -48,6 +48,7 @@ VideoDecoder::VideoDecoder() {
|
|||
_nextVideoTrack = 0;
|
||||
_mainAudioTrack = 0;
|
||||
_canSetDither = true;
|
||||
_canSetDefaultFormat = true;
|
||||
|
||||
// Find the best format for output
|
||||
_defaultHighColorFormat = g_system->getScreenFormat();
|
||||
|
@ -79,6 +80,7 @@ void VideoDecoder::close() {
|
|||
_nextVideoTrack = 0;
|
||||
_mainAudioTrack = 0;
|
||||
_canSetDither = true;
|
||||
_canSetDefaultFormat = true;
|
||||
}
|
||||
|
||||
bool VideoDecoder::loadFile(const Common::Path &filename) {
|
||||
|
@ -208,6 +210,7 @@ Graphics::PixelFormat VideoDecoder::getPixelFormat() const {
|
|||
const Graphics::Surface *VideoDecoder::decodeNextFrame() {
|
||||
_needsUpdate = false;
|
||||
_canSetDither = false;
|
||||
_canSetDefaultFormat = false;
|
||||
|
||||
readNextPacket();
|
||||
|
||||
|
@ -547,6 +550,23 @@ bool VideoDecoder::setDitheringPalette(const byte *palette) {
|
|||
return result;
|
||||
}
|
||||
|
||||
bool VideoDecoder::setOutputPixelFormat(const Graphics::PixelFormat &format) {
|
||||
// If a frame was already decoded, we can't set it now.
|
||||
if (!_canSetDefaultFormat)
|
||||
return false;
|
||||
|
||||
bool result = false;
|
||||
|
||||
for (TrackList::iterator it = _tracks.begin(); it != _tracks.end(); it++) {
|
||||
if ((*it)->getTrackType() == Track::kTrackTypeVideo) {
|
||||
if (((VideoTrack *)*it)->setOutputPixelFormat(format))
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
VideoDecoder::Track::Track() {
|
||||
_paused = false;
|
||||
}
|
||||
|
|
|
@ -397,6 +397,17 @@ public:
|
|||
*/
|
||||
bool setDitheringPalette(const byte *palette);
|
||||
|
||||
/**
|
||||
* Set the default high color format for videos that convert from YUV.
|
||||
*
|
||||
* This should be called after loadStream(), but before a decodeNextFrame()
|
||||
* call. This is enforced.
|
||||
*
|
||||
* @param format The preferred output pixel format
|
||||
* @return true on success, false otherwise
|
||||
*/
|
||||
bool setOutputPixelFormat(const Graphics::PixelFormat &format);
|
||||
|
||||
/////////////////////////////////////////
|
||||
// Audio Control
|
||||
/////////////////////////////////////////
|
||||
|
@ -577,6 +588,11 @@ protected:
|
|||
*/
|
||||
virtual Graphics::PixelFormat getPixelFormat() const = 0;
|
||||
|
||||
/**
|
||||
* Set the default high color format for videos that convert from YUV.
|
||||
*/
|
||||
virtual bool setOutputPixelFormat(const Graphics::PixelFormat &format) { return false; }
|
||||
|
||||
/**
|
||||
* Get the current frame of this track
|
||||
*
|
||||
|
@ -954,8 +970,9 @@ private:
|
|||
mutable bool _dirtyPalette;
|
||||
const byte *_palette;
|
||||
|
||||
// Enforcement of not being able to set dither
|
||||
// Enforcement of not being able to set dither or set the default format
|
||||
bool _canSetDither;
|
||||
bool _canSetDefaultFormat;
|
||||
|
||||
// Default PixelFormat settings
|
||||
Graphics::PixelFormat _defaultHighColorFormat;
|
||||
|
|
Loading…
Reference in a new issue