Generalize GetVaapiContext to GetHwAccelContext.

This commit is contained in:
Johns 2013-08-03 17:27:52 +02:00
parent 8ff65a011a
commit d8e96c7871
6 changed files with 47 additions and 24 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Date: Date:
Generalize GetVaapiContext to GetHwAccelContext.
Add compile time configurable trickspeed packets dump. Add compile time configurable trickspeed packets dump.
Fix bug #1410: wrong spelled AC-3 and E-AC-3. Fix bug #1410: wrong spelled AC-3 and E-AC-3.
Add compile time selectable h264 trickspeed workaround. Add compile time selectable h264 trickspeed workaround.

View File

@ -483,7 +483,7 @@ void CodecVideoOpen(VideoDecoder * decoder, const char *name, int codec_id)
} else { } else {
decoder->VideoCtx->get_format = Codec_get_format; decoder->VideoCtx->get_format = Codec_get_format;
decoder->VideoCtx->hwaccel_context = decoder->VideoCtx->hwaccel_context =
VideoGetVaapiContext(decoder->HwDecoder); VideoGetHwAccelContext(decoder->HwDecoder);
} }
// our pixel format video hardware decoder hook // our pixel format video hardware decoder hook

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: VDR \n" "Project-Id-Version: VDR \n"
"Report-Msgid-Bugs-To: <see README>\n" "Report-Msgid-Bugs-To: <see README>\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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -1272,6 +1272,9 @@ msgstr ""
msgid "video/vdpau: can't put video surface bits: %s\n" msgid "video/vdpau: can't put video surface bits: %s\n"
msgstr "" msgstr ""
msgid "video: get hwaccel context, not supported\n"
msgstr ""
#, c-format #, c-format
msgid "video/vdpau: can't render bitmap surface: %s\n" msgid "video/vdpau: can't render bitmap surface: %s\n"
msgstr "" msgstr ""
@ -1338,9 +1341,6 @@ msgstr ""
msgid "video: repeated pict %d found, but not handled\n" msgid "video: repeated pict %d found, but not handled\n"
msgstr "" msgstr ""
msgid "video/vaapi: get vaapi context, without vaapi enabled\n"
msgstr ""
#, c-format #, c-format
msgid "video/vdpau: decoder rendering failed: %s\n" msgid "video/vdpau: decoder rendering failed: %s\n"
msgstr "" msgstr ""

View File

@ -22,7 +22,7 @@
#define noUSE_SOFTLIMIT ///< add soft buffer limits to Play.. #define noUSE_SOFTLIMIT ///< add soft buffer limits to Play..
#define noUSE_PIP ///< include PIP support + new API #define noUSE_PIP ///< include PIP support + new API
#define DUMP_TRICKSPEED ///< dump raw trickspeed packets #define noDUMP_TRICKSPEED ///< dump raw trickspeed packets
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -2448,7 +2448,8 @@ uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height)
int SetPlayMode(int play_mode) int SetPlayMode(int play_mode)
{ {
VideoDisplayWakeup(); 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 if (MyVideoStream->ClearClose) { // replay clear buffers on close
Clear(); // flush all buffers Clear(); // flush all buffers
MyVideoStream->ClearClose = 0; MyVideoStream->ClearClose = 0;

51
video.c
View File

@ -260,6 +260,7 @@ typedef struct _video_module_
const enum PixelFormat *); const enum PixelFormat *);
void (*const RenderFrame) (VideoHwDecoder *, const AVCodecContext *, void (*const RenderFrame) (VideoHwDecoder *, const AVCodecContext *,
const AVFrame *); const AVFrame *);
void *(*const GetHwAccelContext)(VideoHwDecoder *);
void (*const SetClock) (VideoHwDecoder *, int64_t); void (*const SetClock) (VideoHwDecoder *, int64_t);
int64_t(*const GetClock) (const VideoHwDecoder *); int64_t(*const GetClock) (const VideoHwDecoder *);
void (*const SetTrickSpeed) (const VideoHwDecoder *, int); 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. /// Advance displayed frame of decoder.
/// ///
@ -5363,6 +5374,8 @@ static const VideoModule VaapiModule = {
AVCodecContext *, const enum PixelFormat *))Vaapi_get_format, AVCodecContext *, const enum PixelFormat *))Vaapi_get_format,
.RenderFrame = (void (*const) (VideoHwDecoder *, .RenderFrame = (void (*const) (VideoHwDecoder *,
const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame, const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame,
.GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
VaapiGetHwAccelContext,
.SetClock = (void (*const) (VideoHwDecoder *, int64_t))VaapiSetClock, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))VaapiSetClock,
.GetClock = (int64_t(*const) (const VideoHwDecoder *))VaapiGetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))VaapiGetClock,
.SetTrickSpeed = .SetTrickSpeed =
@ -5399,6 +5412,8 @@ static const VideoModule VaapiGlxModule = {
AVCodecContext *, const enum PixelFormat *))Vaapi_get_format, AVCodecContext *, const enum PixelFormat *))Vaapi_get_format,
.RenderFrame = (void (*const) (VideoHwDecoder *, .RenderFrame = (void (*const) (VideoHwDecoder *,
const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame, const AVCodecContext *, const AVFrame *))VaapiSyncRenderFrame,
.GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
VaapiGetHwAccelContext,
.SetClock = (void (*const) (VideoHwDecoder *, int64_t))VaapiSetClock, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))VaapiSetClock,
.GetClock = (int64_t(*const) (const VideoHwDecoder *))VaapiGetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))VaapiGetClock,
.SetTrickSpeed = .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. /// Render osd surface to output surface.
/// ///
@ -9064,6 +9093,8 @@ static const VideoModule VdpauModule = {
AVCodecContext *, const enum PixelFormat *))Vdpau_get_format, AVCodecContext *, const enum PixelFormat *))Vdpau_get_format,
.RenderFrame = (void (*const) (VideoHwDecoder *, .RenderFrame = (void (*const) (VideoHwDecoder *,
const AVCodecContext *, const AVFrame *))VdpauSyncRenderFrame, const AVCodecContext *, const AVFrame *))VdpauSyncRenderFrame,
.GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
VdpauGetHwAccelContext,
.SetClock = (void (*const) (VideoHwDecoder *, int64_t))VdpauSetClock, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))VdpauSetClock,
.GetClock = (int64_t(*const) (const VideoHwDecoder *))VdpauGetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))VdpauGetClock,
.SetTrickSpeed = .SetTrickSpeed =
@ -9219,6 +9250,8 @@ static const VideoModule NoopModule = {
AVCodecContext *, const enum PixelFormat *))Noop_get_format, AVCodecContext *, const enum PixelFormat *))Noop_get_format,
.RenderFrame = (void (*const) (VideoHwDecoder *, .RenderFrame = (void (*const) (VideoHwDecoder *,
const AVCodecContext *, const AVFrame *))NoopSyncRenderFrame, const AVCodecContext *, const AVFrame *))NoopSyncRenderFrame,
.GetHwAccelContext = (void *(*const)(VideoHwDecoder *))
DummyGetHwAccelContext,
.SetClock = (void (*const) (VideoHwDecoder *, int64_t))NoopSetClock, .SetClock = (void (*const) (VideoHwDecoder *, int64_t))NoopSetClock,
.GetClock = (int64_t(*const) (const VideoHwDecoder *))NoopGetClock, .GetClock = (int64_t(*const) (const VideoHwDecoder *))NoopGetClock,
.SetTrickSpeed = .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 /// FIXME: new ffmpeg supports vdpau hw context
/// ///
/// @param hw_decoder video hardware decoder (must be VA-API) /// @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 return VideoUsedModule->GetHwAccelContext(hw_decoder);
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;
} }
#ifdef USE_VDPAU #ifdef USE_VDPAU

View File

@ -67,8 +67,8 @@ extern enum PixelFormat Video_get_format(VideoHwDecoder *, AVCodecContext *,
extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *, extern void VideoRenderFrame(VideoHwDecoder *, const AVCodecContext *,
const AVFrame *); const AVFrame *);
/// Get ffmpeg vaapi context. /// Get hwaccel context for ffmpeg.
extern struct vaapi_context *VideoGetVaapiContext(VideoHwDecoder *); extern void *VideoGetHwAccelContext(VideoHwDecoder *);
#ifdef AVCODEC_VDPAU_H #ifdef AVCODEC_VDPAU_H
/// Draw vdpau render state. /// Draw vdpau render state.