forked from zillevdr/vdr-plugin-softhddevice-drm
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcodec_video.h
More file actions
72 lines (63 loc) · 2.52 KB
/
Copy pathcodec_video.h
File metadata and controls
72 lines (63 loc) · 2.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: AGPL-3.0-or-later
/**
* @file codec_video.h
* Video Decoder Header File
*
* @copyright 2009 - 2013, 2015 by Johns. All Rights Reserved.
* @copyright 2025 - 2026 by Andreas Baierl. All Rights Reserved.
*
* @license{AGPL-3.0-or-later}
*/
#ifndef __CODEC_VIDEO_H
#define __CODEC_VIDEO_H
#include <mutex>
extern "C" {
#include <libavcodec/avcodec.h>
}
/**
* FFmpeg Based Video Decoder Frontend
* @defgroup videodecoder VideoDecoder
*/
/**
* Video Decoder
*
* FFmpeg based Video Decoder Frontend
*
* Handles:
* - Video packet decoding using FFmpeg
*
* @ingroup videodecoder
*/
class cVideoDecoder {
public:
cVideoDecoder(const char *);
int Open(enum AVCodecID, AVCodecParameters *, AVRational, bool, int, int);
void Close(void);
int SendPacket(const AVPacket *);
int ReceiveFrame(AVFrame **);
void FlushBuffers(void);
int ReopenCodec(enum AVCodecID, AVCodecParameters *, AVRational, int);
AVCodecContext *GetContext(void) { return m_pVideoCtx; };
bool IsHardwareDecoder(void) { return m_isHardwareDecoder; };
const char *Name(void) { return m_pCodecString; };
int GetPacketsSent(void) { return m_cntPacketsSent; };
int GetFramesReceived(void) { return m_cntFramesReceived; };
void SetSkipKeyFramesNum(int num) { m_skipKeyFramesNum = num; };
private:
AVCodecContext *m_pVideoCtx = nullptr; ///< video codec context
const char *m_identifier; ///< identifier for logging
const char *m_pCodecString = "unknown"; ///< codec (long) name string
std::mutex m_mutex; ///< mutex to lock codec context
int m_cntPacketsSent; ///< number of packets sent to decoder
int m_cntFramesReceived; ///< number of decoded frames received from decoder
int m_cntStartKeyFrames; ///< number of keyframes arrived while starting the coded
///< (needed for amlogic h264 decoder in order to drop some frames
///< in ReceiveFrame() before sending them to the renderer)
int m_lastCodedWidth; ///< save coded width while closing for a directly reopen
int m_lastCodedHeight; ///< save coded height while closing for a directly reopen
int m_skipKeyFramesNum = 0; ///< number of Keyframes (= I-Frames in VDR) to be skipped at stream start (hardware specific quirk)
bool m_isHardwareDecoder = false; ///< true, if this is a hardware decoder
int GetExtraData(const AVPacket *);
bool IsKeyFrame(AVFrame *);
};
#endif