MythTV  master
mythvaapiinterop.h
Go to the documentation of this file.
1 #ifndef MYTHVAAPIINTEROP_H
2 #define MYTHVAAPIINTEROP_H
3 
4 // Qt
5 #include <QFile>
6 
7 // MythTV
8 #include "mythopenglinterop.h"
9 
10 struct AVFilterGraph;
11 struct AVFilterContext;
12 
13 // VAAPI
14 #include "va/va.h"
15 #include "va/va_version.h"
16 #if VA_CHECK_VERSION(0,34,0)
17 #include "va/va_compat.h"
18 #endif
19 #define Cursor XCursor // Prevent conflicts with Qt6.
20 #define pointer Xpointer // Prevent conflicts with Qt6.
21 #if defined(_X11_XLIB_H_) && !defined(Bool)
22 #define Bool int
23 #endif
24 #include "va/va_x11.h"
25 #undef None // X11/X.h defines this. Causes compile failure in Qt6.
26 #undef Cursor
27 #undef pointer
28 #include "va/va_glx.h"
29 #include "va/va_drm.h"
30 #include "va/va_drmcommon.h"
31 #undef Bool // Interferes with cmake moc file compilation
32 
33 #ifndef VA_FOURCC_I420
34 #define VA_FOURCC_I420 0x30323449
35 #endif
36 
37 #define INIT_ST \
38  VAStatus va_status; \
39  bool ok = true
40 
41 #define CHECK_ST \
42  ok &= (va_status == VA_STATUS_SUCCESS); \
43  if (!ok) \
44  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Error at %1:%2 (#%3, %4)") \
45  .arg(__FILE__).arg( __LINE__).arg(va_status) \
46  .arg(vaErrorStr(va_status)))
47 
49 {
50  public:
51  static void GetVAAPITypes(MythRenderOpenGL* Context, MythInteropGPU::InteropMap& Types);
53 
54  VASurfaceID VerifySurface(MythRenderOpenGL *Context, MythVideoFrame *Frame);
55  VADisplay GetDisplay (void);
56  QString GetVendor (void);
57 
58  static bool SetupDeinterlacer (MythDeintType Deinterlacer, bool DoubleRate,
59  AVBufferRef *FramesContext, int Width, int Height,
60  AVFilterGraph *&Graph, AVFilterContext *&Source,
61  AVFilterContext *&Sink);
62 
63  protected:
65  ~MythVAAPIInterop() override;
66 
67  void InitaliseDisplay (void);
68  VASurfaceID Deinterlace (MythVideoFrame *Frame, VASurfaceID Current, FrameScanType Scan);
69  virtual void DestroyDeinterlacer (void);
70  virtual void PostInitDeinterlacer(void) { }
71 
72  protected:
73  VADisplay m_vaDisplay { nullptr };
74  QString m_vaVendor { };
75 
77  bool m_deinterlacer2x { false };
78  bool m_firstField { true };
79  AVBufferRef* m_vppFramesContext { nullptr };
80  AVFilterContext* m_filterSink { nullptr };
81  AVFilterContext* m_filterSource { nullptr };
82  AVFilterGraph* m_filterGraph { nullptr };
83  bool m_filterError { false };
84  int m_filterWidth { 0 };
85  int m_filterHeight { 0 };
86  VASurfaceID m_lastFilteredFrame { 0 };
87  uint64_t m_lastFilteredFrameCount { 0 };
88 };
89 
90 #endif
MythVAAPIInterop::m_vppFramesContext
AVBufferRef * m_vppFramesContext
Definition: mythvaapiinterop.h:79
MythVAAPIInterop::m_lastFilteredFrame
VASurfaceID m_lastFilteredFrame
Definition: mythvaapiinterop.h:86
MythVAAPIInterop::m_vaVendor
QString m_vaVendor
Definition: mythvaapiinterop.h:74
MythVAAPIInterop::m_filterSource
AVFilterContext * m_filterSource
Definition: mythvaapiinterop.h:81
MythVAAPIInterop::m_deinterlacer
MythDeintType m_deinterlacer
Definition: mythvaapiinterop.h:76
mythopenglinterop.h
MythVAAPIInterop::GetVAAPITypes
static void GetVAAPITypes(MythRenderOpenGL *Context, MythInteropGPU::InteropMap &Types)
Return a list of interops that are supported by the current render device.
Definition: mythvaapiinterop.cpp:38
MythVAAPIInterop::MythVAAPIInterop
MythVAAPIInterop(MythPlayerUI *Player, MythRenderOpenGL *Context, InteropType Type)
Definition: mythvaapiinterop.cpp:102
MythVAAPIInterop::m_lastFilteredFrameCount
uint64_t m_lastFilteredFrameCount
Definition: mythvaapiinterop.h:87
Frame
Definition: zmdefines.h:93
MythVAAPIInterop::m_filterHeight
int m_filterHeight
Definition: mythvaapiinterop.h:85
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:69
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythVAAPIInterop::SetupDeinterlacer
static bool SetupDeinterlacer(MythDeintType Deinterlacer, bool DoubleRate, AVBufferRef *FramesContext, int Width, int Height, AVFilterGraph *&Graph, AVFilterContext *&Source, AVFilterContext *&Sink)
Definition: mythvaapiinterop.cpp:194
MythVAAPIInterop::InitaliseDisplay
void InitaliseDisplay(void)
Definition: mythvaapiinterop.cpp:125
MythVAAPIInterop::DestroyDeinterlacer
virtual void DestroyDeinterlacer(void)
Definition: mythvaapiinterop.cpp:145
MythInteropGPU::InteropMap
std::map< VideoFrameType, InteropTypes > InteropMap
Definition: mythinteropgpu.h:44
MythVAAPIInterop
Definition: mythvaapiinterop.h:48
MythPlayerUI
Definition: mythplayerui.h:10
MythVAAPIInterop::m_firstField
bool m_firstField
Definition: mythvaapiinterop.h:78
MythOpenGLInterop
Definition: mythopenglinterop.h:17
MythVAAPIInterop::GetDisplay
VADisplay GetDisplay(void)
Definition: mythvaapiinterop.cpp:115
Source
Definition: channelsettings.cpp:69
MythVAAPIInterop::CreateVAAPI
static MythVAAPIInterop * CreateVAAPI(MythPlayerUI *Player, MythRenderOpenGL *Context)
Definition: mythvaapiinterop.cpp:72
MythVAAPIInterop::~MythVAAPIInterop
~MythVAAPIInterop() override
Definition: mythvaapiinterop.cpp:107
MythVAAPIInterop::VerifySurface
VASurfaceID VerifySurface(MythRenderOpenGL *Context, MythVideoFrame *Frame)
Definition: mythvaapiinterop.cpp:161
MythVAAPIInterop::m_filterError
bool m_filterError
Definition: mythvaapiinterop.h:83
MythVAAPIInterop::m_deinterlacer2x
bool m_deinterlacer2x
Definition: mythvaapiinterop.h:77
MythVAAPIInterop::PostInitDeinterlacer
virtual void PostInitDeinterlacer(void)
Definition: mythvaapiinterop.h:70
MythVAAPIInterop::m_filterGraph
AVFilterGraph * m_filterGraph
Definition: mythvaapiinterop.h:82
MythRenderOpenGL
Definition: mythrenderopengl.h:100
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVAAPIInterop::m_filterSink
AVFilterContext * m_filterSink
Definition: mythvaapiinterop.h:80
MythVAAPIInterop::GetVendor
QString GetVendor(void)
Definition: mythvaapiinterop.cpp:120
MythVAAPIInterop::m_filterWidth
int m_filterWidth
Definition: mythvaapiinterop.h:84
MythVAAPIInterop::Deinterlace
VASurfaceID Deinterlace(MythVideoFrame *Frame, VASurfaceID Current, FrameScanType Scan)
Definition: mythvaapiinterop.cpp:320
Player
Definition: zmliveplayer.h:34
MythVideoFrame
Definition: mythframe.h:88
MythInteropGPU::InteropType
InteropType
Definition: mythinteropgpu.h:25
MythVAAPIInterop::m_vaDisplay
VADisplay m_vaDisplay
Definition: mythvaapiinterop.h:73