2#include <Gfx/Graph/decoders/ColorSpace.hpp>
3#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
6#include <libavformat/avformat.h>
22 static const constexpr auto frag = R
"_(#version 450
24)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
26layout(binding=3) uniform sampler2D u_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 vec4 vuya = texture(u_tex, v_texcoord);
46 vec4 rgb = processTexture(vec4(y, u, v, 1.));
47 fragColor = vec4(rgb.rgb, %6);
52 QString swizzle{
"bgr"};
61 , swizzle{
std::move(swz)}
68 auto& rhi = *r.
state.rhi;
69 const auto w = decoder.width, h = decoder.height;
72 auto tex = rhi.newTexture(QRhiTexture::RGBA8, {w, h}, 1, QRhiTexture::Flag{});
75 auto sampler = rhi.newSampler(
76 QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
77 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
79 samplers.push_back({sampler, tex});
83 QString alpha = opaque ?
"1.0" : QString(
"vuya.%1").arg(alphaComp);
86 r.
state, vertexShader(),
89 .arg(colorMatrix(decoder))
96 void exec(
RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame)
override
98 auto pixels = frame.data[0];
99 auto stride = frame.linesize[0];
100 const auto w = decoder.width, h = decoder.height;
102 QRhiTextureUploadEntry entry{
104 res.uploadTexture(samplers[0].texture, {entry});
108#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 29, 100)
109#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
121 static const constexpr auto frag = R
"_(#version 450
123)_" SCORE_GFX_VIDEO_UNIFORMS R"_(
125layout(binding=3) uniform sampler2D u_tex;
127layout(location = 0) in vec2 v_texcoord;
128layout(location = 0) out vec4 fragColor;
132vec4 processTexture(vec4 tex) {
133 vec4 processed = convert_to_rgb(tex);
140 const float s = )_" SCORE_GFX_UNORM10_SCALE R"_(;
141 vec4 xvyu = texture(u_tex, v_texcoord) * s;
146 fragColor = processTexture(vec4(y, u, v, 1.));
158 auto& rhi = *r.
state.rhi;
159 const auto w = decoder.width, h = decoder.height;
163 = rhi.newTexture(QRhiTexture::RGB10A2, {w, h}, 1, QRhiTexture::Flag{});
166 auto sampler = rhi.newSampler(
167 QRhiSampler::Linear, QRhiSampler::Linear, QRhiSampler::None,
168 QRhiSampler::ClampToEdge, QRhiSampler::ClampToEdge);
170 samplers.push_back({sampler, tex});
174 r.
state, vertexShader(),
175 QString(frag).arg(
"").arg(colorMatrix(decoder)));
180 auto pixels = frame.data[0];
181 auto stride = frame.linesize[0];
182 const auto w = decoder.width, h = decoder.height;
184 QRhiTextureUploadEntry entry{
186 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 VUYA / VUYX packed 4:4:4 8-bit videos.
Definition VUYA.hpp:21
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition VUYA.hpp:96
VUYADecoder(Video::ImageFormat &d, bool opaque_, QString swz="bgr", QChar aComp='a')
Definition VUYA.hpp:58
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition VUYA.hpp:66
Decodes XV30 packed 4:4:4 10-bit videos.
Definition VUYA.hpp:120
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition VUYA.hpp:178
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition VUYA.hpp:156