Skip to content

Commit 356e1c7

Browse files
committed
Handle AV_FRAME_FLAG_KEY introduced in FFmpeg 6.1
1 parent 3068c15 commit 356e1c7

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/avutils.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ extern "C" {
2626
#define API_FRAME_NUM ((LIBAVCODEC_VERSION_MAJOR > 60) || (LIBAVCODEC_VERSION_MAJOR == 60 && LIBAVCODEC_VERSION_MINOR >= 2))
2727
// use AVFormatContext::url
2828
#define API_AVFORMAT_URL ((LIBAVFORMAT_VERSION_MAJOR > 58) || (LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR >= 7))
29+
// net key frame flags: AV_FRAME_FLAG_KEY (FFmpeg 6.1)
30+
#define API_FRAME_KEY ((LIBAVUTIL_VERSION_MAJOR > 58) || (LIBAVUTIL_VERSION_MAJOR == 58 && LIBAVUTIL_VERSION_MINOR >= 29))
2931

3032
#if defined(__ICL) || defined (__INTEL_COMPILER)
3133
# define FF_DISABLE_DEPRECATION_WARNINGS __pragma(warning(push)) __pragma(warning(disable:1478))

src/frame.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,26 @@ int VideoFrame::height() const
148148

149149
bool VideoFrame::isKeyFrame() const
150150
{
151+
#if API_FRAME_KEY
152+
return !!(RAW_GET(flags, 0) & AV_FRAME_FLAG_KEY);
153+
#else
151154
return RAW_GET(key_frame, false);
155+
#endif
152156
}
153157

154158
void VideoFrame::setKeyFrame(bool isKey)
155159
{
160+
#if API_FRAME_KEY
161+
if (m_raw) {
162+
if (isKey) {
163+
m_raw->flags |= AV_FRAME_FLAG_KEY;
164+
} else {
165+
m_raw->flags &= ~(AV_FRAME_FLAG_KEY);
166+
}
167+
}
168+
#else
156169
RAW_SET(key_frame, isKey);
170+
#endif
157171
}
158172

159173
int VideoFrame::quality() const

0 commit comments

Comments
 (0)