2#include <Gfx/Graph/decoders/ColorSpace.hpp>
3#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
6#include <libavformat/avformat.h>
20 static const constexpr auto frag = R
"_(#version 450
22)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
24layout(binding=3) uniform sampler2D y_tex;
25layout(binding=4) uniform sampler2D u_tex;
26layout(binding=5) uniform sampler2D v_tex;
28layout(location = 0) in vec2 v_texcoord;
29layout(location = 0) out vec4 fragColor;
33vec4 processTexture(vec4 tex) {
34 vec4 processed = convert_to_rgb(tex);
41 float y = texture(y_tex, v_texcoord).r;
42 float u = texture(u_tex, v_texcoord).r;
43 float v = texture(v_tex, v_texcoord).r;
45 fragColor = processTexture(vec4(y,u,v, 1.));
57 auto& rhi = *r.
state.rhi;
58 const auto w = decoder.width, h = decoder.height;
59 const auto fmt = QRhiTexture::R8;
62 for(
int i = 0; i < 3; i++)
64 auto tex = rhi.newTexture(fmt, {w, h}, 1, QRhiTexture::Flag{});
67 auto sampler = rhi.newSampler(
68 QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
69 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
71 samplers.push_back({sampler, tex});
75 r.
state, vertexShader(), QString(frag).arg(
"").arg(colorMatrix(decoder)));
78 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override
80 const auto w = decoder.width, h = decoder.height;
81 for(
int i = 0; i < 3; i++)
83 QRhiTextureUploadEntry entry{
85 QRhiTextureUploadDescription desc{entry};
86 res.uploadTexture(samplers[i].texture, desc);
Processes and renders a video frame on the GPU.
Definition GPUVideoDecoder.hpp:43
static QRhiTextureSubresourceUploadDescription createTextureUpload(uint8_t *pixels, int w, int h, int bytesPerPixel, int stride)
Utility method to create a QRhiTextureSubresourceUploadDescription.
Definition GPUVideoDecoder.cpp:22
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:94
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
std::pair< QShader, QShader > makeShaders(const RenderState &v, QString vert, QString frag)
Get a pair of compiled vertex / fragment shaders from GLSL 4.5 sources.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:394
Decodes YUV444P videos.
Definition YUV444.hpp:19
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition YUV444.hpp:78
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition YUV444.hpp:55