File ffmpeg-7-1.patch of Package blender
From c72dbeafffa5b3262e90023e092bb1f9928d7079 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>
Date: Tue, 14 May 2024 11:03:49 +0200
Subject: [PATCH] Add compatibility with FFMPEG 7.0
key_frame was deprecated then remove, we should use AV_FRAME_FLAG_KEY
instead.
read_seek2 and read_seek were internalized and can't be used anymore, so
we check directly the return of av_seek_frame.
---
intern/ffmpeg/ffmpeg_compat.h | 9 +++++++++
source/blender/imbuf/intern/anim_movie.cc | 11 +++++------
2 files changed, 14 insertions(+), 6 deletions(-)
Index: blender-4.2.3/intern/ffmpeg/ffmpeg_compat.h
===================================================================
--- blender-4.2.3.orig/intern/ffmpeg/ffmpeg_compat.h
+++ blender-4.2.3/intern/ffmpeg/ffmpeg_compat.h
@@ -161,6 +161,15 @@ FFMPEG_INLINE size_t ffmpeg_get_buffer_a
return align;
}
+FFMPEG_INLINE
+bool av_get_cur_key_frame_pts(const AVFrame *picture) {
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 29, 100)
+ return (picture->flags & AV_FRAME_FLAG_KEY);
+#else
+ return (picture->key_frame);
+#endif
+}
+
/* -------------------------------------------------------------------- */
/** \name Deinterlace code block
*
Index: blender-4.2.3/source/blender/imbuf/intern/anim_movie.cc
===================================================================
--- blender-4.2.3.orig/source/blender/imbuf/intern/anim_movie.cc
+++ blender-4.2.3/source/blender/imbuf/intern/anim_movie.cc
@@ -657,7 +657,7 @@ static void ffmpeg_decode_store_frame_pt
{
anim->cur_pts = av_get_pts_from_frame(anim->pFrame);
- if (anim->pFrame->key_frame) {
+ if (av_get_cur_key_frame_pts(anim->pFrame)) {
anim->cur_key_frame_pts = anim->cur_pts;
}
@@ -1036,11 +1036,10 @@ static int ffmpeg_seek_to_key_frame(ImBu
AVFormatContext *format_ctx = anim->pFormatCtx;
- if (format_ctx->iformat->read_seek2 || format_ctx->iformat->read_seek) {
- ret = av_seek_frame(anim->pFormatCtx, anim->videoStream, seek_pos, AVSEEK_FLAG_BACKWARD);
- }
- else {
- ret = ffmpeg_generic_seek_workaround(anim, &seek_pos, pts_to_search);
+ int ret = av_seek_frame(anim->pFormatCtx, anim->videoStream, seek_pos, AVSEEK_FLAG_BACKWARD);
+
+ if (ret < 0) {
+ ret = ffmpeg_generic_seek_workaround(anim, &seek_pos, pts_to_search);\
av_log(anim->pFormatCtx,
AV_LOG_DEBUG,
"Adjusted final seek seek_pos = %" PRId64 "\n",