MythTV  master
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
MythNVDECContext Class Reference

#include <mythnvdeccontext.h>

Inheritance diagram for MythNVDECContext:
Inheritance graph
[legend]
Collaboration diagram for MythNVDECContext:
Collaboration graph
[legend]

Classes

class  MythNVDECCaps
 

Public Member Functions

 MythNVDECContext (DecoderBase *Parent, MythCodecID CodecID)
 
 ~MythNVDECContext () override
 
void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
 
int HwDecoderInit (AVCodecContext *Context) override
 
bool RetrieveFrame (AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame) override
 
void SetDeinterlacing (AVCodecContext *Context, VideoDisplayProfile *Profile, bool DoubleRate) override
 Enable NVDEC/CUDA deinterlacing if necessary. More...
 
void PostProcessFrame (AVCodecContext *Context, VideoFrame *Frame) override
 
bool IsDeinterlacing (bool &DoubleRate, bool StreamChange=false) override
 
bool DecoderWillResetOnFlush (void) override
 
- Public Member Functions inherited from MythCodecContext
 MythCodecContext (DecoderBase *Parent, MythCodecID CodecID)
 
virtual ~MythCodecContext ()=default
 
virtual int FilteredReceiveFrame (AVCodecContext *Context, AVFrame *Frame)
 Retrieve and process/filter AVFrame. More...
 
virtual void SetDecoderOptions (AVCodecContext *, AVCodec *)
 
virtual bool DecoderWillResetOnAspect (void)
 
virtual bool DecoderNeedsReset (AVCodecContext *)
 

Static Public Member Functions

static MythCodecID GetSupportedCodec (AVCodecContext **CodecContext, AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
 Determine whether NVDEC decoding is supported for this codec. More...
 
static enum AVPixelFormat GetFormat (AVCodecContext *Context, const AVPixelFormat *PixFmt)
 
static bool GetBuffer (AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame, int Flags)
 Convert AVFrame data to MythFrame. More...
 
static int InitialiseDecoder (AVCodecContext *Context)
 
static bool HaveNVDEC (void)
 
static void GetDecoderList (QStringList &Decoders)
 
- Static Public Member Functions inherited from MythCodecContext
static MythCodecContextCreateContext (DecoderBase *Parent, MythCodecID Codec)
 
static void GetDecoders (RenderOptions &Opts)
 
static QStringList GetDecoderDescription (void)
 
static MythCodecID FindDecoder (const QString &Decoder, AVStream *Stream, AVCodecContext **Context, AVCodec **Codec)
 
static int GetBuffer (struct AVCodecContext *Context, AVFrame *Frame, int Flags)
 A generic hardware buffer initialisation method when using AVHWFramesContext. More...
 
static bool GetBuffer2 (struct AVCodecContext *Context, VideoFrame *Frame, AVFrame *AvFrame, int Flags)
 A generic hardware buffer initialisation method when AVHWFramesContext is NOT used. More...
 
static int InitialiseDecoder (AVCodecContext *Context, CreateHWDecoder Callback, const QString &Debug)
 Initialise a hardware decoder that is expected to use AVHWFramesContext. More...
 
static int InitialiseDecoder2 (AVCodecContext *Context, CreateHWDecoder Callback, const QString &Debug)
 Initialise a hardware decoder that is NOT expected to use AVHWFramesContext. More...
 
static void ReleaseBuffer (void *Opaque, uint8_t *Data)
 
static void FramesContextFinished (AVHWFramesContext *Context)
 
static void DeviceContextFinished (AVHWDeviceContext *Context)
 
static void CreateDecoderCallback (void *Wait, void *Context, void *Callback)
 
static AVBufferRef * CreateDevice (AVHWDeviceType Type, MythOpenGLInterop *Interop, const QString &Device=QString())
 
static bool IsUnsupportedProfile (AVCodecContext *Context)
 Most hardware decoders do not support these codecs/profiles. More...
 
static QString GetProfileDescription (CodecProfile Profile, QSize Size, VideoFrameType Format=FMT_NONE, uint ColorDepth=0)
 
static CodecProfile FFmpegToMythProfile (AVCodecID CodecID, int Profile)
 

Private Member Functions

void InitFramesContext (AVCodecContext *Context)
 

Static Private Member Functions

static const std::vector< MythNVDECCaps > & GetProfiles (void)
 

Private Attributes

AVBufferRef * m_framesContext { nullptr }
 
MythDeintType m_deinterlacer { DEINT_NONE }
 
bool m_deinterlacer2x { false }
 

Additional Inherited Members

- Public Types inherited from MythCodecContext
enum  CodecProfile {
  NoProfile = 0, MPEG1, MPEG2, MPEG2Simple,
  MPEG2Main, MPEG2422, MPEG2High, MPEG2Spatial,
  MPEG2SNR, MPEG4, MPEG4Simple, MPEG4SimpleScaleable,
  MPEG4Core, MPEG4Main, MPEG4NBit, MPEG4ScaleableTexture,
  MPEG4SimpleFace, MPEG4BasicAnimated, MPEG4Hybrid, MPEG4AdvancedRT,
  MPEG4CoreScaleable, MPEG4AdvancedCoding, MPEG4AdvancedCore, MPEG4AdvancedScaleableTexture,
  MPEG4SimpleStudio, MPEG4AdvancedSimple, H263, H264,
  H264Baseline, H264ConstrainedBaseline, H264Main, H264MainExtended,
  H264High, H264High10, H264Extended, H264High422,
  H264High444, H264ConstrainedHigh, HEVC, HEVCMain,
  HEVCMain10, HEVCMainStill, HEVCRext, HEVCMain10HDR,
  HEVCMain10HDRPlus, VC1, VC1Simple, VC1Main,
  VC1Complex, VC1Advanced, VP8, VP9,
  VP9_0, VP9_1, VP9_2, VP9_3,
  VP9_2HDR, VP9_2HDRPlus, VP9_3HDR, VP9_3HDRPlus,
  AV1, AV1Main, AV1High, AV1Professional,
  MJPEG
}
 
- Protected Member Functions inherited from MythCodecContext
virtual bool RetrieveHWFrame (VideoFrame *Frame, AVFrame *AvFrame)
 
- Static Protected Member Functions inherited from MythCodecContext
static void DestroyInterop (MythOpenGLInterop *Interop)
 
static void NewHardwareFramesContext (void)
 Track the number of concurrent frames contexts. More...
 
- Protected Attributes inherited from MythCodecContext
DecoderBasem_parent { nullptr }
 
MythCodecID m_codecID { kCodec_NONE }
 
bool m_resetRequired { false }
 
- Static Protected Attributes inherited from MythCodecContext
static QAtomicInt s_hwFramesContextCount
 

Detailed Description

Definition at line 24 of file mythnvdeccontext.h.

Constructor & Destructor Documentation

◆ MythNVDECContext()

MythNVDECContext::MythNVDECContext ( DecoderBase Parent,
MythCodecID  CodecID 
)

Definition at line 16 of file mythnvdeccontext.cpp.

◆ ~MythNVDECContext()

MythNVDECContext::~MythNVDECContext ( )
override

Definition at line 21 of file mythnvdeccontext.cpp.

Member Function Documentation

◆ InitVideoCodec()

void MythNVDECContext::InitVideoCodec ( AVCodecContext *  Context,
bool  SelectedStream,
bool DirectRendering 
)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 195 of file mythnvdeccontext.cpp.

◆ HwDecoderInit()

int MythNVDECContext::HwDecoderInit ( AVCodecContext *  Context)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 207 of file mythnvdeccontext.cpp.

◆ RetrieveFrame()

bool MythNVDECContext::RetrieveFrame ( AVCodecContext *  Context,
VideoFrame Frame,
AVFrame AvFrame 
)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 383 of file mythnvdeccontext.cpp.

◆ SetDeinterlacing()

void MythNVDECContext::SetDeinterlacing ( AVCodecContext *  Context,
VideoDisplayProfile Profile,
bool  DoubleRate 
)
overridevirtual

Enable NVDEC/CUDA deinterlacing if necessary.

Note
We can only set this once just after codec initialisation. We do not have control over the scan type - control is effectively passed to CUDA to detect and handle all deinterlacing.

Reimplemented from MythCodecContext.

Definition at line 233 of file mythnvdeccontext.cpp.

◆ PostProcessFrame()

void MythNVDECContext::PostProcessFrame ( AVCodecContext *  Context,
VideoFrame Frame 
)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 333 of file mythnvdeccontext.cpp.

◆ IsDeinterlacing()

bool MythNVDECContext::IsDeinterlacing ( bool DoubleRate,
bool  StreamChange = false 
)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 352 of file mythnvdeccontext.cpp.

◆ DecoderWillResetOnFlush()

bool MythNVDECContext::DecoderWillResetOnFlush ( void  )
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 347 of file mythnvdeccontext.cpp.

◆ GetSupportedCodec()

MythCodecID MythNVDECContext::GetSupportedCodec ( AVCodecContext **  Context,
AVCodec **  Codec,
const QString &  Decoder,
AVStream *  Stream,
uint  StreamType 
)
static

Determine whether NVDEC decoding is supported for this codec.

The objective here is, as for other decoders, to fail fast so that we can fallback to another decoder as soon as possible if necessary.

Note
Interop support for rendering is implicitly assumed as it only requires an OpenGL context which is checked in HaveNVDEC()

Definition at line 34 of file mythnvdeccontext.cpp.

Referenced by MythCodecContext::FindDecoder().

◆ GetFormat()

enum AVPixelFormat MythNVDECContext::GetFormat ( AVCodecContext *  Context,
const AVPixelFormat *  PixFmt 
)
static

Definition at line 363 of file mythnvdeccontext.cpp.

Referenced by InitVideoCodec().

◆ GetBuffer()

bool MythNVDECContext::GetBuffer ( AVCodecContext *  Context,
VideoFrame Frame,
AVFrame AvFrame,
int  Flags 
)
static

Convert AVFrame data to MythFrame.

Note
The CUDA decoder returns a complete AVFrame which should represent an NV12 frame held in device (GPU) memory. There is no need to call avcodec_default_get_buffer2.

Definition at line 399 of file mythnvdeccontext.cpp.

Referenced by RetrieveFrame().

◆ InitialiseDecoder()

int MythNVDECContext::InitialiseDecoder ( AVCodecContext *  Context)
static

Definition at line 131 of file mythnvdeccontext.cpp.

Referenced by HwDecoderInit().

◆ HaveNVDEC()

bool MythNVDECContext::HaveNVDEC ( void  )
static

Definition at line 506 of file mythnvdeccontext.cpp.

Referenced by MythCodecContext::GetDecoders(), and GetSupportedCodec().

◆ GetDecoderList()

void MythNVDECContext::GetDecoderList ( QStringList &  Decoders)
static

Definition at line 543 of file mythnvdeccontext.cpp.

Referenced by MythCodecContext::GetDecoderDescription().

◆ InitFramesContext()

void MythNVDECContext::InitFramesContext ( AVCodecContext *  Context)
private

Definition at line 626 of file mythnvdeccontext.cpp.

Referenced by GetFormat().

◆ GetProfiles()

const std::vector< MythNVDECContext::MythNVDECCaps > & MythNVDECContext::GetProfiles ( void  )
staticprivate

Definition at line 555 of file mythnvdeccontext.cpp.

Referenced by GetDecoderList(), GetSupportedCodec(), and HaveNVDEC().

Member Data Documentation

◆ m_framesContext

AVBufferRef* MythNVDECContext::m_framesContext { nullptr }
private

Definition at line 70 of file mythnvdeccontext.h.

Referenced by InitFramesContext(), and ~MythNVDECContext().

◆ m_deinterlacer

MythDeintType MythNVDECContext::m_deinterlacer { DEINT_NONE }
private

Definition at line 73 of file mythnvdeccontext.h.

Referenced by IsDeinterlacing(), PostProcessFrame(), and SetDeinterlacing().

◆ m_deinterlacer2x

bool MythNVDECContext::m_deinterlacer2x { false }
private

Definition at line 74 of file mythnvdeccontext.h.

Referenced by IsDeinterlacing(), PostProcessFrame(), and SetDeinterlacing().


The documentation for this class was generated from the following files: