From 313d1d5d8379ce8c0763f43775e767832942a7ef Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Wed, 15 Jan 2014 11:13:50 +0100
Subject: [PATCH] decoder/ffmpeg: support libav v10_alpha1

---
 NEWS                                |  2 ++
 src/decoder/FfmpegDecoderPlugin.cxx | 12 +++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 731aa6bb4..a9c711e9c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,6 @@
 ver 0.18.8 (not yet released)
+* decoder
+  - ffmpeg: support libav v10_alpha1
 
 ver 0.18.7 (2013/01/13)
 * playlist
diff --git a/src/decoder/FfmpegDecoderPlugin.cxx b/src/decoder/FfmpegDecoderPlugin.cxx
index 1876425e2..593f42d39 100644
--- a/src/decoder/FfmpegDecoderPlugin.cxx
+++ b/src/decoder/FfmpegDecoderPlugin.cxx
@@ -38,6 +38,10 @@ extern "C" {
 #include <libavutil/avutil.h>
 #include <libavutil/log.h>
 #include <libavutil/mathematics.h>
+
+#if LIBAVUTIL_VERSION_MAJOR >= 53
+#include <libavutil/frame.h>
+#endif
 }
 
 #include <assert.h>
@@ -453,7 +457,11 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
 	decoder_initialized(decoder, audio_format,
 			    input.seekable, total_time);
 
+#if LIBAVUTIL_VERSION_MAJOR >= 53
+	AVFrame *frame = av_frame_alloc();
+#else
 	AVFrame *frame = avcodec_alloc_frame();
+#endif
 	if (!frame) {
 		LogError(ffmpeg_domain, "Could not allocate frame");
 		avformat_close_input(&format_context);
@@ -497,7 +505,9 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
 		}
 	} while (cmd != DecoderCommand::STOP);
 
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
+#if LIBAVUTIL_VERSION_MAJOR >= 53
+	av_frame_free(&frame);
+#elif LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 28, 0)
 	avcodec_free_frame(&frame);
 #else
 	av_freep(&frame);