From c07ec82e6dc94020592930f5e6a206ddc1357802 Mon Sep 17 00:00:00 2001 From: Johns Date: Mon, 13 Aug 2012 16:57:36 +0200 Subject: [PATCH] Fix bug: Can't use software decoder with VDPAU. --- ChangeLog | 1 + codec.c | 18 +----------------- softhddev.c | 21 ++++++++++----------- video.c | 26 ++++++++++++++++++-------- video.h | 3 +++ 5 files changed, 33 insertions(+), 36 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2bff7d..6949be3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ User johns Date: + Fix bug: Can't use software decoder with VDPAU. Resume plugin, if suspend control stops. Removes old audio code (!USE_AUDIORING). Use -DOSD_DEBUG to debug OSD. diff --git a/codec.c b/codec.c index 369eb6f..5707d6c 100644 --- a/codec.c +++ b/codec.c @@ -363,22 +363,6 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id) if (decoder->VideoCtx) { Error(_("codec: missing close\n")); } - // - // ffmpeg compatibility hack - // -#if 1 || (LIBAVCODEC_VERSION_INT <= AV_VERSION_INT(52,96,0)) - if (name) { - if (!strcmp(name, "h264video_vdpau")) { - name = "h264_vdpau"; - } else if (!strcmp(name, "mpeg4video_vdpau")) { - name = "mpeg4_vdpau"; - } else if (!strcmp(name, "vc1video_vdpau")) { - name = "vc1_vdpau"; - } else if (!strcmp(name, "wmv3video_vdpau")) { - name = "wmv3_vdpau"; - } - } -#endif if (name && (video_codec = avcodec_find_decoder_by_name(name))) { Debug(3, "codec: vdpau decoder found\n"); @@ -939,7 +923,7 @@ static void CodecAudioSetClock(AudioDecoder * audio_decoder, int64_t pts) if (0) { Debug(3, - "codec/audio: interval P:%5 " PRId64 "ms T:%5" PRId64 "ms D:%4" + "codec/audio: interval P:%5" PRId64 "ms T:%5" PRId64 "ms D:%4" PRId64 "ms %f %d\n", pts_diff / 90, tim_diff / (1000 * 1000), delay / 90, drift / 90.0, audio_decoder->DriftCorr); } diff --git a/softhddev.c b/softhddev.c index 215d8a8..1131701 100644 --- a/softhddev.c +++ b/softhddev.c @@ -59,9 +59,9 @@ static int H264Dump(const uint8_t * data, int size); ////////////////////////////////////////////////////////////////////////////// #ifdef USE_VDPAU -static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible +static char VdpauDecoder = 1; ///< vdpau decoder used #else -#define ConfigVdpauDecoder 0 ///< no vdpau decoder configured +#define VdpauDecoder 0 ///< no vdpau decoder configured #endif extern int ConfigAudioBufferTime; ///< config size ms of audio buffer @@ -1533,17 +1533,16 @@ int VideoDecodeInput(void) case CODEC_ID_MPEG2VIDEO: if (last_codec_id != CODEC_ID_MPEG2VIDEO) { last_codec_id = CODEC_ID_MPEG2VIDEO; - CodecVideoOpen(MyVideoDecoder, - ConfigVdpauDecoder ? "mpegvideo_vdpau" : NULL, + CodecVideoOpen(MyVideoDecoder, VideoHardwareDecoder < 0 + && VdpauDecoder ? "mpeg_vdpau" : NULL, CODEC_ID_MPEG2VIDEO); } break; case CODEC_ID_H264: if (last_codec_id != CODEC_ID_H264) { last_codec_id = CODEC_ID_H264; - CodecVideoOpen(MyVideoDecoder, - ConfigVdpauDecoder ? "h264video_vdpau" : NULL, - CODEC_ID_H264); + CodecVideoOpen(MyVideoDecoder, VideoHardwareDecoder + && VdpauDecoder ? "h264_vdpau" : NULL, CODEC_ID_H264); } break; default: @@ -1587,6 +1586,10 @@ int VideoGetBuffers(void) static void StartVideo(void) { VideoInit(X11DisplayName); +#ifdef USE_VDPAU + VdpauDecoder = !strcasecmp(VideoGetDriverName(), "vdpau"); +#endif + if (ConfigFullscreen) { // FIXME: not good looking, mapped and then resized. VideoSetFullscreen(1); @@ -2347,10 +2350,6 @@ int ProcessArgs(int argc, char *const argv[]) continue; case 'v': // video driver VideoSetDevice(optarg); -#ifdef USE_VDPAU - // FIXME: this is a big hack - ConfigVdpauDecoder = !strcasecmp(optarg, "vdpau"); -#endif continue; case 'x': // x11 server ConfigStartX11Server = 1; diff --git a/video.c b/video.c index 5eb4c96..35ea19d 100644 --- a/video.c +++ b/video.c @@ -5345,7 +5345,7 @@ static void VdpauCreateSurfaces(VdpauDecoder * decoder, int width, int height) #ifdef DEBUG if (!decoder->SurfacesNeeded) { - Error(_("video/vaapi: surface needed not set\n")); + Error(_("video/vdpau: surface needed not set\n")); decoder->SurfacesNeeded = 3 + VIDEO_SURFACES_MAX; } #endif @@ -7381,14 +7381,8 @@ static void VdpauRenderFrame(VdpauDecoder * decoder, decoder->InputWidth = video_ctx->width; decoder->InputHeight = video_ctx->height; - // - // detect interlaced input - // - Debug(3, "video/vdpau: interlaced %d top-field-first %d\n", - frame->interlaced_frame, frame->top_field_first); - // FIXME: I hope this didn't change in the middle of the stream - VdpauCleanup(decoder); + decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 2; VdpauSetupOutput(decoder); } // @@ -7402,6 +7396,7 @@ static void VdpauRenderFrame(VdpauDecoder * decoder, default: Fatal(_("video/vdpau: pixel format %d not supported\n"), video_ctx->pix_fmt); + // FIXME: no fatals! } // convert ffmpeg order to vdpau @@ -7421,6 +7416,8 @@ static void VdpauRenderFrame(VdpauDecoder * decoder, VdpauGetErrorString(status)); } + Debug(4, "video/vdpau: sw render hw surface %#08x\n", surface); + VdpauQueueSurface(decoder, surface, 1); } @@ -9942,6 +9939,19 @@ void VideoSetDevice(const char *device) VideoDevice = device; } +/// +/// Get video driver name. +/// +/// @returns name of current video driver. +/// +const char *VideoGetDriverName(void) +{ + if (VideoUsedModule) { + return VideoUsedModule->Name; + } + return ""; +} + /// /// Set video geometry. /// diff --git a/video.h b/video.h index 2ad261d..ea11633 100644 --- a/video.h +++ b/video.h @@ -82,6 +82,9 @@ extern void VideoDisplayWakeup(void); /// Set video device. extern void VideoSetDevice(const char *); + /// Get video driver name. +extern const char *VideoGetDriverName(void); + /// Set video geometry. extern int VideoSetGeometry(const char *);