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

#include <libmythtv/decoders/mythvaapicontext.h>

Inheritance diagram for MythVAAPIContext:
[legend]
Collaboration diagram for MythVAAPIContext:
[legend]

Public Member Functions

 MythVAAPIContext (DecoderBase *Parent, MythCodecID CodecID)
 
 ~MythVAAPIContext () override
 
void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
 
bool RetrieveFrame (AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
 
int FilteredReceiveFrame (AVCodecContext *Context, AVFrame *Frame) override
 Retrieve decoded frame and optionally deinterlace. More...
 
void PostProcessFrame (AVCodecContext *Context, MythVideoFrame *Frame) override
 
bool IsDeinterlacing (bool &DoubleRate, bool StreamChange=false) override
 
bool DecoderWillResetOnFlush () override
 
bool DecoderWillResetOnAspect () override
 
- Public Member Functions inherited from MythCodecContext
 MythCodecContext (DecoderBase *Parent, MythCodecID CodecID)
 
virtual ~MythCodecContext ()=default
 
virtual int HwDecoderInit (AVCodecContext *)
 
virtual void SetDeinterlacing (AVCodecContext *, MythVideoProfile *, bool)
 
virtual void SetDecoderOptions (AVCodecContext *, const AVCodec *)
 
virtual bool DecoderNeedsReset (AVCodecContext *)
 

Static Public Member Functions

static MythCodecID GetSupportedCodec (AVCodecContext **Context, const AVCodec **Codec, const QString &Decoder, uint StreamType)
 Confirm whether VAAPI support is available given Decoder and Context. More...
 
static enum AVPixelFormat GetFormat (AVCodecContext *Context, const AVPixelFormat *PixFmt)
 
static enum AVPixelFormat GetFormat2 (AVCodecContext *Context, const AVPixelFormat *PixFmt)
 
static QString HaveVAAPI (bool ReCheck=false)
 Check whether VAAPI is available and not emulated via VDPAU. More...
 
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 DestroyDeinterlacer ()
 

Static Private Member Functions

static int InitialiseContext (AVCodecContext *Context)
 Create a VAAPI hardware context with appropriate OpenGL interop. More...
 
static int InitialiseContext2 (AVCodecContext *Context)
 Create a VAAPI hardware context without OpenGL interop. More...
 
static VAProfile VAAPIProfileForCodec (const AVCodecContext *Codec)
 
static AVPixelFormat FramesFormat (AVPixelFormat Format)
 
static const VAAPIProfilesGetProfiles ()
 

Private Attributes

MythDeintType m_deinterlacer { DEINT_NONE }
 
bool m_deinterlacer2x { false }
 
bool m_lastInterlaced { false }
 
bool m_lastTopFieldFirst { false }
 
AVFilterContext * m_filterSink { nullptr }
 
AVFilterContext * m_filterSource { nullptr }
 
AVFilterGraph * m_filterGraph { nullptr }
 
bool m_filterError { false }
 
AVBufferRef * m_framesCtx { nullptr }
 
std::array< int64_t, 2 > m_filterPriorPTS { 0 }
 
int64_t m_filterPTSUsed { 0 }
 
int m_filterWidth { 0 }
 
int m_filterHeight { 0 }
 

Additional Inherited Members

- Public Types inherited from MythCodecContext
enum  CodecProfile : std::uint8_t {
  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

Todo:

Scaling errors when deinterlacing H.264 1080 and for 10bit HEVC 1080p.

Fix crash when skipping to the end of an H.264 stream. Appears to be because the decoder is partially initialised but we never feed it any packets to complete the setup (as we have reached the end of the file). Should be a simple null pointer check in FFmpeg.

Definition at line 23 of file mythvaapicontext.h.

Constructor & Destructor Documentation

◆ MythVAAPIContext()

MythVAAPIContext::MythVAAPIContext ( DecoderBase Parent,
MythCodecID  CodecID 
)

Definition at line 33 of file mythvaapicontext.cpp.

◆ ~MythVAAPIContext()

MythVAAPIContext::~MythVAAPIContext ( )
override

Definition at line 38 of file mythvaapicontext.cpp.

Member Function Documentation

◆ InitVideoCodec()

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

Reimplemented from MythCodecContext.

Definition at line 586 of file mythvaapicontext.cpp.

◆ RetrieveFrame()

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

Reimplemented from MythCodecContext.

Definition at line 606 of file mythvaapicontext.cpp.

◆ FilteredReceiveFrame()

int MythVAAPIContext::FilteredReceiveFrame ( AVCodecContext *  Context,
AVFrame Frame 
)
overridevirtual

Retrieve decoded frame and optionally deinterlace.

Note
Deinterlacing is setup in PostProcessFrame which has access to deinterlacer preferences.
In testing, A/V sync is broken for a stream with timestamps that increment by 1 (when doublerate deinterlacing). This is presumably an anomaly. NVDEC doublerate deinterlacers produce the same problem.

Reimplemented from MythCodecContext.

Definition at line 623 of file mythvaapicontext.cpp.

◆ PostProcessFrame()

void MythVAAPIContext::PostProcessFrame ( AVCodecContext *  Context,
MythVideoFrame Frame 
)
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 686 of file mythvaapicontext.cpp.

◆ IsDeinterlacing()

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

Reimplemented from MythCodecContext.

Definition at line 778 of file mythvaapicontext.cpp.

◆ DecoderWillResetOnFlush()

bool MythVAAPIContext::DecoderWillResetOnFlush ( )
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 792 of file mythvaapicontext.cpp.

◆ DecoderWillResetOnAspect()

bool MythVAAPIContext::DecoderWillResetOnAspect ( )
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 798 of file mythvaapicontext.cpp.

◆ GetSupportedCodec()

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

Confirm whether VAAPI support is available given Decoder and Context.

Definition at line 132 of file mythvaapicontext.cpp.

Referenced by MythCodecContext::FindDecoder().

◆ GetFormat()

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

Definition at line 210 of file mythvaapicontext.cpp.

Referenced by InitVideoCodec().

◆ GetFormat2()

AVPixelFormat MythVAAPIContext::GetFormat2 ( AVCodecContext *  Context,
const AVPixelFormat *  PixFmt 
)
static

Definition at line 222 of file mythvaapicontext.cpp.

Referenced by InitVideoCodec().

◆ HaveVAAPI()

QString MythVAAPIContext::HaveVAAPI ( bool  ReCheck = false)
static

Check whether VAAPI is available and not emulated via VDPAU.

The VDPAU backend appears to be largely unmaintained, does not expose the full range of VDPAU functionality (deinterlacing, full colourspace handling etc) and in testing fails when used by FFmpeg. So disallow VAAPI over VDPAU - VDPAU should just be used directly.

Definition at line 419 of file mythvaapicontext.cpp.

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

◆ GetDecoderList()

void MythVAAPIContext::GetDecoderList ( QStringList &  Decoders)
static

Definition at line 575 of file mythvaapicontext.cpp.

Referenced by MythCodecContext::GetDecoderDescription().

◆ InitialiseContext()

int MythVAAPIContext::InitialiseContext ( AVCodecContext *  Context)
staticprivate

Create a VAAPI hardware context with appropriate OpenGL interop.

Definition at line 236 of file mythvaapicontext.cpp.

Referenced by GetFormat().

◆ InitialiseContext2()

int MythVAAPIContext::InitialiseContext2 ( AVCodecContext *  Context)
staticprivate

Create a VAAPI hardware context without OpenGL interop.

Note
Testing with Debian Buster, 10bit copyback requires the i965-va-driver-shaders package instead of i965-va-driver package. Expect a purple screen otherwise:) I suspect this is due to some unnecessary scaling somewhere - as the relevant code should only be hit if scaling is required.

Definition at line 370 of file mythvaapicontext.cpp.

Referenced by GetFormat2().

◆ VAAPIProfileForCodec()

VAProfile MythVAAPIContext::VAAPIProfileForCodec ( const AVCodecContext *  Codec)
staticprivate

Definition at line 43 of file mythvaapicontext.cpp.

Referenced by GetSupportedCodec().

◆ FramesFormat()

AVPixelFormat MythVAAPIContext::FramesFormat ( AVPixelFormat  Format)
inlinestaticprivate

Definition at line 118 of file mythvaapicontext.cpp.

Referenced by InitialiseContext(), and InitialiseContext2().

◆ DestroyDeinterlacer()

void MythVAAPIContext::DestroyDeinterlacer ( )
private

Definition at line 804 of file mythvaapicontext.cpp.

Referenced by FilteredReceiveFrame(), PostProcessFrame(), and ~MythVAAPIContext().

◆ GetProfiles()

const VAAPIProfiles & MythVAAPIContext::GetProfiles ( )
staticprivate

Definition at line 466 of file mythvaapicontext.cpp.

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

Member Data Documentation

◆ m_deinterlacer

MythDeintType MythVAAPIContext::m_deinterlacer { DEINT_NONE }
private

Definition at line 52 of file mythvaapicontext.h.

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

◆ m_deinterlacer2x

bool MythVAAPIContext::m_deinterlacer2x { false }
private

◆ m_lastInterlaced

bool MythVAAPIContext::m_lastInterlaced { false }
private

Definition at line 54 of file mythvaapicontext.h.

Referenced by FilteredReceiveFrame(), and PostProcessFrame().

◆ m_lastTopFieldFirst

bool MythVAAPIContext::m_lastTopFieldFirst { false }
private

Definition at line 55 of file mythvaapicontext.h.

Referenced by FilteredReceiveFrame(), and PostProcessFrame().

◆ m_filterSink

AVFilterContext* MythVAAPIContext::m_filterSink { nullptr }
private

Definition at line 56 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), FilteredReceiveFrame(), and PostProcessFrame().

◆ m_filterSource

AVFilterContext* MythVAAPIContext::m_filterSource { nullptr }
private

Definition at line 57 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), FilteredReceiveFrame(), and PostProcessFrame().

◆ m_filterGraph

AVFilterGraph* MythVAAPIContext::m_filterGraph { nullptr }
private

Definition at line 58 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), FilteredReceiveFrame(), and PostProcessFrame().

◆ m_filterError

bool MythVAAPIContext::m_filterError { false }
private

Definition at line 59 of file mythvaapicontext.h.

Referenced by PostProcessFrame().

◆ m_framesCtx

AVBufferRef* MythVAAPIContext::m_framesCtx { nullptr }
private

Definition at line 60 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), and PostProcessFrame().

◆ m_filterPriorPTS

std::array<int64_t,2> MythVAAPIContext::m_filterPriorPTS { 0 }
private

Definition at line 61 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), and FilteredReceiveFrame().

◆ m_filterPTSUsed

int64_t MythVAAPIContext::m_filterPTSUsed { 0 }
private

Definition at line 62 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), and FilteredReceiveFrame().

◆ m_filterWidth

int MythVAAPIContext::m_filterWidth { 0 }
private

Definition at line 63 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), FilteredReceiveFrame(), and PostProcessFrame().

◆ m_filterHeight

int MythVAAPIContext::m_filterHeight { 0 }
private

Definition at line 64 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), FilteredReceiveFrame(), and PostProcessFrame().


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