Debian Codegraph @

src/engine/smk_decoder.h

raw symbols SCIP
1 /***************************************************************************
2 * fheroes2: https://github.com/ihhub/fheroes2 *
3 * Copyright (C) 2020 - 2025 *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20
21 #pragma once
22
23 #include <cstdint>
24 #include <memory>
25 #include <string>
26 #include <vector>
27
28 #include "smacker.h"
29
30 namespace fheroes2
31 {
32 class Image;
33 }
34
35 class SMKVideoSequence final
36 {
37 public:
38 explicit SMKVideoSequence( const std::string & filePath );
39 ~SMKVideoSequence() = default;
40
41 SMKVideoSequence( const SMKVideoSequence & ) = delete;
42 SMKVideoSequence & operator=( const SMKVideoSequence & ) = delete;
43
44 void resetFrame();
45
46 // Input image must be resized to accommodate the frame, and also it must be a single layer image as video frames shouldn't have any transform-related information.
47 // If the image is smaller than the frame then only a part of the frame will be drawn.
48 void getCurrentFrame( fheroes2::Image & image, int32_t x, int32_t y, int32_t & width, int32_t & height, std::vector<uint8_t> & palette ) const;
49
50 // Input image must be resized to accommodate the frame and also it must be a single layer image as video frames shouldn't have any transform-related information.
51 // If the image is smaller than the frame then only a part of the frame will be drawn.
52 void getNextFrame( fheroes2::Image & image, const int32_t x, const int32_t y, int32_t & width, int32_t & height, std::vector<uint8_t> & palette )
53 {
54 getCurrentFrame( image, x, y, width, height, palette );
55 skipFrame();
56 }
57
58 void skipFrame();
59
60 std::vector<uint8_t> getCurrentPalette() const;
61
62 const std::vector<std::vector<uint8_t>> & getAudioChannels() const
63 {
64 return _audioChannel;
65 }
66
67 int32_t width() const
68 {
69 return _width;
70 }
71
72 int32_t height() const
73 {
74 return _height;
75 }
76
77 double microsecondsPerFrame() const
78 {
79 return _microsecondsPerFrame;
80 }
81
82 unsigned long frameCount() const
83 {
84 return _frameCount;
85 }
86
87 unsigned long getCurrentFrameId() const
88 {
89 return _currentFrameId;
90 }
91
92 private:
93 std::vector<std::vector<uint8_t>> _audioChannel;
94 int32_t _width{ 0 };
95 int32_t _height{ 0 };
96 int32_t _heightScaleFactor{ 1 };
97 double _microsecondsPerFrame{ 0 };
98 unsigned long _frameCount{ 0 };
99 unsigned long _currentFrameId{ 0 };
100
101 std::unique_ptr<struct smk_t, void ( * )( struct smk_t * )> _videoFile{ nullptr, smk_close };
102 };