ScummVM API documentation
video32.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 SCI_GRAPHICS_VIDEO32_H
23#define SCI_GRAPHICS_VIDEO32_H
24
25#include "common/config-manager.h" // for ConfMan
26#include "common/path.h" // for Path
27#include "common/ptr.h"
28#include "common/rect.h" // for Rect
29#include "common/scummsys.h" // for int16, uint8, uint16, int32
30#include "sci/engine/vm_types.h" // for reg_t
31#include "sci/video/robot_decoder.h" // for RobotDecoder
32#include "sci/sound/audio32.h" // for Audio32::kMaxVolume
33#include "video/avi_decoder.h" // for AVIDecoder::setVolume
34#include "video/subtitles.h" // for Video::Subtitles
35
36namespace Video {
37class AdvancedVMDDecoder;
38}
39namespace Sci {
40class EventManager;
41class Plane;
42class ScreenItem;
43class SegManager;
44class SEQDecoder;
45struct Palette;
46
52public:
53 enum EventFlags {
54 kEventFlagNone = 0,
55 kEventFlagEnd = 1,
56 kEventFlagEscapeKey = 2,
57 kEventFlagMouseDown = 4,
58 kEventFlagHotRectangle = 8,
59 kEventFlagToFrame = 0x10,
60 kEventFlagYieldToVM = 0x20,
61 kEventFlagReverse = 0x80
62 };
63
64 friend EventFlags operator|(const EventFlags a, const EventFlags b) {
65 return static_cast<EventFlags>((int)a | (int)b);
66 }
67
68 VideoPlayer(EventManager *eventMan, Video::VideoDecoder *decoder = nullptr) :
69 _eventMan(eventMan),
70 _decoder(decoder),
71 _needsUpdate(false),
72 _currentFrame(nullptr),
73 _hqVideoMode(false)
74 {}
75
76 virtual ~VideoPlayer() {}
77
78protected:
79 EventManager *_eventMan;
80
85
91 bool open(const Common::Path &fileName);
92
102
107 virtual bool shouldStartHQVideo() const {
108 if (!ConfMan.getBool("enable_hq_video")) {
109 return false;
110 }
111
112 if (_decoder->getWidth() == _drawRect.width() &&
114 return false;
115 }
116
117 return true;
118 }
119
124
132 virtual EventFlags playUntilEvent(const EventFlags flags, const uint32 maxSleepMs = 0xFFFFFFFF);
133
138 virtual EventFlags checkForEvent(const EventFlags flags);
139
143 virtual void submitPalette(const uint8 palette[256 * 3]) const;
144
148 virtual void renderFrame(const Graphics::Surface &nextFrame) const;
149
154 void renderLQToSurface(Graphics::Surface &out, const Graphics::Surface &nextFrame, const bool doublePixels, const bool blackLines) const;
155
160 template <typename PixelType>
161 void renderLQToSurfaceDouble(Graphics::Surface &out, const Graphics::Surface &nextFrame, int lineCount) const;
162
166 void setDrawRect(const int16 x, const int16 y, const int16 width, const int16 height);
167
173
179
184
191
196
201
207};
208
209#pragma mark SEQPlayer
210
215class SEQPlayer : public VideoPlayer {
216public:
217 SEQPlayer(EventManager *eventMan);
218
223 void play(const Common::Path &fileName, const int16 numTicks, const int16 x, const int16 y);
224};
225
226#pragma mark -
227#pragma mark AVIPlayer
228
233class AVIPlayer : public VideoPlayer {
234public:
235 enum IOStatus {
236 kIOSuccess = 0,
237 kIOFileNotFound = 2,
238 kIOSeekFailed = 12
239 };
240
241 enum AVIStatus {
242 kAVINotOpen = 0,
243 kAVIOpen = 1,
244 kAVIPlaying = 2,
245 kAVIPaused = 3
246 };
247
248 AVIPlayer(EventManager *eventMan);
249
253 IOStatus open(const Common::Path &fileName);
254
259 IOStatus init(const bool doublePixels);
260
264 IOStatus play(const int16 from, const int16 to, const int16 showStyle, const bool cue);
265
266 EventFlags playUntilEvent(const EventFlags flags, const uint32 maxSleepMs = 0xFFFFFFFF) override;
267
271 IOStatus close();
272
276 IOStatus cue(const uint16 frameNo);
277
281 uint16 getDuration() const;
282
283private:
287 AVIStatus _status;
288};
289
290#pragma mark -
291#pragma mark QuickTimePlayer
292
298public:
299 QuickTimePlayer(EventManager *eventMan);
300
304 void play(const Common::Path &fileName);
305};
306
307#pragma mark -
308#pragma mark VMDPlayer
309
315class VMDPlayer : public VideoPlayer {
316public:
317 enum OpenFlags {
318 kOpenFlagNone = 0,
319 kOpenFlagMute = 1
320 };
321
322 enum IOStatus {
323 kIOSuccess = 0,
324 kIOError = 0xFFFF
325 };
326
327 enum PlayFlags {
328 kPlayFlagNone = 0,
329 kPlayFlagDoublePixels = 1,
330 kPlayFlagBlackLines = 4,
331 kPlayFlagBoost = 0x10,
332 kPlayFlagLeaveScreenBlack = 0x20,
333 kPlayFlagLeaveLastFrame = 0x40,
334 kPlayFlagBlackPalette = 0x80,
335 kPlayFlagStretchVertical = 0x100
336 };
337
338 enum VMDStatus {
339 kVMDNotOpen = 0,
340 kVMDOpen = 1,
341 kVMDPlaying = 2,
342 kVMDPaused = 3,
343 kVMDStopped = 4,
344 kVMDFinished = 5
345 };
346
347 VMDPlayer(EventManager *eventMan, SegManager *segMan);
348 ~VMDPlayer() override;
349
350private:
351 SegManager *_segMan;
352
353#pragma mark -
354#pragma mark VMDPlayer - Playback
355public:
359 IOStatus open(const Common::Path &fileName, const OpenFlags flags);
360
365 void init(int16 x, int16 y, const PlayFlags flags, const int16 boostPercent, const int16 boostStartColor, const int16 boostEndColor);
366
370 IOStatus close();
371
375 VMDStatus getStatus() const;
376
377 // Was WaitForEvent in SSCI
378 EventFlags kernelPlayUntilEvent(const EventFlags flags, const int16 lastFrameNo, const int16 yieldInterval);
379
380private:
384 bool _isOpen;
385
389 bool _isInitialized;
390
396 Resource *_bundledVmd;
397
402 int32 _yieldFrame;
403
408 int32 _yieldInterval;
409
414 int _lastYieldedFrameNo;
415
416 EventFlags playUntilEvent(const EventFlags flags, const uint32 = 0xFFFFFFFF) override;
417 EventFlags checkForEvent(const EventFlags flags) override;
418
419#pragma mark -
420#pragma mark VMDPlayer - Rendering
421public:
426 void ignorePalettes() { _ignorePalettes = true; }
427
431 void setPlane(const int16 priority, const reg_t planeId);
432
433protected:
437 void renderFrame(const Graphics::Surface &nextFrame) const override;
438
442 void submitPalette(const uint8 palette[256 * 3]) const override;
443
444private:
448 Plane *_plane;
449
454 ScreenItem *_screenItem;
455
459 reg_t _bitmapId;
460
465 bool _planeIsOwned;
466
471 int _priority;
472
476 bool _doublePixels;
477
481 bool _stretchVertical;
482
486 bool _blackLines;
487
492 bool _leaveScreenBlack;
493
498 bool _leaveLastFrame;
499
503 bool _ignorePalettes;
504
508 bool _isComposited;
509
514 void fillPalette(const uint8 rawPalette[256 * 3], Palette &outPalette) const;
515
521 void redrawGameScreen() const;
522
531 bool shouldStartHQVideo() const override {
533 return false;
534 }
535
536 if (_priority != 0 || _leaveLastFrame || _showCursor || _blackLines) {
537 return false;
538 }
539
540 return true;
541 }
542
547 bool shouldUseCompositing() const {
548 return isNormallyComposited() && !shouldStartHQVideo();
549 }
550
551 bool isNormallyComposited() const {
552 return (getSciVersion() == SCI_VERSION_3) ||
553 (g_sci->getPlatform() == Common::kPlatformMacintosh &&
554 getSciVersion() >= SCI_VERSION_2_1_LATE);
555 }
556
557 void initOverlay();
558 void renderOverlay(const Graphics::Surface &nextFrame) const;
559 void closeOverlay();
560
561 void initComposited();
562 void renderComposited() const;
563 void closeComposited();
564
565#pragma mark -
566#pragma mark VMDPlayer - Blackout
567public:
572 void setBlackoutArea(const Common::Rect &rect) { _blackoutRect = rect; }
573
574private:
578 Common::Rect _blackoutRect;
579
584 Plane *_blackoutPlane;
585
586#pragma mark -
587#pragma mark VMDPlayer - Palette
588public:
593 void restrictPalette(const uint8 startColor, const int16 endColor);
594
595private:
599 uint8 _startColor;
600
604 uint8 _endColor;
605
618#ifdef SCI_VMD_BLACK_PALETTE
619 bool _blackPalette;
620#endif
621
622#pragma mark -
623#pragma mark VMDPlayer - Brightness boost
624private:
629 int16 _boostPercent;
630
634 uint8 _boostStartColor;
635
639 uint8 _boostEndColor;
640
641#pragma mark -
642#pragma mark VMDPlayer - Mouse cursor
643public:
649 void setShowCursor(const bool shouldShow) { _showCursor = shouldShow; }
650
651private:
655 bool _showCursor;
656
657#pragma mark -
658#pragma mark VMDPlayer - Censorship blobs
659public:
666 int16 addBlob(int16 blockSize, int16 top, int16 left, int16 bottom, int16 right);
667 void deleteBlobs();
668 void deleteBlob(int16 blobNumber);
669
670private:
671 enum {
672 kMaxBlobs = 10
673 };
674
675 struct Blob {
676 int16 blobNumber;
677 int16 blockSize;
678 int16 top;
679 int16 left;
680 int16 bottom;
681 int16 right;
682 };
683
684 Common::List<Blob> _blobs;
685
686 void drawBlobs(Graphics::Surface& frame) const;
687};
688
689#pragma mark -
690#pragma mark DuckPlayer
691
696class DuckPlayer : public VideoPlayer {
697public:
698 enum DuckStatus {
699 kDuckClosed = 0,
700 kDuckOpen = 1,
701 kDuckPlaying = 2,
702 kDuckPaused = 3
703 };
704
705 DuckPlayer(EventManager *eventMan, SegManager *segMan);
706
710 void open(const GuiResourceId resourceId, const int displayMode, const int16 x, const int16 y);
711
715 void close();
716
720 void play(const int lastFrameNo);
721
726 void setDoFrameOut(const bool value) { _doFrameOut = value; }
727
731 void setVolume(const uint8 value) {
733 _decoder->setVolume(_volume);
734 }
735
736protected:
737 bool shouldStartHQVideo() const override {
738 if (!VideoPlayer::shouldStartHQVideo() || _blackLines) {
739 return false;
740 }
741
742 return true;
743 }
744
745 void renderFrame(const Graphics::Surface &nextFrame) const override;
746
747private:
752 Plane *_plane;
753
757 DuckStatus _status;
758
762 uint8 _volume;
763
768 bool _doFrameOut;
769
773 bool _doublePixels;
774
778 bool _blackLines;
779};
780
781#pragma mark -
782#pragma mark Video32
783
788public:
789 Video32(SegManager *segMan, EventManager *eventMan) :
790 _SEQPlayer(eventMan),
791 _AVIPlayer(eventMan),
792 _QuickTimePlayer(eventMan),
793 _VMDPlayer(eventMan, segMan),
794 _robotPlayer(segMan),
795 _duckPlayer(eventMan, segMan) {}
796
797 void beforeSaveLoadWithSerializer(Common::Serializer &ser);
798 void saveLoadWithSerializer(Common::Serializer &ser) override;
799
800 SEQPlayer &getSEQPlayer() { return _SEQPlayer; }
801 AVIPlayer &getAVIPlayer() { return _AVIPlayer; }
802 QuickTimePlayer &getQuickTimePlayer() { return _QuickTimePlayer; }
803 VMDPlayer &getVMDPlayer() { return _VMDPlayer; }
804 RobotDecoder &getRobotPlayer() { return _robotPlayer; }
805 DuckPlayer &getDuckPlayer() { return _duckPlayer; }
806
807private:
808 SEQPlayer _SEQPlayer;
809 AVIPlayer _AVIPlayer;
810 QuickTimePlayer _QuickTimePlayer;
811 VMDPlayer _VMDPlayer;
812 RobotDecoder _robotPlayer;
813 DuckPlayer _duckPlayer;
814};
815
816} // End of namespace Sci
817
818#endif // SCI_GRAPHICS_VIDEO32_H
@ kMaxChannelVolume
Definition: mixer.h:82
Definition: path.h:52
Definition: serializer.h:352
Definition: serializer.h:80
Definition: atari-screen.h:42
Definition: video32.h:233
IOStatus cue(const uint16 frameNo)
IOStatus play(const int16 from, const int16 to, const int16 showStyle, const bool cue)
uint16 getDuration() const
IOStatus close()
EventFlags playUntilEvent(const EventFlags flags, const uint32 maxSleepMs=0xFFFFFFFF) override
IOStatus init(const bool doublePixels)
IOStatus open(const Common::Path &fileName)
@ kMaxVolume
Definition: audio32.h:185
Definition: video32.h:696
void play(const int lastFrameNo)
void setDoFrameOut(const bool value)
Definition: video32.h:726
void setVolume(const uint8 value)
Definition: video32.h:731
void renderFrame(const Graphics::Surface &nextFrame) const override
bool shouldStartHQVideo() const override
Definition: video32.h:737
void open(const GuiResourceId resourceId, const int displayMode, const int16 x, const int16 y)
Definition: event.h:151
Definition: plane32.h:103
Definition: video32.h:297
void play(const Common::Path &fileName)
Definition: resource.h:256
Definition: robot_decoder.h:455
Definition: video32.h:215
void play(const Common::Path &fileName, const int16 numTicks, const int16 x, const int16 y)
Common::Platform getPlatform() const
Definition: screen_item32.h:53
Definition: seg_manager.h:48
Definition: video32.h:315
void setBlackoutArea(const Common::Rect &rect)
Definition: video32.h:572
void restrictPalette(const uint8 startColor, const int16 endColor)
int16 addBlob(int16 blockSize, int16 top, int16 left, int16 bottom, int16 right)
void renderFrame(const Graphics::Surface &nextFrame) const override
IOStatus close()
void init(int16 x, int16 y, const PlayFlags flags, const int16 boostPercent, const int16 boostStartColor, const int16 boostEndColor)
IOStatus open(const Common::Path &fileName, const OpenFlags flags)
void setPlane(const int16 priority, const reg_t planeId)
void setShowCursor(const bool shouldShow)
Definition: video32.h:649
void submitPalette(const uint8 palette[256 *3]) const override
VMDStatus getStatus() const
void ignorePalettes()
Definition: video32.h:426
Definition: video32.h:787
Definition: video32.h:51
bool _hqVideoMode
Definition: video32.h:206
bool startHQVideo(const Graphics::PixelFormat &format)
virtual EventFlags playUntilEvent(const EventFlags flags, const uint32 maxSleepMs=0xFFFFFFFF)
void renderLQToSurfaceDouble(Graphics::Surface &out, const Graphics::Surface &nextFrame, int lineCount) const
void showUnsupportedFormatDialog()
virtual bool shouldStartHQVideo() const
Definition: video32.h:107
bool _needsUpdate
Definition: video32.h:190
virtual EventFlags checkForEvent(const EventFlags flags)
void setSubtitlePosition() const
const Graphics::Surface * _currentFrame
Definition: video32.h:195
virtual void submitPalette(const uint8 palette[256 *3]) const
void renderLQToSurface(Graphics::Surface &out, const Graphics::Surface &nextFrame, const bool doublePixels, const bool blackLines) const
bool open(const Common::Path &fileName)
void setDrawRect(const int16 x, const int16 y, const int16 width, const int16 height)
Video::Subtitles _subtitles
Definition: video32.h:200
virtual void renderFrame(const Graphics::Surface &nextFrame) const
Common::ScopedPtr< Video::VideoDecoder > _decoder
Definition: video32.h:84
Common::Rect _drawRect
Definition: video32.h:183
Definition: subtitles.h:78
Definition: video_decoder.h:53
virtual uint16 getHeight() const
void setVolume(byte volume)
virtual uint16 getWidth() const
Definition: console.h:28
SciEngine * g_sci
T height() const
Definition: rect.h:218
T width() const
Definition: rect.h:217
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: surface.h:67
Definition: helpers.h:247
Definition: vm_types.h:39