diff --git a/video.c b/video.c index 2cbfa0e..0049850 100644 --- a/video.c +++ b/video.c @@ -152,6 +152,15 @@ typedef enum #include #include +#if LIBAVCODEC_VERSION_INT == AV_VERSION_INT(54,86,100) + /// + /// ffmpeg version 1.1.1 calls get_format with zero width and height + /// for H264 codecs. + /// since version 1.1.3 get_format is called twice. + /// +#define FFMPEG_BUG1_WORKAROUND ///< get_format bug workaround +#endif + #include "misc.h" #include "video.h" #include "audio.h" @@ -2429,6 +2438,7 @@ static void VaapiSetup(VaapiDecoder * decoder, static VASurfaceID VaapiGetSurface(VaapiDecoder * decoder, const AVCodecContext * video_ctx) { +#ifdef FFMPEG_BUG1_WORKAROUND // get_format not called with valid informations. if (video_ctx->width != decoder->InputWidth || video_ctx->height != decoder->InputHeight) { @@ -2459,6 +2469,7 @@ static VASurfaceID VaapiGetSurface(VaapiDecoder * decoder, } // FIXME: too late to switch to software rending on failures } +#endif return VaapiGetSurface0(decoder); } @@ -2659,7 +2670,7 @@ static enum PixelFormat Vaapi_get_format(VaapiDecoder * decoder, decoder->InputWidth = 0; decoder->InputHeight = 0; -#if 0 +#ifndef FFMPEG_BUG1_WORKAROUND if (video_ctx->width && video_ctx->height) { VAStatus status; @@ -6743,6 +6754,7 @@ static void VdpauSetupOutput(VdpauDecoder * decoder) static unsigned VdpauGetSurface(VdpauDecoder * decoder, const AVCodecContext * video_ctx) { +#ifdef FFMPEG_BUG1_WORKAROUND // get_format not called with valid informations. if (video_ctx->width != decoder->InputWidth || video_ctx->height != decoder->InputHeight) { @@ -6766,6 +6778,7 @@ static unsigned VdpauGetSurface(VdpauDecoder * decoder, VdpauSetupOutput(decoder); } +#endif return VdpauGetSurface0(decoder); } @@ -6925,7 +6938,7 @@ static enum PixelFormat Vdpau_get_format(VdpauDecoder * decoder, decoder->InputWidth = 0; decoder->InputHeight = 0; -#if 0 +#ifndef FFMPEG_BUG1_WORKAROUND if (video_ctx->width && video_ctx->height) { VdpStatus status;