vdr-plugin-softhddevice-drm-gles 1.6.2
Video Decoder

FFMpeg Video Decoder Frontend. More...

Classes

class  cVideoDecoder
 Video Decoder. More...
 

Functions

static enum AVPixelFormat GetFormat (AVCodecContext *videoCtx, const enum AVPixelFormat *fmt)
 Callback to negotiate the PixelFormat.
 
static const AVCodecHWConfigFindHWConfig (const AVCodec *codec)
 Find a hardware based video decoder config.
 
static const AVCodecFindHWDecoder (enum AVCodecID codecId)
 Find a suitable video codec (hardware decoding)
 
static const AVCodecFindSWDecoder (enum AVCodecID codecId)
 Find a suitable video codec (software decoding)
 
 cVideoDecoder::cVideoDecoder (int, const char *)
 Create a new video decoder.
 
int cVideoDecoder::Open (enum AVCodecID, AVCodecParameters *, AVRational, bool, int, int)
 Open the video decoder.
 
void cVideoDecoder::Close (void)
 Close video decoder.
 
int cVideoDecoder::GetExtraData (const AVPacket *)
 Get extradata from avpkt.
 
int cVideoDecoder::SendPacket (const AVPacket *)
 Send a video packet to be decoded.
 
int cVideoDecoder::ReceiveFrame (AVFrame **)
 Receive a decoded a video frame.
 
int cVideoDecoder::ReopenCodec (enum AVCodecID, AVCodecParameters *, AVRational, int)
 Reopen the video decoder.
 
void cVideoDecoder::FlushBuffers (void)
 Flush the video decoder buffers.
 
bool cVideoDecoder::IsKeyFrame (AVFrame *)
 Check, if this is a key frame.
 

Detailed Description

FFMpeg Video Decoder Frontend.

Video Decoder.

Function Documentation

◆ Close()

◆ cVideoDecoder()

cVideoDecoder::cVideoDecoder ( int  hardwareQuirks,
const char identifier 
)

Create a new video decoder.

Parameters
hardwareQuirkshardware specific quirks for decoder
identifierstring to identify decoder for video or pip stream (used within logging only)

Definition at line 145 of file codec_video.cpp.

References cSoftHdLogger::LogFFmpegCallback().

◆ FindHWConfig()

static const AVCodecHWConfig * FindHWConfig ( const AVCodec codec)
static

Find a hardware based video decoder config.

Parameters
codeccodec for which we should find a hw config
Returns
AVCodecHWConfig if found, NULL otherwise

Definition at line 84 of file codec_video.cpp.

Referenced by FindHWDecoder(), and cVideoDecoder::Open().

◆ FindHWDecoder()

static const AVCodec * FindHWDecoder ( enum AVCodecID  codecId)
static

Find a suitable video codec (hardware decoding)

Parameters
codecIdvideo codec id
Returns
AVCodec if found, NULL otherwise

Definition at line 107 of file codec_video.cpp.

References FindHWConfig().

Referenced by cVideoDecoder::Open().

◆ FindSWDecoder()

static const AVCodec * FindSWDecoder ( enum AVCodecID  codecId)
static

Find a suitable video codec (software decoding)

Parameters
codecIdvideo codec id
Returns
AVCodec if found, NULL otherwise

Definition at line 133 of file codec_video.cpp.

Referenced by cVideoDecoder::Open().

◆ FlushBuffers()

void cVideoDecoder::FlushBuffers ( void  )

Flush the video decoder buffers.

Also reset packet sent/ frame received counter

Definition at line 572 of file codec_video.cpp.

References L_CODEC, LOGDEBUG2, cVideoDecoder::m_cntFramesReceived, cVideoDecoder::m_cntPacketsSent, cVideoDecoder::m_identifier, cVideoDecoder::m_mutex, and cVideoDecoder::m_pVideoCtx.

Referenced by cVideoStream::FlushDecoder().

◆ GetExtraData()

int cVideoDecoder::GetExtraData ( const AVPacket avpkt)
private

Get extradata from avpkt.

Parameters
avpktvideo packet
Return values
0extradata set
-1something went wrong

Definition at line 336 of file codec_video.cpp.

References LOGERROR, cVideoDecoder::m_identifier, and cVideoDecoder::m_pVideoCtx.

Referenced by cVideoDecoder::SendPacket().

◆ GetFormat()

static enum AVPixelFormat GetFormat ( AVCodecContext videoCtx,
const enum AVPixelFormat fmt 
)
static

Callback to negotiate the PixelFormat.

Parameters
videoCtxvideo codec context
fmtthe list of formats which are supported by the codec, it is terminated by -1 as 0 is a valid format, the formats are ordered by quality
Returns
the negotiated pixel format

Definition at line 55 of file codec_video.cpp.

References L_CODEC, LOGDEBUG2, and LOGWARNING.

Referenced by cVideoDecoder::Open().

◆ IsKeyFrame()

bool cVideoDecoder::IsKeyFrame ( AVFrame frame)
private

Check, if this is a key frame.

Parameters
frameAVFrame
Returns
true, if this frame is a key frame

Definition at line 589 of file codec_video.cpp.

Referenced by cVideoDecoder::ReceiveFrame().

◆ Open()

int cVideoDecoder::Open ( enum AVCodecID  codecId,
AVCodecParameters par,
AVRational  timebase,
bool  forceSoftwareDecoder,
int  width,
int  height 
)

Open the video decoder.

Parameters
codecIdvideo codec id
parcodec parameters
timebasetimebase
forceSoftwareDecoderforce software decoding
widthforce width (only for H264 and if par is not set)
heightforce height (only for H264 and if par is not set)
Return values
0decoder successfully opend
-1opening the decoder failed

Definition at line 169 of file codec_video.cpp.

References av_err2str, FindHWConfig(), FindHWDecoder(), FindSWDecoder(), GetFormat(), L_CODEC, LOGDEBUG2, LOGERROR, LOGINFO, cVideoDecoder::m_cntFramesReceived, cVideoDecoder::m_cntPacketsSent, cVideoDecoder::m_cntStartKeyFrames, cVideoDecoder::m_hardwareQuirks, cVideoDecoder::m_identifier, cVideoDecoder::m_isHardwareDecoder, cVideoDecoder::m_mutex, cVideoDecoder::m_pCodecString, cVideoDecoder::m_pVideoCtx, cVideoDecoder::Open(), QUIRK_CODEC_DISABLE_H264_HW, and QUIRK_CODEC_DISABLE_MPEG_HW.

Referenced by cVideoDecoder::Open(), cVideoStream::OpenDecoder(), and cVideoDecoder::ReopenCodec().

◆ ReceiveFrame()

int cVideoDecoder::ReceiveFrame ( AVFrame **  frame)

Receive a decoded a video frame.

Parameters
[out]framedecoded AVFrame
instanceinstance name for logging
Return values
0received frame
AVERROR(EAGAIN)get no frame, send avpkt again
AVERROR_EOFEOF, needs flushing
AVERROR(EINVAL)get no frame, something went wrong
retreturn other ffmpeg error

Definition at line 477 of file codec_video.cpp.

References av_err2str, isInterlacedFrame(), cVideoDecoder::IsKeyFrame(), L_CODEC, L_PACKET, LOGDEBUG2, LOGFATAL, cVideoDecoder::m_cntFramesReceived, cVideoDecoder::m_cntPacketsSent, cVideoDecoder::m_cntStartKeyFrames, cVideoDecoder::m_hardwareQuirks, cVideoDecoder::m_identifier, cVideoDecoder::m_mutex, cVideoDecoder::m_pVideoCtx, QUIRK_CODEC_SKIP_FIRST_FRAMES, QUIRK_CODEC_SKIP_NUM_FRAMES, and Timestamp2String().

Referenced by cVideoStream::DecodeInput().

◆ ReopenCodec()

int cVideoDecoder::ReopenCodec ( enum AVCodecID  codecId,
AVCodecParameters par,
AVRational  timebase,
int  forceSoftwareDecoding 
)

Reopen the video decoder.

Parameters
codecIdvideo codec id
parcodec parameters
timebasetimebase
forceSoftwareDecodingforce software decoding
Return values
0success
-1reopen decoder failed
Todo:
: This is just a temporary implementation RPi's ffmpeg decoder is broken. In order to get the same result if we want to flush the decoder, we need to close and reopen it. This function is only needed, if some decoder can't flush correctly. Once this is fixed in ffmpeg, we can drop this function. remove, once ffmpeg is fixed

Definition at line 554 of file codec_video.cpp.

References cVideoDecoder::Close(), L_CODEC, LOGDEBUG2, cVideoDecoder::m_cntFramesReceived, cVideoDecoder::m_cntPacketsSent, cVideoDecoder::m_cntStartKeyFrames, cVideoDecoder::m_identifier, cVideoDecoder::m_lastCodedHeight, cVideoDecoder::m_lastCodedWidth, cVideoDecoder::m_pVideoCtx, and cVideoDecoder::Open().

Referenced by cVideoStream::DecodeInput(), and cVideoStream::FlushDecoder().

◆ SendPacket()

int cVideoDecoder::SendPacket ( const AVPacket avpkt)

Send a video packet to be decoded.

Parameters
avpktvideo packet
Return values
0packet was sent
AVERROR(EAGAIN)packet was not accepted, first receive frame and send packet again
AVERROR(EINVAL)invalid input or missing m_pVideoCtx
retother ffmpeg error

Definition at line 422 of file codec_video.cpp.

References av_err2str, cVideoDecoder::GetExtraData(), L_CODEC, L_PACKET, LOGDEBUG2, cVideoDecoder::m_cntPacketsSent, cVideoDecoder::m_identifier, cVideoDecoder::m_mutex, cVideoDecoder::m_pVideoCtx, and Timestamp2String().

Referenced by cVideoStream::CheckForcingFrameDecode(), and cVideoStream::DecodeInput().