scummvm/engines/nancy/video.h

100 lines
2.8 KiB
C
Raw Normal View History

2012-10-11 19:24:50 +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.
*
* 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.
2012-10-11 19:24:50 +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
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2012-10-11 19:24:50 +00:00
*
*/
#ifndef NANCY_VIDEO_H
#define NANCY_VIDEO_H
#include "video/video_decoder.h"
namespace Common {
2021-01-04 21:16:23 +00:00
class ReadStream;
2012-10-11 19:24:50 +00:00
class SeekableReadStream;
}
namespace Graphics {
struct Surface;
}
namespace Nancy {
class Decompressor;
class AVFDecoder : public Video::VideoDecoder {
public:
virtual ~AVFDecoder();
bool loadStream(Common::SeekableReadStream *stream) override;
2021-01-04 21:16:23 +00:00
const Graphics::Surface *decodeFrame(uint frameNr);
void addFrameTime(const uint16 timeToAdd);
2012-10-11 19:24:50 +00:00
private:
class AVFVideoTrack : public FixedRateVideoTrack {
friend class AVFDecoder;
2012-10-11 19:24:50 +00:00
public:
AVFVideoTrack(Common::SeekableReadStream *stream, uint32 chunkFileFormat);
virtual ~AVFVideoTrack();
uint16 getWidth() const override { return _width; }
uint16 getHeight() const override { return _height; }
Graphics::PixelFormat getPixelFormat() const override { return _pixelFormat; }
int getCurFrame() const override { return _curFrame; }
int getFrameCount() const override { return _frameCount; }
bool isSeekable() const override { return true; }
bool seek(const Audio::Timestamp &time) override;
bool setReverse(bool reverse) override;
bool isReversed() const override { return _reversed; }
bool endOfTrack() const override;
const Graphics::Surface *decodeNextFrame() override;
2021-01-04 21:16:23 +00:00
const Graphics::Surface *decodeFrame(uint frameNr);
2012-10-11 19:24:50 +00:00
protected:
Common::Rational getFrameRate() const override { return Common::Rational(1000, _frameTime); }
2012-10-11 19:24:50 +00:00
private:
struct ChunkInfo {
Common::String name;
2012-10-11 19:24:50 +00:00
uint16 index;
uint32 offset;
uint32 compressedSize;
uint32 size;
byte type;
2012-10-11 19:24:50 +00:00
};
bool decode(byte *outBuf, uint32 frameSize, Common::ReadStream &inBuf) const;
2012-10-11 19:24:50 +00:00
Common::SeekableReadStream *_fileStream;
Graphics::PixelFormat _pixelFormat;
uint _width, _height, _depth, _frameSize;
2012-10-11 19:24:50 +00:00
int _curFrame;
uint _frameCount;
2012-10-14 23:33:40 +00:00
uint32 _frameTime;
2012-10-11 19:24:50 +00:00
Graphics::Surface *_surface;
int _refFrame;
2012-10-11 19:24:50 +00:00
Common::Array<ChunkInfo> _chunkInfo;
Decompressor *_dec;
bool _reversed;
2012-10-11 19:24:50 +00:00
};
};
} // End of namespace Nancy
#endif // NANCY_VIDEO_H