File 0001-Port-vdpau-to-ffmpeg-3.0.patch of Package libmlt

From 55c64e0d74c37b84c5a0b46c2cb28cc0c73e523d Mon Sep 17 00:00:00 2001
From: "Dr. Robert Marmorstein" <robert@narnia.homeunix.com>
Date: Thu, 22 Dec 2016 15:18:13 -0500
Subject: [PATCH] Port vdpau to ffmpeg-3.0+

---
 src/modules/avformat/vdpau.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/src/modules/avformat/vdpau.c b/src/modules/avformat/vdpau.c
index 63b52b9b..cbe61daf 100644
--- a/src/modules/avformat/vdpau.c
+++ b/src/modules/avformat/vdpau.c
@@ -40,6 +40,8 @@ static VdpDecoderRender        *vdp_decoder_render;
 static int vdpau_init_done = 0;
 static int vdpau_supported = 1;
 
+static void vdpau_release_buffer( void *opaque, uint8_t *data);
+
 /** VDPAUD functions
 */
 
@@ -141,7 +143,7 @@ static enum AVPixelFormat vdpau_get_format( struct AVCodecContext *s, const enum
 	return AV_PIX_FMT_VDPAU_H264;
 }
 
-static int vdpau_get_buffer( AVCodecContext *codec_context, AVFrame *frame )
+static int vdpau_get_buffer( AVCodecContext *codec_context, AVFrame *frame, int flags )
 {
 	int error = 0;
 	producer_avformat self = codec_context->opaque;
@@ -159,10 +161,12 @@ static int vdpau_get_buffer( AVCodecContext *codec_context, AVFrame *frame )
 			frame->linesize[0] = 0;
 			frame->linesize[1] = 0;
 			frame->linesize[2] = 0;
-			frame->type = FF_BUFFER_TYPE_USER;
 			render->state = FF_VDPAU_STATE_USED_FOR_REFERENCE;
 			frame->reordered_opaque = codec_context->reordered_opaque;
-			if ( frame->reference )
+			frame->buf[0] = av_buffer_create(frame->data[0], frame->linesize[0], vdpau_release_buffer, self, flags );
+			frame->buf[1] = av_buffer_ref(frame->buf[0]);
+			frame->buf[2] = av_buffer_ref(frame->buf[0]);
+			if ( av_buffer_get_ref_count(frame->buf[0]))
 			{
 				self->vdpau->ip_age[0] = self->vdpau->ip_age[1] + 1;
 				self->vdpau->ip_age[1] = 1;
@@ -190,18 +194,15 @@ static int vdpau_get_buffer( AVCodecContext *codec_context, AVFrame *frame )
 	return error;
 }
 
-static void vdpau_release_buffer( AVCodecContext *codec_context, AVFrame *frame )
+static void vdpau_release_buffer( void *opaque, uint8_t *data)
 {
-	producer_avformat self = codec_context->opaque;
+	producer_avformat self = (producer_avformat)opaque;
 	if ( self->vdpau )
 	{
-		struct vdpau_render_state *render = (struct vdpau_render_state*) frame->data[0];
+		struct vdpau_render_state *render = (struct vdpau_render_state*) data;
 		mlt_log_debug( MLT_PRODUCER_SERVICE(self->parent), "vdpau_release_buffer (%x)\n", render->surface );
-		int i;
 
 		render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE;
-		for ( i = 0; i < 4; i++ )
-			frame->data[i] = NULL;
 		mlt_deque_push_back( self->vdpau->deque, render );
 	}
 }
@@ -236,8 +237,7 @@ static int vdpau_decoder_init( producer_avformat self )
 	
 	self->video_codec->opaque = self;
 	self->video_codec->get_format = vdpau_get_format;
-	self->video_codec->get_buffer = vdpau_get_buffer;
-	self->video_codec->release_buffer = vdpau_release_buffer;
+	self->video_codec->get_buffer2 = vdpau_get_buffer;
 	self->video_codec->draw_horiz_band = vdpau_draw_horiz;
 	self->video_codec->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
 	self->video_codec->pix_fmt = AV_PIX_FMT_VDPAU_H264;
-- 
2.11.0