Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2699 from FernetMenta/hwaccel

move vdpau into hwaccel
  • Loading branch information...
commit 06b20663ebf9a59691b6e61e4ac0fa2d46968441 2 parents 37d7b77 + 6bfa7bb
@FernetMenta FernetMenta authored
View
2  lib/ffmpeg/libavcodec/mpeg12.c
@@ -1202,6 +1202,7 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
#endif
#if CONFIG_MPEG1_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU_MPEG1,
+ AV_PIX_FMT_VDPAU,
#endif
AV_PIX_FMT_YUV420P,
AV_PIX_FMT_NONE
@@ -1214,6 +1215,7 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
#endif
#if CONFIG_MPEG2_VDPAU_HWACCEL
AV_PIX_FMT_VDPAU_MPEG2,
+ AV_PIX_FMT_VDPAU,
#endif
#if CONFIG_MPEG2_DXVA2_HWACCEL
AV_PIX_FMT_DXVA2_VLD,
View
2  lib/ffmpeg/libavcodec/vdpau_vc1.c
@@ -59,7 +59,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
else
info->picture_type = s->pict_type - 1 + s->pict_type / 3;
- info->frame_coding_mode = v->fcm;
+ info->frame_coding_mode = v->fcm ? v->fcm + 1 : 0;
info->postprocflag = v->postprocflag;
info->pulldown = v->broadcast;
info->interlace = v->interlace;
View
32 ...backport-register-vdpau-hwaccel-for-mpeg12-fe1f36547d0be963e352de0cde1a6cba59ea2e78.patch
@@ -0,0 +1,32 @@
+From bb6ba57092c402b6f2e5edf6d1691beafafa0460 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Mon, 6 May 2013 20:58:28 +0200
+Subject: [PATCH] ffmpeg backport: register vdpau hwaccel for mpeg12
+
+---
+ libavcodec/mpeg12.c | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
+index 9d2743a..0f94772 100644
+--- a/libavcodec/mpeg12.c
++++ b/libavcodec/mpeg12.c
+@@ -1202,6 +1202,7 @@ static const enum AVPixelFormat mpeg1_hwaccel_pixfmt_list_420[] = {
+ #endif
+ #if CONFIG_MPEG1_VDPAU_HWACCEL
+ AV_PIX_FMT_VDPAU_MPEG1,
++ AV_PIX_FMT_VDPAU,
+ #endif
+ AV_PIX_FMT_YUV420P,
+ AV_PIX_FMT_NONE
+@@ -1214,6 +1215,7 @@ static const enum AVPixelFormat mpeg2_hwaccel_pixfmt_list_420[] = {
+ #endif
+ #if CONFIG_MPEG2_VDPAU_HWACCEL
+ AV_PIX_FMT_VDPAU_MPEG2,
++ AV_PIX_FMT_VDPAU,
+ #endif
+ #if CONFIG_MPEG2_DXVA2_HWACCEL
+ AV_PIX_FMT_DXVA2_VLD,
+--
+1.7.9.5
+
View
25 ...037-backport-fix-vdpau-vc1-interlace-modes-b37cc5995b88ec68a68cb8e496a008e1cd467077.patch
@@ -0,0 +1,25 @@
+From b37cc5995b88ec68a68cb8e496a008e1cd467077 Mon Sep 17 00:00:00 2001
+From: Rainer Hochecker <fernetmenta@online.de>
+Date: Sun, 5 May 2013 15:12:59 +0200
+Subject: [PATCH] fix vdpau vc1 interlace modes
+
+---
+ libavcodec/vdpau_vc1.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libavcodec/vdpau_vc1.c b/libavcodec/vdpau_vc1.c
+index f5da9bb..993ef26 100644
+--- a/libavcodec/vdpau_vc1.c
++++ b/libavcodec/vdpau_vc1.c
+@@ -59,7 +59,7 @@ static int vdpau_vc1_start_frame(AVCodecContext *avctx,
+ else
+ info->picture_type = s->pict_type - 1 + s->pict_type / 3;
+
+- info->frame_coding_mode = v->fcm;
++ info->frame_coding_mode = v->fcm ? v->fcm + 1 : 0;
+ info->postprocflag = v->postprocflag;
+ info->pulldown = v->broadcast;
+ info->interlace = v->interlace;
+--
+1.7.9.5
+
View
36 xbmc/cores/dvdplayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
@@ -74,9 +74,6 @@ enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
#ifdef HAVE_LIBVDPAU
if(CVDPAU::IsVDPAUFormat(*cur) && CSettings::Get().GetBool("videoplayer.usevdpau"))
{
- if(ctx->GetHardware())
- return *cur;
-
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
CVDPAU* vdp = new CVDPAU();
if(vdp->Open(avctx, *cur))
@@ -203,39 +200,6 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
}
}
-#ifdef HAVE_LIBVDPAU
- if(CSettings::Get().GetBool("videoplayer.usevdpau") && !m_bSoftware)
- {
- while((pCodec = m_dllAvCodec.av_codec_next(pCodec)))
- {
- if(pCodec->id == hints.codec
- && pCodec->capabilities & CODEC_CAP_HWACCEL_VDPAU)
- {
- if ((pCodec->id == CODEC_ID_MPEG4) && !g_advancedSettings.m_videoAllowMpeg4VDPAU)
- continue;
-
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Creating VDPAU(%ix%i, %d)",hints.width, hints.height, hints.codec);
- CVDPAU* vdp = new CVDPAU();
- m_pCodecContext = m_dllAvCodec.avcodec_alloc_context3(pCodec);
- m_pCodecContext->codec_id = hints.codec;
- m_pCodecContext->width = hints.width;
- m_pCodecContext->height = hints.height;
- m_pCodecContext->coded_width = hints.width;
- m_pCodecContext->coded_height = hints.height;
- if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE))
- {
- m_pHardware = vdp;
- m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
- break;
- }
- m_dllAvUtil.av_freep(&m_pCodecContext);
- CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Failed to get VDPAU device");
- vdp->Release();
- }
- }
- }
-#endif
-
if(pCodec == NULL)
pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
View
66 xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.cpp
@@ -184,6 +184,9 @@ bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int su
return false;
}
+ if ((avctx->codec_id == CODEC_ID_MPEG4) && !g_advancedSettings.m_videoAllowMpeg4VDPAU)
+ return false;
+
if (!dl_handle)
{
dl_handle = dlopen("libvdpau.so.1", RTLD_LAZY);
@@ -239,10 +242,15 @@ bool CVDPAU::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int su
InitCSCMatrix(avctx->coded_height);
/* finally setup ffmpeg */
+ memset(&m_hwContext, 0, sizeof(AVVDPAUContext));
+ m_hwContext.render = CVDPAU::Render;
+ m_hwContext.bitstream_buffers_allocated = 0;
avctx->get_buffer = CVDPAU::FFGetBuffer;
avctx->release_buffer = CVDPAU::FFReleaseBuffer;
avctx->draw_horiz_band = CVDPAU::FFDrawSlice;
avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
+ avctx->hwaccel_context = &m_hwContext;
+ avctx->thread_count = 1;
g_Windowing.Register(this);
return true;
@@ -272,6 +280,11 @@ void CVDPAU::Close()
free(render);
}
+ if (m_hwContext.bitstream_buffers_allocated)
+ {
+ m_dllAvUtil.av_freep(&m_hwContext.bitstream_buffers);
+ }
+
g_Windowing.Unregister(this);
m_dllAvUtil.Unload();
}
@@ -497,11 +510,10 @@ int CVDPAU::Check(AVCodecContext* avctx)
bool CVDPAU::IsVDPAUFormat(PixelFormat format)
{
- if ((format >= PIX_FMT_VDPAU_H264) && (format <= PIX_FMT_VDPAU_VC1)) return true;
-#if (defined PIX_FMT_VDPAU_MPEG4_IN_AVUTIL)
- if (format == PIX_FMT_VDPAU_MPEG4) return true;
-#endif
- else return false;
+ if (format == AV_PIX_FMT_VDPAU)
+ return true;
+ else
+ return false;
}
void CVDPAU::CheckFeatures()
@@ -914,35 +926,35 @@ void CVDPAU::FiniVDPAUOutput()
}
-void CVDPAU::ReadFormatOf( PixelFormat fmt
+void CVDPAU::ReadFormatOf( AVCodecID codec
, VdpDecoderProfile &vdp_decoder_profile
, VdpChromaType &vdp_chroma_type)
{
- switch (fmt)
+ switch (codec)
{
- case PIX_FMT_VDPAU_MPEG1:
+ case AV_CODEC_ID_MPEG1VIDEO:
vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG1;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
- case PIX_FMT_VDPAU_MPEG2:
+ case AV_CODEC_ID_MPEG2VIDEO:
vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG2_MAIN;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
- case PIX_FMT_VDPAU_H264:
+ case AV_CODEC_ID_H264:
vdp_decoder_profile = VDP_DECODER_PROFILE_H264_HIGH;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
- case PIX_FMT_VDPAU_WMV3:
+ case AV_CODEC_ID_WMV3:
vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_MAIN;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
- case PIX_FMT_VDPAU_VC1:
+ case AV_CODEC_ID_VC1:
vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
#if (defined PIX_FMT_VDPAU_MPEG4_IN_AVUTIL) && \
(defined VDP_DECODER_PROFILE_MPEG4_PART2_ASP)
- case PIX_FMT_VDPAU_MPEG4:
+ case AV_CODEC_ID_MPEG4:
vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
vdp_chroma_type = VDP_CHROMA_TYPE_420;
break;
@@ -969,9 +981,9 @@ bool CVDPAU::ConfigVDPAU(AVCodecContext* avctx, int ref_frames)
past[1] = past[0] = current = future = NULL;
CLog::Log(LOGNOTICE, " (VDPAU) screenWidth:%i vidWidth:%i surfaceWidth:%i",OutWidth,vid_width,surface_width);
CLog::Log(LOGNOTICE, " (VDPAU) screenHeight:%i vidHeight:%i surfaceHeight:%i",OutHeight,vid_height,surface_height);
- ReadFormatOf(avctx->pix_fmt, vdp_decoder_profile, vdp_chroma_type);
+ ReadFormatOf(avctx->codec_id, vdp_decoder_profile, vdp_chroma_type);
- if(avctx->pix_fmt == PIX_FMT_VDPAU_H264)
+ if(avctx->codec_id == AV_CODEC_ID_H264)
{
max_references = ref_frames;
if (max_references > 16) max_references = 16;
@@ -1229,7 +1241,7 @@ int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
{
// create a new surface
VdpDecoderProfile profile;
- ReadFormatOf(avctx->pix_fmt, profile, vdp->vdp_chroma_type);
+ ReadFormatOf(avctx->codec_id, profile, vdp->vdp_chroma_type);
render = (vdpau_render_state*)calloc(sizeof(vdpau_render_state), 1);
if (render == NULL)
{
@@ -1259,8 +1271,9 @@ int CVDPAU::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
if (render == NULL)
return -1;
- pic->data[1] = pic->data[2] = NULL;
- pic->data[0]= (uint8_t*)render;
+ pic->data[1] = pic->data[2] = NULL;
+ pic->data[0] = (uint8_t*)render;
+ pic->data[3] = (uint8_t*)(uintptr_t)render->surface;
pic->linesize[0] = pic->linesize[1] = pic->linesize[2] = 0;
@@ -1313,6 +1326,13 @@ void CVDPAU::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
render->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE;
}
+VdpStatus CVDPAU::Render(VdpDecoder decoder, VdpVideoSurface target,
+ VdpPictureInfo const *picture_info,
+ uint32_t bitstream_buffer_count,
+ VdpBitstreamBuffer const * bitstream_buffers)
+{
+ return VDP_STATUS_OK;
+}
void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
const AVFrame *src, int offset[4],
@@ -1355,8 +1375,8 @@ void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
}
uint32_t max_refs = 0;
- if(s->pix_fmt == PIX_FMT_VDPAU_H264)
- max_refs = render->info.h264.num_ref_frames;
+ if(s->codec_id == AV_CODEC_ID_H264)
+ max_refs = vdp->m_hwContext.info.h264.num_ref_frames;
if(vdp->decoder == VDP_INVALID_HANDLE
|| vdp->vdpauConfigured == false
@@ -1368,9 +1388,9 @@ void CVDPAU::FFDrawSlice(struct AVCodecContext *s,
vdp_st = vdp->vdp_decoder_render(vdp->decoder,
render->surface,
- (VdpPictureInfo const *)&(render->info),
- render->bitstream_buffers_used,
- render->bitstream_buffers);
+ (VdpPictureInfo const *)&(vdp->m_hwContext.info),
+ vdp->m_hwContext.bitstream_buffers_used,
+ vdp->m_hwContext.bitstream_buffers);
vdp->CheckStatus(vdp_st, __LINE__);
}
View
7 xbmc/cores/dvdplayer/DVDCodecs/Video/VDPAU.h
@@ -94,6 +94,10 @@ class CVDPAU
const AVFrame *src, int offset[4],
int y, int type, int height);
static int FFGetBuffer(AVCodecContext *avctx, AVFrame *pic);
+ static VdpStatus Render(VdpDecoder decoder, VdpVideoSurface target,
+ VdpPictureInfo const *picture_info,
+ uint32_t bitstream_buffer_count,
+ VdpBitstreamBuffer const * bitstream_buffers);
void Present();
bool ConfigVDPAU(AVCodecContext *avctx, int ref_frames);
@@ -222,11 +226,12 @@ class CVDPAU
int m_feature_count;
static bool IsVDPAUFormat(PixelFormat fmt);
- static void ReadFormatOf( PixelFormat fmt
+ static void ReadFormatOf( AVCodecID codec
, VdpDecoderProfile &decoder_profile
, VdpChromaType &chroma_type);
std::vector<vdpau_render_state*> m_videoSurfaces;
+ AVVDPAUContext m_hwContext;
DllAvUtil m_dllAvUtil;
enum VDPAUOutputMethod
Please sign in to comment.
Something went wrong with that request. Please try again.