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

#include <mythcodeccontext.h>

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

Public Types

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
}
 

Public Member Functions

 MythCodecContext (DecoderBase *Parent, MythCodecID CodecID)
 
virtual ~MythCodecContext ()=default
 
virtual void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering)
 
virtual int HwDecoderInit (AVCodecContext *)
 
virtual bool RetrieveFrame (AVCodecContext *, MythVideoFrame *, AVFrame *)
 
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 DecoderWillResetOnFlush (void)
 
virtual bool DecoderWillResetOnAspect (void)
 
virtual bool DecoderNeedsReset (AVCodecContext *)
 

Static Public Member Functions

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)
 

Protected Member Functions

virtual bool RetrieveHWFrame (MythVideoFrame *Frame, AVFrame *AvFrame)
 

Static Protected Member Functions

static void DestroyInterop (MythInteropGPU *Interop)
 
static void NewHardwareFramesContext (void)
 Track the number of concurrent frames contexts. More...
 

Protected Attributes

DecoderBasem_parent { nullptr }
 
MythCodecID m_codecID { kCodec_NONE }
 
bool m_resetRequired { false }
 

Static Protected Attributes

static QAtomicInt s_hwFramesContextCount
 

Detailed Description

Definition at line 54 of file mythcodeccontext.h.

Member Enumeration Documentation

◆ CodecProfile

Enumerator
NoProfile 
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 

Definition at line 57 of file mythcodeccontext.h.

Constructor & Destructor Documentation

◆ MythCodecContext()

MythCodecContext::MythCodecContext ( DecoderBase Parent,
MythCodecID  CodecID 
)
explicit

Definition at line 70 of file mythcodeccontext.cpp.

Referenced by CreateContext().

◆ ~MythCodecContext()

virtual MythCodecContext::~MythCodecContext ( )
virtualdefault

Member Function Documentation

◆ CreateContext()

MythCodecContext * MythCodecContext::CreateContext ( DecoderBase Parent,
MythCodecID  Codec 
)
static

Definition at line 76 of file mythcodeccontext.cpp.

Referenced by AvFormatDecoder::InitVideoCodec().

◆ GetDecoders()

void MythCodecContext::GetDecoders ( RenderOptions Opts,
bool  Reinit = false 
)
static

Definition at line 146 of file mythcodeccontext.cpp.

Referenced by MythVideoProfile::InitStatics().

◆ GetDecoderDescription()

QStringList MythCodecContext::GetDecoderDescription ( void  )
static

Definition at line 118 of file mythcodeccontext.cpp.

Referenced by StatusBox::doDecoderStatus().

◆ FindDecoder()

MythCodecID MythCodecContext::FindDecoder ( const QString &  Decoder,
AVStream *  Stream,
AVCodecContext **  Context,
const AVCodec **  Codec 
)
static

Definition at line 249 of file mythcodeccontext.cpp.

Referenced by AvFormatDecoder::ScanStreams().

◆ GetBuffer()

int MythCodecContext::GetBuffer ( struct AVCodecContext *  Context,
AVFrame Frame,
int  Flags 
)
static

A generic hardware buffer initialisation method when using AVHWFramesContext.

Definition at line 326 of file mythcodeccontext.cpp.

Referenced by MythVDPAUContext::InitVideoCodec(), and MythVAAPIContext::InitVideoCodec().

◆ GetBuffer2()

bool MythCodecContext::GetBuffer2 ( struct AVCodecContext *  Context,
MythVideoFrame Frame,
AVFrame AvFrame,
int  Flags 
)
static

A generic hardware buffer initialisation method when AVHWFramesContext is NOT used.

Definition at line 377 of file mythcodeccontext.cpp.

Referenced by MythMediaCodecContext::RetrieveFrame(), and MythVTBContext::RetrieveFrame().

◆ InitialiseDecoder()

int MythCodecContext::InitialiseDecoder ( AVCodecContext *  Context,
CreateHWDecoder  Callback,
const QString &  Debug 
)
static

Initialise a hardware decoder that is expected to use AVHWFramesContext.

Definition at line 527 of file mythcodeccontext.cpp.

Referenced by MythVDPAUContext::GetFormat(), and MythVAAPIContext::GetFormat().

◆ InitialiseDecoder2()

int MythCodecContext::InitialiseDecoder2 ( AVCodecContext *  Context,
CreateHWDecoder  Callback,
const QString &  Debug 
)
static

Initialise a hardware decoder that is NOT expected to use AVHWFramesContext.

Definition at line 544 of file mythcodeccontext.cpp.

Referenced by MythV4L2M2MContext::GetV4L2RequestFormat(), MythMediaCodecContext::HwDecoderInit(), MythVTBContext::HwDecoderInit(), and MythNVDECContext::HwDecoderInit().

◆ ReleaseBuffer()

void MythCodecContext::ReleaseBuffer ( void *  Opaque,
uint8_t *  Data 
)
static

◆ FramesContextFinished()

void MythCodecContext::FramesContextFinished ( AVHWFramesContext *  Context)
static

◆ DeviceContextFinished()

void MythCodecContext::DeviceContextFinished ( AVHWDeviceContext *  Context)
static

◆ CreateDecoderCallback()

void MythCodecContext::CreateDecoderCallback ( void *  Wait,
void *  Context,
void *  Callback 
)
static

Definition at line 495 of file mythcodeccontext.cpp.

Referenced by InitialiseDecoder(), and InitialiseDecoder2().

◆ GetPlayerUI()

MythPlayerUI * MythCodecContext::GetPlayerUI ( AVCodecContext *  Context)
static

◆ FrameTypeIsSupported()

bool MythCodecContext::FrameTypeIsSupported ( AVCodecContext *  Context,
VideoFrameType  Format 
)
static

◆ CreateDevice()

AVBufferRef * MythCodecContext::CreateDevice ( AVHWDeviceType  Type,
MythInteropGPU Interop,
const QString &  Device = QString() 
)
static

◆ IsUnsupportedProfile()

bool MythCodecContext::IsUnsupportedProfile ( AVCodecContext *  Context)
static

Most hardware decoders do not support these codecs/profiles.

Definition at line 599 of file mythcodeccontext.cpp.

Referenced by MythVDPAUContext::GetSupportedCodec(), MythVTBContext::GetSupportedCodec(), and MythNVDECContext::GetSupportedCodec().

◆ GetProfileDescription()

QString MythCodecContext::GetProfileDescription ( CodecProfile  Profile,
QSize  Size,
VideoFrameType  Format = FMT_NONE,
uint  ColorDepth = 0 
)
static

◆ FFmpegToMythProfile()

MythCodecContext::CodecProfile MythCodecContext::FFmpegToMythProfile ( AVCodecID  CodecID,
int  Profile 
)
static

◆ InitVideoCodec()

void MythCodecContext::InitVideoCodec ( AVCodecContext *  Context,
bool  SelectedStream,
bool DirectRendering 
)
virtual

◆ HwDecoderInit()

virtual int MythCodecContext::HwDecoderInit ( AVCodecContext *  )
inlinevirtual

◆ RetrieveFrame()

virtual bool MythCodecContext::RetrieveFrame ( AVCodecContext *  ,
MythVideoFrame ,
AVFrame  
)
inlinevirtual

◆ FilteredReceiveFrame()

int MythCodecContext::FilteredReceiveFrame ( AVCodecContext *  Context,
AVFrame Frame 
)
virtual

Retrieve and process/filter AVFrame.

Note
This default implementation implements no processing/filtering

Reimplemented in MythVAAPIContext.

Definition at line 624 of file mythcodeccontext.cpp.

Referenced by AvFormatDecoder::ProcessVideoPacket().

◆ SetDeinterlacing()

virtual void MythCodecContext::SetDeinterlacing ( AVCodecContext *  ,
MythVideoProfile ,
bool   
)
inlinevirtual

Reimplemented in MythNVDECContext.

Definition at line 156 of file mythcodeccontext.h.

Referenced by AvFormatDecoder::InitVideoCodec().

◆ PostProcessFrame()

virtual void MythCodecContext::PostProcessFrame ( AVCodecContext *  ,
MythVideoFrame  
)
inlinevirtual

Reimplemented in MythNVDECContext, MythVAAPIContext, and MythMediaCodecContext.

Definition at line 157 of file mythcodeccontext.h.

Referenced by AvFormatDecoder::ProcessVideoFrame().

◆ IsDeinterlacing()

virtual bool MythCodecContext::IsDeinterlacing ( bool ,
bool  = false 
)
inlinevirtual

◆ SetDecoderOptions()

virtual void MythCodecContext::SetDecoderOptions ( AVCodecContext *  ,
const AVCodec *   
)
inlinevirtual

Reimplemented in MythMMALContext, and MythV4L2M2MContext.

Definition at line 159 of file mythcodeccontext.h.

Referenced by AvFormatDecoder::ScanStreams().

◆ DecoderWillResetOnFlush()

virtual bool MythCodecContext::DecoderWillResetOnFlush ( void  )
inlinevirtual

◆ DecoderWillResetOnAspect()

virtual bool MythCodecContext::DecoderWillResetOnAspect ( void  )
inlinevirtual

◆ DecoderNeedsReset()

virtual bool MythCodecContext::DecoderNeedsReset ( AVCodecContext *  )
inlinevirtual

Reimplemented in MythVDPAUContext.

Definition at line 162 of file mythcodeccontext.h.

Referenced by AvFormatDecoder::ProcessVideoPacket(), and AvFormatDecoder::SeekReset().

◆ RetrieveHWFrame()

bool MythCodecContext::RetrieveHWFrame ( MythVideoFrame Frame,
AVFrame AvFrame 
)
protectedvirtual

◆ DestroyInterop()

void MythCodecContext::DestroyInterop ( MythInteropGPU Interop)
staticprotected

◆ NewHardwareFramesContext()

void MythCodecContext::NewHardwareFramesContext ( void  )
staticprotected

Track the number of concurrent frames contexts.

More than one hardware frames context is indicative of wider issues and needs to be avoided.

This currently only applies to VDPAU and VAAPI

Definition at line 432 of file mythcodeccontext.cpp.

Referenced by MythVDPAUContext::GetFormat2(), MythVTBContext::InitFramesContext(), MythNVDECContext::InitFramesContext(), MythVDPAUContext::InitialiseContext(), MythVAAPIContext::InitialiseContext(), and MythVAAPIContext::InitialiseContext2().

Member Data Documentation

◆ s_hwFramesContextCount

QAtomicInt MythCodecContext::s_hwFramesContextCount
staticprotected

Definition at line 168 of file mythcodeccontext.h.

Referenced by FramesContextFinished(), and NewHardwareFramesContext().

◆ m_parent

DecoderBase* MythCodecContext::m_parent { nullptr }
protected

◆ m_codecID

MythCodecID MythCodecContext::m_codecID { kCodec_NONE }
protected

◆ m_resetRequired

bool MythCodecContext::m_resetRequired { false }
protected

Definition at line 172 of file mythcodeccontext.h.

Referenced by MythVDPAUContext::DecoderNeedsReset().


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