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 *, VideoFrame *, AVFrame *)
 
virtual int FilteredReceiveFrame (AVCodecContext *Context, AVFrame *Frame)
 Retrieve and process/filter AVFrame. More...
 
virtual void SetDeinterlacing (AVCodecContext *, VideoDisplayProfile *, bool)
 
virtual void PostProcessFrame (AVCodecContext *, VideoFrame *)
 
virtual bool IsDeinterlacing (bool &, bool=false)
 
virtual void SetDecoderOptions (AVCodecContext *, 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)
 
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)
 

Protected Member Functions

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

Static Protected Member Functions

static void DestroyInterop (MythOpenGLInterop *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 50 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 53 of file mythcodeccontext.h.

Constructor & Destructor Documentation

◆ MythCodecContext()

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

Definition at line 66 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 72 of file mythcodeccontext.cpp.

Referenced by AvFormatDecoder::InitVideoCodec().

◆ GetDecoders()

void MythCodecContext::GetDecoders ( RenderOptions Opts)
static

Definition at line 142 of file mythcodeccontext.cpp.

Referenced by AvFormatDecoder::GetDecoders().

◆ GetDecoderDescription()

QStringList MythCodecContext::GetDecoderDescription ( void  )
static

Definition at line 114 of file mythcodeccontext.cpp.

Referenced by StatusBox::doDecoderStatus().

◆ FindDecoder()

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

Definition at line 235 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 311 of file mythcodeccontext.cpp.

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

◆ GetBuffer2()

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

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

Definition at line 362 of file mythcodeccontext.cpp.

Referenced by MythMediaCodecContext::RetrieveFrame(), MythV4L2M2MContext::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 493 of file mythcodeccontext.cpp.

Referenced by MythVAAPIContext::GetFormat(), and MythV4L2M2MContext::GetV4L2RequestFormat().

◆ 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 513 of file mythcodeccontext.cpp.

Referenced by MythMediaCodecContext::HwDecoderInit(), MythNVDECContext::HwDecoderInit(), and MythVTBContext::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 480 of file mythcodeccontext.cpp.

Referenced by InitialiseDecoder(), and InitialiseDecoder2().

◆ CreateDevice()

AVBufferRef * MythCodecContext::CreateDevice ( AVHWDeviceType  Type,
MythOpenGLInterop 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 571 of file mythcodeccontext.cpp.

Referenced by MythNVDECContext::GetSupportedCodec(), MythVDPAUContext::GetSupportedCodec(), and MythVTBContext::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 *  ,
VideoFrame ,
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 596 of file mythcodeccontext.cpp.

Referenced by AvFormatDecoder::ProcessVideoPacket().

◆ SetDeinterlacing()

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

Reimplemented in MythNVDECContext.

Definition at line 150 of file mythcodeccontext.h.

Referenced by AvFormatDecoder::InitVideoCodec().

◆ PostProcessFrame()

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

Reimplemented in MythVAAPIContext, MythNVDECContext, and MythMediaCodecContext.

Definition at line 151 of file mythcodeccontext.h.

Referenced by AvFormatDecoder::ProcessVideoFrame().

◆ IsDeinterlacing()

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

◆ SetDecoderOptions()

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

Reimplemented in MythV4L2M2MContext, and MythMMALContext.

Definition at line 153 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 156 of file mythcodeccontext.h.

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

◆ RetrieveHWFrame()

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

◆ DestroyInterop()

void MythCodecContext::DestroyInterop ( MythOpenGLInterop 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 417 of file mythcodeccontext.cpp.

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

Member Data Documentation

◆ s_hwFramesContextCount

QAtomicInt MythCodecContext::s_hwFramesContextCount
staticprotected

Definition at line 162 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 166 of file mythcodeccontext.h.

Referenced by MythVDPAUContext::DecoderNeedsReset().


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