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 #include "va/va_x11.h"
22 #undef None // X11/X.h defines this. Causes compile failure in Qt6.
23 #undef Cursor
24 #undef pointer
25 #include "va/va_glx.h"
26 #include "va/va_drm.h"
27 #include "va/va_drmcommon.h"
28 
29 #ifndef VA_FOURCC_I420
30 #define VA_FOURCC_I420 0x30323449
31 #endif
32 
33 #define INIT_ST \
34  VAStatus va_status; \
35  bool ok = true
36 
37 #define CHECK_ST \
38  ok &= (va_status == VA_STATUS_SUCCESS); \
39  if (!ok) \
40  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Error at %1:%2 (#%3, %4)") \
41  .arg(__FILE__).arg( __LINE__).arg(va_status) \
42  .arg(vaErrorStr(va_status)))
43 
45 {
46  public:
47  static void GetVAAPITypes(MythRenderOpenGL* Context, MythInteropGPU::InteropMap& Types);
49 
50  VASurfaceID VerifySurface(MythRenderOpenGL *Context, MythVideoFrame *Frame);
51  VADisplay GetDisplay (void);
52  QString GetVendor (void);
53 
54  static bool SetupDeinterlacer (MythDeintType Deinterlacer, bool DoubleRate,
55  AVBufferRef *FramesContext, int Width, int Height,
56  AVFilterGraph *&Graph, AVFilterContext *&Source,
57  AVFilterContext *&Sink);
58 
59  protected:
61  ~MythVAAPIInterop() override;
62 
63  void InitaliseDisplay (void);
64  VASurfaceID Deinterlace (MythVideoFrame *Frame, VASurfaceID Current, FrameScanType Scan);
65  virtual void DestroyDeinterlacer (void);
66  virtual void PostInitDeinterlacer(void) { }
67 
68  protected:
69  VADisplay m_vaDisplay { nullptr };
70  QString m_vaVendor { };
71 
73  bool m_deinterlacer2x { false };
74  bool m_firstField { true };
75  AVBufferRef* m_vppFramesContext { nullptr };
76  AVFilterContext* m_filterSink { nullptr };
77  AVFilterContext* m_filterSource { nullptr };
78  AVFilterGraph* m_filterGraph { nullptr };
79  bool m_filterError { false };
80  int m_filterWidth { 0 };
81  int m_filterHeight { 0 };
82  VASurfaceID m_lastFilteredFrame { 0 };
83  uint64_t m_lastFilteredFrameCount { 0 };
84 };
85 
86 #endif
MythVAAPIInterop::m_vppFramesContext
AVBufferRef * m_vppFramesContext
Definition: mythvaapiinterop.h:75
MythVAAPIInterop::m_lastFilteredFrame
VASurfaceID m_lastFilteredFrame
Definition: mythvaapiinterop.h:82
MythVAAPIInterop::m_vaVendor
QString m_vaVendor
Definition: mythvaapiinterop.h:70
MythVAAPIInterop::m_filterSource
AVFilterContext * m_filterSource
Definition: mythvaapiinterop.h:77
MythVAAPIInterop::m_deinterlacer
MythDeintType m_deinterlacer
Definition: mythvaapiinterop.h:72
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:83
Frame
Definition: zmdefines.h:93
MythVAAPIInterop::m_filterHeight
int m_filterHeight
Definition: mythvaapiinterop.h:81
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:45
MythVAAPIInterop
Definition: mythvaapiinterop.h:44
MythPlayerUI
Definition: mythplayerui.h:10
MythVAAPIInterop::m_firstField
bool m_firstField
Definition: mythvaapiinterop.h:74
MythOpenGLInterop
Definition: mythopenglinterop.h:17
MythVAAPIInterop::GetDisplay
VADisplay GetDisplay(void)
Definition: mythvaapiinterop.cpp:115
Source
Definition: channelsettings.cpp:68
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:79
MythVAAPIInterop::m_deinterlacer2x
bool m_deinterlacer2x
Definition: mythvaapiinterop.h:73
MythVAAPIInterop::PostInitDeinterlacer
virtual void PostInitDeinterlacer(void)
Definition: mythvaapiinterop.h:66
MythVAAPIInterop::m_filterGraph
AVFilterGraph * m_filterGraph
Definition: mythvaapiinterop.h:78
MythRenderOpenGL
Definition: mythrenderopengl.h:99
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVAAPIInterop::m_filterSink
AVFilterContext * m_filterSink
Definition: mythvaapiinterop.h:76
MythVAAPIInterop::GetVendor
QString GetVendor(void)
Definition: mythvaapiinterop.cpp:120
MythVAAPIInterop::m_filterWidth
int m_filterWidth
Definition: mythvaapiinterop.h:80
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:26
MythVAAPIInterop::m_vaDisplay
VADisplay m_vaDisplay
Definition: mythvaapiinterop.h:69