You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/media-video/ffmpegthumbnailer/files/ffmpeg5-8.patch

55 lines
1.9 KiB

From 3ffdd65cbda6ef21d36c96013db1b0f4dc9fc57b Mon Sep 17 00:00:00 2001
From: Zane van Iperen <zane@zanevaniperen.com>
Date: Mon, 15 Mar 2021 17:52:01 +1000
Subject: [PATCH] lib/movedecoder: don't rely on avformat to allocate a context
---
libffmpegthumbnailer/moviedecoder.cpp | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/libffmpegthumbnailer/moviedecoder.cpp b/libffmpegthumbnailer/moviedecoder.cpp
index e58904e..da5f32a 100644
--- a/libffmpegthumbnailer/moviedecoder.cpp
+++ b/libffmpegthumbnailer/moviedecoder.cpp
@@ -90,8 +90,7 @@ void MovieDecoder::destroy()
{
if (m_pVideoCodecContext)
{
- avcodec_close(m_pVideoCodecContext);
- m_pVideoCodecContext = nullptr;
+ avcodec_free_context(&m_pVideoCodecContext);
}
if ((!m_FormatContextWasGiven) && m_pFormatContext)
@@ -196,8 +195,7 @@ void MovieDecoder::initializeVideo(bool preferEmbeddedMetadata)
}
m_pVideoStream = m_pFormatContext->streams[m_VideoStream];
- m_pVideoCodecContext = m_pVideoStream->codec;
- m_pVideoCodec = avcodec_find_decoder(m_pVideoCodecContext->codec_id);
+ m_pVideoCodec = avcodec_find_decoder(m_pVideoStream->codecpar->codec_id);
if (m_pVideoCodec == nullptr)
{
@@ -207,6 +205,20 @@ void MovieDecoder::initializeVideo(bool preferEmbeddedMetadata)
throw logic_error("Video Codec not found");
}
+ m_pVideoCodecContext = avcodec_alloc_context3(m_pVideoCodec);
+
+ if (m_pVideoCodecContext == nullptr)
+ {
+ destroy();
+ throw logic_error("Could not allocate video codec context");
+ }
+
+ if (avcodec_parameters_to_context(m_pVideoCodecContext, m_pVideoStream->codecpar) < 0)
+ {
+ destroy();
+ throw logic_error("Could not configure video codec context");
+ }
+
m_pVideoCodecContext->workaround_bugs = 1;
if (avcodec_open2(m_pVideoCodecContext, m_pVideoCodec, nullptr) < 0)