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, MythVideoFrame *Frame, AVFrame *AvFrame) override;
32  void SetDeinterlacing (AVCodecContext *Context,
33  MythVideoProfile *Profile, bool DoubleRate) override;
34  void PostProcessFrame (AVCodecContext *Context, MythVideoFrame *Frame) override;
35  bool IsDeinterlacing (bool &DoubleRate, bool StreamChange = false) override;
36  bool DecoderWillResetOnFlush (void) override;
37  static MythCodecID GetSupportedCodec (AVCodecContext **CodecContext,
38  const 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, MythVideoFrame *Frame,
44  AVFrame *AvFrame, int Flags);
45  static int InitialiseDecoder (AVCodecContext *Context);
46  static bool HaveNVDEC (bool Reinit = false);
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:134
MythNVDECContext::PostProcessFrame
void PostProcessFrame(AVCodecContext *Context, MythVideoFrame *Frame) override
Definition: mythnvdeccontext.cpp:327
MythNVDECContext::MythNVDECCaps::m_minimum
QSize m_minimum
Definition: mythnvdeccontext.h:63
MythNVDECContext::RetrieveFrame
bool RetrieveFrame(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
Definition: mythnvdeccontext.cpp:377
MythNVDECContext::~MythNVDECContext
~MythNVDECContext() override
Definition: mythnvdeccontext.cpp:23
MythCodecID
MythCodecID
Definition: mythcodecid.h:11
Frame
Definition: zmdefines.h:93
MythNVDECContext::GetBuffer
static bool GetBuffer(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame, int Flags)
Convert AVFrame data to MythFrame.
Definition: mythnvdeccontext.cpp:393
MythDate::Format
Format
Definition: mythdate.h:15
MythNVDECContext::GetFormat
static enum AVPixelFormat GetFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
Definition: mythnvdeccontext.cpp:357
FMT_NONE
@ FMT_NONE
Definition: mythframe.h:22
mythframe.h
MythNVDECContext::GetDecoderList
static void GetDecoderList(QStringList &Decoders)
Definition: mythnvdeccontext.cpp:550
MythNVDECContext::MythNVDECCaps::Supports
bool Supports(cudaVideoCodec Codec, cudaVideoChromaFormat Format, uint Depth, int Width, int Height) const
Definition: mythnvdeccontext.cpp:490
MythDeintType
MythDeintType
Definition: mythframe.h:67
MythVideoProfile
Definition: mythvideoprofile.h:83
MythNVDECContext::InitVideoCodec
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
Definition: mythnvdeccontext.cpp:189
MythNVDECContext::MythNVDECCaps
Definition: mythnvdeccontext.h:50
MythNVDECContext::GetProfiles
static const std::vector< MythNVDECCaps > & GetProfiles(void)
Definition: mythnvdeccontext.cpp:564
MythCodecContext::NoProfile
@ NoProfile
Definition: mythcodeccontext.h:57
AVFrame
struct AVFrame AVFrame
Definition: BorderDetector.h:15
Decoder
Definition: decoder.h:70
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
VideoFrameType
VideoFrameType
Definition: mythframe.h:20
mythcodecid.h
MythNVDECContext::DecoderWillResetOnFlush
bool DecoderWillResetOnFlush(void) override
Definition: mythnvdeccontext.cpp:341
uint
unsigned int uint
Definition: compat.h:81
DEINT_NONE
@ DEINT_NONE
Definition: mythframe.h:69
MythNVDECContext::MythNVDECCaps::m_maximum
QSize m_maximum
Definition: mythnvdeccontext.h:64
MythCodecContext::CodecProfile
CodecProfile
Definition: mythcodeccontext.h:55
MythNVDECContext::SetDeinterlacing
void SetDeinterlacing(AVCodecContext *Context, MythVideoProfile *Profile, bool DoubleRate) override
Enable NVDEC/CUDA deinterlacing if necessary.
Definition: mythnvdeccontext.cpp:227
MythNVDECContext::MythNVDECCaps::m_macroBlocks
uint m_macroBlocks
Definition: mythnvdeccontext.h:65
MythNVDECContext::HaveNVDEC
static bool HaveNVDEC(bool Reinit=false)
Definition: mythnvdeccontext.cpp:513
MythNVDECContext::HwDecoderInit
int HwDecoderInit(AVCodecContext *Context) override
Definition: mythnvdeccontext.cpp:201
MythNVDECContext::InitFramesContext
void InitFramesContext(AVCodecContext *Context)
Definition: mythnvdeccontext.cpp:635
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:449
MythNVDECContext::IsDeinterlacing
bool IsDeinterlacing(bool &DoubleRate, bool StreamChange=false) override
Definition: mythnvdeccontext.cpp:346
mythcodeccontext.h
MythCodecContext
Definition: mythcodeccontext.h:52
MythVideoFrame
Definition: mythframe.h:88
MythNVDECContext::m_framesContext
AVBufferRef * m_framesContext
Definition: mythnvdeccontext.h:70
MythNVDECContext::MythNVDECContext
MythNVDECContext(DecoderBase *Parent, MythCodecID CodecID)
Definition: mythnvdeccontext.cpp:18
DecoderBase
Definition: decoderbase.h:120
MythNVDECContext::GetSupportedCodec
static MythCodecID GetSupportedCodec(AVCodecContext **CodecContext, const AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Determine whether NVDEC decoding is supported for this codec.
Definition: mythnvdeccontext.cpp:33
MythNVDECContext::MythNVDECCaps::m_type
VideoFrameType m_type
Definition: mythnvdeccontext.h:59