summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorMichael Maltese <michaeljosephmaltese@gmail.com>2017-01-02 16:45:20 -0800
committerMichael Maltese <michaeljosephmaltese@gmail.com>2017-02-06 20:23:37 -0800
commitac214190fd4fb720a3e26bda2bb30bb2c2124ddb (patch)
tree8280cefa92da04f3d39d558700d74edfa82b23a9 /Source/Core/VideoCommon
parentbdf09c7d3bc5a22b562ce0f51400090b13ea8879 (diff)
AVIDump: Replace deprecated avcodec_encode_video2
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/AVIDump.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/Source/Core/VideoCommon/AVIDump.cpp b/Source/Core/VideoCommon/AVIDump.cpp
index 6e26d3a99f..c231e4facb 100644
--- a/Source/Core/VideoCommon/AVIDump.cpp
+++ b/Source/Core/VideoCommon/AVIDump.cpp
@@ -168,6 +168,37 @@ static void PreparePacket(AVPacket* pkt)
pkt->size = 0;
}
+static int ReceivePacket(AVCodecContext* avctx, AVPacket* pkt, int* got_packet)
+{
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100)
+ return avcodec_encode_video2(avctx, pkt, nullptr, got_packet);
+#else
+ *got_packet = 0;
+ int error = avcodec_receive_packet(avctx, pkt);
+ if (!error)
+ *got_packet = 1;
+ if (error == AVERROR(EAGAIN))
+ return 0;
+
+ return error;
+#endif
+}
+
+static int SendFrameAndReceivePacket(AVCodecContext* avctx, AVPacket* pkt, AVFrame* frame,
+ int* got_packet)
+{
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 37, 100)
+ return avcodec_encode_video2(avctx, pkt, frame, got_packet);
+#else
+ *got_packet = 0;
+ int error = avcodec_send_frame(avctx, frame);
+ if (error)
+ return error;
+
+ return ReceivePacket(avctx, pkt, got_packet);
+#endif
+}
+
void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const Frame& state)
{
// Assume that the timing is valid, if the savestate id of the new frame
@@ -226,7 +257,7 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const
{
s_last_frame = state.ticks;
s_last_pts = pts_in_ticks;
- error = avcodec_encode_video2(s_stream->codec, &pkt, s_scaled_frame, &got_packet);
+ error = SendFrameAndReceivePacket(s_stream->codec, &pkt, s_scaled_frame, &got_packet);
}
while (!error && got_packet)
{
@@ -248,7 +279,7 @@ void AVIDump::AddFrame(const u8* data, int width, int height, int stride, const
// Handle delayed frames.
PreparePacket(&pkt);
- error = avcodec_encode_video2(s_stream->codec, &pkt, nullptr, &got_packet);
+ error = ReceivePacket(s_stream->codec, &pkt, &got_packet);
}
if (error)
ERROR_LOG(VIDEO, "Error while encoding video: %d", error);