Loading...
Searching...
No Matches
DXV.hpp
1#pragma once
2#include <Gfx/Graph/decoders/GPUVideoDecoder.hpp>
3
4extern "C" {
5#include <libavformat/avformat.h>
6#include <dxv.h>
7}
8
9namespace score::gfx
10{
20{
21 // DXV sub-format tags (little-endian uint32 from packet header)
22 enum DXVFormat : uint32_t
23 {
24 FMT_DXT1 = 0x44585431, // MKBETAG('D','X','T','1')
25 FMT_DXT5 = 0x44585435, // MKBETAG('D','X','T','5')
26 FMT_YCG6 = 0x59434736, // MKBETAG('Y','C','G','6')
27 FMT_YG10 = 0x59473130, // MKBETAG('Y','G','1','0')
28 };
29
30 DXVDecoder(QRhiTexture::Format fmt, Video::ImageFormat& d, QString filter = "");
31
32 std::pair<QShader, QShader> init(RenderList& r) override;
33 void exec(RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame) override;
34
35 // Packet header info
37 {
38 DXVFormat format{};
39 bool isRaw{};
40 bool isOldFormat{};
41 const uint8_t* data{};
42 int dataSize{};
43 };
44 static PacketHeader parseHeader(const uint8_t* pkt, int pktSize);
45
46private:
47 void uploadTexture(QRhiResourceUpdateBatch& res, const uint8_t* data, std::size_t size);
48
49 QRhiTexture::Format m_format;
50 Video::ImageFormat& m_decoder;
51 QString m_filter;
52
53 static constexpr int buffer_size = 1024 * 1024 * 16;
54 std::unique_ptr<char[]> m_buffer = std::make_unique<char[]>(buffer_size);
55};
56
65{
66 DXVYCoCgDecoder(bool hasAlpha, Video::ImageFormat& d, QString filter = "");
68
69 std::pair<QShader, QShader> init(RenderList& r) override;
70 void exec(RenderList&, QRhiResourceUpdateBatch& res, AVFrame& frame) override;
71
72private:
73 bool m_hasAlpha; // true for YG10 (has alpha), false for YCG6
74 Video::ImageFormat& m_decoder;
75 QString m_filter;
76 DXVDecompressContext m_ctx;
77
78 static constexpr int buffer_size = 1024 * 1024 * 16;
79 std::unique_ptr<char[]> m_yBuffer = std::make_unique<char[]>(buffer_size);
80 std::unique_ptr<char[]> m_cocgBuffer = std::make_unique<char[]>(buffer_size);
81};
82
83}
Processes and renders a video frame on the GPU.
Definition GPUVideoDecoder.hpp:43
List of nodes to be rendered to an output.
Definition RenderList.hpp:19
Graphics rendering pipeline for ossia score.
Definition Filter/PreviewWidget.hpp:12
Definition VideoInterface.hpp:18
Decodes DXV DXT1/DXT5 (Resolume) format to GPU.
Definition DXV.hpp:20
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition DXV.cpp:106
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition DXV.cpp:134
Decodes DXV YCG6/YG10 (YCoCg) format to GPU.
Definition DXV.hpp:65
std::pair< QShader, QShader > init(RenderList &r) override
Initialize a GPUVideoDecoder.
Definition DXV.cpp:269
void exec(RenderList &, QRhiResourceUpdateBatch &res, AVFrame &frame) override
Decode and upload a video frame to the GPU.
Definition DXV.cpp:307