MythTV  master
Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
MythDRMPRIMEContext Class Reference

A generic context handler for codecs that return AV_PIX_FMT_DRM_PRIME frames. More...

#include <mythdrmprimecontext.h>

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

Public Member Functions

 MythDRMPRIMEContext (DecoderBase *Parent, MythCodecID CodecID)
 
 ~MythDRMPRIMEContext () override
 
int HwDecoderInit (AVCodecContext *Context) override
 
void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
 
bool RetrieveFrame (AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
 
bool DecoderWillResetOnFlush (void) override
 
bool GetDRMBuffer (AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame, int)
 
- 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 SetDeinterlacing (AVCodecContext *, MythVideoProfile *, bool)
 
virtual void PostProcessFrame (AVCodecContext *, MythVideoFrame *)
 
virtual bool IsDeinterlacing (bool &, bool=false)
 
virtual void SetDecoderOptions (AVCodecContext *, const AVCodec *)
 
virtual bool DecoderWillResetOnAspect (void)
 
virtual bool DecoderNeedsReset (AVCodecContext *)
 

Static Public Member Functions

static MythCodecID GetSupportedCodec (AVCodecContext **Context, const AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
 
static bool HavePrimeDecoders (bool Reinit=false, AVCodecID Codec=AV_CODEC_ID_NONE)
 
static enum AVPixelFormat GetFormat (AVCodecContext *Context, const AVPixelFormat *PixFmt)
 
- Static Public Member Functions inherited from MythCodecContext
static MythCodecContextCreateContext (DecoderBase *Parent, MythCodecID Codec)
 
static void GetDecoders (RenderOptions &Opts, bool Reinit=false)
 
static QStringList GetDecoderDescription (void)
 
static MythCodecID FindDecoder (const QString &Decoder, AVStream *Stream, AVCodecContext **Context, const 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, MythVideoFrame *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 MythPlayerUIGetPlayerUI (AVCodecContext *Context)
 
static bool FrameTypeIsSupported (AVCodecContext *Context, VideoFrameType Format)
 
static AVBufferRef * CreateDevice (AVHWDeviceType Type, MythInteropGPU *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)
 

Static Protected Member Functions

static MythCodecID GetPrimeCodec (AVCodecContext **Context, const AVCodec **Codec, AVStream *Stream, MythCodecID Successs, MythCodecID Failure, const QString &CodecName, AVPixelFormat Format)
 
- Static Protected Member Functions inherited from MythCodecContext
static void DestroyInterop (MythInteropGPU *Interop)
 
static void NewHardwareFramesContext (void)
 Track the number of concurrent frames contexts. More...
 

Protected Attributes

MythOpenGLInteropm_interop { nullptr }
 
- Protected Attributes inherited from MythCodecContext
DecoderBasem_parent { nullptr }
 
MythCodecID m_codecID { kCodec_NONE }
 
bool m_resetRequired { false }
 

Static Protected Attributes

static QRecursiveMutex s_drmPrimeLock
 
static QStringList s_drmPrimeDecoders
 
- Static Protected Attributes inherited from MythCodecContext
static QAtomicInt s_hwFramesContextCount
 

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 (MythVideoFrame *Frame, AVFrame *AvFrame)
 

Detailed Description

A generic context handler for codecs that return AV_PIX_FMT_DRM_PRIME frames.

Note
There is currently no support for codecs that use AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX or AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX. They will need additional handling if they are created (all current DRM PRIME codecs use AV_CODEC_HW_CONFIG_METHOD_INTERNAL).
This will currently only pick up the Rockchip/rkmpp decoder on supported platforms. v4l2m2m codecs are filtered out and handled separately as we can detect what actual support is available and handle software based formats as well in the subclass (although the DRM PRIME version of the v4l2m2m codec works fine purely with this class).
The Rockchip/mpp library has support for codec checks via mpp_check_support_format, so it should be easy to add actual decoder check support for these devices.
Todo:
When Rockchip support is complete, refactor this to a pure virtual class and create appropriate sub-classes as needed for the specific codecs.

Definition at line 14 of file mythdrmprimecontext.h.

Constructor & Destructor Documentation

◆ MythDRMPRIMEContext()

MythDRMPRIMEContext::MythDRMPRIMEContext ( DecoderBase Parent,
MythCodecID  CodecID 
)

Definition at line 30 of file mythdrmprimecontext.cpp.

◆ ~MythDRMPRIMEContext()

MythDRMPRIMEContext::~MythDRMPRIMEContext ( )
override

Definition at line 35 of file mythdrmprimecontext.cpp.

Member Function Documentation

◆ GetSupportedCodec()

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

Definition at line 70 of file mythdrmprimecontext.cpp.

Referenced by MythCodecContext::FindDecoder().

◆ HwDecoderInit()

int MythDRMPRIMEContext::HwDecoderInit ( AVCodecContext *  Context)
overridevirtual

Reimplemented from MythCodecContext.

Reimplemented in MythV4L2M2MContext.

Definition at line 106 of file mythdrmprimecontext.cpp.

Referenced by MythV4L2M2MContext::HwDecoderInit().

◆ InitVideoCodec()

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

Reimplemented from MythCodecContext.

Reimplemented in MythV4L2M2MContext.

Definition at line 121 of file mythdrmprimecontext.cpp.

Referenced by MythV4L2M2MContext::InitVideoCodec().

◆ RetrieveFrame()

bool MythDRMPRIMEContext::RetrieveFrame ( AVCodecContext *  Context,
MythVideoFrame Frame,
AVFrame AvFrame 
)
overridevirtual

Reimplemented from MythCodecContext.

Reimplemented in MythV4L2M2MContext.

Definition at line 138 of file mythdrmprimecontext.cpp.

Referenced by MythV4L2M2MContext::RetrieveFrame().

◆ DecoderWillResetOnFlush()

bool MythDRMPRIMEContext::DecoderWillResetOnFlush ( void  )
overridevirtual

Reimplemented from MythCodecContext.

Reimplemented in MythV4L2M2MContext.

Definition at line 133 of file mythdrmprimecontext.cpp.

◆ HavePrimeDecoders()

bool MythDRMPRIMEContext::HavePrimeDecoders ( bool  Reinit = false,
AVCodecID  Codec = AV_CODEC_ID_NONE 
)
static

Definition at line 188 of file mythdrmprimecontext.cpp.

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

◆ GetFormat()

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

Definition at line 146 of file mythdrmprimecontext.cpp.

Referenced by InitVideoCodec().

◆ GetDRMBuffer()

bool MythDRMPRIMEContext::GetDRMBuffer ( AVCodecContext *  Context,
MythVideoFrame Frame,
AVFrame AvFrame,
int   
)

Definition at line 157 of file mythdrmprimecontext.cpp.

Referenced by RetrieveFrame().

◆ GetPrimeCodec()

MythCodecID MythDRMPRIMEContext::GetPrimeCodec ( AVCodecContext **  Context,
const AVCodec **  Codec,
AVStream *  Stream,
MythCodecID  Successs,
MythCodecID  Failure,
const QString &  CodecName,
AVPixelFormat  Format 
)
staticprotected

Member Data Documentation

◆ s_drmPrimeLock

QRecursiveMutex MythDRMPRIMEContext::s_drmPrimeLock
staticprotected

Definition at line 41 of file mythdrmprimecontext.h.

Referenced by GetSupportedCodec(), and HavePrimeDecoders().

◆ s_drmPrimeDecoders

QStringList MythDRMPRIMEContext::s_drmPrimeDecoders
staticprotected

Definition at line 42 of file mythdrmprimecontext.h.

Referenced by GetSupportedCodec(), and HavePrimeDecoders().

◆ m_interop

MythOpenGLInterop* MythDRMPRIMEContext::m_interop { nullptr }
protected

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