MythTV master
mythnvdeccontext.h
Go to the documentation of this file.
1#ifndef MYTHNVDECCONTEXT_H
2#define MYTHNVDECCONTEXT_H
3
4// Qt
5#include <QSize>
6
7// MythTV
8#include "mythframe.h"
9#include "mythcodecid.h"
10#include "mythcodeccontext.h"
11
12// FFmpeg
13extern "C" {
14#include "libavutil/pixfmt.h"
15#include "libavutil/hwcontext.h"
16#include "libavcodec/avcodec.h"
17#include "libavutil/pixdesc.h"
18#include <ffnvcodec/dynlink_cuda.h>
19#include <ffnvcodec/dynlink_cuviddec.h>
20}
21
22// Std
23#include <vector>
24
26{
27 public:
29 ~MythNVDECContext() override;
30 void InitVideoCodec (AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override;
31 int HwDecoderInit (AVCodecContext *Context) override;
32 bool RetrieveFrame (AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override;
33 void SetDeinterlacing (AVCodecContext *Context,
34 MythVideoProfile *Profile, bool DoubleRate) override;
35 void PostProcessFrame (AVCodecContext *Context, MythVideoFrame *Frame) override;
36 bool IsDeinterlacing (bool &DoubleRate, bool StreamChange = false) override;
37 bool DecoderWillResetOnFlush (void) override;
38 static MythCodecID GetSupportedCodec (AVCodecContext **CodecContext,
39 const AVCodec **Codec,
40 const QString &Decoder,
41 AVStream *Stream,
42 uint StreamType);
43 static enum AVPixelFormat GetFormat (AVCodecContext *Context, const AVPixelFormat *PixFmt);
44 static bool GetBuffer (AVCodecContext *Context, MythVideoFrame *Frame,
45 AVFrame *AvFrame, int Flags);
46 static int InitialiseDecoder (AVCodecContext *Context);
47 static bool HaveNVDEC (bool Reinit = false);
48 static void GetDecoderList (QStringList &Decoders);
49
50 private:
52 {
53 public:
54 MythNVDECCaps(cudaVideoCodec Codec, uint Depth, cudaVideoChromaFormat Format,
55 QSize Minimum, QSize Maximum, uint MacroBlocks);
56 bool Supports(cudaVideoCodec Codec, cudaVideoChromaFormat Format, uint Depth,
57 int Width, int Height) const;
58
61 cudaVideoCodec m_codec { cudaVideoCodec_NumCodecs };
63 cudaVideoChromaFormat m_format { cudaVideoChromaFormat_Monochrome };
64 QSize m_minimum;
65 QSize m_maximum;
67 };
68
69 private:
70 void InitFramesContext(AVCodecContext *Context);
71 AVBufferRef* m_framesContext { nullptr };
72
73 static const std::vector<MythNVDECCaps>& GetProfiles(void);
75 bool m_deinterlacer2x { false };
76};
77
78#endif // MYTHNVDECCONTEXT_H
AVFrame AVFrame
cudaVideoChromaFormat m_format
MythCodecContext::CodecProfile m_profile
MythNVDECCaps(cudaVideoCodec Codec, uint Depth, cudaVideoChromaFormat Format, QSize Minimum, QSize Maximum, uint MacroBlocks)
bool Supports(cudaVideoCodec Codec, cudaVideoChromaFormat Format, uint Depth, int Width, int Height) const
bool IsDeinterlacing(bool &DoubleRate, bool StreamChange=false) override
MythDeintType m_deinterlacer
static int InitialiseDecoder(AVCodecContext *Context)
static enum AVPixelFormat GetFormat(AVCodecContext *Context, const AVPixelFormat *PixFmt)
static void GetDecoderList(QStringList &Decoders)
static bool GetBuffer(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame, int Flags)
Convert AVFrame data to MythFrame.
void PostProcessFrame(AVCodecContext *Context, MythVideoFrame *Frame) override
static MythCodecID GetSupportedCodec(AVCodecContext **CodecContext, const AVCodec **Codec, const QString &Decoder, AVStream *Stream, uint StreamType)
Determine whether NVDEC decoding is supported for this codec.
~MythNVDECContext() override
bool RetrieveFrame(AVCodecContext *Context, MythVideoFrame *Frame, AVFrame *AvFrame) override
AVBufferRef * m_framesContext
void InitVideoCodec(AVCodecContext *Context, bool SelectedStream, bool &DirectRendering) override
int HwDecoderInit(AVCodecContext *Context) override
MythNVDECContext(DecoderBase *Parent, MythCodecID CodecID)
void SetDeinterlacing(AVCodecContext *Context, MythVideoProfile *Profile, bool DoubleRate) override
Enable NVDEC/CUDA deinterlacing if necessary.
void InitFramesContext(AVCodecContext *Context)
static bool HaveNVDEC(bool Reinit=false)
bool DecoderWillResetOnFlush(void) override
static const std::vector< MythNVDECCaps > & GetProfiles(void)
unsigned int uint
Definition: freesurround.h:24
MythCodecID
Definition: mythcodecid.h:14
MythDeintType
Definition: mythframe.h:67
@ DEINT_NONE
Definition: mythframe.h:68
VideoFrameType
Definition: mythframe.h:20
@ FMT_NONE
Definition: mythframe.h:21