Loading...
Searching...
No Matches
DirectVideoNodeRenderer.hpp
1#pragma once
2#include <Gfx/Graph/NodeRenderer.hpp>
3#include <Gfx/Graph/VideoNode.hpp>
4#include <Video/VideoInterface.hpp>
5
6extern "C" {
7struct AVFormatContext;
8struct AVCodecContext;
9struct AVStream;
10struct AVFrame;
11struct AVPacket;
12struct SwsContext;
13}
14
15namespace Video
16{
17class Rescale;
18}
19
20namespace score::gfx
21{
22class GPUVideoDecoder;
23
35{
36public:
38 const VideoNodeBase& node, const Video::VideoMetadata& metadata) noexcept;
40
41 DirectVideoNodeRenderer() = delete;
44 DirectVideoNodeRenderer& operator=(const DirectVideoNodeRenderer&) = delete;
46
47 TextureRenderTarget renderTargetForInput(const Port& input) override;
48
49 void init(RenderList& renderer, QRhiResourceUpdateBatch& res) override;
50 void runRenderPass(RenderList&, QRhiCommandBuffer& commands, Edge& edge) override;
51 void update(RenderList& renderer, QRhiResourceUpdateBatch& res, Edge* edge) override;
52 void release(RenderList& r) override;
53
54private:
55 const VideoNodeBase& node() const noexcept
56 {
57 return static_cast<const VideoNodeBase&>(NodeRenderer::node);
58 }
59
60 bool openFile();
61 void closeFile();
62 bool seekAndDecode(int64_t flicks);
63
64 void createGpuDecoder();
65 void setupGpuDecoder(RenderList& r);
66 void createPipelines(RenderList& r);
67
68 // Video file info
69 std::string m_filePath;
70 Video::ImageFormat m_frameFormat{};
71 double m_fps{};
72 double m_flicks_per_dts{};
73 double m_dts_per_flicks{};
74 bool m_useAVCodec{true};
75
76 // Own LibAV context
77 AVFormatContext* m_formatContext{};
78 AVCodecContext* m_codecContext{};
79 const void* m_codec{}; // AVCodec*
80 AVStream* m_avstream{};
81 AVFrame* m_decodedFrame{};
82
83 // Render state
84 PassMap m_p;
85 MeshBuffers m_meshBuffer{};
86 QRhiBuffer* m_processUBO{};
87 QRhiBuffer* m_materialUBO{};
88
89 struct Material
90 {
91 float scale_w{}, scale_h{};
92 float tex_w{}, tex_h{};
93 };
94
95 std::unique_ptr<GPUVideoDecoder> m_gpu;
96 score::gfx::ScaleMode m_currentScaleMode{};
97
98 int64_t m_lastRequestedFlicks{-1};
99 int64_t m_lastDecodedDts{INT64_MIN};
100 bool m_recomputeScale{true};
101};
102
103}
Renderer for intra-only video codecs with instant seeking.
Definition DirectVideoNodeRenderer.hpp:35
Renderer for a given node.
Definition NodeRenderer.hpp:11
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
Definition VideoNode.hpp:72
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
ScaleMode
How to resize a texture to adapt it to a viewport.
Definition Scale.hpp:10
Definition VideoInterface.hpp:18
Definition VideoInterface.hpp:31
Connection between two score::gfx::Port.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:74
Definition Mesh.hpp:23
Port of a score::gfx::Node.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:53
Useful abstraction for storing all the data related to a render target.
Definition score-plugin-gfx/Gfx/Graph/Utils.hpp:119