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

#include <mythvtbcontext.h>

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

Public Member Functions

 MythVTBContext (DecoderBase *Parent, MythCodecID CodecID)
 
 ~MythVTBContext () override
 
void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
 
bool RetrieveFrame (AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
 
int HwDecoderInit (AVCodecContext *Context) 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 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 MythCodecID GetSupportedCodec (AVCodecContext **Context, const AVCodec **Codec, const QString &Decoder, uint StreamType)
 
static enum AVPixelFormat GetFormat (AVCodecContext *Context, const enum AVPixelFormat *PixFmt)
 
static bool HaveVTB (bool Reinit=false)
 
static void GetDecoderList (QStringList &Decoders)
 
- 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)
 

Private Member Functions

void InitFramesContext (AVCodecContext *Context)
 Create a hardware frames context if needed. More...
 

Static Private Member Functions

static const VTBProfilesGetProfiles (void)
 
static int InitialiseDecoder (AVCodecContext *Context)
 

Private Attributes

AVBufferRef * m_framesContext { nullptr }
 

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)
 
- 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 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 17 of file mythvtbcontext.h.

Constructor & Destructor Documentation

◆ MythVTBContext()

MythVTBContext::MythVTBContext ( DecoderBase Parent,
MythCodecID  CodecID 
)

Definition at line 23 of file mythvtbcontext.cpp.

◆ ~MythVTBContext()

MythVTBContext::~MythVTBContext ( )
override

Definition at line 28 of file mythvtbcontext.cpp.

Member Function Documentation

◆ InitVideoCodec()

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

Reimplemented from MythCodecContext.

Definition at line 33 of file mythvtbcontext.cpp.

◆ RetrieveFrame()

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

Reimplemented from MythCodecContext.

Definition at line 46 of file mythvtbcontext.cpp.

◆ HwDecoderInit()

int MythVTBContext::HwDecoderInit ( AVCodecContext *  Context)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 57 of file mythvtbcontext.cpp.

◆ GetSupportedCodec()

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

Definition at line 76 of file mythvtbcontext.cpp.

Referenced by MythCodecContext::FindDecoder().

◆ GetFormat()

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

Definition at line 181 of file mythvtbcontext.cpp.

Referenced by InitVideoCodec().

◆ HaveVTB()

bool MythVTBContext::HaveVTB ( bool  Reinit = false)
static

Definition at line 236 of file mythvtbcontext.cpp.

Referenced by MythCodecContext::GetDecoders().

◆ GetDecoderList()

void MythVTBContext::GetDecoderList ( QStringList &  Decoders)
static

Definition at line 265 of file mythvtbcontext.cpp.

Referenced by MythCodecContext::GetDecoderDescription().

◆ GetProfiles()

const VTBProfiles & MythVTBContext::GetProfiles ( void  )
staticprivate

Definition at line 202 of file mythvtbcontext.cpp.

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

◆ InitialiseDecoder()

int MythVTBContext::InitialiseDecoder ( AVCodecContext *  Context)
staticprivate

Definition at line 131 of file mythvtbcontext.cpp.

Referenced by HwDecoderInit().

◆ InitFramesContext()

void MythVTBContext::InitFramesContext ( AVCodecContext *  Context)
private

Create a hardware frames context if needed.

Note
We now use our own frames context to ensure stream changes are handled properly. This still fails to recreate the hardware decoder context however as the code in videotoolbox.c returns kVTVideoDecoderNotAvailableNowErr (i.e. VideoToolbox takes an indeterminate amount of time to free the old decoder and does not allow a new one to be created until it has done so). This appears to be a common issue - though may work better on newer hardware that supports multiple decoders (tested on an ancient MacBook). So hardware decoding will fail ungracefully and we fall back to software decoding. It is possible to handle this more gracefully by patching videotoolbox.c to use kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder rather than kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder. In this case VideoToolbox will use software decoding instead and the switch is relatively seemless. BUT the decoder no longer uses reference counted buffers and MythVTBInterop will leak textures as it does not expect a unique CVPixelBufferRef for every new frame. Also note that the FFmpeg code does not 'require' hardware decoding for HEVC - so software decoding may be used for HEVC - which will break the interop class as noted, but I cannot test this with my current hardware (and I don't have an HEVC sample with a resolution change).

Definition at line 299 of file mythvtbcontext.cpp.

Referenced by GetFormat().

Member Data Documentation

◆ m_framesContext

AVBufferRef* MythVTBContext::m_framesContext { nullptr }
private

Definition at line 42 of file mythvtbcontext.h.

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


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