2#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
4#include <hap/source/hap.h>
6#if !defined(__EMSCRIPTEN__)
10#include <libavformat/avformat.h>
26 const uint8_t* data{};
29 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override;
30 void setPixels_noEncoding(
31 QRhiResourceUpdateBatch& res,
const uint8_t* data_start, std::size_t size);
32 void setPixels_snappy(
33 QRhiResourceUpdateBatch& res,
const uint8_t* data_start, std::size_t size);
35 static constexpr int buffer_size = 1024 * 1024 * 16;
36 std::unique_ptr<char[]> m_buffer = std::make_unique<char[]>(1024 * 1024 * 16);
44 static inline const QString fragment = QStringLiteral(R
"_(#version 450
46)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
48layout(binding=3) uniform sampler2D y_tex;
50layout(location = 0) in vec2 v_texcoord;
51layout(location = 0) out vec4 fragColor;
53vec4 processYCoCg(vec4 CoCgSY) {
54 const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0);
56 float scale = ( CoCgSY.z * ( 255.0 / 8.0 ) ) + 1.0;
58 float Co = CoCgSY.x / scale;
59 float Cg = CoCgSY.y / scale;
62 vec4 rgba = vec4(Y + Co - Cg, Y + Cg, Y - Co - Cg, 1.0);
66vec4 processTexture(vec4 tex) {
74 fragColor = processTexture(texture(y_tex, v_texcoord));
77 static inline const QString ycocg_filter
78 = QStringLiteral(
"processed = processYCoCg(processed);\n");
81 QRhiTexture::Format format;
93 static inline const QString fragment = QStringLiteral(R
"_(#version 450
95)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
97layout(binding=3) uniform sampler2D y_tex;
98layout(binding=4) uniform sampler2D alpha_tex;
100layout(location = 0) in vec2 v_texcoord;
101layout(location = 0) out vec4 fragColor;
103// FIXME what's that???
104vec4 processYCoCg(vec4 CoCgSY, vec4 alpha) {
105 const vec4 offsets = vec4(-0.50196078431373, -0.50196078431373, 0.0, 0.0);
107 float scale = ( CoCgSY.z * ( 255.0 / 8.0 ) ) + 1.0;
109 float Co = CoCgSY.x / scale;
110 float Cg = CoCgSY.y / scale;
113 vec4 rgba = vec4(Y + Co - Cg, Y + Cg, Y - Co - Cg, alpha.r);
117vec4 processTexture(vec4 tex) {
118 vec4 processed = tex;
125 vec4 ycocg = texture(y_tex, v_texcoord);
126 vec4 alpha = texture(alpha_tex, v_texcoord);
127 fragColor = processTexture(processYCoCg(ycocg, alpha));
135 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override;
137 static void setPixels(
138 QRhiResourceUpdateBatch& res, QRhiTexture* tex,
const uint8_t* ycocg_start,
139 std::size_t ycocg_size);
141 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:90
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:19
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition HAP.cpp:33
Decodes HAP basic format.
Definition HAP.hpp:43
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition HAP.cpp:113
Decodes HAP-M (HAP + alpha channel)
Definition HAP.hpp:92
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition HAP.cpp:141
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition HAP.cpp:175