Workaround for ffmpeg 1.1.x get_format bug.

This commit is contained in:
Johns 2013-02-25 16:33:40 +01:00
parent 746746d5b7
commit 21e4f4ee04
1 changed files with 15 additions and 2 deletions

17
video.c
View File

@ -152,6 +152,15 @@ typedef enum
#include <libavcodec/vaapi.h>
#include <libavutil/pixdesc.h>
#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;