2#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
5#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 p_tex;
31layout(location = 0) in vec2 v_texcoord;
32layout(location = 0) out vec4 fragColor;
34vec4 processTexture(vec4 tex) {
42 float index = texture(y_tex, score_tc(v_texcoord)).r;
43 fragColor = processTexture(texelFetch(p_tex, ivec2(int(index * 255.0 + 0.5), 0), 0));
48 , filter{std::move(f)}
57 auto& rhi = *r.
state.rhi;
58 const auto w = decoder.width, h = decoder.height;
63 auto tex = rhi.newTexture(QRhiTexture::R8, {w, h}, 1, QRhiTexture::Flag{});
65 auto sampler = rhi.newSampler(
66 QRhiSampler::Nearest, QRhiSampler::Nearest, QRhiSampler::None,
67 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
69 samplers.push_back({sampler, tex});
72 auto tex = rhi.newTexture(QRhiTexture::BGRA8, {256, 1}, 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});
84 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override
86 const auto w = decoder.width, h = decoder.height;
88 QRhiTextureUploadEntry entry{
90 QRhiTextureUploadDescription desc{entry};
91 res.uploadTexture(samplers[0].texture, desc);
95 QRhiTextureUploadEntry entry{
97 QRhiTextureUploadDescription desc{entry};
98 res.uploadTexture(samplers[1].texture, desc);
Processes and renders a video frame on the GPU.
Definition GPUVideoDecoder.hpp:161
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:33
RenderState & state
RenderState corresponding to this RenderList.
Definition RenderList.hpp:274
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:1359
Decodes 8-bit palettized video (AV_PIX_FMT_PAL8): GIF, QuickTime and MS RLE, and the screen and game ...
Definition PAL8.hpp:23
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition PAL8.hpp:84
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition PAL8.hpp:55