Gentoo Archives: gentoo-commits

From: Alexis Ballier <aballier@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: media-video/ffmpegthumbnailer/files/, media-video/ffmpegthumbnailer/
Date: Mon, 28 Feb 2022 10:06:03
Message-Id: 1646042758.564304e8f9ed045fd252214d4433dc8f6aca18f4.aballier@gentoo
1 commit: 564304e8f9ed045fd252214d4433dc8f6aca18f4
2 Author: Alexis Ballier <aballier <AT> gentoo <DOT> org>
3 AuthorDate: Mon Feb 28 10:05:23 2022 +0000
4 Commit: Alexis Ballier <aballier <AT> gentoo <DOT> org>
5 CommitDate: Mon Feb 28 10:05:58 2022 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=564304e8
7
8 media-video/ffmpegthumbnailer: ffmpeg5 fixes
9
10 from upstream
11
12 Package-Manager: Portage-3.0.30, Repoman-3.0.3
13 Signed-off-by: Alexis Ballier <aballier <AT> gentoo.org>
14
15 .../ffmpegthumbnailer-2.2.2-r1.ebuild | 61 +++++++++++++++++++++
16 .../ffmpegthumbnailer/files/ffmpeg5-1.patch | 22 ++++++++
17 .../ffmpegthumbnailer/files/ffmpeg5-10.patch | 22 ++++++++
18 .../ffmpegthumbnailer/files/ffmpeg5-2.patch | 28 ++++++++++
19 .../ffmpegthumbnailer/files/ffmpeg5-3.patch | 26 +++++++++
20 .../ffmpegthumbnailer/files/ffmpeg5-4.patch | 32 +++++++++++
21 .../ffmpegthumbnailer/files/ffmpeg5-5.patch | 37 +++++++++++++
22 .../ffmpegthumbnailer/files/ffmpeg5-6.patch | 23 ++++++++
23 .../ffmpegthumbnailer/files/ffmpeg5-7.patch | 27 ++++++++++
24 .../ffmpegthumbnailer/files/ffmpeg5-8.patch | 54 +++++++++++++++++++
25 .../ffmpegthumbnailer/files/ffmpeg5-9.patch | 62 ++++++++++++++++++++++
26 11 files changed, 394 insertions(+)
27
28 diff --git a/media-video/ffmpegthumbnailer/ffmpegthumbnailer-2.2.2-r1.ebuild b/media-video/ffmpegthumbnailer/ffmpegthumbnailer-2.2.2-r1.ebuild
29 new file mode 100644
30 index 000000000000..4906d0009027
31 --- /dev/null
32 +++ b/media-video/ffmpegthumbnailer/ffmpegthumbnailer-2.2.2-r1.ebuild
33 @@ -0,0 +1,61 @@
34 +# Copyright 1999-2022 Gentoo Authors
35 +# Distributed under the terms of the GNU General Public License v2
36 +
37 +EAPI=7
38 +
39 +inherit cmake
40 +
41 +DESCRIPTION="Lightweight video thumbnailer that can be used by file managers"
42 +HOMEPAGE="https://github.com/dirkvdb/ffmpegthumbnailer"
43 +SRC_URI="https://github.com/dirkvdb/${PN}/releases/download/${PV}/${P}.tar.bz2"
44 +
45 +LICENSE="GPL-2"
46 +SLOT="0"
47 +KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~ppc ~ppc64 ~riscv ~sparc ~x86"
48 +IUSE="gnome gtk jpeg png test"
49 +RESTRICT="!test? ( test )"
50 +
51 +REQUIRED_USE="gnome? ( gtk )
52 + test? ( png jpeg )"
53 +
54 +BDEPEND="
55 + virtual/pkgconfig
56 +"
57 +RDEPEND="
58 + gtk? ( dev-libs/glib:2= )
59 + jpeg? ( virtual/jpeg:0= )
60 + >=media-video/ffmpeg-2.7:0=
61 + png? ( media-libs/libpng:0= )
62 +"
63 +DEPEND="${RDEPEND}"
64 +
65 +DOCS=( AUTHORS ChangeLog README.md )
66 +PATCHES=(
67 + "${FILESDIR}/ffmpeg5-1.patch"
68 + "${FILESDIR}/ffmpeg5-2.patch"
69 + "${FILESDIR}/ffmpeg5-3.patch"
70 + "${FILESDIR}/ffmpeg5-4.patch"
71 + "${FILESDIR}/ffmpeg5-5.patch"
72 + "${FILESDIR}/ffmpeg5-6.patch"
73 + "${FILESDIR}/ffmpeg5-7.patch"
74 + "${FILESDIR}/ffmpeg5-8.patch"
75 + "${FILESDIR}/ffmpeg5-9.patch"
76 + "${FILESDIR}/ffmpeg5-10.patch"
77 +)
78 +
79 +src_prepare() {
80 + rm -rf out* || die
81 +
82 + cmake_src_prepare
83 +}
84 +
85 +src_configure() {
86 + local mycmakeargs=(
87 + -DENABLE_GIO=$(usex gtk)
88 + -DENABLE_TESTS=$(usex test)
89 + -DENABLE_THUMBNAILER=$(usex gnome)
90 + -DHAVE_JPEG=$(usex jpeg)
91 + -DHAVE_PNG=$(usex png)
92 + )
93 + cmake_src_configure
94 +}
95
96 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-1.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-1.patch
97 new file mode 100644
98 index 000000000000..d852f3b4131d
99 --- /dev/null
100 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-1.patch
101 @@ -0,0 +1,22 @@
102 +From 67be4abd22b726e277c4b67bfb3abf5a65cfd9b5 Mon Sep 17 00:00:00 2001
103 +From: Zane van Iperen <zane@×××××××××××××.com>
104 +Date: Mon, 15 Mar 2021 17:23:23 +1000
105 +Subject: [PATCH] lib/moviedecoder: remove unused variable
106 +
107 +---
108 + libffmpegthumbnailer/moviedecoder.cpp | 2 --
109 + 1 file changed, 2 deletions(-)
110 +
111 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
112 +index 290e212..aa44adf 100644
113 +--- a/libffmpegthumbnailer/moviedecoder.cpp
114 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
115 +@@ -570,8 +570,6 @@ bool MovieDecoder::getVideoPacket()
116 + bool framesAvailable = true;
117 + bool frameDecoded = false;
118 +
119 +- int attempts = 0;
120 +-
121 + if (m_pPacket)
122 + {
123 + av_packet_unref(m_pPacket);
124
125 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-10.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-10.patch
126 new file mode 100644
127 index 000000000000..81e57aab1c96
128 --- /dev/null
129 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-10.patch
130 @@ -0,0 +1,22 @@
131 +From efb5b618f1c1471c1a7900aed3a59d851ea9a210 Mon Sep 17 00:00:00 2001
132 +From: Paul Jonkins <paul.ionkin@×××××.com>
133 +Date: Wed, 23 Jun 2021 17:53:55 +0200
134 +Subject: [PATCH] Constify AVCodec
135 +
136 +---
137 + libffmpegthumbnailer/moviedecoder.h | 2 +-
138 + 1 file changed, 1 insertion(+), 1 deletion(-)
139 +
140 +diff --git a/libffmpegthumbnailer/moviedecoder.h b/libffmpegthumbnailer/moviedecoder.h
141 +index 3ef5f12..fb6add2 100644
142 +--- a/libffmpegthumbnailer/moviedecoder.h
143 ++++ b/libffmpegthumbnailer/moviedecoder.h
144 +@@ -78,7 +78,7 @@ class MovieDecoder
145 + int m_VideoStream;
146 + AVFormatContext* m_pFormatContext;
147 + AVCodecContext* m_pVideoCodecContext;
148 +- AVCodec* m_pVideoCodec;
149 ++ const AVCodec* m_pVideoCodec;
150 + AVFilterGraph* m_pFilterGraph;
151 + AVFilterContext* m_pFilterSource;
152 + AVFilterContext* m_pFilterSink;
153
154 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-2.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-2.patch
155 new file mode 100644
156 index 000000000000..8f22829f6bb7
157 --- /dev/null
158 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-2.patch
159 @@ -0,0 +1,28 @@
160 +From 66f64668e7a063e790813c7733ca438ab112af89 Mon Sep 17 00:00:00 2001
161 +From: Zane van Iperen <zane@×××××××××××××.com>
162 +Date: Mon, 15 Mar 2021 17:42:07 +1000
163 +Subject: [PATCH] lib/moviedecoder: clang-tidy fixes
164 +
165 +---
166 + libffmpegthumbnailer/moviedecoder.cpp | 4 ++--
167 + 1 file changed, 2 insertions(+), 2 deletions(-)
168 +
169 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
170 +index aa44adf..79c950b 100644
171 +--- a/libffmpegthumbnailer/moviedecoder.cpp
172 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
173 +@@ -503,12 +503,12 @@ void MovieDecoder::seek(int timeInSeconds)
174 + avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
175 +
176 + int keyFrameAttempts = 0;
177 +- bool gotFrame = 0;
178 ++ bool gotFrame;
179 +
180 + do
181 + {
182 + int count = 0;
183 +- gotFrame = 0;
184 ++ gotFrame = false;
185 +
186 + while (!gotFrame && count < 20)
187 + {
188
189 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-3.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-3.patch
190 new file mode 100644
191 index 000000000000..ad7625775cf0
192 --- /dev/null
193 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-3.patch
194 @@ -0,0 +1,26 @@
195 +From 96c22aa66719846854895afcb72962862d5a4ffd Mon Sep 17 00:00:00 2001
196 +From: Zane van Iperen <zane@×××××××××××××.com>
197 +Date: Mon, 15 Mar 2021 20:39:32 +1000
198 +Subject: [PATCH] lib/moviedecoder: remove SilenceLogLevel
199 +
200 +Was unused.
201 +---
202 + libffmpegthumbnailer/moviedecoder.cpp | 5 -----
203 + 1 file changed, 5 deletions(-)
204 +
205 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
206 +index 79c950b..21df096 100644
207 +--- a/libffmpegthumbnailer/moviedecoder.cpp
208 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
209 +@@ -41,11 +41,6 @@ using namespace std;
210 + namespace ffmpegthumbnailer
211 + {
212 +
213 +-struct SilenceLogLevel
214 +-{
215 +- SilenceLogLevel() { av_log_set_level(AV_LOG_QUIET); }
216 +-};
217 +-
218 + MovieDecoder::MovieDecoder(AVFormatContext* pavContext)
219 + : m_VideoStream(-1)
220 + , m_pFormatContext(pavContext)
221
222 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-4.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-4.patch
223 new file mode 100644
224 index 000000000000..eb063973ae37
225 --- /dev/null
226 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-4.patch
227 @@ -0,0 +1,32 @@
228 +From 664680f4bfeb89923f485eba270f9e49a8d02bfc Mon Sep 17 00:00:00 2001
229 +From: Zane van Iperen <zane@×××××××××××××.com>
230 +Date: Mon, 15 Mar 2021 17:25:40 +1000
231 +Subject: [PATCH] lib/moviedecoder: remove registration calls
232 +
233 +They're not needed anymore.
234 +---
235 + libffmpegthumbnailer/moviedecoder.cpp | 4 ----
236 + 1 file changed, 4 deletions(-)
237 +
238 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
239 +index 21df096..ac3e5b9 100644
240 +--- a/libffmpegthumbnailer/moviedecoder.cpp
241 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
242 +@@ -65,8 +65,6 @@ MovieDecoder::~MovieDecoder()
243 +
244 + void MovieDecoder::initialize(const string& filename, bool preferEmbeddedMetadata)
245 + {
246 +- av_register_all();
247 +- avcodec_register_all();
248 + avformat_network_init();
249 +
250 + string inputFile = filename == "-" ? "pipe:" : filename;
251 +@@ -386,8 +384,6 @@ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::
252 + auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
253 + std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
254 +
255 +- avfilter_register_all();
256 +-
257 + m_pFilterGraph = avfilter_graph_alloc();
258 + assert(m_pFilterGraph);
259 +
260
261 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-5.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-5.patch
262 new file mode 100644
263 index 000000000000..e2a131b31ebc
264 --- /dev/null
265 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-5.patch
266 @@ -0,0 +1,37 @@
267 +From 1ae42e664e1f3c915d186ae00aa2c8018b998708 Mon Sep 17 00:00:00 2001
268 +From: Zane van Iperen <zane@×××××××××××××.com>
269 +Date: Mon, 15 Mar 2021 17:30:21 +1000
270 +Subject: [PATCH] lib/moviedecoder: remove use of AVBufferSinkParams
271 +
272 +---
273 + libffmpegthumbnailer/moviedecoder.cpp | 9 +--------
274 + 1 file changed, 1 insertion(+), 8 deletions(-)
275 +
276 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
277 +index ac3e5b9..dece668 100644
278 +--- a/libffmpegthumbnailer/moviedecoder.cpp
279 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
280 +@@ -379,11 +379,6 @@ std::string MovieDecoder::createScaleString(const std::string& sizeString, bool
281 +
282 + void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::string& size, bool maintainAspectRatio)
283 + {
284 +- static const AVPixelFormat pixelFormats[] = { AV_PIX_FMT_RGB24, AV_PIX_FMT_NONE };
285 +-
286 +- auto del = [] (AVBufferSinkParams* p) { av_freep(p); };
287 +- std::unique_ptr<AVBufferSinkParams, decltype(del)> buffersinkParams(av_buffersink_params_alloc(), del);
288 +-
289 + m_pFilterGraph = avfilter_graph_alloc();
290 + assert(m_pFilterGraph);
291 +
292 +@@ -395,10 +390,8 @@ void MovieDecoder::initializeFilterGraph(const AVRational& timeBase, const std::
293 +
294 + checkRc(avfilter_graph_create_filter(&m_pFilterSource, avfilter_get_by_name("buffer"), "thumb_buffer", ss.str().c_str(), nullptr, m_pFilterGraph),
295 + "Failed to create filter source");
296 +- buffersinkParams->pixel_fmts = pixelFormats;
297 +- checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, buffersinkParams.get(), m_pFilterGraph),
298 ++ checkRc(avfilter_graph_create_filter(&m_pFilterSink, avfilter_get_by_name("buffersink"), "thumb_buffersink", nullptr, nullptr, m_pFilterGraph),
299 + "Failed to create filter sink");
300 +- buffersinkParams.release();
301 +
302 + AVFilterContext* yadifFilter = nullptr;
303 + if (m_pFrame->interlaced_frame != 0)
304
305 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-6.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-6.patch
306 new file mode 100644
307 index 000000000000..59860a599ef2
308 --- /dev/null
309 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-6.patch
310 @@ -0,0 +1,23 @@
311 +From 19675349662a4ea4455d7d13b01cca28ab585762 Mon Sep 17 00:00:00 2001
312 +From: Zane van Iperen <zane@×××××××××××××.com>
313 +Date: Mon, 15 Mar 2021 17:39:58 +1000
314 +Subject: [PATCH] lib/moviedecoder: use m_pVideoCodecContext instead of
315 + AVStream::codec
316 +
317 +---
318 + libffmpegthumbnailer/moviedecoder.cpp | 2 +-
319 + 1 file changed, 1 insertion(+), 1 deletion(-)
320 +
321 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
322 +index dece668..0b7a280 100644
323 +--- a/libffmpegthumbnailer/moviedecoder.cpp
324 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
325 +@@ -484,7 +484,7 @@ void MovieDecoder::seek(int timeInSeconds)
326 + }
327 +
328 + checkRc(av_seek_frame(m_pFormatContext, -1, timestamp, 0), "Seeking in video failed");
329 +- avcodec_flush_buffers(m_pFormatContext->streams[m_VideoStream]->codec);
330 ++ avcodec_flush_buffers(m_pVideoCodecContext);
331 +
332 + int keyFrameAttempts = 0;
333 + bool gotFrame;
334
335 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-7.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-7.patch
336 new file mode 100644
337 index 000000000000..ac1eb3c25423
338 --- /dev/null
339 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-7.patch
340 @@ -0,0 +1,27 @@
341 +From 4f74f83a009fa2b3f3d546adb24d4f1406910007 Mon Sep 17 00:00:00 2001
342 +From: Zane van Iperen <zane@×××××××××××××.com>
343 +Date: Mon, 15 Mar 2021 17:49:03 +1000
344 +Subject: [PATCH] lib/moviedecoder: codec -> codecpar
345 +
346 +---
347 + libffmpegthumbnailer/moviedecoder.cpp | 6 +++---
348 + 1 file changed, 3 insertions(+), 3 deletions(-)
349 +
350 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
351 +index 0b7a280..e58904e 100644
352 +--- a/libffmpegthumbnailer/moviedecoder.cpp
353 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
354 +@@ -145,10 +145,10 @@ int32_t MovieDecoder::findPreferedVideoStream(bool preferEmbeddedMetadata)
355 + for (unsigned int i = 0; i < m_pFormatContext->nb_streams; ++i)
356 + {
357 + AVStream *stream = m_pFormatContext->streams[i];
358 +- auto ctx = m_pFormatContext->streams[i]->codec;
359 +- if (ctx->codec_type == AVMEDIA_TYPE_VIDEO)
360 ++ auto par = m_pFormatContext->streams[i]->codecpar;
361 ++ if (par->codec_type == AVMEDIA_TYPE_VIDEO)
362 + {
363 +- if (!preferEmbeddedMetadata || !isStillImageCodec(ctx->codec_id))
364 ++ if (!preferEmbeddedMetadata || !isStillImageCodec(par->codec_id))
365 + {
366 + videoStreams.push_back(i);
367 + continue;
368
369 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-8.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-8.patch
370 new file mode 100644
371 index 000000000000..d160cbb2404f
372 --- /dev/null
373 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-8.patch
374 @@ -0,0 +1,54 @@
375 +From 3ffdd65cbda6ef21d36c96013db1b0f4dc9fc57b Mon Sep 17 00:00:00 2001
376 +From: Zane van Iperen <zane@×××××××××××××.com>
377 +Date: Mon, 15 Mar 2021 17:52:01 +1000
378 +Subject: [PATCH] lib/movedecoder: don't rely on avformat to allocate a context
379 +
380 +---
381 + libffmpegthumbnailer/moviedecoder.cpp | 20 ++++++++++++++++----
382 + 1 file changed, 16 insertions(+), 4 deletions(-)
383 +
384 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
385 +index e58904e..da5f32a 100644
386 +--- a/libffmpegthumbnailer/moviedecoder.cpp
387 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
388 +@@ -90,8 +90,7 @@ void MovieDecoder::destroy()
389 + {
390 + if (m_pVideoCodecContext)
391 + {
392 +- avcodec_close(m_pVideoCodecContext);
393 +- m_pVideoCodecContext = nullptr;
394 ++ avcodec_free_context(&m_pVideoCodecContext);
395 + }
396 +
397 + if ((!m_FormatContextWasGiven) && m_pFormatContext)
398 +@@ -196,8 +195,7 @@ void MovieDecoder::initializeVideo(bool preferEmbeddedMetadata)
399 + }
400 +
401 + m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
402 +- m_pVideoCodecContext = m_pVideoStream->codec;
403 +- m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
404 ++ m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
405 +
406 + if (m_pVideoCodec == nullptr)
407 + {
408 +@@ -207,6 +205,20 @@ void MovieDecoder::initializeVideo(bool preferEmbeddedMetadata)
409 + throw logic_error("Video Codec not found");
410 + }
411 +
412 ++ m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
413 ++
414 ++ if (m_pVideoCodecContext == nullptr)
415 ++ {
416 ++ destroy();
417 ++ throw logic_error("Could not allocate video codec context");
418 ++ }
419 ++
420 ++ if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
421 ++ {
422 ++ destroy();
423 ++ throw logic_error("Could not configure video codec context");
424 ++ }
425 ++
426 + m_pVideoCodecContext->workaround_bugs = 1;
427 +
428 + if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)
429
430 diff --git a/media-video/ffmpegthumbnailer/files/ffmpeg5-9.patch b/media-video/ffmpegthumbnailer/files/ffmpeg5-9.patch
431 new file mode 100644
432 index 000000000000..42db9faef363
433 --- /dev/null
434 +++ b/media-video/ffmpegthumbnailer/files/ffmpeg5-9.patch
435 @@ -0,0 +1,62 @@
436 +From f9273852c8e3d7af77d6c8929b1ac6c8a26eca50 Mon Sep 17 00:00:00 2001
437 +From: Zane van Iperen <zane@×××××××××××××.com>
438 +Date: Mon, 15 Mar 2021 20:57:45 +1000
439 +Subject: [PATCH] lib/moviedecoder: replace avcodec_decode_video2() usage
440 +
441 +---
442 + libffmpegthumbnailer/moviedecoder.cpp | 31 +++++++++++++++++++++------
443 + 1 file changed, 24 insertions(+), 7 deletions(-)
444 +
445 +diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
446 +index da5f32a..f32577a 100644
447 +--- a/libffmpegthumbnailer/moviedecoder.cpp
448 ++++ b/libffmpegthumbnailer/moviedecoder.cpp
449 +@@ -548,17 +548,33 @@ bool MovieDecoder::decodeVideoPacket()
450 + return false;
451 + }
452 +
453 +- av_frame_unref(m_pFrame);
454 +-
455 +- int frameFinished;
456 ++ int rc = avcodec_send_packet(m_pVideoCodecContext, m_pPacket);
457 ++ if(rc == AVERROR(EAGAIN))
458 ++ {
459 ++ rc = 0;
460 ++ }
461 +
462 +- int bytesDecoded = avcodec_decode_video2(m_pVideoCodecContext, m_pFrame, &frameFinished, m_pPacket);
463 +- if (bytesDecoded < 0)
464 ++ if(rc == AVERROR_EOF)
465 ++ {
466 ++ return false;
467 ++ }
468 ++ else if(rc < 0)
469 + {
470 +- throw logic_error("Failed to decode video frame: bytesDecoded < 0");
471 ++ throw logic_error("Failed to decode video frame: avcodec_send_packet() < 0");
472 + }
473 +
474 +- return frameFinished > 0;
475 ++ rc = avcodec_receive_frame(m_pVideoCodecContext, m_pFrame);
476 ++ switch(rc)
477 ++ {
478 ++ case 0:
479 ++ return true;
480 ++
481 ++ case AVERROR(EAGAIN):
482 ++ return false;
483 ++
484 ++ default:
485 ++ throw logic_error("Failed to decode video frame: avcodec_receive_frame() < 0");
486 ++ }
487 + }
488 +
489 + bool MovieDecoder::getVideoPacket()
490 +@@ -574,6 +590,7 @@ bool MovieDecoder::getVideoPacket()
491 +
492 + m_pPacket = new AVPacket();
493 +
494 ++
495 + while (framesAvailable && !frameDecoded)
496 + {
497 + framesAvailable = av_read_frame(m_pFormatContext, m_pPacket) >= 0;