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