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 // VAAPI
11 #include "va/va.h"
12 #include "va/va_version.h"
13 #if VA_CHECK_VERSION(0,34,0)
14 #include "va/va_compat.h"
15 #endif
16 #include "va/va_x11.h"
17 #include "va/va_glx.h"
18 #include "va/va_drm.h"
19 #include "va/va_drmcommon.h"
20 
21 #ifndef VA_FOURCC_I420
22 #define VA_FOURCC_I420 0x30323449
23 #endif
24 
25 #define INIT_ST \
26  VAStatus va_status; \
27  bool ok = true
28 
29 #define CHECK_ST \
30  ok &= (va_status == VA_STATUS_SUCCESS); \
31  if (!ok) \
32  LOG(VB_GENERAL, LOG_ERR, LOC + QString("Error at %1:%2 (#%3, %4)") \
33  .arg(__FILE__).arg( __LINE__).arg(va_status) \
34  .arg(vaErrorStr(va_status)))
35 
37 {
38  friend class MythOpenGLInterop;
39 
40  public:
41  static MythVAAPIInterop* Create(MythRenderOpenGL *Context, Type InteropType);
42 
44  VADisplay GetDisplay (void);
45  QString GetVendor (void);
46 
47  static bool SetupDeinterlacer (MythDeintType Deinterlacer, bool DoubleRate,
48  AVBufferRef *FramesContext, int Width, int Height,
49  AVFilterGraph *&Graph, AVFilterContext *&Source,
50  AVFilterContext *&Sink);
51 
52  protected:
54  ~MythVAAPIInterop() override;
55 
57  void InitaliseDisplay (void);
58  VASurfaceID Deinterlace (MythVideoFrame *Frame, VASurfaceID Current, FrameScanType Scan);
59  virtual void DestroyDeinterlacer (void);
60  virtual void PostInitDeinterlacer(void) { }
61 
62  protected:
63  VADisplay m_vaDisplay { nullptr };
64  QString m_vaVendor { };
65 
67  bool m_deinterlacer2x { false };
68  bool m_firstField { true };
69  AVBufferRef *m_vppFramesContext { nullptr };
70  AVFilterContext *m_filterSink { nullptr };
71  AVFilterContext *m_filterSource { nullptr };
72  AVFilterGraph *m_filterGraph { nullptr };
73  bool m_filterError { false };
74  int m_filterWidth { 0 };
75  int m_filterHeight { 0 };
76  VASurfaceID m_lastFilteredFrame { 0 };
77  uint64_t m_lastFilteredFrameCount { 0 };
78 };
79 
80 #endif // MYTHVAAPIINTEROP_H
MythVAAPIInterop::m_vppFramesContext
AVBufferRef * m_vppFramesContext
Definition: mythvaapiinterop.h:69
MythVAAPIInterop::m_lastFilteredFrame
VASurfaceID m_lastFilteredFrame
Definition: mythvaapiinterop.h:76
MythVAAPIInterop::m_vaVendor
QString m_vaVendor
Definition: mythvaapiinterop.h:64
MythVAAPIInterop::m_filterSource
AVFilterContext * m_filterSource
Definition: mythvaapiinterop.h:71
MythVAAPIInterop::m_deinterlacer
MythDeintType m_deinterlacer
Definition: mythvaapiinterop.h:66
MythVAAPIInterop::MythVAAPIInterop
MythVAAPIInterop(MythRenderOpenGL *Context, Type InteropType)
Definition: mythvaapiinterop.cpp:78
mythopenglinterop.h
MythVAAPIInterop::Create
static MythVAAPIInterop * Create(MythRenderOpenGL *Context, Type InteropType)
Definition: mythvaapiinterop.cpp:56
MythVAAPIInterop::m_lastFilteredFrameCount
uint64_t m_lastFilteredFrameCount
Definition: mythvaapiinterop.h:77
Frame
Definition: zmdefines.h:94
MythVAAPIInterop::m_filterHeight
int m_filterHeight
Definition: mythvaapiinterop.h:75
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:64
FrameScanType
FrameScanType
Definition: videoouttypes.h:95
Context
QHash< QString, Action * > Context
Definition: action.h:77
MythDate::Format
Format
Definition: mythdate.h:13
MythVAAPIInterop::SetupDeinterlacer
static bool SetupDeinterlacer(MythDeintType Deinterlacer, bool DoubleRate, AVBufferRef *FramesContext, int Width, int Height, AVFilterGraph *&Graph, AVFilterContext *&Source, AVFilterContext *&Sink)
Definition: mythvaapiinterop.cpp:170
MythVAAPIInterop::InitaliseDisplay
void InitaliseDisplay(void)
Definition: mythvaapiinterop.cpp:101
MythVAAPIInterop::DestroyDeinterlacer
virtual void DestroyDeinterlacer(void)
Definition: mythvaapiinterop.cpp:121
MythVAAPIInterop
Definition: mythvaapiinterop.h:37
MythVAAPIInterop::m_firstField
bool m_firstField
Definition: mythvaapiinterop.h:68
MythOpenGLInterop
Definition: mythopenglinterop.h:24
MythVAAPIInterop::GetDisplay
VADisplay GetDisplay(void)
Definition: mythvaapiinterop.cpp:91
Source
Definition: channelsettings.cpp:69
MythVAAPIInterop::~MythVAAPIInterop
~MythVAAPIInterop() override
Definition: mythvaapiinterop.cpp:83
MythOpenGLInterop::Type
Type
Definition: mythopenglinterop.h:30
MythVAAPIInterop::VerifySurface
VASurfaceID VerifySurface(MythRenderOpenGL *Context, MythVideoFrame *Frame)
Definition: mythvaapiinterop.cpp:137
MythVAAPIInterop::m_filterError
bool m_filterError
Definition: mythvaapiinterop.h:73
MythVAAPIInterop::m_deinterlacer2x
bool m_deinterlacer2x
Definition: mythvaapiinterop.h:67
MythVAAPIInterop::PostInitDeinterlacer
virtual void PostInitDeinterlacer(void)
Definition: mythvaapiinterop.h:60
MythVAAPIInterop::m_filterGraph
AVFilterGraph * m_filterGraph
Definition: mythvaapiinterop.h:72
MythRenderOpenGL
Definition: mythrenderopengl.h:99
MythDeintType
MythDeintType
Definition: mythframe.h:63
MythVAAPIInterop::m_filterSink
AVFilterContext * m_filterSink
Definition: mythvaapiinterop.h:70
MythVAAPIInterop::GetVendor
QString GetVendor(void)
Definition: mythvaapiinterop.cpp:96
MythVAAPIInterop::GetInteropType
static Type GetInteropType(VideoFrameType Format)
Return an 'interoperability' method that is supported by the current render device.
Definition: mythvaapiinterop.cpp:31
MythVAAPIInterop::m_filterWidth
int m_filterWidth
Definition: mythvaapiinterop.h:74
VideoFrameType
VideoFrameType
Definition: mythframe.h:16
MythVAAPIInterop::Deinterlace
VASurfaceID Deinterlace(MythVideoFrame *Frame, VASurfaceID Current, FrameScanType Scan)
Definition: mythvaapiinterop.cpp:296
MythVideoFrame
Definition: mythframe.h:83
MythVAAPIInterop::m_vaDisplay
VADisplay m_vaDisplay
Definition: mythvaapiinterop.h:63