#include "cores/VideoRenderers/RenderFlags.h"
using namespace VDPAU;
-#define NUM_RENDER_PICS 9
+#define NUM_RENDER_PICS 7
+#define NUM_CROP_PIX 3
#define ARSIZE(x) (sizeof(x) / sizeof((x)[0]))
+// settings codecs mapping
+DVDCodecAvailableType g_vdpau_available[] = {
+ { AV_CODEC_ID_H263, "videoplayer.usevdpaumpeg4" },
+ { AV_CODEC_ID_MPEG4, "videoplayer.usevdpaumpeg4" },
+ { AV_CODEC_ID_WMV3, "videoplayer.usevdpauvc1" },
+ { AV_CODEC_ID_VC1, "videoplayer.usevdpauvc1" },
+ { AV_CODEC_ID_MPEG2VIDEO, "videoplayer.usevdpaumpeg2" },
+};
+const size_t settings_count = sizeof(g_vdpau_available) / sizeof(DVDCodecAvailableType);
+
CDecoder::Desc decoder_profiles[] = {
{"MPEG1", VDP_DECODER_PROFILE_MPEG1},
{"MPEG2_SIMPLE", VDP_DECODER_PROFILE_MPEG2_SIMPLE},
{"VC1_SIMPLE", VDP_DECODER_PROFILE_VC1_SIMPLE},
{"VC1_MAIN", VDP_DECODER_PROFILE_VC1_MAIN},
{"VC1_ADVANCED", VDP_DECODER_PROFILE_VC1_ADVANCED},
-#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_ASP
{"MPEG4_PART2_ASP", VDP_DECODER_PROFILE_MPEG4_PART2_ASP},
-#endif
};
const size_t decoder_profile_count = sizeof(decoder_profiles)/sizeof(CDecoder::Desc);
{
delete m_context;
m_context = 0;
+ *ctx = NULL;
return false;
}
}
return true;
}
+VDPAU_procs& CVDPAUContext::GetProcs()
+{
+ return m_vdpProcs;
+}
+
+VdpVideoMixerFeature* CVDPAUContext::GetFeatures()
+{
+ return m_vdpFeatures;
+}
+
+int CVDPAUContext::GetFeatureCount()
+{
+ return m_featureCount;
+}
+
bool CVDPAUContext::LoadSymbols()
{
if (!m_dlHandle)
vdp_st = dl_vdp_device_create_x11(m_display,
mScreen,
&m_vdpDevice,
- &m_vdp_get_proc_address);
+ &m_vdpProcs.vdp_get_proc_address);
CLog::Log(LOGNOTICE,"vdp_device = 0x%08x vdp_st = 0x%08x",m_vdpDevice,vdp_st);
if (vdp_st != VDP_STATUS_OK)
m_vdpDevice = VDP_INVALID_HANDLE;
return false;
}
- vdp_st = m_vdp_get_proc_address(m_vdpDevice, VDP_FUNC_ID_DEVICE_DESTROY, (void**)&m_vdp_device_destroy);
+ QueryProcs();
+ SpewHardwareAvailable();
return true;
}
-void CVDPAUContext::GetProcs(VDPAU_procs &procs)
+void CVDPAUContext::QueryProcs()
{
VdpStatus vdp_st;
- procs.vdp_get_proc_address = m_vdp_get_proc_address;
-
#define VDP_PROC(id, proc) \
do { \
- vdp_st = m_vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \
+ vdp_st = m_vdpProcs.vdp_get_proc_address(m_vdpDevice, id, (void**)&proc); \
if (vdp_st != VDP_STATUS_OK) \
{ \
CLog::Log(LOGERROR, "CVDPAUContext::GetProcs - failed to get proc id"); \
} \
} while(0);
- VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , procs.vdp_get_error_string);
- VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , procs.vdp_device_destroy);
- VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , procs.vdp_generate_csc_matrix);
- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , procs.vdp_video_surface_create);
- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , procs.vdp_video_surface_destroy);
- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_video_surface_put_bits_y_cb_cr);
- VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , procs.vdp_video_surface_get_bits_y_cb_cr);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , procs.vdp_output_surface_put_bits_y_cb_cr);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , procs.vdp_output_surface_put_bits_native);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , procs.vdp_output_surface_create);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , procs.vdp_output_surface_destroy);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , procs.vdp_output_surface_get_bits_native);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, procs.vdp_output_surface_render_output_surface);
- VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , procs.vdp_output_surface_put_bits_indexed);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , procs.vdp_video_mixer_create);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , procs.vdp_video_mixer_set_feature_enables);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , procs.vdp_video_mixer_destroy);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , procs.vdp_video_mixer_render);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , procs.vdp_video_mixer_set_attribute_values);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , procs.vdp_video_mixer_query_parameter_support);
- VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , procs.vdp_video_mixer_query_feature_support);
- VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , procs.vdp_decoder_create);
- VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , procs.vdp_decoder_destroy);
- VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , procs.vdp_decoder_render);
- VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , procs.vdp_decoder_query_caps);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY , procs.vdp_presentation_queue_target_destroy);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE , procs.vdp_presentation_queue_create);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY , procs.vdp_presentation_queue_destroy);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY , procs.vdp_presentation_queue_display);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, procs.vdp_presentation_queue_block_until_surface_idle);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11 , procs.vdp_presentation_queue_target_create_x11);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS , procs.vdp_presentation_queue_query_surface_status);
- VDP_PROC(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME , procs.vdp_presentation_queue_get_time);
-
+ VDP_PROC(VDP_FUNC_ID_GET_ERROR_STRING , m_vdpProcs.vdp_get_error_string);
+ VDP_PROC(VDP_FUNC_ID_DEVICE_DESTROY , m_vdpProcs.vdp_device_destroy);
+ VDP_PROC(VDP_FUNC_ID_GENERATE_CSC_MATRIX , m_vdpProcs.vdp_generate_csc_matrix);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_CREATE , m_vdpProcs.vdp_video_surface_create);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY , m_vdpProcs.vdp_video_surface_destroy);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR , m_vdpProcs.vdp_video_surface_put_bits_y_cb_cr);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR , m_vdpProcs.vdp_video_surface_get_bits_y_cb_cr);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_Y_CB_CR , m_vdpProcs.vdp_output_surface_put_bits_y_cb_cr);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE , m_vdpProcs.vdp_output_surface_put_bits_native);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE , m_vdpProcs.vdp_output_surface_create);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY , m_vdpProcs.vdp_output_surface_destroy);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE , m_vdpProcs.vdp_output_surface_get_bits_native);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, m_vdpProcs.vdp_output_surface_render_output_surface);
+ VDP_PROC(VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED , m_vdpProcs.vdp_output_surface_put_bits_indexed);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_CREATE , m_vdpProcs.vdp_video_mixer_create);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES , m_vdpProcs.vdp_video_mixer_set_feature_enables);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_DESTROY , m_vdpProcs.vdp_video_mixer_destroy);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_RENDER , m_vdpProcs.vdp_video_mixer_render);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES , m_vdpProcs.vdp_video_mixer_set_attribute_values);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_PARAMETER_SUPPORT , m_vdpProcs.vdp_video_mixer_query_parameter_support);
+ VDP_PROC(VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT , m_vdpProcs.vdp_video_mixer_query_feature_support);
+ VDP_PROC(VDP_FUNC_ID_DECODER_CREATE , m_vdpProcs.vdp_decoder_create);
+ VDP_PROC(VDP_FUNC_ID_DECODER_DESTROY , m_vdpProcs.vdp_decoder_destroy);
+ VDP_PROC(VDP_FUNC_ID_DECODER_RENDER , m_vdpProcs.vdp_decoder_render);
+ VDP_PROC(VDP_FUNC_ID_DECODER_QUERY_CAPABILITIES , m_vdpProcs.vdp_decoder_query_caps);
#undef VDP_PROC
}
void CVDPAUContext::DestroyContext()
{
- if (!m_vdp_device_destroy)
+ if (!m_vdpProcs.vdp_device_destroy)
return;
- m_vdp_device_destroy(m_vdpDevice);
+ m_vdpProcs.vdp_device_destroy(m_vdpDevice);
m_vdpDevice = VDP_INVALID_HANDLE;
}
+void CVDPAUContext::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo
+{
+ VdpStatus rv;
+ CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:");
+ CLog::Log(LOGNOTICE,"name level macbs width height");
+ CLog::Log(LOGNOTICE,"------------------------------------");
+ for(unsigned int x=0; x<decoder_profile_count; ++x)
+ {
+ VdpBool is_supported = false;
+ uint32_t max_level, max_macroblocks, max_width, max_height;
+ rv = m_vdpProcs.vdp_decoder_query_caps(m_vdpDevice, decoder_profiles[x].id,
+ &is_supported, &max_level, &max_macroblocks, &max_width, &max_height);
+ if(rv == VDP_STATUS_OK && is_supported)
+ {
+ CLog::Log(LOGNOTICE,"%-16s %2i %5i %5i %5i\n", decoder_profiles[x].name,
+ max_level, max_macroblocks, max_width, max_height);
+ }
+ }
+ CLog::Log(LOGNOTICE,"------------------------------------");
+ m_featureCount = 0;
+#define CHECK_SUPPORT(feature) \
+ do { \
+ VdpBool supported; \
+ if(m_vdpProcs.vdp_video_mixer_query_feature_support(m_vdpDevice, feature, &supported) == VDP_STATUS_OK && supported) { \
+ CLog::Log(LOGNOTICE, "Mixer feature: "#feature); \
+ m_vdpFeatures[m_featureCount++] = feature; \
+ } \
+ } while(false)
+
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_SHARPNESS);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE);
+#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8);
+ CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9);
+#endif
+#undef CHECK_SUPPORT
+}
+
+bool CVDPAUContext::Supports(VdpVideoMixerFeature feature)
+{
+ for(int i = 0; i < m_featureCount; i++)
+ {
+ if(m_vdpFeatures[i] == feature)
+ return true;
+ }
+ return false;
+}
+
//-----------------------------------------------------------------------------
// VDPAU Video Surface states
//-----------------------------------------------------------------------------
CDecoder::CDecoder() : m_vdpauOutput(&m_inMsgEvent)
{
- m_vdpauConfig.vdpDevice = VDP_INVALID_HANDLE;
m_vdpauConfig.videoSurfaces = &m_videoSurfaces;
m_vdpauConfigured = false;
m_vdpauConfig.context = 0;
}
-bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat, unsigned int surfaces)
+bool CDecoder::Open(AVCodecContext* avctx, const enum PixelFormat fmt, unsigned int surfaces)
{
+ // check if user wants to decode this format with VDPAU
+ std::string gpuvendor = g_Windowing.GetRenderVendor();
+ std::transform(gpuvendor.begin(), gpuvendor.end(), gpuvendor.begin(), ::tolower);
+ // nvidia is whitelisted despite for mpeg-4 we need to query user settings
+ if ((gpuvendor.compare(0, 6, "nvidia") != 0) || (avctx->codec_id == AV_CODEC_ID_MPEG4) || (avctx->codec_id == AV_CODEC_ID_H263))
+ {
+ if (CDVDVideoCodec::IsCodecDisabled(g_vdpau_available, settings_count, avctx->codec_id))
+ return false;
+ }
+
+#ifndef GL_NV_vdpau_interop
+ CLog::Log(LOGNOTICE, "VDPAU: compilation without required extension GL_NV_vdpau_interop");
+ return false;
+#endif
+ if (!g_Windowing.IsExtSupported("GL_NV_vdpau_interop"))
+ {
+ CLog::Log(LOGNOTICE, "VDPAU::Open: required extension GL_NV_vdpau_interop not found");
+ return false;
+ }
+
if(avctx->coded_width == 0
|| avctx->coded_height == 0)
{
- CLog::Log(LOGWARNING,"(VDPAU) no width/height available, can't init");
+ CLog::Log(LOGWARNING,"VDPAU::Open: no width/height available, can't init");
return false;
}
m_vdpauConfig.numRenderBuffers = surfaces;
m_decoderThread = CThread::GetCurrentThreadId();
- if ((avctx->codec_id == AV_CODEC_ID_MPEG4) && !g_advancedSettings.m_videoAllowMpeg4VDPAU)
- return false;
-
if (!CVDPAUContext::EnsureContext(&m_vdpauConfig.context))
return false;
- m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs);
- m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice();
m_DisplayState = VDPAU_OPEN;
m_vdpauConfigured = false;
m_presentPicture = 0;
{
- SpewHardwareAvailable();
-
VdpDecoderProfile profile = 0;
- if(avctx->codec_id == AV_CODEC_ID_H264)
- profile = VDP_DECODER_PROFILE_H264_HIGH;
-#ifdef VDP_DECODER_PROFILE_MPEG4_PART2_ASP
- else if(avctx->codec_id == AV_CODEC_ID_MPEG4)
- profile = VDP_DECODER_PROFILE_MPEG4_PART2_ASP;
-#endif
+
+ // convert FFMPEG codec ID to VDPAU profile.
+ ReadFormatOf(avctx->codec_id, profile, m_vdpauConfig.vdpChromaType);
if(profile)
{
+ VdpStatus vdp_st;
+ VdpBool is_supported = false;
+ uint32_t max_level, max_macroblocks, max_width, max_height;
+
+ // query device capabilities to ensure that VDPAU can handle the requested codec
+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_query_caps(m_vdpauConfig.context->GetDevice(),
+ profile, &is_supported, &max_level, &max_macroblocks, &max_width, &max_height);
+
+ // test to make sure there is a possibility the codec will work
+ if (CheckStatus(vdp_st, __LINE__))
+ {
+ CLog::Log(LOGERROR, "VDPAU::Open: error %s(%d) checking for decoder support", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st);
+ return false;
+ }
+
+ if (max_width < avctx->coded_width || max_height < avctx->coded_height)
+ {
+ CLog::Log(LOGWARNING,"VDPAU::Open: requested picture dimensions (%i, %i) exceed hardware capabilities ( %i, %i).",
+ avctx->coded_width, avctx->coded_height, max_width, max_height);
+ return false;
+ }
+
if (!CDVDCodecUtils::IsVP3CompatibleWidth(avctx->coded_width))
- CLog::Log(LOGWARNING,"(VDPAU) width %i might not be supported because of hardware bug", avctx->width);
+ CLog::Log(LOGWARNING,"VDPAU::Open width %i might not be supported because of hardware bug", avctx->width);
- /* attempt to create a decoder with this width/height, some sizes are not supported by hw */
- VdpStatus vdp_st;
- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice, profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder);
+ // attempt to create a decoder with this width/height, some sizes are not supported by hw
+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_create(m_vdpauConfig.context->GetDevice(), profile, avctx->coded_width, avctx->coded_height, 5, &m_vdpauConfig.vdpDecoder);
- if(vdp_st != VDP_STATUS_OK)
+ if (CheckStatus(vdp_st, __LINE__))
{
- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) checking for decoder support\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st);
+ CLog::Log(LOGERROR, "VDPAU::Open: error: %s(%d) checking for decoder support", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st);
return false;
}
- m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
+ m_vdpauConfig.context->GetProcs().vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
CheckStatus(vdp_st, __LINE__);
- }
- /* finally setup ffmpeg */
- memset(&m_hwContext, 0, sizeof(AVVDPAUContext));
- m_hwContext.render = CDecoder::Render;
- m_hwContext.bitstream_buffers_allocated = 0;
- avctx->get_buffer = CDecoder::FFGetBuffer;
- avctx->reget_buffer = CDecoder::FFGetBuffer;
- avctx->release_buffer = CDecoder::FFReleaseBuffer;
- avctx->draw_horiz_band = CDecoder::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;
+ // finally setup ffmpeg
+ memset(&m_hwContext, 0, sizeof(AVVDPAUContext));
+ m_hwContext.render = CDecoder::Render;
+ m_hwContext.bitstream_buffers_allocated = 0;
+ avctx->get_buffer = CDecoder::FFGetBuffer;
+ avctx->reget_buffer = CDecoder::FFGetBuffer;
+ avctx->release_buffer = CDecoder::FFReleaseBuffer;
+ avctx->draw_horiz_band = CDecoder::FFDrawSlice;
+ avctx->slice_flags=SLICE_FLAG_CODED_ORDER|SLICE_FLAG_ALLOW_FIELD;
+ avctx->hwaccel_context = &m_hwContext;
+
+ g_Windowing.Register(this);
+ return true;
+ }
}
return false;
}
VdpVideoSurface surf;
while((surf = m_videoSurfaces.RemoveNext(true)) != VDP_INVALID_HANDLE)
{
- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf);
+ m_vdpauConfig.context->GetProcs().vdp_video_surface_destroy(surf);
}
}
return IHardwareDecoder::Release();
if (CVDPAUContext::EnsureContext(&m_vdpauConfig.context))
{
- m_vdpauConfig.context->GetProcs(m_vdpauConfig.vdpProcs);
- m_vdpauConfig.vdpDevice = m_vdpauConfig.context->GetDevice();
m_DisplayState = VDPAU_OPEN;
m_vdpauConfigured = false;
}
bool CDecoder::Supports(VdpVideoMixerFeature feature)
{
- for(int i = 0; i < m_vdpauConfig.featureCount; i++)
- {
- if(m_vdpauConfig.vdpFeatures[i] == feature)
- return true;
- }
- return false;
+ return m_vdpauConfig.context->Supports(feature);
}
bool CDecoder::Supports(EINTERLACEMETHOD method)
|| method == VS_INTERLACEMETHOD_AUTO)
return true;
- if (!m_vdpauConfig.usePixmaps)
- {
- if (method == VS_INTERLACEMETHOD_RENDER_BOB)
- return true;
- }
+ if (method == VS_INTERLACEMETHOD_RENDER_BOB)
+ return true;
if (method == VS_INTERLACEMETHOD_VDPAU_INVERSE_TELECINE)
return false;
void CDecoder::FiniVDPAUOutput()
{
- if (m_vdpauConfig.vdpDevice == VDP_INVALID_HANDLE || !m_vdpauConfigured) return;
+ if (!m_vdpauConfigured)
+ return;
CLog::Log(LOGNOTICE, " (VDPAU) %s", __FUNCTION__);
VdpStatus vdp_st;
- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_destroy(m_vdpauConfig.vdpDecoder);
if (CheckStatus(vdp_st, __LINE__))
return;
m_vdpauConfig.vdpDecoder = VDP_INVALID_HANDLE;
VdpVideoSurface surf;
while((surf = m_videoSurfaces.RemoveNext()) != VDP_INVALID_HANDLE)
{
- m_vdpauConfig.vdpProcs.vdp_video_surface_destroy(surf);
+ m_vdpauConfig.context->GetProcs().vdp_video_surface_destroy(surf);
if (CheckStatus(vdp_st, __LINE__))
return;
}
else
m_vdpauConfig.maxReferences = 2;
- vdp_st = m_vdpauConfig.vdpProcs.vdp_decoder_create(m_vdpauConfig.vdpDevice,
+ vdp_st = m_vdpauConfig.context->GetProcs().vdp_decoder_create(m_vdpauConfig.context->GetDevice(),
vdp_decoder_profile,
m_vdpauConfig.surfaceWidth,
m_vdpauConfig.surfaceHeight,
sizeof(m_vdpauConfig)))
{
bool success = reply->signal == COutputControlProtocol::ACC ? true : false;
- if (success)
- {
- CVdpauConfig *data;
- data = (CVdpauConfig*)reply->data;
- if (data)
- {
- m_vdpauConfig.usePixmaps = data->usePixmaps;
- }
- }
reply->Release();
if (!success)
{
m_inMsgEvent.Reset();
m_vdpauConfigured = true;
+ m_ErrorCount = 0;
return true;
}
-void CDecoder::SpewHardwareAvailable() //CopyrighVDPAUt (c) 2008 Wladimir J. van der Laan -- VDPInfo
-{
- VdpStatus rv;
- CLog::Log(LOGNOTICE,"VDPAU Decoder capabilities:");
- CLog::Log(LOGNOTICE,"name level macbs width height");
- CLog::Log(LOGNOTICE,"------------------------------------");
- for(unsigned int x=0; x<decoder_profile_count; ++x)
- {
- VdpBool is_supported = false;
- uint32_t max_level, max_macroblocks, max_width, max_height;
- rv = m_vdpauConfig.vdpProcs.vdp_decoder_query_caps(m_vdpauConfig.vdpDevice, decoder_profiles[x].id,
- &is_supported, &max_level, &max_macroblocks, &max_width, &max_height);
- if(rv == VDP_STATUS_OK && is_supported)
- {
- CLog::Log(LOGNOTICE,"%-16s %2i %5i %5i %5i\n", decoder_profiles[x].name,
- max_level, max_macroblocks, max_width, max_height);
- }
- }
- CLog::Log(LOGNOTICE,"------------------------------------");
- m_vdpauConfig.featureCount = 0;
-#define CHECK_SUPPORT(feature) \
- do { \
- VdpBool supported; \
- if(m_vdpauConfig.vdpProcs.vdp_video_mixer_query_feature_support(m_vdpauConfig.vdpDevice, feature, &supported) == VDP_STATUS_OK && supported) { \
- CLog::Log(LOGNOTICE, "Mixer feature: "#feature); \
- m_vdpauConfig.vdpFeatures[m_vdpauConfig.featureCount++] = feature; \
- } \
- } while(false)
-
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_SHARPNESS);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE);
-#ifdef VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8);
- CHECK_SUPPORT(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9);
-#endif
-#undef CHECK_SUPPORT
-
-}
-
int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic)
{
//CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
VdpDecoderProfile profile;
ReadFormatOf(avctx->codec_id, profile, vdp->m_vdpauConfig.vdpChromaType);
- vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_video_surface_create(vdp->m_vdpauConfig.vdpDevice,
+ vdp_st = vdp->m_vdpauConfig.context->GetProcs().vdp_video_surface_create(vdp->m_vdpauConfig.context->GetDevice(),
vdp->m_vdpauConfig.vdpChromaType,
avctx->coded_width,
avctx->coded_height,
void CDecoder::FFReleaseBuffer(AVCodecContext *avctx, AVFrame *pic)
{
- //CLog::Log(LOGNOTICE,"%s",__FUNCTION__);
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
CDecoder* vdp = (CDecoder*)ctx->GetHardware();
uint64_t startTime = CurrentHostCounter();
uint16_t decoded, processed, rend;
vdp->m_bufferStats.Get(decoded, processed, rend);
- vdp_st = vdp->m_vdpauConfig.vdpProcs.vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder,
+ vdp_st = vdp->m_vdpauConfig.context->GetProcs().vdp_decoder_render(vdp->m_vdpauConfig.vdpDecoder,
surf,
(VdpPictureInfo const *)&(vdp->m_hwContext.info),
vdp->m_hwContext.bitstream_buffers_used,
vdp->m_hwContext.bitstream_buffers);
- vdp->CheckStatus(vdp_st, __LINE__);
+ if (vdp->CheckStatus(vdp_st, __LINE__))
+ vdp->m_DecoderError = true;
+ else
+ vdp->m_DecoderError = false;
+
uint64_t diff = CurrentHostCounter() - startTime;
if (diff*1000/CurrentHostFrequency() > 30)
CLog::Log(LOGDEBUG, "CVDPAU::DrawSlice - VdpDecoderRender long decoding: %d ms, dec: %d, proc: %d, rend: %d", (int)((diff*1000)/CurrentHostFrequency()), decoded, processed, rend);
CSingleLock lock(m_DecoderSection);
+ if (m_DecoderError && pFrame)
+ return VC_ERROR;
+
if (!m_vdpauConfigured)
return VC_ERROR;
uint64_t startTime = CurrentHostCounter();
while (!retval)
{
- if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg))
+ // first fill the buffers to keep vdpau busy
+ // mixer will run with decoded >= 2. output is limited by number of output surfaces
+ // In case mixer is bypassed we limit by looking at processed
+ if (decoded < 3 && processed < 3)
+ {
+ retval |= VC_BUFFER;
+ }
+ else if (m_vdpauOutput.m_dataPort.ReceiveInMessage(&msg))
{
if (msg->signal == COutputDataProtocol::PICTURE)
{
msg->Release();
}
- // TODO
- if (1) //(m_codecControl & DVP_FLAG_DRAIN))
+ if (decoded < 3 && processed < 3)
{
- if (decoded + processed + render < 4)
- {
- retval |= VC_BUFFER;
- }
- }
- else
- {
- if (decoded < 4 && (processed + render) < 3)
- {
- retval |= VC_BUFFER;
- }
+ retval |= VC_BUFFER;
}
if (!retval && !m_inMsgEvent.WaitMSec(2000))
{
if (vdp_st != VDP_STATUS_OK)
{
- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_vdpauConfig.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
+
+ m_ErrorCount++;
if(m_DisplayState == VDPAU_OPEN)
{
m_DisplayEvent.Reset();
m_DisplayState = VDPAU_LOST;
}
- else
+ else if (m_ErrorCount > 2)
m_DisplayState = VDPAU_ERROR;
}
return true;
}
+ m_ErrorCount = 0;
return false;
}
// Mixer
//-----------------------------------------------------------------------------
CMixer::CMixer(CEvent *inMsgEvent) :
- CThread("Vdpau Mixer Thread"),
+ CThread("Vdpau Mixer"),
m_controlPort("ControlPort", inMsgEvent, &m_outMsgEvent),
m_dataPort("DataPort", inMsgEvent, &m_outMsgEvent)
{
}
else
{
-// if (m_extTimeout != 0)
-// {
-// SetPostProcFeatures(false);
-// CLog::Log(LOGWARNING,"CVDPAU::Mixer timeout - decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size());
-// }
m_extTimeout = 100;
}
return;
}
else
{
-// if (m_extTimeout != 0)
-// {
-// SetPostProcFeatures(false);
-// CLog::Log(LOGNOTICE,"---mixer wait2 decoded: %d, outputSurf: %d", (int)m_decodedPics.size(), (int)m_outputSurfaces.size());
-// }
m_extTimeout = 100;
}
return;
&m_config.vdpChromaType};
VdpStatus vdp_st = VDP_STATUS_ERROR;
- vdp_st = m_config.vdpProcs.vdp_video_mixer_create(m_config.vdpDevice,
- m_config.featureCount,
- m_config.vdpFeatures,
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_create(m_config.context->GetDevice(),
+ m_config.context->GetFeatureCount(),
+ m_config.context->GetFeatures(),
ARSIZE(parameters),
parameters,
parameter_values,
&m_videoMixer);
CheckStatus(vdp_st, __LINE__);
- // create 3 pitches of black lines needed for clipping top
- // and bottom lines when de-interlacing
- m_BlackBar = new uint32_t[3*m_config.outWidth];
- memset(m_BlackBar, 0, 3*m_config.outWidth*sizeof(uint32_t));
-
}
void CMixer::InitCSCMatrix(int Width)
VDP_VIDEO_MIXER_FEATURE_INVERSE_TELECINE};
VdpBool enabled[]={0,0,0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
if(m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION))
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_NOISE_REDUCTION};
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_SHARPNESS};
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
float studioCSC[3][4];
GenerateStudioCSCMatrix(colorStandard, studioCSC);
void const * pm_CSCMatix[] = { &studioCSC };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
}
else
{
- vdp_st = m_config.vdpProcs.vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix);
+ vdp_st = m_config.context->GetProcs().vdp_generate_csc_matrix(&m_Procamp, colorStandard, &m_CSCMatrix);
void const * pm_CSCMatix[] = { &m_CSCMatrix };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, pm_CSCMatix);
}
CheckStatus(vdp_st, __LINE__);
if (!CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction)
{
VdpBool enabled[]= {0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
return;
}
VdpBool enabled[]={1};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
void* nr[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction };
CLog::Log(LOGNOTICE,"Setting Noise Reduction to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_NoiseReduction);
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, nr);
CheckStatus(vdp_st, __LINE__);
}
if (!CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness)
{
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
return;
}
VdpBool enabled[]={1};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
void* sh[] = { &CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness };
CLog::Log(LOGNOTICE,"Setting Sharpness to %f",CMediaSettings::Get().GetCurrentVideoSettings().m_Sharpness);
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attributes), attributes, sh);
CheckStatus(vdp_st, __LINE__);
}
if (mode == VS_DEINTERLACEMODE_OFF)
{
VdpBool enabled[] = {0,0,0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
}
else
{
VdpBool enabled[] = {1,0,0};
if (g_advancedSettings.m_videoVDPAUtelecine)
enabled[2] = 1;
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
}
else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL
|| method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_HALF)
VdpBool enabled[] = {1,0,0};
if (g_advancedSettings.m_videoVDPAUtelecine)
enabled[2] = 1;
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
}
else if (method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL
|| method == VS_INTERLACEMETHOD_VDPAU_TEMPORAL_SPATIAL_HALF)
VdpBool enabled[] = {1,1,0};
if (g_advancedSettings.m_videoVDPAUtelecine)
enabled[2] = 1;
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
}
else
{
VdpBool enabled[]={0,0,0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
}
}
CheckStatus(vdp_st, __LINE__);
val = 0;
void const *values[]={&val};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_attribute_values(m_videoMixer, ARSIZE(attribute), attribute, values);
CheckStatus(vdp_st, __LINE__);
}
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 8:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 7:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 6:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 5:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 4:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 3:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 2:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
case 1:
if (m_config.vdpau->Supports(VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1))
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
break;
}
default:
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L1 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L2 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L3 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L4 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L5 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L6 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L7 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L8 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
{
VdpVideoMixerFeature feature[] = { VDP_VIDEO_MIXER_FEATURE_HIGH_QUALITY_SCALING_L9 };
VdpBool enabled[]={0};
- vdp_st = m_config.vdpProcs.vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_set_feature_enables(m_videoMixer, ARSIZE(feature), feature, enabled);
CheckStatus(vdp_st, __LINE__);
}
}
-
void CMixer::Init()
{
m_Brightness = 0.0;
m_Sharpness = 0.0;
m_DeintMode = 0;
m_Deint = 0;
+ m_Upscale = 0;
+ m_SeenInterlaceFlag = false;
m_ColorMatrix = 0;
m_PostProc = false;
m_vdpError = false;
{
m_outputSurfaces.pop();
}
- m_config.vdpProcs.vdp_video_mixer_destroy(m_videoMixer);
-
- delete [] m_BlackBar;
+ m_config.context->GetProcs().vdp_video_mixer_destroy(m_videoMixer);
}
void CMixer::Flush()
void CMixer::InitCycle()
{
CheckFeatures();
- uint64_t latency;
int flags;
+ uint64_t latency;
m_config.stats->GetParams(latency, flags);
- latency = (latency*1000)/CurrentHostFrequency();
// TODO
if (0) //flags & DVP_FLAG_NO_POSTPROC)
SetPostProcFeatures(false);
EDEINTERLACEMODE mode = CMediaSettings::Get().GetCurrentVideoSettings().m_DeinterlaceMode;
EINTERLACEMETHOD method = GetDeinterlacingMethod();
bool interlaced = m_mixerInput[1].DVDPic.iFlags & DVP_FLAG_INTERLACED;
+ m_SeenInterlaceFlag |= interlaced;
// TODO
if (//!(flags & DVP_FLAG_NO_POSTPROC) &&
}
m_mixerstep = 0;
+ m_processPicture.crop = false;
if (m_mixerInput[1].DVDPic.format == RENDER_FMT_VDPAU)
{
m_processPicture.outputSurface = m_outputSurfaces.front();
m_mixerInput[1].DVDPic.iWidth = m_config.outWidth;
m_mixerInput[1].DVDPic.iHeight = m_config.outHeight;
+ if (m_SeenInterlaceFlag)
+ {
+ double ratio = (double)m_mixerInput[1].DVDPic.iDisplayHeight / m_mixerInput[1].DVDPic.iHeight;
+ m_mixerInput[1].DVDPic.iDisplayHeight = lrint(ratio*(m_mixerInput[1].DVDPic.iHeight-NUM_CROP_PIX*2));
+ m_processPicture.crop = true;
+ }
}
else
{
m_config.videoSurfaces->ClearRender(tmp.videoSurface);
}
m_mixerInput.pop_back();
-// m_config.stats->DecDecoded();
}
}
past_surfaces[1] = m_mixerInput[2].videoSurface;
}
past_surfaces[0] = m_mixerInput[1].videoSurface;
- futu_surfaces[0] = m_mixerInput[1].videoSurface;
- futu_surfaces[1] = m_mixerInput[1].videoSurface;
+ futu_surfaces[0] = m_mixerInput[0].videoSurface;
+ futu_surfaces[1] = m_mixerInput[0].videoSurface;
if (m_mixerInput[0].DVDPic.pts != DVD_NOPTS_VALUE &&
m_mixerInput[1].DVDPic.pts != DVD_NOPTS_VALUE)
destRect.y1 = m_config.outHeight;
// start vdpau video mixer
- vdp_st = m_config.vdpProcs.vdp_video_mixer_render(m_videoMixer,
+ vdp_st = m_config.context->GetProcs().vdp_video_mixer_render(m_videoMixer,
VDP_INVALID_HANDLE,
0,
m_mixerfield,
0,
NULL);
CheckStatus(vdp_st, __LINE__);
-
- if (m_mixerfield != VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME)
- {
- // in order to clip top and bottom lines when de-interlacing
- // we black those lines as a work around for not working
- // background colour using the mixer
- // pixel perfect is preferred over overscanning or zooming
-
- VdpRect clipRect = destRect;
- clipRect.y1 = clipRect.y0 + 2;
- uint32_t *data[] = {m_BlackBar};
- uint32_t pitches[] = {destRect.x1};
- vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
- (void**)data,
- pitches,
- &clipRect);
- CheckStatus(vdp_st, __LINE__);
-
- clipRect = destRect;
- clipRect.y0 = clipRect.y1 - 2;
- vdp_st = m_config.vdpProcs.vdp_output_surface_put_bits_native(m_processPicture.outputSurface,
- (void**)data,
- pitches,
- &clipRect);
- CheckStatus(vdp_st, __LINE__);
- }
}
{
if (vdp_st != VDP_STATUS_OK)
{
- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
m_vdpError = true;
return true;
}
// Output
//-----------------------------------------------------------------------------
COutput::COutput(CEvent *inMsgEvent) :
- CThread("Vdpau Output Thread"),
+ CThread("Vdpau Output"),
m_controlPort("OutputControlPort", inMsgEvent, &m_outMsgEvent),
m_dataPort("OutputDataPort", inMsgEvent, &m_outMsgEvent),
m_mixer(&m_outMsgEvent)
bool COutput::Uninit()
{
m_mixer.Dispose();
+ glFlush();
+ while(ProcessSyncPicture())
+ {
+ Sleep(10);
+ }
GLUnmapSurfaces();
- GLUnbindPixmaps();
ReleaseBufferPool();
DestroyGlxContext();
return true;
bool COutput::HasWork()
{
- if (m_config.usePixmaps)
- {
- if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0)
- return true;
- if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty())
- return true;
- return false;
- }
- else
- {
- if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
- return true;
- return false;
- }
+ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
+ return true;
+ return false;
}
CVdpauRenderPicture* COutput::ProcessMixerPicture()
{
CVdpauRenderPicture *retPic = NULL;
- if (m_config.usePixmaps)
- {
- if (!m_bufferPool.processedPics.empty() && FindFreePixmap() >= 0)
- {
- unsigned int i = FindFreePixmap();
- VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[i];
- pixmap->used = true;
- CVdpauProcessedPicture pic = m_bufferPool.processedPics.front();
- m_bufferPool.processedPics.pop();
- pixmap->surface = pic.outputSurface;
- pixmap->DVDPic = pic.DVDPic;
- pixmap->id = i;
- m_bufferPool.notVisiblePixmaps.push_back(i);
- m_config.vdpProcs.vdp_presentation_queue_display(pixmap->vdp_flip_queue,
- pixmap->surface,0,0,0);
- }
- if (!m_bufferPool.notVisiblePixmaps.empty() && !m_bufferPool.freeRenderPics.empty())
- {
- VdpStatus vdp_st;
- VdpTime time;
- VdpPresentationQueueStatus status;
- int idx = m_bufferPool.notVisiblePixmaps.front();
- VdpauBufferPool::Pixmaps *pixmap = &m_bufferPool.pixmaps[idx];
- vdp_st = m_config.vdpProcs.vdp_presentation_queue_query_surface_status(
- pixmap->vdp_flip_queue, pixmap->surface, &status, &time);
-
- if (vdp_st == VDP_STATUS_OK && status == VDP_PRESENTATION_QUEUE_STATUS_VISIBLE)
- {
- int idx = m_bufferPool.freeRenderPics.front();
- retPic = m_bufferPool.allRenderPics[idx];
- m_bufferPool.freeRenderPics.pop_front();
- m_bufferPool.usedRenderPics.push_back(idx);
- retPic->sourceIdx = pixmap->id;
- retPic->DVDPic = pixmap->DVDPic;
- retPic->valid = true;
- retPic->texture[0] = pixmap->texture;
- retPic->crop = CRect(0,0,0,0);
- m_bufferPool.notVisiblePixmaps.pop_front();
- m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &pixmap->surface, sizeof(pixmap->surface));
- }
- }
- } // pixmap
- else if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
+ if (!m_bufferPool.processedPics.empty() && !m_bufferPool.freeRenderPics.empty())
{
int idx = m_bufferPool.freeRenderPics.front();
retPic = m_bufferPool.allRenderPics[idx];
m_config.useInteropYuv = false;
m_bufferPool.numOutputSurfaces = NUM_RENDER_PICS;
EnsureBufferPool();
- GLMapSurfaces();
+ GLMapSurface(false, procPic.outputSurface);
retPic->sourceIdx = procPic.outputSurface;
retPic->texture[0] = m_bufferPool.glOutputSurfaceMap[procPic.outputSurface].texture[0];
- retPic->crop = CRect(0,0,0,0);
+ retPic->texWidth = m_config.outWidth;
+ retPic->texHeight = m_config.outHeight;
+ retPic->crop.x1 = 0;
+ retPic->crop.y1 = procPic.crop ? NUM_CROP_PIX : 0;
+ retPic->crop.x2 = m_config.outWidth;
+ retPic->crop.y2 = m_config.outHeight - retPic->crop.y1;
}
else
{
m_config.useInteropYuv = true;
- GLMapSurfaces();
+ GLMapSurface(true, procPic.videoSurface);
retPic->sourceIdx = procPic.videoSurface;
for (unsigned int i=0; i<4; ++i)
retPic->texture[i] = m_bufferPool.glVideoSurfaceMap[procPic.videoSurface].texture[i];
void COutput::ProcessReturnPicture(CVdpauRenderPicture *pic)
{
- if (m_config.usePixmaps)
- {
- m_bufferPool.pixmaps[pic->sourceIdx].used = false;
- return;
- }
- else if (pic->DVDPic.format == RENDER_FMT_VDPAU_420)
+ if (pic->DVDPic.format == RENDER_FMT_VDPAU_420)
{
std::map<VdpVideoSurface, VdpauBufferPool::GLVideoSurface>::iterator it;
it = m_bufferPool.glVideoSurfaceMap.find(pic->sourceIdx);
CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
return;
}
+#ifdef GL_NV_vdpau_interop
+ glVDPAUUnmapSurfacesNV(1, &(it->second.glVdpauSurface));
+#endif
VdpVideoSurface surf = it->second.sourceVuv;
m_config.videoSurfaces->ClearRender(surf);
}
CLog::Log(LOGDEBUG, "COutput::ProcessReturnPicture - gl surface not found");
return;
}
+#ifdef GL_NV_vdpau_interop
+ glVDPAUUnmapSurfacesNV(1, &(it->second.glVdpauSurface));
+#endif
VdpOutputSurface outSurf = it->second.sourceRgb;
m_mixer.m_dataPort.SendOutMessage(CMixerDataProtocol::BUFFER, &outSurf, sizeof(outSurf));
}
}
-int COutput::FindFreePixmap()
-{
- // find free pixmap
- unsigned int i;
- for (i = 0; i < m_bufferPool.pixmaps.size(); ++i)
- {
- if (!m_bufferPool.pixmaps[i].used)
- break;
- }
- if (i == m_bufferPool.pixmaps.size())
- return -1;
- else
- return i;
-}
-
bool COutput::EnsureBufferPool()
{
VdpStatus vdp_st;
VdpOutputSurface outputSurface;
for (int i = m_bufferPool.outputSurfaces.size(); i < m_bufferPool.numOutputSurfaces; i++)
{
- vdp_st = m_config.vdpProcs.vdp_output_surface_create(m_config.vdpDevice,
+ vdp_st = m_config.context->GetProcs().vdp_output_surface_create(m_config.context->GetDevice(),
VDP_RGBA_FORMAT_B8G8R8A8,
m_config.outWidth,
m_config.outHeight,
sizeof(VdpOutputSurface));
CLog::Log(LOGNOTICE, "VDPAU::COutput::InitBufferPool - Output Surface created");
}
-
-
- if (m_config.usePixmaps && m_bufferPool.pixmaps.empty())
- {
- // create pixmpas
- VdpauBufferPool::Pixmaps pixmap;
- unsigned int numPixmaps = NUM_RENDER_PICS;
- for (unsigned int i = 0; i < numPixmaps; i++)
- {
- pixmap.pixmap = None;
- pixmap.glPixmap = None;
- pixmap.vdp_flip_queue = VDP_INVALID_HANDLE;
- pixmap.vdp_flip_target = VDP_INVALID_HANDLE;
- MakePixmap(pixmap);
- glXMakeCurrent(m_Display, None, NULL);
- vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_create_x11(m_config.vdpDevice,
- pixmap.pixmap, //x_window,
- &pixmap.vdp_flip_target);
-
- CheckStatus(vdp_st, __LINE__);
-
- vdp_st = m_config.vdpProcs.vdp_presentation_queue_create(m_config.vdpDevice,
- pixmap.vdp_flip_target,
- &pixmap.vdp_flip_queue);
- CheckStatus(vdp_st, __LINE__);
- glXMakeCurrent(m_Display, m_glPixmap, m_glContext);
-
- pixmap.id = i;
- pixmap.used = false;
- m_bufferPool.pixmaps.push_back(pixmap);
- }
- GLBindPixmaps();
- }
-
return true;
}
CSingleLock lock(m_bufferPool.renderPicSec);
- if (m_config.usePixmaps)
- {
- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); ++i)
- {
- if (m_bufferPool.pixmaps[i].vdp_flip_queue != VDP_INVALID_HANDLE)
- {
- vdp_st = m_config.vdpProcs.vdp_presentation_queue_destroy(m_bufferPool.pixmaps[i].vdp_flip_queue);
- CheckStatus(vdp_st, __LINE__);
- }
- if (m_bufferPool.pixmaps[i].vdp_flip_target != VDP_INVALID_HANDLE)
- {
- vdp_st = m_config.vdpProcs.vdp_presentation_queue_target_destroy(m_bufferPool.pixmaps[i].vdp_flip_target);
- CheckStatus(vdp_st, __LINE__);
- }
- if (m_bufferPool.pixmaps[i].glPixmap)
- {
- glXDestroyPixmap(m_Display, m_bufferPool.pixmaps[i].glPixmap);
- }
- if (m_bufferPool.pixmaps[i].pixmap)
- {
- XFreePixmap(m_Display, m_bufferPool.pixmaps[i].pixmap);
- }
- }
- m_bufferPool.pixmaps.clear();
- }
-
// release all output surfaces
for (unsigned int i = 0; i < m_bufferPool.outputSurfaces.size(); ++i)
{
if (m_bufferPool.outputSurfaces[i] == VDP_INVALID_HANDLE)
continue;
- vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]);
+ vdp_st = m_config.context->GetProcs().vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]);
CheckStatus(vdp_st, __LINE__);
}
m_bufferPool.outputSurfaces.clear();
m_bufferPool.glOutputSurfaceMap.erase(it_map);
#endif
- vdp_st = m_config.vdpProcs.vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]);
+ vdp_st = m_config.context->GetProcs().vdp_output_surface_destroy(m_bufferPool.outputSurfaces[i]);
CheckStatus(vdp_st, __LINE__);
m_bufferPool.outputSurfaces[i] = VDP_INVALID_HANDLE;
}
}
-bool COutput::MakePixmap(VdpauBufferPool::Pixmaps &pixmap)
-{
- CLog::Log(LOGNOTICE,"Creating %ix%i pixmap", m_config.outWidth, m_config.outHeight);
-
- // Get our window attribs.
- XWindowAttributes wndattribs;
- XGetWindowAttributes(m_Display, g_Windowing.GetWindow(), &wndattribs);
-
- pixmap.pixmap = XCreatePixmap(m_Display,
- g_Windowing.GetWindow(),
- m_config.outWidth,
- m_config.outHeight,
- wndattribs.depth);
- if (!pixmap.pixmap)
- {
- CLog::Log(LOGERROR, "VDPAU::COUtput::MakePixmap - GLX Error: MakePixmap: Unable to create XPixmap");
- return false;
- }
-
-// XGCValues values = {};
-// GC xgc;
-// values.foreground = BlackPixel (m_Display, DefaultScreen (m_Display));
-// xgc = XCreateGC(m_Display, pixmap.pixmap, GCForeground, &values);
-// XFillRectangle(m_Display, pixmap.pixmap, xgc, 0, 0, m_config.outWidth, m_config.outHeight);
-// XFreeGC(m_Display, xgc);
-
- if(!MakePixmapGL(pixmap))
- return false;
-
- return true;
-}
-
-bool COutput::MakePixmapGL(VdpauBufferPool::Pixmaps &pixmap)
-{
- int num=0;
- int fbConfigIndex = 0;
-
- int doubleVisAttributes[] = {
- GLX_RENDER_TYPE, GLX_RGBA_BIT,
- GLX_RED_SIZE, 8,
- GLX_GREEN_SIZE, 8,
- GLX_BLUE_SIZE, 8,
- GLX_ALPHA_SIZE, 8,
- GLX_DEPTH_SIZE, 8,
- GLX_DRAWABLE_TYPE, GLX_PIXMAP_BIT,
- GLX_BIND_TO_TEXTURE_RGBA_EXT, True,
- GLX_DOUBLEBUFFER, False,
- GLX_Y_INVERTED_EXT, True,
- GLX_X_RENDERABLE, True,
- None
- };
-
- int pixmapAttribs[] = {
- GLX_TEXTURE_TARGET_EXT, GLX_TEXTURE_2D_EXT,
- GLX_TEXTURE_FORMAT_EXT, GLX_TEXTURE_FORMAT_RGBA_EXT,
- None
- };
-
- GLXFBConfig *fbConfigs;
- fbConfigs = glXChooseFBConfig(m_Display, g_Windowing.GetCurrentScreen(), doubleVisAttributes, &num);
- if (fbConfigs==NULL)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - No compatible framebuffers found");
- return false;
- }
- fbConfigIndex = 0;
-
- pixmap.glPixmap = glXCreatePixmap(m_Display, fbConfigs[fbConfigIndex], pixmap.pixmap, pixmapAttribs);
-
- if (!pixmap.glPixmap)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput::MakPixmapGL - Could not create Pixmap");
- XFree(fbConfigs);
- return false;
- }
- XFree(fbConfigs);
- return true;
-}
-
bool COutput::GLInit()
{
- glXBindTexImageEXT = NULL;
- glXReleaseTexImageEXT = NULL;
#ifdef GL_NV_vdpau_interop
glVDPAUInitNV = NULL;
glVDPAUFiniNV = NULL;
glVDPAUGetSurfaceivNV = NULL;
#endif
- m_config.usePixmaps = false;
-
#ifdef GL_NV_vdpau_interop
- if (glewIsSupported("GL_NV_vdpau_interop"))
- {
if (!glVDPAUInitNV)
glVDPAUInitNV = (PFNGLVDPAUINITNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUInitNV");
if (!glVDPAUFiniNV)
if (!glVDPAUGetSurfaceivNV)
glVDPAUGetSurfaceivNV = (PFNGLVDPAUGETSURFACEIVNVPROC)glXGetProcAddress((GLubyte *) "glVDPAUGetSurfaceivNV");
- CLog::Log(LOGNOTICE, "VDPAU::COutput GL interop supported");
- }
- else
-#endif
- {
- m_config.usePixmaps = true;
- CSettings::Get().SetBool("videoplayer.usevdpaumixer",true);
- }
- if (!glXBindTexImageEXT)
- glXBindTexImageEXT = (PFNGLXBINDTEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXBindTexImageEXT");
- if (!glXReleaseTexImageEXT)
- glXReleaseTexImageEXT = (PFNGLXRELEASETEXIMAGEEXTPROC)glXGetProcAddress((GLubyte *) "glXReleaseTexImageEXT");
-
-#ifdef GL_NV_vdpau_interop
- if (!m_config.usePixmaps)
+ while (glGetError() != GL_NO_ERROR);
+ glVDPAUInitNV(reinterpret_cast<void*>(m_config.context->GetDevice()), reinterpret_cast<void*>(m_config.context->GetProcs().vdp_get_proc_address));
+ if (glGetError() != GL_NO_ERROR)
{
- while (glGetError() != GL_NO_ERROR);
- glVDPAUInitNV(reinterpret_cast<void*>(m_config.vdpDevice), reinterpret_cast<void*>(m_config.vdpProcs.vdp_get_proc_address));
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed");
- m_vdpError = true;
- return false;
- }
- CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized");
+ CLog::Log(LOGERROR, "VDPAU::COutput - GLInitInterop glVDPAUInitNV failed");
+ m_vdpError = true;
+ return false;
}
+ CLog::Log(LOGNOTICE, "VDPAU::COutput: vdpau gl interop initialized");
#endif
#ifdef GL_ARB_sync
return true;
}
-void COutput::GLMapSurfaces()
+void COutput::GLMapSurface(bool yuv, uint32_t source)
{
#ifdef GL_NV_vdpau_interop
- if (m_config.usePixmaps)
- return;
- if (m_config.useInteropYuv)
+ if (yuv)
{
- VdpauBufferPool::GLVideoSurface glSurface;
- VdpVideoSurface surf;
- if (m_config.videoSurfaces->Size() != m_bufferPool.glVideoSurfaceMap.size())
+ std::map<VdpVideoSurface, VdpauBufferPool::GLVideoSurface>::iterator it;
+ it = m_bufferPool.glVideoSurfaceMap.find(source);
+ if (it == m_bufferPool.glVideoSurfaceMap.end())
{
- for (unsigned int i = 0; i < m_config.videoSurfaces->Size(); i++)
- {
- surf = m_config.videoSurfaces->GetAtIndex(i);
+ VdpauBufferPool::GLVideoSurface glSurface;
+ VdpVideoSurface surf = source;
- if (surf == VDP_INVALID_HANDLE)
- continue;
+ if (surf == VDP_INVALID_HANDLE)
+ return;
- if (m_bufferPool.glVideoSurfaceMap.find(surf) == m_bufferPool.glVideoSurfaceMap.end())
- {
- glSurface.sourceVuv = surf;
- while (glGetError() != GL_NO_ERROR) ;
- glGenTextures(4, glSurface.texture);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error creating texture");
- m_vdpError = true;
- }
- glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast<void*>(surf),
+ glSurface.sourceVuv = surf;
+ while (glGetError() != GL_NO_ERROR) ;
+ glGenTextures(4, glSurface.texture);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error creating texture");
+ m_vdpError = true;
+ }
+ glSurface.glVdpauSurface = glVDPAURegisterVideoSurfaceNV(reinterpret_cast<void*>(surf),
GL_TEXTURE_2D, 4, glSurface.texture);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error register video surface");
- m_vdpError = true;
- }
- glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
- m_vdpError = true;
- }
- glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
- m_vdpError = true;
- }
- m_bufferPool.glVideoSurfaceMap[surf] = glSurface;
- if (m_vdpError)
- return;
- CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface");
- }
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error register video surface");
+ m_vdpError = true;
}
+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
+ m_vdpError = true;
+ }
+ m_bufferPool.glVideoSurfaceMap[surf] = glSurface;
+
+ CLog::Log(LOGNOTICE, "VDPAU::COutput registered surface");
}
+
+ while (glGetError() != GL_NO_ERROR) ;
+ glVDPAUMapSurfacesNV(1, &m_bufferPool.glVideoSurfaceMap[source].glVdpauSurface);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
+ m_vdpError = true;
+ }
+
+ if (m_vdpError)
+ return;
}
else
{
- if (m_bufferPool.glOutputSurfaceMap.size() != m_bufferPool.numOutputSurfaces)
+ std::map<VdpOutputSurface, VdpauBufferPool::GLVideoSurface>::iterator it;
+ it = m_bufferPool.glOutputSurfaceMap.find(source);
+ if (it == m_bufferPool.glOutputSurfaceMap.end())
{
- VdpauBufferPool::GLVideoSurface glSurface;
- for (unsigned int i = m_bufferPool.glOutputSurfaceMap.size(); i<m_bufferPool.outputSurfaces.size(); i++)
+ unsigned int idx = 0;
+ for (idx = 0; idx<m_bufferPool.outputSurfaces.size(); idx++)
{
- glSurface.sourceRgb = m_bufferPool.outputSurfaces[i];
- glGenTextures(1, glSurface.texture);
- glSurface.glVdpauSurface = glVDPAURegisterOutputSurfaceNV(reinterpret_cast<void*>(m_bufferPool.outputSurfaces[i]),
+ if (m_bufferPool.outputSurfaces[idx] == source)
+ break;
+ }
+
+ VdpauBufferPool::GLVideoSurface glSurface;
+ glSurface.sourceRgb = m_bufferPool.outputSurfaces[idx];
+ glGenTextures(1, glSurface.texture);
+ glSurface.glVdpauSurface = glVDPAURegisterOutputSurfaceNV(reinterpret_cast<void*>(m_bufferPool.outputSurfaces[idx]),
GL_TEXTURE_2D, 1, glSurface.texture);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error register output surface");
- m_vdpError = true;
- }
- glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
- m_vdpError = true;
- }
- glVDPAUMapSurfacesNV(1, &glSurface.glVdpauSurface);
- if (glGetError() != GL_NO_ERROR)
- {
- CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
- m_vdpError = true;
- }
- m_bufferPool.glOutputSurfaceMap[m_bufferPool.outputSurfaces[i]] = glSurface;
- if (m_vdpError)
- return;
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error register output surface");
+ m_vdpError = true;
+ }
+ glVDPAUSurfaceAccessNV(glSurface.glVdpauSurface, GL_READ_ONLY);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error setting access");
+ m_vdpError = true;
}
+ m_bufferPool.glOutputSurfaceMap[source] = glSurface;
CLog::Log(LOGNOTICE, "VDPAU::COutput registered output surfaces");
}
+
+ while (glGetError() != GL_NO_ERROR) ;
+ glVDPAUMapSurfacesNV(1, &m_bufferPool.glOutputSurfaceMap[source].glVdpauSurface);
+ if (glGetError() != GL_NO_ERROR)
+ {
+ CLog::Log(LOGERROR, "VDPAU::COutput error mapping surface");
+ m_vdpError = true;
+ }
+
+ if (m_vdpError)
+ return;
}
#endif
}
void COutput::GLUnmapSurfaces()
{
#ifdef GL_NV_vdpau_interop
- if (m_config.usePixmaps)
- return;
{
std::map<VdpVideoSurface, VdpauBufferPool::GLVideoSurface>::iterator it;
#endif
}
-void COutput::GLBindPixmaps()
-{
- if (!m_config.usePixmaps)
- return;
-
- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++)
- {
- // create texture
- glGenTextures(1, &m_bufferPool.pixmaps[i].texture);
-
- //bind texture
- glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture);
-
- // bind pixmap
- glXBindTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT, NULL);
-
- glBindTexture(GL_TEXTURE_2D, 0);
- }
-
- CLog::Log(LOGNOTICE, "VDPAU::COutput: bound pixmaps");
-}
-
-void COutput::GLUnbindPixmaps()
-{
- if (!m_config.usePixmaps)
- return;
-
- for (unsigned int i = 0; i < m_bufferPool.pixmaps.size(); i++)
- {
- // create texture
- if (!glIsTexture(m_bufferPool.pixmaps[i].texture))
- continue;
-
- //bind texture
- glBindTexture(GL_TEXTURE_2D, m_bufferPool.pixmaps[i].texture);
-
- // release pixmap
- glXReleaseTexImageEXT(m_Display, m_bufferPool.pixmaps[i].glPixmap, GLX_FRONT_LEFT_EXT);
-
- glBindTexture(GL_TEXTURE_2D, 0);
-
- glDeleteTextures(1, &m_bufferPool.pixmaps[i].texture);
- }
- CLog::Log(LOGNOTICE, "VDPAU::COutput: unbound pixmaps");
-}
-
bool COutput::CheckStatus(VdpStatus vdp_st, int line)
{
if (vdp_st != VDP_STATUS_OK)
{
- CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.vdpProcs.vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
+ CLog::Log(LOGERROR, " (VDPAU) Error: %s(%d) at %s:%d\n", m_config.context->GetProcs().vdp_get_error_string(vdp_st), vdp_st, __FILE__, line);
m_vdpError = true;
return true;
}