Description: Replace deprecated FFmpeg API
Author: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Last-Update: <2015-11-02>

--- vdr-plugin-softhddevice-0.6.0+git20150324.orig/Todo
+++ vdr-plugin-softhddevice-0.6.0+git20150324/Todo
@@ -43,7 +43,6 @@ video:
     check start with 24Hz display rate
     crash with ffmpeg without vaapi and vdpau.
     still-picture of PES recordings should use VideoMpegEnqueue.
-    convert PIX_FMT_... PixelFormat to new names AV_PIX_FMT_..., AVPixelFormat.
     atmo service support 3D grab
     no warnings during still picture
 
--- vdr-plugin-softhddevice-0.6.0+git20150324.orig/codec.c
+++ vdr-plugin-softhddevice-0.6.0+git20150324/codec.c
@@ -134,7 +134,7 @@ struct _video_decoder_
 //----------------------------------------------------------------------------
 
 /**
-**	Callback to negotiate the PixelFormat.
+**	Callback to negotiate the AVPixelFormat.
 **
 **	@param video_ctx	codec context
 **	@param fmt		is the list of formats which are supported by
@@ -142,8 +142,8 @@ struct _video_decoder_
 **				valid format, the formats are ordered by
 **				quality.
 */
-static enum PixelFormat Codec_get_format(AVCodecContext * video_ctx,
-    const enum PixelFormat *fmt)
+static enum AVPixelFormat Codec_get_format(AVCodecContext * video_ctx,
+    const enum AVPixelFormat *fmt)
 {
     VideoDecoder *decoder;
 
@@ -170,6 +170,8 @@ static enum PixelFormat Codec_get_format
     return Video_get_format(decoder->HwDecoder, video_ctx, fmt);
 }
 
+static void Codec_free_buffer(void *opaque, uint8_t *data);
+
 /**
 **	Video buffer management, get buffer for frame.
 **
@@ -178,7 +180,7 @@ static enum PixelFormat Codec_get_format
 **	@param video_ctx	Codec context
 **	@param frame		Get buffer for this frame
 */
-static int Codec_get_buffer(AVCodecContext * video_ctx, AVFrame * frame)
+static int Codec_get_buffer2(AVCodecContext * video_ctx, AVFrame * frame, int flags)
 {
     VideoDecoder *decoder;
 
@@ -188,19 +190,19 @@ static int Codec_get_buffer(AVCodecConte
     // libav 0.8.5 53.35.0 still needs this
 #endif
     if (!decoder->GetFormatDone) {	// get_format missing
-	enum PixelFormat fmts[2];
+	enum AVPixelFormat fmts[2];
 
 	fprintf(stderr, "codec: buggy libav, use ffmpeg\n");
 	Warning(_("codec: buggy libav, use ffmpeg\n"));
 	fmts[0] = video_ctx->pix_fmt;
-	fmts[1] = PIX_FMT_NONE;
+	fmts[1] = AV_PIX_FMT_NONE;
 	Codec_get_format(video_ctx, fmts);
     }
 #ifdef USE_VDPAU
-    // VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
-    if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
-	    && video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
-	|| video_ctx->pix_fmt == PIX_FMT_VDPAU_MPEG4) {
+    // VDPAU: AV_PIX_FMT_VDPAU_H264 .. AV_PIX_FMT_VDPAU_VC1 AV_PIX_FMT_VDPAU_MPEG4
+    if ((AV_PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
+	    && video_ctx->pix_fmt <= AV_PIX_FMT_VDPAU_VC1)
+	|| video_ctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG4) {
 	unsigned surface;
 	struct vdpau_render_state *vrs;
 
@@ -217,7 +219,8 @@ static int Codec_get_buffer(AVCodecConte
 	frame->age = 256 * 256 * 256 * 64;
 #endif
 	// render
-	frame->data[0] = (void *)vrs;
+	frame->buf[0] = av_buffer_create((uint8_t*)vrs, 0, Codec_free_buffer, video_ctx, 0);
+	frame->data[0] = frame->buf[0]->data;
 	frame->data[1] = NULL;
 	frame->data[2] = NULL;
 	frame->data[3] = NULL;
@@ -248,8 +251,9 @@ static int Codec_get_buffer(AVCodecConte
 	frame->age = 256 * 256 * 256 * 64;
 #endif
 	// vaapi needs both fields set
-	frame->data[0] = (void *)(size_t) surface;
-	frame->data[3] = (void *)(size_t) surface;
+	frame->buf[0] = av_buffer_create((uint8_t*)(size_t)surface, 0, Codec_free_buffer, video_ctx, 0);
+	frame->data[0] = frame->buf[0]->data;
+	frame->data[3] = frame->data[0];
 
 #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(52,66,100)
 	// reordered frames
@@ -262,29 +266,30 @@ static int Codec_get_buffer(AVCodecConte
 	return 0;
     }
     //Debug(3, "codec: fallback to default get_buffer\n");
-    return avcodec_default_get_buffer(video_ctx, frame);
+    return avcodec_default_get_buffer2(video_ctx, frame, flags);
 }
 
 /**
 **	Video buffer management, release buffer for frame.
 **	Called to release buffers which were allocated with get_buffer.
 **
-**	@param video_ctx	Codec context
-**	@param frame		Release buffer for this frame
+**	@param opaque	opaque data
+**	@param data		buffer data
 */
-static void Codec_release_buffer(AVCodecContext * video_ctx, AVFrame * frame)
+static void Codec_free_buffer(void *opaque, uint8_t *data)
 {
+    AVCodecContext *video_ctx = (AVCodecContext *)opaque;
 #ifdef USE_VDPAU
-    // VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
-    if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
-	    && video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
-	|| video_ctx->pix_fmt == PIX_FMT_VDPAU_MPEG4) {
+    // VDPAU: AV_PIX_FMT_VDPAU_H264 .. AV_PIX_FMT_VDPAU_VC1 AV_PIX_FMT_VDPAU_MPEG4
+    if ((AV_PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
+	    && video_ctx->pix_fmt <= AV_PIX_FMT_VDPAU_VC1)
+	|| video_ctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG4) {
 	VideoDecoder *decoder;
 	struct vdpau_render_state *vrs;
 	unsigned surface;
 
 	decoder = video_ctx->opaque;
-	vrs = (struct vdpau_render_state *)frame->data[0];
+	vrs = (struct vdpau_render_state *)data;
 	surface = vrs->surface;
 
 	//Debug(3, "codec: release surface %#010x\n", surface);
@@ -292,7 +297,7 @@ static void Codec_release_buffer(AVCodec
 
 	av_freep(&vrs->bitstream_buffers);
 	vrs->bitstream_buffers_allocated = 0;
-	av_freep(&frame->data[0]);
+	av_freep(&data);
 
 	return;
     }
@@ -303,18 +308,13 @@ static void Codec_release_buffer(AVCodec
 	unsigned surface;
 
 	decoder = video_ctx->opaque;
-	surface = (unsigned)(size_t) frame->data[3];
+	surface = (unsigned)(size_t) data;
 
 	//Debug(3, "codec: release surface %#010x\n", surface);
 	VideoReleaseSurface(decoder->HwDecoder, surface);
 
-	frame->data[0] = NULL;
-	frame->data[3] = NULL;
-
 	return;
     }
-    //Debug(3, "codec: fallback to default release_buffer\n");
-    return avcodec_default_release_buffer(video_ctx, frame);
 }
 
 /// libav: compatibility hack
@@ -341,10 +341,10 @@ static void Codec_draw_horiz_band(AVCode
     int height)
 {
 #ifdef USE_VDPAU
-    // VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
-    if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
-	    && video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
-	|| video_ctx->pix_fmt == PIX_FMT_VDPAU_MPEG4) {
+    // VDPAU: AV_PIX_FMT_VDPAU_H264 .. AV_PIX_FMT_VDPAU_VC1 AV_PIX_FMT_VDPAU_MPEG4
+    if ((AV_PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
+	    && video_ctx->pix_fmt <= AV_PIX_FMT_VDPAU_VC1)
+	|| video_ctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG4) {
 	VideoDecoder *decoder;
 	struct vdpau_render_state *vrs;
 
@@ -489,9 +489,7 @@ void CodecVideoOpen(VideoDecoder * decod
     if (video_codec->capabilities & CODEC_CAP_HWACCEL_VDPAU) {
 	// FIXME: get_format never called.
 	decoder->VideoCtx->get_format = Codec_get_format;
-	decoder->VideoCtx->get_buffer = Codec_get_buffer;
-	decoder->VideoCtx->release_buffer = Codec_release_buffer;
-	decoder->VideoCtx->reget_buffer = Codec_get_buffer;
+	decoder->VideoCtx->get_buffer2 = Codec_get_buffer2;
 	decoder->VideoCtx->draw_horiz_band = Codec_draw_horiz_band;
 	decoder->VideoCtx->slice_flags =
 	    SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
@@ -506,9 +504,7 @@ void CodecVideoOpen(VideoDecoder * decod
     // our pixel format video hardware decoder hook
     if (decoder->VideoCtx->hwaccel_context) {
 	decoder->VideoCtx->get_format = Codec_get_format;
-	decoder->VideoCtx->get_buffer = Codec_get_buffer;
-	decoder->VideoCtx->release_buffer = Codec_release_buffer;
-	decoder->VideoCtx->reget_buffer = Codec_get_buffer;
+	decoder->VideoCtx->get_buffer2 = Codec_get_buffer2;
 #if 0
 	decoder->VideoCtx->thread_count = 1;
 	decoder->VideoCtx->draw_horiz_band = NULL;
@@ -520,7 +516,7 @@ void CodecVideoOpen(VideoDecoder * decod
     //
     //	Prepare frame buffer for decoder
     //
-    if (!(decoder->Frame = avcodec_alloc_frame())) {
+    if (!(decoder->Frame = av_frame_alloc())) {
 	Fatal(_("codec: can't allocate decoder frame\n"));
     }
     // reset buggy ffmpeg/libav flag
@@ -535,7 +531,7 @@ void CodecVideoOpen(VideoDecoder * decod
 void CodecVideoClose(VideoDecoder * video_decoder)
 {
     // FIXME: play buffered data
-    av_freep(&video_decoder->Frame);
+    av_frame_free(&video_decoder->Frame);
     if (video_decoder->VideoCtx) {
 	pthread_mutex_lock(&CodecLockMutex);
 	avcodec_close(video_decoder->VideoCtx);
@@ -681,7 +677,7 @@ struct _audio_decoder_
     int HwSampleRate;			///< hw sample rate
     int HwChannels;			///< hw channels
 
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
     AVFrame *Frame;			///< decoded audio frame buffer
 #endif
 
@@ -761,7 +757,7 @@ AudioDecoder *CodecAudioNewDecoder(void)
     if (!(audio_decoder = calloc(1, sizeof(*audio_decoder)))) {
 	Fatal(_("codec: can't allocate audio decoder\n"));
     }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
     if (!(audio_decoder->Frame = av_frame_alloc())) {
 	Fatal(_("codec: can't allocate audio decoder frame buffer\n"));
     }
@@ -777,7 +773,7 @@ AudioDecoder *CodecAudioNewDecoder(void)
 */
 void CodecAudioDelDecoder(AudioDecoder * decoder)
 {
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
     av_frame_free(&decoder->Frame);	// callee does checks
 #endif
     free(decoder);
@@ -1803,7 +1799,7 @@ void CodecAudioDecode(AudioDecoder * aud
 {
     AVCodecContext *audio_ctx;
 
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,28,1)
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
     AVFrame frame[1];
 #else
     AVFrame *frame;
@@ -1816,12 +1812,12 @@ void CodecAudioDecode(AudioDecoder * aud
     // FIXME: don't need to decode pass-through codecs
 
     // new AVFrame API
-#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,28,1)
+#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
     avcodec_get_frame_defaults(frame);
 #else
     frame = audio_decoder->Frame;
-    av_frame_unref(frame);
 #endif
+    av_frame_unref(frame);
 
     got_frame = 0;
     n = avcodec_decode_audio4(audio_ctx, frame, &got_frame,
--- vdr-plugin-softhddevice-0.6.0+git20150324.orig/video.c
+++ vdr-plugin-softhddevice-0.6.0+git20150324/video.c
@@ -259,8 +259,8 @@ typedef struct _video_module_
     void (*const DelHwDecoder) (VideoHwDecoder *);
     unsigned (*const GetSurface) (VideoHwDecoder *, const AVCodecContext *);
     void (*const ReleaseSurface) (VideoHwDecoder *, unsigned);
-    enum PixelFormat (*const get_format) (VideoHwDecoder *, AVCodecContext *,
-	const enum PixelFormat *);
+    enum AVPixelFormat (*const get_format) (VideoHwDecoder *, AVCodecContext *,
+	const enum AVPixelFormat *);
     void (*const RenderFrame) (VideoHwDecoder *, const AVCodecContext *,
 	const AVFrame *);
     void *(*const GetHwAccelContext)(VideoHwDecoder *);
@@ -1522,7 +1522,7 @@ struct _vaapi_decoder_
     /// flags for put surface for different resolutions groups
     unsigned SurfaceFlagsTable[VideoResolutionMax];
 
-    enum PixelFormat PixFmt;		///< ffmpeg frame pixfmt
+    enum AVPixelFormat PixFmt;		///< ffmpeg frame pixfmt
     int WrongInterlacedWarned;		///< warning about interlace flag issued
     int Interlaced;			///< ffmpeg interlaced flag
     int TopFieldFirst;			///< ffmpeg top field displayed first
@@ -2026,7 +2026,7 @@ static VaapiDecoder *VaapiNewHwDecoder(V
     decoder->OutputWidth = VideoWindowWidth;
     decoder->OutputHeight = VideoWindowHeight;
 
-    decoder->PixFmt = PIX_FMT_NONE;
+    decoder->PixFmt = AV_PIX_FMT_NONE;
 
     decoder->Stream = stream;
     if (!VaapiDecoderN) {		// FIXME: hack sync on audio
@@ -2517,7 +2517,7 @@ static void VaapiUpdateOutput(VaapiDecod
 ///	FIXME: must check if put/get with this format is supported (see intel)
 ///
 static int VaapiFindImageFormat(VaapiDecoder * decoder,
-    enum PixelFormat pix_fmt, VAImageFormat * format)
+    enum AVPixelFormat pix_fmt, VAImageFormat * format)
 {
     VAImageFormat *imgfrmts;
     int imgfrmt_n;
@@ -2528,12 +2528,12 @@ static int VaapiFindImageFormat(VaapiDec
 	    // NV12, YV12, I420, BGRA
 	    // intel: I420 is native format for MPEG-2 decoded surfaces
 	    // intel: NV12 is native format for H.264 decoded surfaces
-	case PIX_FMT_YUV420P:
-	case PIX_FMT_YUVJ420P:
+	case AV_PIX_FMT_YUV420P:
+	case AV_PIX_FMT_YUVJ420P:
 	    // fourcc = VA_FOURCC_YV12; // YVU
 	    fourcc = VA_FOURCC('I', '4', '2', '0');	// YUV
 	    break;
-	case PIX_FMT_NV12:
+	case AV_PIX_FMT_NV12:
 	    fourcc = VA_FOURCC_NV12;
 	    break;
 	default:
@@ -2602,7 +2602,7 @@ static void VaapiSetup(VaapiDecoder * de
 #endif
     // FIXME: PixFmt not set!
     //VaapiFindImageFormat(decoder, decoder->PixFmt, format);
-    VaapiFindImageFormat(decoder, PIX_FMT_NV12, format);
+    VaapiFindImageFormat(decoder, AV_PIX_FMT_NV12, format);
 
     // FIXME: this image is only needed for software decoder and auto-crop
     if (decoder->GetPutImage
@@ -2872,7 +2872,7 @@ static VAEntrypoint VaapiFindEntrypoint(
 }
 
 ///
-///	Callback to negotiate the PixelFormat.
+///	Callback to negotiate the AVPixelFormat.
 ///
 ///	@param fmt	is the list of formats which are supported by the codec,
 ///			it is terminated by -1 as 0 is a valid format, the
@@ -2880,10 +2880,10 @@ static VAEntrypoint VaapiFindEntrypoint(
 ///
 ///	@note + 2 surface for software deinterlace
 ///
-static enum PixelFormat Vaapi_get_format(VaapiDecoder * decoder,
-    AVCodecContext * video_ctx, const enum PixelFormat *fmt)
+static enum AVPixelFormat Vaapi_get_format(VaapiDecoder * decoder,
+    AVCodecContext * video_ctx, const enum AVPixelFormat *fmt)
 {
-    const enum PixelFormat *fmt_idx;
+    const enum AVPixelFormat *fmt_idx;
     VAProfile profiles[vaMaxNumProfiles(VaDisplay)];
     int profile_n;
     VAEntrypoint entrypoints[vaMaxNumEntrypoints(VaDisplay)];
@@ -2967,16 +2967,16 @@ static enum PixelFormat Vaapi_get_format
     }
     Debug(3, "codec: %d entrypoints\n", entrypoint_n);
     //	look through formats
-    for (fmt_idx = fmt; *fmt_idx != PIX_FMT_NONE; fmt_idx++) {
-	Debug(3, "\t%#010x %s\n", *fmt_idx, av_get_pix_fmt_name(*fmt_idx));
+    for (fmt_idx = fmt; *fmt_idx != AV_PIX_FMT_NONE; fmt_idx++) {
+	Debug(3, "\t%#010x %s\n", *fmt_idx, av_get_AV_PIX_FMT_name(*fmt_idx));
 	// check supported pixel format with entry point
 	switch (*fmt_idx) {
-	    case PIX_FMT_VAAPI_VLD:
+	    case AV_PIX_FMT_VAAPI_VLD:
 		e = VaapiFindEntrypoint(entrypoints, entrypoint_n,
 		    VAEntrypointVLD);
 		break;
-	    case PIX_FMT_VAAPI_MOCO:
-	    case PIX_FMT_VAAPI_IDCT:
+	    case AV_PIX_FMT_VAAPI_MOCO:
+	    case AV_PIX_FMT_VAAPI_IDCT:
 		Debug(3, "codec: this VA-API pixel format is not supported\n");
 	    default:
 		continue;
@@ -3052,7 +3052,7 @@ static enum PixelFormat Vaapi_get_format
     }
 #endif
 
-    Debug(3, "\t%#010x %s\n", fmt_idx[0], av_get_pix_fmt_name(fmt_idx[0]));
+    Debug(3, "\t%#010x %s\n", fmt_idx[0], av_get_AV_PIX_FMT_name(fmt_idx[0]));
     return *fmt_idx;
 
   slow_path:
@@ -3061,7 +3061,7 @@ static enum PixelFormat Vaapi_get_format
     decoder->Entrypoint = VA_INVALID_ID;
     decoder->VaapiContext->config_id = VA_INVALID_ID;
     decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 2;
-    decoder->PixFmt = PIX_FMT_NONE;
+    decoder->PixFmt = AV_PIX_FMT_NONE;
 
     decoder->InputWidth = 0;
     decoder->InputHeight = 0;
@@ -3262,8 +3262,8 @@ static void VaapiAutoCrop(VaapiDecoder *
 
 	// FIXME: PixFmt not set!
 	//VaapiFindImageFormat(decoder, decoder->PixFmt, format);
-	VaapiFindImageFormat(decoder, PIX_FMT_NV12, format);
-	//VaapiFindImageFormat(decoder, PIX_FMT_YUV420P, format);
+	VaapiFindImageFormat(decoder, AV_PIX_FMT_NV12, format);
+	//VaapiFindImageFormat(decoder, AV_PIX_FMT_YUV420P, format);
 	if (vaCreateImage(VaDisplay, format, width, height,
 		decoder->Image) != VA_STATUS_SUCCESS) {
 	    Error(_("video/vaapi: can't create image!\n"));
@@ -3618,7 +3618,7 @@ static void VaapiBlackSurface(VaapiDecod
 	if (decoder->Image->image_id == VA_INVALID_ID) {
 	    VAImageFormat format[1];
 
-	    VaapiFindImageFormat(decoder, PIX_FMT_NV12, format);
+	    VaapiFindImageFormat(decoder, AV_PIX_FMT_NV12, format);
 	    status =
 		vaCreateImage(VaDisplay, format, VideoWindowWidth,
 		VideoWindowHeight, decoder->Image);
@@ -4263,8 +4263,8 @@ static void VaapiCreateDeinterlaceImages
     // I420 Y U V 2x2
 
     // Intel needs NV12
-    VaapiFindImageFormat(decoder, PIX_FMT_NV12, format);
-    //VaapiFindImageFormat(decoder, PIX_FMT_YUV420P, format);
+    VaapiFindImageFormat(decoder, AV_PIX_FMT_NV12, format);
+    //VaapiFindImageFormat(decoder, AV_PIX_FMT_YUV420P, format);
     for (i = 0; i < 5; ++i) {
 	if (vaCreateImage(decoder->VaDisplay, format, decoder->InputWidth,
 		decoder->InputHeight,
@@ -4336,7 +4336,7 @@ static void VaapiCpuDerive(VaapiDecoder
     if (decoder->Image->image_id == VA_INVALID_ID) {
 	VAImageFormat format[1];
 
-	VaapiFindImageFormat(decoder, PIX_FMT_NV12, format);
+	VaapiFindImageFormat(decoder, AV_PIX_FMT_NV12, format);
 	if (vaCreateImage(VaDisplay, format, decoder->InputWidth,
 		decoder->InputHeight, decoder->Image) != VA_STATUS_SUCCESS) {
 	    Error(_("video/vaapi: can't create image!\n"));
@@ -5628,8 +5628,8 @@ static const VideoModule VaapiModule = {
 	    const AVCodecContext *))VaapiGetSurface,
     .ReleaseSurface =
 	(void (*const) (VideoHwDecoder *, unsigned))VaapiReleaseSurface,
-    .get_format = (enum PixelFormat(*const) (VideoHwDecoder *,
-	    AVCodecContext *, const enum PixelFormat *))Vaapi_get_format,
+    .get_format = (enum AVPixelFormat(*const) (VideoHwDecoder *,
+	    AVCodecContext *, const enum AVPixelFormat *))Vaapi_get_format,
     .RenderFrame = (void (*const) (VideoHwDecoder *,
 	    const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame,
     .GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
@@ -5670,8 +5670,8 @@ static const VideoModule VaapiGlxModule
 	    const AVCodecContext *))VaapiGetSurface,
     .ReleaseSurface =
 	(void (*const) (VideoHwDecoder *, unsigned))VaapiReleaseSurface,
-    .get_format = (enum PixelFormat(*const) (VideoHwDecoder *,
-	    AVCodecContext *, const enum PixelFormat *))Vaapi_get_format,
+    .get_format = (enum AVPixelFormat(*const) (VideoHwDecoder *,
+	    AVCodecContext *, const enum AVPixelFormat *))Vaapi_get_format,
     .RenderFrame = (void (*const) (VideoHwDecoder *,
 	    const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame,
     .GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
@@ -5726,7 +5726,7 @@ typedef struct _vdpau_decoder_
     int OutputWidth;			///< real video output width
     int OutputHeight;			///< real video output height
 
-    enum PixelFormat PixFmt;		///< ffmpeg frame pixfmt
+    enum AVPixelFormat PixFmt;		///< ffmpeg frame pixfmt
     int WrongInterlacedWarned;		///< warning about interlace flag issued
     int Interlaced;			///< ffmpeg interlaced flag
     int TopFieldFirst;			///< ffmpeg top field displayed first
@@ -6455,7 +6455,7 @@ static VdpauDecoder *VdpauNewHwDecoder(V
     decoder->OutputWidth = VideoWindowWidth;
     decoder->OutputHeight = VideoWindowHeight;
 
-    decoder->PixFmt = PIX_FMT_NONE;
+    decoder->PixFmt = AV_PIX_FMT_NONE;
 
 #ifdef USE_AUTOCROP
     //decoder->AutoCropBuffer = NULL;	// done by calloc
@@ -7300,16 +7300,16 @@ static VdpDecoderProfile VdpauCheckProfi
 }
 
 ///
-///	Callback to negotiate the PixelFormat.
+///	Callback to negotiate the AVPixelFormat.
 ///
 ///	@param fmt	is the list of formats which are supported by the codec,
 ///			it is terminated by -1 as 0 is a valid format, the
 ///			formats are ordered by quality.
 ///
-static enum PixelFormat Vdpau_get_format(VdpauDecoder * decoder,
-    AVCodecContext * video_ctx, const enum PixelFormat *fmt)
+static enum AVPixelFormat Vdpau_get_format(VdpauDecoder * decoder,
+    AVCodecContext * video_ctx, const enum AVPixelFormat *fmt)
 {
-    const enum PixelFormat *fmt_idx;
+    const enum AVPixelFormat *fmt_idx;
     VdpDecoderProfile profile;
     int max_refs;
 
@@ -7323,16 +7323,16 @@ static enum PixelFormat Vdpau_get_format
     //	look through formats
     //
     Debug(3, "%s: codec %d fmts:\n", __FUNCTION__, video_ctx->codec_id);
-    for (fmt_idx = fmt; *fmt_idx != PIX_FMT_NONE; fmt_idx++) {
-	Debug(3, "\t%#010x %s\n", *fmt_idx, av_get_pix_fmt_name(*fmt_idx));
+    for (fmt_idx = fmt; *fmt_idx != AV_PIX_FMT_NONE; fmt_idx++) {
+	Debug(3, "\t%#010x %s\n", *fmt_idx, av_get_AV_PIX_FMT_name(*fmt_idx));
 	// check supported pixel format with entry point
 	switch (*fmt_idx) {
-	    case PIX_FMT_VDPAU_H264:
-	    case PIX_FMT_VDPAU_MPEG1:
-	    case PIX_FMT_VDPAU_MPEG2:
-	    case PIX_FMT_VDPAU_WMV3:
-	    case PIX_FMT_VDPAU_VC1:
-	    case PIX_FMT_VDPAU_MPEG4:
+	    case AV_PIX_FMT_VDPAU_H264:
+	    case AV_PIX_FMT_VDPAU_MPEG1:
+	    case AV_PIX_FMT_VDPAU_MPEG2:
+	    case AV_PIX_FMT_VDPAU_WMV3:
+	    case AV_PIX_FMT_VDPAU_VC1:
+	    case AV_PIX_FMT_VDPAU_MPEG4:
 		break;
 	    default:
 		continue;
@@ -7340,7 +7340,7 @@ static enum PixelFormat Vdpau_get_format
 	break;
     }
 
-    if (*fmt_idx == PIX_FMT_NONE) {
+    if (*fmt_idx == AV_PIX_FMT_NONE) {
 	Error(_("video/vdpau: no valid vdpau pixfmt found\n"));
 	goto slow_path;
     }
@@ -7447,14 +7447,14 @@ static enum PixelFormat Vdpau_get_format
     }
 #endif
 
-    Debug(3, "\t%#010x %s\n", fmt_idx[0], av_get_pix_fmt_name(fmt_idx[0]));
+    Debug(3, "\t%#010x %s\n", fmt_idx[0], av_get_AV_PIX_FMT_name(fmt_idx[0]));
     return *fmt_idx;
 
   slow_path:
     // no accelerated format found
     decoder->Profile = VDP_INVALID_HANDLE;
     decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 2;
-    decoder->PixFmt = PIX_FMT_NONE;
+    decoder->PixFmt = AV_PIX_FMT_NONE;
 
     decoder->InputWidth = 0;
     decoder->InputHeight = 0;
@@ -8040,10 +8040,10 @@ static void VdpauRenderFrame(VdpauDecode
     //
     // Hardware render
     //
-    // VDPAU: PIX_FMT_VDPAU_H264 .. PIX_FMT_VDPAU_VC1 PIX_FMT_VDPAU_MPEG4
-    if ((PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
-	    && video_ctx->pix_fmt <= PIX_FMT_VDPAU_VC1)
-	|| video_ctx->pix_fmt == PIX_FMT_VDPAU_MPEG4) {
+    // VDPAU: AV_PIX_FMT_VDPAU_H264 .. AV_PIX_FMT_VDPAU_VC1 AV_PIX_FMT_VDPAU_MPEG4
+    if ((AV_PIX_FMT_VDPAU_H264 <= video_ctx->pix_fmt
+	    && video_ctx->pix_fmt <= AV_PIX_FMT_VDPAU_VC1)
+	|| video_ctx->pix_fmt == AV_PIX_FMT_VDPAU_MPEG4) {
 	struct vdpau_render_state *vrs;
 
 	vrs = (struct vdpau_render_state *)frame->data[0];
@@ -8086,11 +8086,11 @@ static void VdpauRenderFrame(VdpauDecode
 	//	Copy data from frame to image
 	//
 	switch (video_ctx->pix_fmt) {
-	    case PIX_FMT_YUV420P:
-	    case PIX_FMT_YUVJ420P:	// some streams produce this
+	    case AV_PIX_FMT_YUV420P:
+	    case AV_PIX_FMT_YUVJ420P:	// some streams produce this
 		break;
-	    case PIX_FMT_YUV422P:
-	    case PIX_FMT_YUV444P:
+	    case AV_PIX_FMT_YUV422P:
+	    case AV_PIX_FMT_YUV444P:
 	    default:
 		Fatal(_("video/vdpau: pixel format %d not supported\n"),
 		    video_ctx->pix_fmt);
@@ -9415,8 +9415,8 @@ static const VideoModule VdpauModule = {
 	    const AVCodecContext *))VdpauGetSurface,
     .ReleaseSurface =
 	(void (*const) (VideoHwDecoder *, unsigned))VdpauReleaseSurface,
-    .get_format = (enum PixelFormat(*const) (VideoHwDecoder *,
-	    AVCodecContext *, const enum PixelFormat *))Vdpau_get_format,
+    .get_format = (enum AVPixelFormat(*const) (VideoHwDecoder *,
+	    AVCodecContext *, const enum AVPixelFormat *))Vdpau_get_format,
     .RenderFrame = (void (*const) (VideoHwDecoder *,
 	    const AVCodecContext *, const AVFrame *))VdpauSyncRenderFrame,
     .GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
@@ -9576,8 +9576,8 @@ static const VideoModule NoopModule = {
 #endif
     .ReleaseSurface = NoopReleaseSurface,
 #if 0
-    .get_format = (enum PixelFormat(*const) (VideoHwDecoder *,
-	    AVCodecContext *, const enum PixelFormat *))Noop_get_format,
+    .get_format = (enum AVPixelFormat(*const) (VideoHwDecoder *,
+	    AVCodecContext *, const enum AVPixelFormat *))Noop_get_format,
     .RenderFrame = (void (*const) (VideoHwDecoder *,
 	    const AVCodecContext *, const AVFrame *))NoopSyncRenderFrame,
     .GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
@@ -9811,7 +9811,7 @@ static void VideoEvent(void)
 
 	case MapNotify:
 	    Debug(3, "video/event: MapNotify\n");
-	    // µwm workaround
+	    // \B5wm workaround
 	    VideoThreadLock();
 	    xcb_change_window_attributes(Connection, VideoWindow,
 		XCB_CW_CURSOR, &VideoBlankCursor);
@@ -10143,7 +10143,7 @@ void VideoReleaseSurface(VideoHwDecoder
 }
 
 ///
-///	Callback to negotiate the PixelFormat.
+///	Callback to negotiate the AVPixelFormat.
 ///
 ///	@param hw_decoder	video hardware decoder
 ///	@param video_ctx	ffmpeg video codec context
@@ -10152,8 +10152,8 @@ void VideoReleaseSurface(VideoHwDecoder
 ///				valid format, the formats are ordered by
 ///				quality.
 ///
-enum PixelFormat Video_get_format(VideoHwDecoder * hw_decoder,
-    AVCodecContext * video_ctx, const enum PixelFormat *fmt)
+enum AVPixelFormat Video_get_format(VideoHwDecoder * hw_decoder,
+    AVCodecContext * video_ctx, const enum AVPixelFormat *fmt)
 {
 #ifdef DEBUG
     int ms_delay;
--- vdr-plugin-softhddevice-0.6.0+git20150324.orig/video.h
+++ vdr-plugin-softhddevice-0.6.0+git20150324/video.h
@@ -59,9 +59,9 @@ extern unsigned VideoGetSurface(VideoHwD
     /// Release a video hardware surface
 extern void VideoReleaseSurface(VideoHwDecoder *, unsigned);
 
-    /// Callback to negotiate the PixelFormat.
-extern enum PixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *,
-    const enum PixelFormat *);
+    /// Callback to negotiate the AVPixelFormat.
+extern enum AVPixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *,
+    const enum AVPixelFormat *);
 
     /// Render a ffmpeg frame.
 extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *,
