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.
|
|
|
|
*
|
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.
|
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
|
2021-12-26 17:47:58 +00:00
|
|
|
* 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();
|
|
|
|
|
2021-11-13 21:20:07 +00:00
|
|
|
bool loadStream(Common::SeekableReadStream *stream) override;
|
2021-01-04 21:16:23 +00:00
|
|
|
const Graphics::Surface *decodeFrame(uint frameNr);
|
2021-03-06 11:25:11 +00:00
|
|
|
void addFrameTime(const uint16 timeToAdd);
|
2012-10-11 19:24:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
class AVFVideoTrack : public FixedRateVideoTrack {
|
2021-03-06 11:25:11 +00:00
|
|
|
friend class AVFDecoder;
|
2012-10-11 19:24:50 +00:00
|
|
|
public:
|
2021-03-11 22:23:11 +00:00
|
|
|
AVFVideoTrack(Common::SeekableReadStream *stream, uint32 chunkFileFormat);
|
2021-01-24 12:34:32 +00:00
|
|
|
virtual ~AVFVideoTrack();
|
|
|
|
|
2021-11-13 21:20:07 +00:00
|
|
|
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:
|
2021-11-13 21:20:07 +00:00
|
|
|
Common::Rational getFrameRate() const override { return Common::Rational(1000, _frameTime); }
|
2012-10-11 19:24:50 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct ChunkInfo {
|
2021-03-11 22:23:11 +00:00
|
|
|
Common::String name;
|
2012-10-11 19:24:50 +00:00
|
|
|
uint16 index;
|
|
|
|
uint32 offset;
|
|
|
|
uint32 compressedSize;
|
|
|
|
uint32 size;
|
2012-10-14 11:03:53 +00:00
|
|
|
byte type;
|
2012-10-11 19:24:50 +00:00
|
|
|
};
|
|
|
|
|
2012-10-17 21:38:42 +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;
|
2012-10-17 21:38:42 +00:00
|
|
|
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;
|
2012-10-17 21:38:42 +00:00
|
|
|
int _refFrame;
|
2012-10-11 19:24:50 +00:00
|
|
|
Common::Array<ChunkInfo> _chunkInfo;
|
|
|
|
Decompressor *_dec;
|
2021-01-24 21:59:57 +00:00
|
|
|
bool _reversed;
|
2012-10-11 19:24:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Nancy
|
|
|
|
|
2021-02-19 00:17:41 +00:00
|
|
|
#endif // NANCY_VIDEO_H
|