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 <mythvaapicontext.h>

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

Public Member Functions

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

Static Public Member Functions

static MythCodecID GetSupportedCodec (AVCodecContext **Context, 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)
 
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)
 

Private Member Functions

void DestroyDeinterlacer (void)
 

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 (void)
 

Private Attributes

MythDeintType m_deinterlacer { DEINT_NONE }
 
bool m_deinterlacer2x { false }
 
int m_lastInterlaced { 0 }
 
int m_lastTopFieldFirst { 0 }
 
AVFilterContext * m_filterSink { nullptr }
 
AVFilterContext * m_filterSource { nullptr }
 
AVFilterGraph * m_filterGraph { nullptr }
 
bool m_filterError { false }
 
AVBufferRef * m_framesCtx { nullptr }
 
int64_t m_filterPriorPTS [2] { 0 }
 
int64_t m_filterPTSUsed { 0 }
 
int m_filterWidth { 0 }
 
int m_filterHeight { 0 }
 

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 (VideoFrame *Frame, AVFrame *AvFrame)
 
- Static Protected Member Functions inherited from MythCodecContext
static void DestroyInterop (MythOpenGLInterop *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 31 of file mythvaapicontext.cpp.

◆ ~MythVAAPIContext()

MythVAAPIContext::~MythVAAPIContext ( void  )
override

Definition at line 36 of file mythvaapicontext.cpp.

Member Function Documentation

◆ InitVideoCodec()

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

Reimplemented from MythCodecContext.

Definition at line 624 of file mythvaapicontext.cpp.

◆ RetrieveFrame()

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

Reimplemented from MythCodecContext.

Definition at line 644 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 661 of file mythvaapicontext.cpp.

◆ PostProcessFrame()

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

Reimplemented from MythCodecContext.

Definition at line 726 of file mythvaapicontext.cpp.

◆ IsDeinterlacing()

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

Reimplemented from MythCodecContext.

Definition at line 818 of file mythvaapicontext.cpp.

◆ DecoderWillResetOnFlush()

bool MythVAAPIContext::DecoderWillResetOnFlush ( void  )
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 832 of file mythvaapicontext.cpp.

◆ DecoderWillResetOnAspect()

bool MythVAAPIContext::DecoderWillResetOnAspect ( void  )
overridevirtual

Reimplemented from MythCodecContext.

Definition at line 838 of file mythvaapicontext.cpp.

◆ GetSupportedCodec()

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

Confirm whether VAAPI support is available given Decoder and Context.

Definition at line 130 of file mythvaapicontext.cpp.

Referenced by MythCodecContext::FindDecoder().

◆ GetFormat()

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

Definition at line 226 of file mythvaapicontext.cpp.

Referenced by InitVideoCodec().

◆ GetFormat2()

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

Definition at line 238 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 442 of file mythvaapicontext.cpp.

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

◆ GetDecoderList()

void MythVAAPIContext::GetDecoderList ( QStringList &  Decoders)
static

Definition at line 613 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 252 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 393 of file mythvaapicontext.cpp.

Referenced by GetFormat2().

◆ VAAPIProfileForCodec()

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

Definition at line 41 of file mythvaapicontext.cpp.

Referenced by GetSupportedCodec().

◆ FramesFormat()

AVPixelFormat MythVAAPIContext::FramesFormat ( AVPixelFormat  Format)
inlinestaticprivate

Definition at line 116 of file mythvaapicontext.cpp.

Referenced by InitialiseContext(), and InitialiseContext2().

◆ DestroyDeinterlacer()

void MythVAAPIContext::DestroyDeinterlacer ( void  )
private

Definition at line 844 of file mythvaapicontext.cpp.

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

◆ GetProfiles()

const VAAPIProfiles & MythVAAPIContext::GetProfiles ( void  )
staticprivate

Definition at line 489 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 56 of file mythvaapicontext.h.

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

◆ m_deinterlacer2x

bool MythVAAPIContext::m_deinterlacer2x { false }
private

◆ m_lastInterlaced

int MythVAAPIContext::m_lastInterlaced { 0 }
private

Definition at line 58 of file mythvaapicontext.h.

Referenced by FilteredReceiveFrame(), and PostProcessFrame().

◆ m_lastTopFieldFirst

int MythVAAPIContext::m_lastTopFieldFirst { 0 }
private

Definition at line 59 of file mythvaapicontext.h.

Referenced by FilteredReceiveFrame(), and PostProcessFrame().

◆ m_filterSink

AVFilterContext* MythVAAPIContext::m_filterSink { nullptr }
private

Definition at line 60 of file mythvaapicontext.h.

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

◆ m_filterSource

AVFilterContext* MythVAAPIContext::m_filterSource { nullptr }
private

Definition at line 61 of file mythvaapicontext.h.

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

◆ m_filterGraph

AVFilterGraph* MythVAAPIContext::m_filterGraph { nullptr }
private

Definition at line 62 of file mythvaapicontext.h.

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

◆ m_filterError

bool MythVAAPIContext::m_filterError { false }
private

Definition at line 63 of file mythvaapicontext.h.

Referenced by PostProcessFrame().

◆ m_framesCtx

AVBufferRef* MythVAAPIContext::m_framesCtx { nullptr }
private

Definition at line 64 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), and PostProcessFrame().

◆ m_filterPriorPTS

int64_t MythVAAPIContext::m_filterPriorPTS[2] { 0 }
private

Definition at line 65 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), and FilteredReceiveFrame().

◆ m_filterPTSUsed

int64_t MythVAAPIContext::m_filterPTSUsed { 0 }
private

Definition at line 66 of file mythvaapicontext.h.

Referenced by DestroyDeinterlacer(), and FilteredReceiveFrame().

◆ m_filterWidth

int MythVAAPIContext::m_filterWidth { 0 }
private

Definition at line 67 of file mythvaapicontext.h.

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

◆ m_filterHeight

int MythVAAPIContext::m_filterHeight { 0 }
private

Definition at line 68 of file mythvaapicontext.h.

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


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