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) const;
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
MythNVDECContext::m_deinterlacer2x
bool m_deinterlacer2x
Definition: mythnvdeccontext.h:74
MythNVDECContext::MythNVDECCaps::m_depth
uint m_depth
Definition: mythnvdeccontext.h:61
MythNVDECContext::InitialiseDecoder
static int InitialiseDecoder(AVCodecContext *Context)
Definition: mythnvdeccontext.cpp:139
MythNVDECContext::MythNVDECCaps::m_minimum
QSize m_minimum
Definition: mythnvdeccontext.h:63
MythNVDECContext::~MythNVDECContext
~MythNVDECContext() override
Definition: mythnvdeccontext.cpp:21
MythNVDECContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **CodecContext, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Determine whether NVDEC decoding is supported for this codec.
Definition: mythnvdeccontext.cpp:34
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:55
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:53
Frame
Definition: zmdefines.h:93
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:123
Context
QHash< QString, Action * > Context
Definition: action.h:77
MythDate::Format
Format
Definition: mythdate.h:12
MythNVDECContext::GetFormat
static enum AVPixelFormat GetFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
Definition: mythnvdeccontext.cpp:371
mythframe.h
VideoFrame
Definition: mythframe.h:137
MythNVDECContext::GetBuffer
static bool GetBuffer(AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame, int Flags)
Convert AVFrame data to MythFrame.
Definition: mythnvdeccontext.cpp:407
MythNVDECContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythnvdeccontext.cpp:564
MythNVDECContext::MythNVDECCaps::Supports
bool Supports(cudaVideoCodec Codec, cudaVideoChromaFormat Format, uint Depth, int Width, int Height) const
Definition: mythnvdeccontext.cpp:504
MythNVDECContext::InitVideoCodec
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
Definition: mythnvdeccontext.cpp:203
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:26
MythNVDECContext::RetrieveFrame
bool RetrieveFrame(AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame) override
Definition: mythnvdeccontext.cpp:391
MythNVDECContext::MythNVDECCaps
Definition: mythnvdeccontext.h:50
MythNVDECContext::GetProfiles
static const std::vector< MythNVDECCaps > & GetProfiles(void)
Definition: mythnvdeccontext.cpp:578
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
Decoder
Definition: decoder.h:65
MythNVDECContext::m_deinterlacer
MythDeintType m_deinterlacer
Definition: mythnvdeccontext.h:73
MythNVDECContext
Definition: mythnvdeccontext.h:24
MythNVDECContext::MythNVDECCaps::m_format
cudaVideoChromaFormat m_format
Definition: mythnvdeccontext.h:62
mythcodecid.h
MythNVDECContext::DecoderWillResetOnFlush
bool DecoderWillResetOnFlush(void) override
Definition: mythnvdeccontext.cpp:355
uint
unsigned int uint
Definition: compat.h:140
MythNVDECContext::PostProcessFrame
void PostProcessFrame(AVCodecContext *Context, VideoFrame *Frame) override
Definition: mythnvdeccontext.cpp:341
MythNVDECContext::MythNVDECCaps::m_maximum
QSize m_maximum
Definition: mythnvdeccontext.h:64
VideoDisplayProfile
Definition: videodisplayprofile.h:69
MythDeintType
MythDeintType
Definition: mythframe.h:121
MythNVDECContext::HaveNVDEC
static bool HaveNVDEC(void)
Definition: mythnvdeccontext.cpp:527
MythNVDECContext::MythNVDECCaps::m_macroBlocks
uint m_macroBlocks
Definition: mythnvdeccontext.h:65
MythNVDECContext::HwDecoderInit
int HwDecoderInit(AVCodecContext *Context) override
Definition: mythnvdeccontext.cpp:215
MythNVDECContext::InitFramesContext
void InitFramesContext(AVCodecContext *Context)
Definition: mythnvdeccontext.cpp:649
MythNVDECContext::MythNVDECCaps::m_profile
MythCodecContext::CodecProfile m_profile
Definition: mythnvdeccontext.h:58
MythNVDECContext::MythNVDECCaps::m_codec
cudaVideoCodec m_codec
Definition: mythnvdeccontext.h:60
MythNVDECContext::MythNVDECCaps::MythNVDECCaps
MythNVDECCaps(cudaVideoCodec Codec, uint Depth, cudaVideoChromaFormat Format, QSize Minimum, QSize Maximum, uint MacroBlocks)
Definition: mythnvdeccontext.cpp:463
MythNVDECContext::IsDeinterlacing
bool IsDeinterlacing(bool &DoubleRate, bool StreamChange=false) override
Definition: mythnvdeccontext.cpp:360
mythcodeccontext.h
MythCodecContext
Definition: mythcodeccontext.h:50
VideoFrameType
VideoFrameType
Definition: mythframe.h:24
MythNVDECContext::SetDeinterlacing
void SetDeinterlacing(AVCodecContext *Context, VideoDisplayProfile *Profile, bool DoubleRate) override
Enable NVDEC/CUDA deinterlacing if necessary.
Definition: mythnvdeccontext.cpp:241
MythNVDECContext::m_framesContext
AVBufferRef * m_framesContext
Definition: mythnvdeccontext.h:70
MythNVDECContext::MythNVDECContext
MythNVDECContext(DecoderBase *Parent, MythCodecID CodecID)
Definition: mythnvdeccontext.cpp:16
DecoderBase
Definition: decoderbase.h:119
MythNVDECContext::MythNVDECCaps::m_type
VideoFrameType m_type
Definition: mythnvdeccontext.h:59