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 = QList<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, VideoFrame* Frame, AVFrame* AvFrame) override;
31  int FilteredReceiveFrame (AVCodecContext *Context, AVFrame *Frame) override;
32  void PostProcessFrame (AVCodecContext *Context, VideoFrame *Frame) override;
33  bool IsDeinterlacing (bool &DoubleRate, bool StreamChange = false) override;
34  bool DecoderWillResetOnFlush (void) override;
35  bool DecoderWillResetOnAspect (void) override;
36 
37  static MythCodecID GetSupportedCodec (AVCodecContext **Context,
38  AVCodec **Codec,
39  const QString &Decoder,
40  uint StreamType);
41  static enum AVPixelFormat GetFormat (AVCodecContext *Context,
42  const AVPixelFormat *PixFmt);
43  static enum AVPixelFormat GetFormat2 (AVCodecContext *Context,
44  const AVPixelFormat *PixFmt);
45  static QString HaveVAAPI (bool ReCheck = false);
46  static void GetDecoderList (QStringList &Decoders);
47 
48  private:
49  static int InitialiseContext (AVCodecContext *Context);
50  static int InitialiseContext2 (AVCodecContext *Context);
51  static VAProfile VAAPIProfileForCodec(const AVCodecContext *Codec);
52  static AVPixelFormat FramesFormat (AVPixelFormat Format);
53  void DestroyDeinterlacer (void);
54  static const VAAPIProfiles& GetProfiles(void);
55 
56  MythDeintType m_deinterlacer { DEINT_NONE };
57  bool m_deinterlacer2x { false };
58  int m_lastInterlaced { 0 };
59  int m_lastTopFieldFirst { 0 };
60  AVFilterContext *m_filterSink { nullptr };
61  AVFilterContext *m_filterSource { nullptr };
62  AVFilterGraph *m_filterGraph { nullptr };
63  bool m_filterError { false };
64  AVBufferRef *m_framesCtx { nullptr };
65  int64_t m_filterPriorPTS[2] { 0 };
66  int64_t m_filterPTSUsed { 0 };
67  int m_filterWidth { 0 };
68  int m_filterHeight { 0 };
69 };
70 
71 #endif // MYTHVAAPICONTEXT_H
QPair< MythCodecContext::CodecProfile, QPair< QSize, QSize > > VAAPIProfile
virtual bool DecoderWillResetOnAspect(void)
QHash< QString, Action * > Context
Definition: action.h:77
QList< VAAPIProfile > VAAPIProfiles
virtual void PostProcessFrame(AVCodecContext *, VideoFrame *)
MythCodecID
Definition: mythcodecid.h:10
struct AVFrame AVFrame
MythDeintType
Definition: mythframe.h:120
virtual int FilteredReceiveFrame(AVCodecContext *Context, AVFrame *Frame)
Retrieve and process/filter AVFrame.
#define MTV_PUBLIC
Definition: mythtvexp.h:15
virtual void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering)
unsigned int uint
Definition: compat.h:140
virtual bool DecoderWillResetOnFlush(void)
virtual bool IsDeinterlacing(bool &, bool=false)
virtual bool RetrieveFrame(AVCodecContext *, VideoFrame *, AVFrame *)