2#include <Gfx/Graph/decoders/ColorSpace.hpp>
3#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
6#include <libavformat/avformat.h>
27 static const constexpr auto frag = R
"_(#version 450
29)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
31layout(binding=3) uniform sampler2D u_tex;
33layout(location = 0) in vec2 v_texcoord;
34layout(location = 0) out vec4 fragColor;
38vec4 processTexture(vec4 tex) {
39 vec4 processed = convert_to_rgb(tex);
46 int x = int(floor(v_texcoord.x * mat.texSz.x));
47 int y = int(floor(v_texcoord.y * mat.texSz.y));
50 const float s = )_" SCORE_GFX_MSB_ALIGNED_SCALE R"_(;
51 float luma = texelFetch(u_tex, ivec2(x, y), 0).r * s;
52 float cb = texelFetch(u_tex, ivec2(cx, y), 0).g * s;
53 float cr = texelFetch(u_tex, ivec2(cx + 1, y), 0).g * s;
55 fragColor = processTexture(vec4(luma, cb, cr, 1.));
67 auto& rhi = *r.
state.rhi;
68 const auto w = decoder.width, h = decoder.height;
71 auto tex = rhi.newTexture(QRhiTexture::RG16, {w, h}, 1, QRhiTexture::Flag{});
74 auto sampler = rhi.newSampler(
75 QRhiSampler::Nearest, QRhiSampler::Nearest, QRhiSampler::None,
76 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
78 samplers.push_back({sampler, tex});
82 r.
state, vertexShader(),
83 QString(frag).arg(
"").arg(colorMatrix(decoder)));
86 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override
88 const auto w = decoder.width, h = decoder.height;
89 auto pixels = frame.data[0];
90 auto stride = frame.linesize[0];
94 res.uploadTexture(samplers[0].texture, {entry});
Processes and renders a video frame on the GPU.
Definition GPUVideoDecoder.hpp:90
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:30
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:169
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:11
std::pair< QShader, QShader > makeShaders(const RenderState &v, QString vert, QString frag, int multiViewCount)
Get a pair of compiled vertex / fragment shaders from GLSL 4.5 sources.
Definition score-plugin-gfx/Gfx/Graph/Utils.cpp:1238
Decodes Y210 packed 4:2:2 10-bit videos.
Definition Y210.hpp:26
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition Y210.hpp:86
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition Y210.hpp:65