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