MythTV  master
mythvaapicontext.h
Go to the documentation of this file.
1 #ifndef MYTHVAAPICONTEXT_H
2 #define MYTHVAAPICONTEXT_H
3 
4 // MythTV
6 
7 // VAAPI
8 #include "va/va.h"
9 
10 // FFmpeg
11 extern "C" {
12 #include "libavutil/pixfmt.h"
13 #include "libavutil/hwcontext.h"
14 #include "libavcodec/avcodec.h"
15 #include "libavfilter/avfilter.h"
16 #include "libavformat/avformat.h"
17 #include "libavfilter/buffersrc.h"
18 }
19 
20 using VAAPIProfile = QPair<MythCodecContext::CodecProfile,QPair<QSize,QSize>>;
21 using VAAPIProfiles = QVector<VAAPIProfile>;
22 
24 {
25  public:
26  MythVAAPIContext (DecoderBase* Parent, MythCodecID CodecID);
27  ~MythVAAPIContext() override;
28 
29  void InitVideoCodec (AVCodecContext* Context, bool SelectedStream, bool& DirectRendering) override;
30  bool RetrieveFrame (AVCodecContext* Context, MythVideoFrame* Frame, AVFrame* AvFrame) override;
31  int FilteredReceiveFrame (AVCodecContext* Context, AVFrame* Frame) override;
32  void PostProcessFrame (AVCodecContext* Context, MythVideoFrame* Frame) override;
33  bool IsDeinterlacing (bool& DoubleRate, bool StreamChange = false) override;
34  bool DecoderWillResetOnFlush () override;
35  bool DecoderWillResetOnAspect () override;
36 
37  static MythCodecID GetSupportedCodec (AVCodecContext** Context, AVCodec** Codec,
38  const QString& Decoder, uint StreamType);
39  static enum AVPixelFormat GetFormat (AVCodecContext* Context, const AVPixelFormat* PixFmt);
40  static enum AVPixelFormat GetFormat2 (AVCodecContext* Context, const AVPixelFormat* PixFmt);
41  static QString HaveVAAPI (bool ReCheck = false);
42  static void GetDecoderList (QStringList& Decoders);
43 
44  private:
45  static int InitialiseContext (AVCodecContext* Context);
46  static int InitialiseContext2 (AVCodecContext* Context);
47  static VAProfile VAAPIProfileForCodec(const AVCodecContext* Codec);
48  static AVPixelFormat FramesFormat (AVPixelFormat Format);
49  void DestroyDeinterlacer ();
50  static const VAAPIProfiles& GetProfiles();
51 
52  MythDeintType m_deinterlacer { DEINT_NONE };
53  bool m_deinterlacer2x { false };
54  int m_lastInterlaced { 0 };
55  bool m_lastTopFieldFirst { false };
56  AVFilterContext* m_filterSink { nullptr };
57  AVFilterContext* m_filterSource { nullptr };
58  AVFilterGraph* m_filterGraph { nullptr };
59  bool m_filterError { false };
60  AVBufferRef* m_framesCtx { nullptr };
61  std::array<int64_t,2> m_filterPriorPTS { 0 };
62  int64_t m_filterPTSUsed { 0 };
63  int m_filterWidth { 0 };
64  int m_filterHeight { 0 };
65 };
66 
67 #endif
Frame
Definition: zmdefines.h:93
VAAPIProfiles
QVector< VAAPIProfile > VAAPIProfiles
Definition: mythvaapicontext.h:21
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:69
MythCodecContext::InitVideoCodec
virtual void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering)
Definition: mythcodeccontext.cpp:302
MythDate::Format
Format
Definition: mythdate.h:15
MythCodecContext::DecoderWillResetOnFlush
virtual bool DecoderWillResetOnFlush(void)
Definition: mythcodeccontext.h:159
MythCodecContext::DecoderWillResetOnAspect
virtual bool DecoderWillResetOnAspect(void)
Definition: mythcodeccontext.h:160
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
Decoder
Definition: decoder.h:70
MythCodecContext::PostProcessFrame
virtual void PostProcessFrame(AVCodecContext *, MythVideoFrame *)
Definition: mythcodeccontext.h:156
MythVAAPIContext
Definition: mythvaapicontext.h:23
MythCodecContext::IsDeinterlacing
virtual bool IsDeinterlacing(bool &, bool=false)
Definition: mythcodeccontext.h:157
VAAPIProfile
QPair< MythCodecContext::CodecProfile, QPair< QSize, QSize > > VAAPIProfile
Definition: mythvaapicontext.h:20
uint
unsigned int uint
Definition: compat.h:140
MythCodecContext::FilteredReceiveFrame
virtual int FilteredReceiveFrame(AVCodecContext *Context, AVFrame *Frame)
Retrieve and process/filter AVFrame.
Definition: mythcodeccontext.cpp:620
MTV_PUBLIC
#define MTV_PUBLIC
Definition: mythtvexp.h:15
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythCodecContext::RetrieveFrame
virtual bool RetrieveFrame(AVCodecContext *, MythVideoFrame *, AVFrame *)
Definition: mythcodeccontext.h:153
mythcodeccontext.h
MythCodecContext
Definition: mythcodeccontext.h:53
MythVideoFrame
Definition: mythframe.h:88
DecoderBase
Definition: decoderbase.h:120