ScummVM API documentation
video.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef NANCY_VIDEO_H
23 #define NANCY_VIDEO_H
24 
25 #include "video/video_decoder.h"
26 
27 namespace Common {
28 class ReadStream;
29 class SeekableReadStream;
30 }
31 
32 namespace Graphics {
33 struct Surface;
34 }
35 
36 namespace Nancy {
37 
38 class Decompressor;
39 class VideoCacheLoader;
40 
42  friend class VideoCacheLoader;
43 public:
44  enum CacheHint { kLoadForward, kLoadBidirectional };
45 
46  AVFDecoder(CacheHint cacheHint = kLoadForward) : _cacheHint(cacheHint) {}
47  virtual ~AVFDecoder();
48 
49  bool loadStream(Common::SeekableReadStream *stream) override;
50  const Graphics::Surface *decodeFrame(uint frameNr);
51  void addFrameTime(const uint16 timeToAdd);
52  bool atEnd() const;
53 
54 private:
55  CacheHint _cacheHint;
56  class AVFVideoTrack : public FixedRateVideoTrack {
57  friend class AVFDecoder;
58  friend class VideoCacheLoader;
59  public:
60  AVFVideoTrack(Common::SeekableReadStream *stream, uint32 chunkFileFormat, CacheHint cacheHint);
61  virtual ~AVFVideoTrack();
62 
63  uint16 getWidth() const override { return _width; }
64  uint16 getHeight() const override { return _height; }
65  Graphics::PixelFormat getPixelFormat() const override { return _pixelFormat; }
66  int getCurFrame() const override { return _curFrame; }
67  int getFrameCount() const override { return _frameCount; }
68  bool isSeekable() const override { return true; }
69  bool seek(const Audio::Timestamp &time) override;
70  bool setReverse(bool reverse) override;
71  bool isReversed() const override { return _reversed; }
72  bool endOfTrack() const override;
73  const Graphics::Surface *decodeNextFrame() override;
74  const Graphics::Surface *decodeFrame(uint frameNr);
75 
76  protected:
77  Common::Rational getFrameRate() const override { return Common::Rational(1000, _frameTime); }
78 
79  private:
80  struct ChunkInfo {
81  Common::String name;
82  uint16 index;
83  uint32 offset;
84  uint32 compressedSize;
85  uint32 size;
86  byte type;
87  };
88 
89  bool decode(byte *outBuf, uint32 frameSize, Common::ReadStream &inBuf) const;
90 
91  Common::SeekableReadStream *_fileStream;
92  Graphics::PixelFormat _pixelFormat;
93  uint _width, _height, _depth, _frameSize;
94  int _curFrame;
95  uint _frameCount;
96  uint32 _frameTime;
97  Common::Array<ChunkInfo> _chunkInfo;
98  Decompressor *_dec;
99  bool _reversed;
100  bool _compressed;
101 
104  CacheHint _cacheHint;
105  };
106 };
107 
108 } // End of namespace Nancy
109 
110 #endif // NANCY_VIDEO_H
Definition: str.h:59
Definition: surface.h:67
Definition: video_decoder.h:686
Definition: pixelformat.h:138
Definition: timestamp.h:83
Definition: stream.h:745
Definition: rational.h:40
Definition: video_decoder.h:53
Definition: algorithm.h:29
Definition: formatinfo.h:28
Definition: video.h:41
Definition: decompress.h:35
Definition: stream.h:385
Definition: actionmanager.h:32