MythTV master
mythvdpauhelper.h
Go to the documentation of this file.
1#ifndef MYTHVDPAUHELPER_H
2#define MYTHVDPAUHELPER_H
3
4#include <vector>
5
6// Qt
7#include <QSize>
8#include <QMutex>
9#include <QFlags>
10
11// MythTV
12#include "mythframe.h"
13#include "mythcodeccontext.h"
14#include "videoouttypes.h"
15
16// FFmpeg
17extern "C" {
18#include "libavutil/hwcontext_vdpau.h"
19#include "libavcodec/avcodec.h"
20}
21
22class MythXDisplay;
24
26{
27 public:
29 uint32_t Macroblocks, uint32_t Level);
30 bool Supported(int Width, int Height, int Level) const;
31 QSize m_maxSize { 0, 0 };
32 uint32_t m_maxMacroBlocks { 0 };
33 uint32_t m_maxLevel { 0 };
34};
35
36using VDPAUProfile = QPair<MythCodecContext::CodecProfile, VDPAUCodec>;
37using VDPAUProfiles = std::vector<VDPAUProfile>;
38
39class MythVDPAUHelper : public QObject
40{
41 Q_OBJECT
42
43 public:
44 enum VDPMixerFeature : std::uint8_t
45 {
48 VDPMixerSpatial = 0x02
49 };
50
51 Q_DECLARE_FLAGS(VDPMixerFeatures, VDPMixerFeature)
52
53 static bool HaveVDPAU(bool Reinit = false);
54 static bool CheckH264Decode(AVCodecContext *Context);
55 static const VDPAUProfiles& GetProfiles(void);
56 static void GetDecoderList (QStringList &Decoders);
57
58 explicit MythVDPAUHelper(AVVDPAUDeviceContext *Context);
59 ~MythVDPAUHelper(void) override;
60
61 bool IsValid(void) const;
62 void SetPreempted(void);
63 bool IsFeatureAvailable(uint Feature);
64 bool IsAttributeAvailable(uint Attribute);
65 VdpOutputSurface CreateOutputSurface(QSize Size);
66 VdpVideoMixer CreateMixer(QSize Size, VdpChromaType ChromaType = VDP_CHROMA_TYPE_420,
67 MythDeintType Deinterlacer = DEINT_BASIC);
68 void MixerRender(VdpVideoMixer Mixer, VdpVideoSurface Source, VdpOutputSurface Dest,
69 FrameScanType Scan, int TopFieldFirst, QVector<AVBufferRef*>& Frames);
70 void SetCSCMatrix(VdpVideoMixer Mixer, MythVideoColourSpace *ColourSpace);
71 void DeleteOutputSurface(VdpOutputSurface Surface);
72 void DeleteMixer(VdpVideoMixer Mixer);
73 QSize GetSurfaceParameters(VdpVideoSurface Surface, VdpChromaType &Chroma);
74
75 signals:
76 void DisplayPreempted(void);
77
78 protected:
79 MythVDPAUHelper(void);
80
81 bool H264DecodeCheck (VdpDecoderProfile Profile, AVCodecContext *Context);
82 bool HEVCSupported (void);
83 bool ProfileCheck (VdpDecoderProfile Profile, uint32_t &Level,
84 uint32_t &Macros, uint32_t &Width, uint32_t &Height);
85
86 private:
87 bool InitProcs(void);
88
89 private:
90 VdpDevice m_device { 0 };
91 MythXDisplay *m_display { nullptr };
92
93 VdpGetProcAddress *m_vdpGetProcAddress { nullptr };
94 VdpGetErrorString *m_vdpGetErrorString { nullptr };
95 VdpGetInformationString *m_vdpGetInformationString { nullptr };
96 VdpDeviceDestroy *m_vdpDeviceDestroy { nullptr };
97 VdpDecoderQueryCapabilities *m_vdpDecoderQueryCapabilities { nullptr };
98 VdpDecoderCreate *m_vdpDecoderCreate { nullptr };
99 VdpDecoderDestroy *m_vdpDecoderDestroy { nullptr };
100 VdpVideoMixerCreate *m_vdpVideoMixerCreate { nullptr };
101 VdpVideoMixerDestroy *m_vdpVideoMixerDestroy { nullptr };
102 VdpVideoMixerRender *m_vdpVideoMixerRender { nullptr };
103 VdpVideoMixerSetAttributeValues *m_vdpVideoMixerSetAttributeValues { nullptr };
104 VdpVideoMixerSetFeatureEnables *m_vdpVideoMixerSetFeatureEnables { nullptr };
105 VdpVideoMixerQueryFeatureSupport *m_vdpVideoMixerQueryFeatureSupport { nullptr };
106 VdpVideoMixerQueryAttributeSupport *m_vdpVideoMixerQueryAttributeSupport { nullptr };
107 VdpOutputSurfaceCreate *m_vdpOutputSurfaceCreate { nullptr };
108 VdpOutputSurfaceDestroy *m_vdpOutputSurfaceDestroy { nullptr };
109 VdpVideoSurfaceGetParameters *m_vdpVideoSurfaceGetParameters { nullptr };
110 VdpPreemptionCallbackRegister *m_vdpPreemptionCallbackRegister { nullptr };
111
112 bool m_createdDevice { false };
113 bool m_valid { false };
114};
115
116#endif // MYTHVDPAUHELPER_H
A simple wrapper around VDPAU functionality.
void DeleteOutputSurface(VdpOutputSurface Surface)
VdpOutputSurface CreateOutputSurface(QSize Size)
VdpVideoMixerDestroy * m_vdpVideoMixerDestroy
VdpVideoMixerSetFeatureEnables * m_vdpVideoMixerSetFeatureEnables
bool HEVCSupported(void)
void MixerRender(VdpVideoMixer Mixer, VdpVideoSurface Source, VdpOutputSurface Dest, FrameScanType Scan, int TopFieldFirst, QVector< AVBufferRef * > &Frames)
bool IsValid(void) const
VdpOutputSurfaceDestroy * m_vdpOutputSurfaceDestroy
static bool CheckH264Decode(AVCodecContext *Context)
VdpVideoMixerCreate * m_vdpVideoMixerCreate
QSize GetSurfaceParameters(VdpVideoSurface Surface, VdpChromaType &Chroma)
VdpDecoderQueryCapabilities * m_vdpDecoderQueryCapabilities
void DeleteMixer(VdpVideoMixer Mixer)
~MythVDPAUHelper(void) override
MythXDisplay * m_display
static bool HaveVDPAU(bool Reinit=false)
VdpDecoderDestroy * m_vdpDecoderDestroy
bool IsFeatureAvailable(uint Feature)
VdpVideoMixerQueryAttributeSupport * m_vdpVideoMixerQueryAttributeSupport
void SetCSCMatrix(VdpVideoMixer Mixer, MythVideoColourSpace *ColourSpace)
static void GetDecoderList(QStringList &Decoders)
VdpGetErrorString * m_vdpGetErrorString
VdpVideoMixerSetAttributeValues * m_vdpVideoMixerSetAttributeValues
VdpVideoMixer CreateMixer(QSize Size, VdpChromaType ChromaType=VDP_CHROMA_TYPE_420, MythDeintType Deinterlacer=DEINT_BASIC)
VdpDeviceDestroy * m_vdpDeviceDestroy
VdpDevice m_device
void DisplayPreempted(void)
VdpVideoMixerRender * m_vdpVideoMixerRender
VdpDecoderCreate * m_vdpDecoderCreate
static const VDPAUProfiles & GetProfiles(void)
VdpVideoSurfaceGetParameters * m_vdpVideoSurfaceGetParameters
void SetPreempted(void)
bool H264DecodeCheck(VdpDecoderProfile Profile, AVCodecContext *Context)
VdpVideoMixerQueryFeatureSupport * m_vdpVideoMixerQueryFeatureSupport
bool ProfileCheck(VdpDecoderProfile Profile, uint32_t &Level, uint32_t &Macros, uint32_t &Width, uint32_t &Height)
bool IsAttributeAvailable(uint Attribute)
VdpOutputSurfaceCreate * m_vdpOutputSurfaceCreate
VdpGetProcAddress * m_vdpGetProcAddress
VdpGetInformationString * m_vdpGetInformationString
VdpPreemptionCallbackRegister * m_vdpPreemptionCallbackRegister
MythVideoColourSpace contains a QMatrix4x4 that can convert YCbCr data to RGB.
uint32_t m_maxMacroBlocks
uint32_t m_maxLevel
bool Supported(int Width, int Height, int Level) const
VDPAUCodec(MythCodecContext::CodecProfile Profile, QSize Size, uint32_t Macroblocks, uint32_t Level)
unsigned int uint
Definition: compat.h:60
MythDeintType
Definition: mythframe.h:67
@ DEINT_BASIC
Definition: mythframe.h:69
std::vector< VDPAUProfile > VDPAUProfiles
QPair< MythCodecContext::CodecProfile, VDPAUCodec > VDPAUProfile
Definition: surface.h:4
FrameScanType
Definition: videoouttypes.h:95