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 (VideoFrame *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  long long m_lastFilteredFrameCount { 0 };
78 };
79 
80 #endif // MYTHVAAPIINTEROP_H
~MythVAAPIInterop() override
QHash< QString, Action * > Context
Definition: action.h:77
virtual void PostInitDeinterlacer(void)
AVFilterContext * m_filterSink
static Type GetInteropType(VideoFrameType Format)
Return an 'interoperability' method that is supported by the current render device.
AVFilterGraph * m_filterGraph
FrameScanType
Definition: videoouttypes.h:78
VideoFrameType
Definition: mythframe.h:23
QString GetVendor(void)
long long m_lastFilteredFrameCount
VASurfaceID VerifySurface(MythRenderOpenGL *Context, VideoFrame *Frame)
MythDeintType
Definition: mythframe.h:120
AVFilterContext * m_filterSource
VASurfaceID Deinterlace(VideoFrame *Frame, VASurfaceID Current, FrameScanType Scan)
MythVAAPIInterop(MythRenderOpenGL *Context, Type InteropType)
AVBufferRef * m_vppFramesContext
VASurfaceID m_lastFilteredFrame
MythDeintType m_deinterlacer
static MythVAAPIInterop * Create(MythRenderOpenGL *Context, Type InteropType)
void InitaliseDisplay(void)
virtual void DestroyDeinterlacer(void)
static bool SetupDeinterlacer(MythDeintType Deinterlacer, bool DoubleRate, AVBufferRef *FramesContext, int Width, int Height, AVFilterGraph *&Graph, AVFilterContext *&Source, AVFilterContext *&Sink)
VADisplay GetDisplay(void)