summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon/FrameDump.cpp
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2021-05-17 20:38:39 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2021-11-02 13:50:21 +0100
commit7590f07b80d2ff994912675bc2e3689c5b69bd57 (patch)
treef23d6cd2beb62ed4b1b45980bd1d52f9e8ace8fc /Source/Core/VideoCommon/FrameDump.cpp
parent24db6e467a6560126c5e718e40735c62362d3246 (diff)
FrameDump: Remove deprecated call to av_init_packet()
This function was deprecated in ffmpeg in January[1], while its replacement got introduced in 2015[2], so now might be the time to start using it in Dolphin. :) [1] https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/f7db77bd8785d1715d3e7ed7e69bd1cc991f2d07 [2] https://git.ffmpeg.org/gitweb/ffmpeg.git/commit/a9a60106370f862e191dea58e748626da6a8fe97
Diffstat (limited to 'Source/Core/VideoCommon/FrameDump.cpp')
-rw-r--r--Source/Core/VideoCommon/FrameDump.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/Source/Core/VideoCommon/FrameDump.cpp b/Source/Core/VideoCommon/FrameDump.cpp
index ceba863b89..2773c0e0fe 100644
--- a/Source/Core/VideoCommon/FrameDump.cpp
+++ b/Source/Core/VideoCommon/FrameDump.cpp
@@ -333,12 +333,18 @@ void FrameDump::AddFrame(const FrameData& frame)
void FrameDump::ProcessPackets()
{
- while (true)
+ auto pkt = std::unique_ptr<AVPacket, std::function<void(AVPacket*)>>(
+ av_packet_alloc(), [](AVPacket* packet) { av_packet_free(&packet); });
+
+ if (!pkt)
{
- AVPacket pkt;
- av_init_packet(&pkt);
+ ERROR_LOG_FMT(FRAMEDUMP, "Could not allocate packet");
+ return;
+ }
- const int receive_error = avcodec_receive_packet(m_context->codec, &pkt);
+ while (true)
+ {
+ const int receive_error = avcodec_receive_packet(m_context->codec, pkt.get());
if (receive_error == AVERROR(EAGAIN) || receive_error == AVERROR_EOF)
{
@@ -352,10 +358,10 @@ void FrameDump::ProcessPackets()
break;
}
- av_packet_rescale_ts(&pkt, m_context->codec->time_base, m_context->stream->time_base);
- pkt.stream_index = m_context->stream->index;
+ av_packet_rescale_ts(pkt.get(), m_context->codec->time_base, m_context->stream->time_base);
+ pkt->stream_index = m_context->stream->index;
- if (const int write_error = av_interleaved_write_frame(m_context->format, &pkt))
+ if (const int write_error = av_interleaved_write_frame(m_context->format, pkt.get()))
{
ERROR_LOG_FMT(FRAMEDUMP, "Error writing packet: {}", write_error);
break;