From d8e96c7871078d376de02210d2c350998f5a1fba Mon Sep 17 00:00:00 2001 From: Johns Date: Sat, 3 Aug 2013 17:27:52 +0200 Subject: [PATCH] Generalize GetVaapiContext to GetHwAccelContext. --- ChangeLog | 1 + codec.c | 2 +- po/de_DE.po | 8 ++++---- softhddev.c | 5 +++-- video.c | 51 ++++++++++++++++++++++++++++++++++++--------------- video.h | 4 ++-- 6 files changed, 47 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index 405949d..d4983cd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ User johns Date: + Generalize GetVaapiContext to GetHwAccelContext. Add compile time configurable trickspeed packets dump. Fix bug #1410: wrong spelled AC-3 and E-AC-3. Add compile time selectable h264 trickspeed workaround. diff --git a/codec.c b/codec.c index 4bd15fe..4eea14f 100644 --- a/codec.c +++ b/codec.c @@ -483,7 +483,7 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id) } else { decoder->VideoCtx->get_format = Codec_get_format; decoder->VideoCtx->hwaccel_context = - VideoGetVaapiContext(decoder->HwDecoder); + VideoGetHwAccelContext(decoder->HwDecoder); } // our pixel format video hardware decoder hook diff --git a/po/de_DE.po b/po/de_DE.po index 5e4d6ac..91867ef 100644 --- a/po/de_DE.po +++ b/po/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: VDR \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2013-07-25 13:22+0200\n" +"POT-Creation-Date: 2013-08-03 17:21+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -1272,6 +1272,9 @@ msgstr "" msgid "video/vdpau: can't put video surface bits: %s\n" msgstr "" +msgid "video: get hwaccel context, not supported\n" +msgstr "" + #, c-format msgid "video/vdpau: can't render bitmap surface: %s\n" msgstr "" @@ -1338,9 +1341,6 @@ msgstr "" msgid "video: repeated pict %d found, but not handled\n" msgstr "" -msgid "video/vaapi: get vaapi context, without vaapi enabled\n" -msgstr "" - #, c-format msgid "video/vdpau: decoder rendering failed: %s\n" msgstr "" diff --git a/softhddev.c b/softhddev.c index e3787bd..b11e43a 100644 --- a/softhddev.c +++ b/softhddev.c @@ -22,7 +22,7 @@ #define noUSE_SOFTLIMIT ///< add soft buffer limits to Play.. #define noUSE_PIP ///< include PIP support + new API -#define DUMP_TRICKSPEED ///< dump raw trickspeed packets +#define noDUMP_TRICKSPEED ///< dump raw trickspeed packets #include #include @@ -2448,7 +2448,8 @@ uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height) int SetPlayMode(int play_mode) { VideoDisplayWakeup(); - if (MyVideoStream->Decoder) { // tell video parser we have new stream + // tell video parser we have new stream + if (MyVideoStream->Decoder && !MyVideoStream->SkipStream) { if (MyVideoStream->ClearClose) { // replay clear buffers on close Clear(); // flush all buffers MyVideoStream->ClearClose = 0; diff --git a/video.c b/video.c index 54bb851..f51cfa6 100644 --- a/video.c +++ b/video.c @@ -260,6 +260,7 @@ typedef struct _video_module_ const enum PixelFormat *); void (*const RenderFrame) (VideoHwDecoder *, const AVCodecContext *, const AVFrame *); + void *(*const GetHwAccelContext)(VideoHwDecoder *); void (*const SetClock) (VideoHwDecoder *, int64_t); int64_t(*const GetClock) (const VideoHwDecoder *); void (*const SetTrickSpeed) (const VideoHwDecoder *, int); @@ -4575,6 +4576,16 @@ static void VaapiRenderFrame(VaapiDecoder * decoder, } } +/// +/// Get hwaccel context for ffmpeg. +/// +/// @param decoder VA-API hw decoder +/// +static void *VaapiGetHwAccelContext(VaapiDecoder * decoder) +{ + return decoder->Vaapi.VaapiContext; +} + /// /// Advance displayed frame of decoder. /// @@ -5363,6 +5374,8 @@ static const VideoModule VaapiModule = { AVCodecContext *, const enum PixelFormat *))Vaapi_get_format, .RenderFrame = (void (*const) (VideoHwDecoder *, const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame, + .GetHwAccelContext = (void *(*const)(VideoHwDecoder *)) + VaapiGetHwAccelContext, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))VaapiSetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))VaapiGetClock, .SetTrickSpeed = @@ -5399,6 +5412,8 @@ static const VideoModule VaapiGlxModule = { AVCodecContext *, const enum PixelFormat *))Vaapi_get_format, .RenderFrame = (void (*const) (VideoHwDecoder *, const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame, + .GetHwAccelContext = (void *(*const)(VideoHwDecoder *)) + VaapiGetHwAccelContext, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))VaapiSetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))VaapiGetClock, .SetTrickSpeed = @@ -7842,6 +7857,20 @@ static void VdpauRenderFrame(VdpauDecoder * decoder, } } +/// +/// Get hwaccel context for ffmpeg. +/// +/// @param decoder VDPAU hw decoder +/// +static void *VdpauGetHwAccelContext(VdpauDecoder * decoder) +{ + (void)decoder; + + // FIXME: new ffmpeg versions supports struct AVVDPAUContext + Error(_("video: get hwaccel context, not supported\n")); + return NULL; +} + /// /// Render osd surface to output surface. /// @@ -9064,6 +9093,8 @@ static const VideoModule VdpauModule = { AVCodecContext *, const enum PixelFormat *))Vdpau_get_format, .RenderFrame = (void (*const) (VideoHwDecoder *, const AVCodecContext *, const AVFrame *))VdpauSyncRenderFrame, + .GetHwAccelContext = (void *(*const)(VideoHwDecoder *)) + VdpauGetHwAccelContext, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))VdpauSetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))VdpauGetClock, .SetTrickSpeed = @@ -9219,6 +9250,8 @@ static const VideoModule NoopModule = { AVCodecContext *, const enum PixelFormat *))Noop_get_format, .RenderFrame = (void (*const) (VideoHwDecoder *, const AVCodecContext *, const AVFrame *))NoopSyncRenderFrame, + .GetHwAccelContext = (void *(*const)(VideoHwDecoder *)) + DummyGetHwAccelContext, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))NoopSetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))NoopGetClock, .SetTrickSpeed = @@ -9817,27 +9850,15 @@ void VideoRenderFrame(VideoHwDecoder * hw_decoder, } /// -/// Get VA-API ffmpeg context +/// Get hwaccel context for ffmpeg. /// /// FIXME: new ffmpeg supports vdpau hw context /// /// @param hw_decoder video hardware decoder (must be VA-API) /// -struct vaapi_context *VideoGetVaapiContext(VideoHwDecoder * hw_decoder) +void *VideoGetHwAccelContext(VideoHwDecoder * hw_decoder) { -#ifdef USE_VAAPI - if (VideoUsedModule == &VaapiModule) { - return hw_decoder->Vaapi.VaapiContext; - } -#ifdef USE_GLX - if (VideoUsedModule == &VaapiGlxModule) { - return hw_decoder->Vaapi.VaapiContext; - } -#endif -#endif - (void)hw_decoder; - Error(_("video/vaapi: get vaapi context, without vaapi enabled\n")); - return NULL; + return VideoUsedModule->GetHwAccelContext(hw_decoder); } #ifdef USE_VDPAU diff --git a/video.h b/video.h index 5e27b73..fa3e44f 100644 --- a/video.h +++ b/video.h @@ -67,8 +67,8 @@ extern enum PixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *, extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *, const AVFrame *); - /// Get ffmpeg vaapi context. -extern struct vaapi_context *VideoGetVaapiContext(VideoHwDecoder *); + /// Get hwaccel context for ffmpeg. +extern void *VideoGetHwAccelContext(VideoHwDecoder *); #ifdef AVCODEC_VDPAU_H /// Draw vdpau render state.