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 HOLLYWOOD_RUNAWAY_VIDEO_H
23#define HOLLYWOOD_RUNAWAY_VIDEO_H
24
25#include "common/array.h"
26#include "common/ptr.h"
27#include "hollywood/resource.h"
28#include "hollywood/runaway/graphics.h"
29#include "video/video_decoder.h"
30
31namespace Hollywood {
32
33// Silent AVI/Bink clips are advanced by the engine clock so menu pauses also
34// freeze frame callbacks and the separately stored room sound effects.
36public:
37 enum FrameStatus { kFrameError, kFramePending, kFrameReady };
38 bool load(const char *name);
39 void close();
40 bool decodeToFrame(uint frame);
41 bool seekToFrame(uint frame);
42 bool isBink() const;
43 void cacheFrames(uint first, uint last);
44 // A zero budget checks readiness without decoding; prefetch keeps the displayed frame.
45 FrameStatus prepareFrame(uint frame, uint maxFrames);
46 FrameStatus prefetchFrame(uint frame, uint maxFrames);
47 uint width() const { return _frame ? _frame->w : 0; }
48 uint height() const { return _frame ? _frame->h : 0; }
49 uint frameCount() const { return _decoder ? _decoder->getFrameCount() : 0; }
50 uint frameAtTime(uint32 milliseconds) const;
51 void draw(Graphics::ManagedSurface &surface, const Common::Rect &destination) const;
52 void drawRegion(Graphics::ManagedSurface &surface, const Common::Rect &source, const Common::Rect &destination) const;
53
54private:
55 bool useCachedFrame(uint frame);
56 bool decodeFrames(uint frame);
57
58 struct CachedFrame {
59 bool enabled = false;
61 };
62 Common::Array<CachedFrame> _cachedFrames;
63 uint32 _cacheBytes = 0;
66 const Graphics::Surface *_frame = nullptr;
67 const Graphics::Surface *_decodedFrame = nullptr;
68 Graphics::ManagedSurface _heldFrame;
69};
70
71// The CD stores patch/mouth pairs; GOG stores the same poses as Bink frames.
73public:
74 bool load(char chapter, uint movie);
75 void close();
76 RunawayVideo::FrameStatus prepare(uint portrait, uint maxFrames);
77 bool draw(Graphics::ManagedSurface &surface, const Common::Rect &destination, uint portrait, uint mouth);
78
79private:
80 RunawayVideo _video;
81 ChunkArchive _archive;
82 RunawayAnimation _mouth;
83 Graphics::ManagedSurface _portrait, _talking;
84 struct Portrait {
85 uint firstFrame = 0;
86 Common::Rect bounds;
88 };
89 Common::Array<Portrait> _portraits;
90 bool _loaded = false;
91 int _loadedPortrait = -1;
92 uint _preparedFrames = 0;
93 char _chapter = 'B';
94 uint _movie = 0;
95};
96
97} // namespace Hollywood
98
99#endif
Definition: managed_surface.h:51
Definition: resource.h:59
Definition: graphics.h:54
Definition: video.h:72
Definition: video.h:35
uint32 getFrameCount() const
Definition: rect.h:536
Definition: surface.h:67
int16 h
Definition: surface.h:76
int16 w
Definition: surface.h:71