MythTV  master
mythnvdeccontext.h
Go to the documentation of this file.
1 #ifndef MYTHNVDECCONTEXT_H
2 #define MYTHNVDECCONTEXT_H
3 
4 // Qt
5 #include <QSize>
6 
7 // MythTV
8 #include "mythframe.h"
9 #include "mythcodecid.h"
10 #include "mythcodeccontext.h"
11 
12 // FFmpeg
13 extern "C" {
14 #include "libavutil/pixfmt.h"
15 #include "libavutil/hwcontext.h"
16 #include "libavcodec/avcodec.h"
17 #include "libavutil/pixdesc.h"
18 #include "compat/cuda/dynlink_loader.h"
19 }
20 
21 // Std
22 #include <vector>
23 
25 {
26  public:
27  MythNVDECContext(DecoderBase *Parent, MythCodecID CodecID);
28  ~MythNVDECContext() override;
29  void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override;
30  int HwDecoderInit (AVCodecContext *Context) override;
31  bool RetrieveFrame (AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame) override;
32  void SetDeinterlacing (AVCodecContext *Context,
33  VideoDisplayProfile *Profile, bool DoubleRate) override;
34  void PostProcessFrame (AVCodecContext *Context, VideoFrame *Frame) override;
35  bool IsDeinterlacing (bool &DoubleRate, bool StreamChange = false) override;
36  bool DecoderWillResetOnFlush (void) override;
37  static MythCodecID GetSupportedCodec (AVCodecContext **CodecContext,
38  AVCodec **Codec,
39  const QString &Decoder,
40  AVStream *Stream,
41  uint StreamType);
42  static enum AVPixelFormat GetFormat (AVCodecContext *Context, const AVPixelFormat *PixFmt);
43  static bool GetBuffer (AVCodecContext *Context, VideoFrame *Frame,
44  AVFrame *AvFrame, int Flags);
45  static int InitialiseDecoder (AVCodecContext *Context);
46  static bool HaveNVDEC (void);
47  static void GetDecoderList (QStringList &Decoders);
48 
49  private:
51  {
52  public:
53  MythNVDECCaps(cudaVideoCodec Codec, uint Depth, cudaVideoChromaFormat Format,
54  QSize Minimum, QSize Maximum, uint MacroBlocks);
55  bool Supports(cudaVideoCodec Codec, cudaVideoChromaFormat Format, uint Depth,
56  int Width, int Height);
57 
60  cudaVideoCodec m_codec { cudaVideoCodec_NumCodecs };
61  uint m_depth { 0 };
62  cudaVideoChromaFormat m_format { cudaVideoChromaFormat_Monochrome };
63  QSize m_minimum { };
64  QSize m_maximum { };
66  };
67 
68  private:
69  void InitFramesContext(AVCodecContext *Context);
70  AVBufferRef* m_framesContext { nullptr };
71 
72  static const std::vector<MythNVDECCaps>& GetProfiles(void);
74  bool m_deinterlacer2x { false };
75 };
76 
77 #endif // MYTHNVDECCONTEXT_H
void PostProcessFrame(AVCodecContext *Context, VideoFrame *Frame) override
QHash< QString, Action * > Context
Definition: action.h:77
MythCodecContext::CodecProfile m_profile
bool DecoderWillResetOnFlush(void) override
MythCodecID
Definition: mythcodecid.h:10
struct AVFrame AVFrame
static bool HaveNVDEC(void)
int HwDecoderInit(AVCodecContext *Context) override
void InitFramesContext(AVCodecContext *Context)
cudaVideoChromaFormat m_format
VideoFrameType
Definition: mythframe.h:23
bool IsDeinterlacing(bool &DoubleRate, bool StreamChange=false) override
MythDeintType
Definition: mythframe.h:120
AVBufferRef * m_framesContext
MythNVDECContext(DecoderBase *Parent, MythCodecID CodecID)
void SetDeinterlacing(AVCodecContext *Context, VideoDisplayProfile *Profile, bool DoubleRate) override
Enable NVDEC/CUDA deinterlacing if necessary.
unsigned int uint
Definition: compat.h:140
static MythCodecID GetSupportedCodec(AVCodecContext **CodecContext, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Determine whether NVDEC decoding is supported for this codec.
static int InitialiseDecoder(AVCodecContext *Context)
~MythNVDECContext() override
bool Supports(cudaVideoCodec Codec, cudaVideoChromaFormat Format, uint Depth, int Width, int Height)
MythNVDECCaps(cudaVideoCodec Codec, uint Depth, cudaVideoChromaFormat Format, QSize Minimum, QSize Maximum, uint MacroBlocks)
static bool GetBuffer(AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame, int Flags)
Convert AVFrame data to MythFrame.
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
static enum AVPixelFormat GetFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
bool RetrieveFrame(AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame) override
static void GetDecoderList(QStringList &Decoders)
MythDeintType m_deinterlacer
static const std::vector< MythNVDECCaps > & GetProfiles(void)