2#include <Gfx/Graph/decoders/ColorSpace.hpp>
3#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
6#include <libavformat/avformat.h>
24 static const constexpr auto frag = R
"_(#version 450
26)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
28layout(binding=3) uniform sampler2D y_tex;
29layout(binding=4) uniform sampler2D uv_tex;
31layout(location = 0) in vec2 v_texcoord;
32layout(location = 0) out vec4 fragColor;
36vec4 processTexture(vec4 tex) {
37 vec4 processed = convert_to_rgb(tex);
44 const float s = )_" SCORE_GFX_MSB_ALIGNED_SCALE R"_(;
45 float y = s * texture(y_tex, v_texcoord).r;
46 float u = s * texture(uv_tex, v_texcoord).r;
47 float v = s * texture(uv_tex, v_texcoord).g;
49 fragColor = processTexture(vec4(y, u, v, 1.));
61 auto& rhi = *r.
state.rhi;
62 const auto w = decoder.width, h = decoder.height;
66 auto tex = rhi.newTexture(QRhiTexture::R16, {w, h}, 1, QRhiTexture::Flag{});
69 auto sampler = rhi.newSampler(
70 QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
71 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
73 samplers.push_back({sampler, tex});
79 = rhi.newTexture(QRhiTexture::RG16, {w / 2, h}, 1, QRhiTexture::Flag{});
82 auto sampler = rhi.newSampler(
83 QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
84 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
86 samplers.push_back({sampler, tex});
90 r.
state, vertexShader(), QString(frag).arg(
"").arg(colorMatrix(decoder)));
93 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override
96 const auto w = decoder.width, h = decoder.height;
97 QRhiTextureUploadEntry entry{
99 res.uploadTexture(samplers[0].texture, {entry});
102 const auto w = decoder.width / 2, h = decoder.height;
103 QRhiTextureUploadEntry entry{
105 res.uploadTexture(samplers[1].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 P210 semi-planar 4:2:2 10-bit videos.
Definition P210.hpp:23
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition P210.hpp:59
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition P210.hpp:93