2 #include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
4 #include <hap/source/hap.h>
9 #include <libavformat/avformat.h>
25 const uint8_t* data{};
28 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override;
29 void setPixels_noEncoding(
30 QRhiResourceUpdateBatch& res,
const uint8_t* data_start, std::size_t size);
31 void setPixels_snappy(
32 QRhiResourceUpdateBatch& res,
const uint8_t* data_start, std::size_t size);
34 static constexpr
int buffer_size = 1024 * 1024 * 16;
35 std::unique_ptr<char[]> m_buffer = std::make_unique<char[]>(1024 * 1024 * 16);
43 static inline const QString fragment = QStringLiteral(R
"_(#version 450
45 )_" SCORE_GFX_VIDEO_UNIFORMS R"_(
47 layout(binding=3) uniform sampler2D y_tex;
49 layout(location = 0) in vec2 v_texcoord;
50 layout(location = 0) out vec4 fragColor;
52 vec4 processYCoCg(vec4 CoCgSY) {
53 const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0);
55 float scale = ( CoCgSY.z * ( 255.0 / 8.0 ) ) + 1.0;
57 float Co = CoCgSY.x / scale;
58 float Cg = CoCgSY.y / scale;
61 vec4 rgba = vec4(Y + Co - Cg, Y + Cg, Y - Co - Cg, 1.0);
65 vec4 processTexture(vec4 tex) {
73 fragColor = processTexture(texture(y_tex, v_texcoord));
76 static inline const QString ycocg_filter
77 = QStringLiteral(
"processed = processYCoCg(processed);\n");
80 QRhiTexture::Format format;
92 static inline const QString fragment = QStringLiteral(R
"_(#version 450
94 )_" SCORE_GFX_VIDEO_UNIFORMS R"_(
96 layout(binding=3) uniform sampler2D y_tex;
97 layout(binding=4) uniform sampler2D alpha_tex;
99 layout(location = 0) in vec2 v_texcoord;
100 layout(location = 0) out vec4 fragColor;
102 vec4 processYCoCg(vec4 CoCgSY, vec4 alpha) {
103 const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0);
105 float scale = ( CoCgSY.z * ( 255.0 / 8.0 ) ) + 1.0;
107 float Co = CoCgSY.x / scale;
108 float Cg = CoCgSY.y / scale;
111 vec4 rgba = vec4(Y + Co - Cg, Y + Cg, Y - Co - Cg, alpha.r);
115 vec4 processTexture(vec4 tex) {
116 vec4 processed = tex;
123 vec4 ycocg = texture(y_tex, v_texcoord);
124 vec4 alpha = texture(alpha_tex, v_texcoord);
125 fragColor = processTexture(processYCoCg(ycocg, alpha));
133 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override;
135 static void setPixels(
136 QRhiResourceUpdateBatch& res, QRhiTexture* tex,
const uint8_t* ycocg_start,
137 std::size_t ycocg_size);
139 std::unique_ptr<char[]> m_alphaBuffer = std::make_unique<char[]>(1024 * 1024 * 16);
Processes and renders a video frame on the GPU.
Definition: GPUVideoDecoder.hpp:43
List of nodes to be rendered to an output.
Definition: RenderList.hpp:19
Graphics rendering pipeline for ossia score.
Definition: Filter/PreviewWidget.hpp:12
Base class for HAP ((c) Vidvox) decoding.
Definition: HAP.hpp:18
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition: HAP.cpp:32
Decodes HAP basic format.
Definition: HAP.hpp:42
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition: HAP.cpp:110
Decodes HAP-M (HAP + alpha channel)
Definition: HAP.hpp:91
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition: HAP.cpp:138
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition: HAP.cpp:172