20#include <libavcodec/avcodec.h>
21#include <libavcodec/bsf.h>
23#include <libavutil/pixdesc.h>
53 LOGDEBUG2(
L_CODEC,
"videocodec: %s: PixelFormat: %s videoCtx->pix_fmt: %s sw_pix_fmt: %s Codecname: %s",
113 if (
codec->id != codecId)
149#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,18,100)
169 int width,
int height)
238 }
else if (width && height) {
271 LOGDEBUG2(
L_CODEC,
"videocodec: %s: %s: Could not open hw decoder \"%s\", force using software decoder",
279 LOGINFO(
"videocodec: %s: %s (%s) for codec \"%s\" opened%s, using %s decoding with %d threads%s",
568#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(58,7,100)
569 return frame->key_frame;
static void LogFFmpegCallback(void *, int, const char *, va_list)
Callback for ffmpeg logs.
cVideoDecoder(const char *)
Create a new video decoder.
int ReopenCodec(enum AVCodecID, AVCodecParameters *, AVRational, int)
Reopen the video decoder.
int m_lastCodedHeight
save coded height while closing for a directly reopen
int m_skipKeyFramesNum
number of Keyframes (= I-Frames in VDR) to be skipped at stream start (hardware specific quirk)
bool m_isHardwareDecoder
true, if this is a hardware decoder
int SendPacket(const AVPacket *)
Send a video packet to be decoded.
int Open(enum AVCodecID, AVCodecParameters *, AVRational, bool, int, int)
Open the video decoder.
int m_cntFramesReceived
number of decoded frames received from decoder
int GetExtraData(const AVPacket *)
Get extradata from avpkt.
int m_cntStartKeyFrames
number of keyframes arrived while starting the coded (needed for amlogic h264 decoder in order to dro...
void FlushBuffers(void)
Flush the video decoder buffers.
std::mutex m_mutex
mutex to lock codec context
AVCodecContext * m_pVideoCtx
video codec context
int m_cntPacketsSent
number of packets sent to decoder
int m_lastCodedWidth
save coded width while closing for a directly reopen
const char * m_pCodecString
codec (long) name string
bool IsKeyFrame(AVFrame *)
Check, if this is a key frame.
const char * m_identifier
identifier for logging
int ReceiveFrame(AVFrame **)
Receive a decoded a video frame.
void Close(void)
Close video decoder.
Video Decoder Header File.
#define LOGDEBUG2
log to LOG_DEBUG and add a prefix
#define LOGERROR
log to LOG_ERR
#define LOGWARNING
log to LOG_WARN
#define LOGINFO
log to LOG_INFO
#define LOGFATAL
log to LOG_ERR and abort
static bool isInterlacedFrame(AVFrame *frame)
Check, if this is an interlaced frame.
static const char * Timestamp2String(int64_t ts, uint8_t divisor)
Nice time-stamp string.
@ L_PACKET
decoder packet/frame tracking logs
static const AVCodecHWConfig * FindHWConfig(const AVCodec *codec)
Find a hardware based video decoder config.
static enum AVPixelFormat GetFormat(AVCodecContext *videoCtx, const enum AVPixelFormat *fmt)
Callback to negotiate the PixelFormat.
static const AVCodec * FindHWDecoder(enum AVCodecID codecId)
Find a suitable video codec (hardware decoding)
static const AVCodec * FindSWDecoder(enum AVCodecID codecId)
Find a suitable video codec (software decoding)