本文整理汇总了C++中vdpau::CDecoder::Open方法的典型用法代码示例。如果您正苦于以下问题:C++ CDecoder::Open方法的具体用法?C++ CDecoder::Open怎么用?C++ CDecoder::Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vdpau::CDecoder
的用法示例。
在下文中一共展示了CDecoder::Open方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetFormat
enum AVPixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
, const AVPixelFormat * fmt )
{
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
// if frame threading is enabled hw accel is not allowed
if(ctx->m_decoderState != STATE_HW_SINGLE)
{
return avcodec_default_get_format(avctx, fmt);
}
// fix an ffmpeg issue here, it calls us with an invalid profile
// then a 2nd call with a valid one
if (avctx->codec_id == AV_CODEC_ID_VC1 && avctx->profile == FF_PROFILE_UNKNOWN)
{
return avcodec_default_get_format(avctx, fmt);
}
// hardware decoder de-selected, restore standard ffmpeg
if (ctx->GetHardware())
{
ctx->SetHardware(NULL);
avctx->get_buffer2 = avcodec_default_get_buffer2;
avctx->slice_flags = 0;
avctx->hwaccel_context = 0;
}
const AVPixelFormat * cur = fmt;
while(*cur != AV_PIX_FMT_NONE)
{
#ifdef HAVE_LIBVDPAU
if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVDPAU))
{
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
if(vdp->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(vdp);
return *cur;
}
else
vdp->Release();
}
#endif
#ifdef HAS_DX
if(DXVA::CDecoder::Supports(*cur) && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEDXVA2) &&
!ctx->m_hints.dvd && !ctx->m_hints.stills)
{
CLog::Log(LOGNOTICE, "CDVDVideoCodecFFmpeg::GetFormat - Creating DXVA(%ix%i)", avctx->width, avctx->height);
DXVA::CDecoder* dec = new DXVA::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAVE_LIBVA
// mpeg4 vaapi decoding is disabled
if(*cur == AV_PIX_FMT_VAAPI_VLD && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVAAPI))
{
VAAPI::CDecoder* dec = new VAAPI::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount) == true)
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef TARGET_DARWIN
if (*cur == AV_PIX_FMT_VIDEOTOOLBOX && CSettings::GetInstance().GetBool(CSettings::SETTING_VIDEOPLAYER_USEVTB))
{
VTB::CDecoder* dec = new VTB::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAS_MMAL
if (*cur == AV_PIX_FMT_YUV420P)
{
MMAL::CDecoder* dec = new MMAL::CDecoder();
ctx->m_pCodecContext->hwaccel_context = (void *)ctx->m_options.m_opaque_pointer;
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
//.........这里部分代码省略.........
示例2: GetFormat
enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
, const PixelFormat * fmt )
{
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
// if frame threading is enabled hw accel is not allowed
if(ctx->m_decoderState != STATE_HW_SINGLE)
{
return avcodec_default_get_format(avctx, fmt);
}
const PixelFormat * cur = fmt;
while(*cur != PIX_FMT_NONE)
{
#ifdef HAVE_LIBVDPAU
if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && CSettings::Get().GetBool("videoplayer.usevdpau"))
{
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
if(vdp->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(vdp);
return *cur;
}
else
vdp->Release();
}
#endif
#ifdef HAS_DX
if(DXVA::CDecoder::Supports(*cur) && CSettings::Get().GetBool("videoplayer.usedxva2"))
{
CLog::Log(LOGNOTICE, "CDVDVideoCodecFFmpeg::GetFormat - Creating DXVA(%ix%i)", avctx->width, avctx->height);
DXVA::CDecoder* dec = new DXVA::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAVE_LIBVA
// mpeg4 vaapi decoding is disabled
if(*cur == PIX_FMT_VAAPI_VLD && CSettings::Get().GetBool("videoplayer.usevaapi"))
{
VAAPI::CDecoder* dec = new VAAPI::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount) == true)
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef TARGET_DARWIN_OSX
if (*cur == AV_PIX_FMT_VDA && CSettings::Get().GetBool("videoplayer.usevda") && g_advancedSettings.m_useFfmpegVda)
{
VDA::CDecoder* dec = new VDA::CDecoder();
if(dec->Open(avctx, ctx->m_pCodecContext, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
cur++;
}
// hardware decoder de-selected, restore standard ffmpeg
if (ctx->GetHardware())
{
ctx->SetHardware(NULL);
avctx->get_buffer2 = avcodec_default_get_buffer2;
avctx->slice_flags = 0;
avctx->hwaccel_context = 0;
}
ctx->m_decoderState = STATE_HW_FAILED;
return avcodec_default_get_format(avctx, fmt);
}
示例3: GetFormat
enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
, const PixelFormat * fmt )
{
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
// if frame threading is enabled hw accel is not allowed
if((EDECODEMETHOD) CSettings::Get().GetInt("videoplayer.decodingmethod") != VS_DECODEMETHOD_HARDWARE || !ctx->IsHardwareAllowed())
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
const PixelFormat * cur = fmt;
while(*cur != PIX_FMT_NONE)
{
#ifdef HAVE_LIBVDPAU
if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && CSettings::Get().GetBool("videoplayer.usevdpau"))
{
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
if(vdp->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(vdp);
return *cur;
}
else
vdp->Release();
}
#endif
#ifdef HAS_DX
if(DXVA::CDecoder::Supports(*cur) && CSettings::Get().GetBool("videoplayer.usedxva2"))
{
DXVA::CDecoder* dec = new DXVA::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAVE_LIBVA
// mpeg4 vaapi decoding is disabled
if(*cur == PIX_FMT_VAAPI_VLD && CSettings::Get().GetBool("videoplayer.usevaapi"))
{
VAAPI::CDecoder* dec = new VAAPI::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef TARGET_DARWIN_OSX
if (*cur == AV_PIX_FMT_VDA_VLD && CSettings::Get().GetBool("videoplayer.usevda"))
{
VDA::CDecoder* dec = new VDA::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
cur++;
}
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
}
示例4: GetFormat
enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
, const PixelFormat * fmt )
{
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
if(!ctx->IsHardwareAllowed())
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
/* there are many corrupt mpeg2 rips from dvd's which don't *
* follow profile spec properly, they go corrupt on hw, so *
* keep those running in software for the time being. */
if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
&& avctx->height <= 576
&& avctx->width <= 720)
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
const PixelFormat * cur = fmt;
while(*cur != PIX_FMT_NONE)
{
#ifdef HAVE_LIBVDPAU
if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && CSettings::Get().GetBool("videoplayer.usevdpau"))
{
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
if(vdp->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(vdp);
return *cur;
}
else
vdp->Release();
}
#endif
#ifdef HAS_DX
if(DXVA::CDecoder::Supports(*cur) && CSettings::Get().GetBool("videoplayer.usedxva2"))
{
DXVA::CDecoder* dec = new DXVA::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAVE_LIBVA
// mpeg4 vaapi decoding is disabled
if(*cur == PIX_FMT_VAAPI_VLD && CSettings::Get().GetBool("videoplayer.usevaapi")
&& (avctx->codec_id != AV_CODEC_ID_MPEG4 || g_advancedSettings.m_videoAllowMpeg4VAAPI))
{
if (ctx->GetHardware() != NULL)
{
ctx->SetHardware(NULL);
}
VAAPI::CDecoder* dec = new VAAPI::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef TARGET_DARWIN_OSX
if (*cur == AV_PIX_FMT_VDA_VLD && CSettings::Get().GetBool("videoplayer.usevda"))
{
VDA::CDecoder* dec = new VDA::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
cur++;
}
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
}
示例5: GetFormat
enum PixelFormat CDVDVideoCodecFFmpeg::GetFormat( struct AVCodecContext * avctx
, const PixelFormat * fmt )
{
CDVDVideoCodecFFmpeg* ctx = (CDVDVideoCodecFFmpeg*)avctx->opaque;
if(!ctx->IsHardwareAllowed())
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
const PixelFormat * cur = fmt;
while(*cur != PIX_FMT_NONE)
{
#ifdef HAVE_LIBVDPAU
if(VDPAU::CDecoder::IsVDPAUFormat(*cur) && g_guiSettings.GetBool("videoplayer.usevdpau"))
{
if(ctx->GetHardware())
return *cur;
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::GetFormat - Creating VDPAU(%ix%i)", avctx->width, avctx->height);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
if(vdp->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(vdp);
return *cur;
}
else
vdp->Release();
}
#endif
#ifdef HAS_DX
if(DXVA::CDecoder::Supports(*cur) && g_guiSettings.GetBool("videoplayer.usedxva2"))
{
DXVA::CDecoder* dec = new DXVA::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAVE_LIBXVBA
if(*cur == PIX_FMT_XVBA_VLD && g_guiSettings.GetBool("videoplayer.usexvba"))
{
XVBA::CDecoder* dec = new XVBA::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
#ifdef HAVE_LIBVA
// mpeg4 vaapi decoding is disabled
if(*cur == PIX_FMT_VAAPI_VLD && g_guiSettings.GetBool("videoplayer.usevaapi")
&& (avctx->codec_id != CODEC_ID_MPEG4 || g_advancedSettings.m_videoAllowMpeg4VAAPI))
{
VAAPI::CDecoder* dec = new VAAPI::CDecoder();
if(dec->Open(avctx, *cur, ctx->m_uSurfacesCount))
{
ctx->SetHardware(dec);
return *cur;
}
else
dec->Release();
}
#endif
cur++;
}
return ctx->m_dllAvCodec.avcodec_default_get_format(avctx, fmt);
}
示例6: Open
bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
{
AVCodec* pCodec;
if(!m_dllAvUtil.Load()
|| !m_dllAvCodec.Load()
|| !m_dllSwScale.Load()
|| !m_dllAvFilter.Load()
) return false;
m_dllAvCodec.avcodec_register_all();
m_dllAvFilter.avfilter_register_all();
m_bSoftware = hints.software;
m_iOrientation = hints.orientation;
for(std::vector<ERenderFormat>::iterator it = options.m_formats.begin(); it != options.m_formats.end(); ++it)
{
m_formats.push_back((PixelFormat)CDVDCodecUtils::PixfmtFromEFormat(*it));
if(*it == RENDER_FMT_YUV420P)
m_formats.push_back(PIX_FMT_YUVJ420P);
}
m_formats.push_back(PIX_FMT_NONE); /* always add none to get a terminated list in ffmpeg world */
pCodec = NULL;
m_pCodecContext = NULL;
if (hints.codec == CODEC_ID_H264)
{
switch(hints.profile)
{
case FF_PROFILE_H264_HIGH_10:
case FF_PROFILE_H264_HIGH_10_INTRA:
case FF_PROFILE_H264_HIGH_422:
case FF_PROFILE_H264_HIGH_422_INTRA:
case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
case FF_PROFILE_H264_HIGH_444_INTRA:
case FF_PROFILE_H264_CAVLC_444:
// this is needed to not open the decoders
m_bSoftware = true;
// this we need to enable multithreading for hi10p via advancedsettings
m_isHi10p = true;
break;
}
}
#ifdef HAVE_LIBVDPAU
if(g_guiSettings.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);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
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;
// check number of surfaces used in renderer
unsigned int surfaces = 0;
for(std::vector<CDVDCodecOption>::iterator it = options.m_keys.begin(); it != options.m_keys.end(); it++)
{
if (it->m_name == "surfaces")
{
surfaces = std::atoi(it->m_value.c_str());
break;
}
}
if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE, surfaces))
{
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);
if(pCodec == NULL)
{
CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to find codec %d", hints.codec);
return false;
}
//.........这里部分代码省略.........
示例7: Open
bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options)
{
AVCodec* pCodec;
if(!m_dllAvUtil.Load()
|| !m_dllAvCodec.Load()
|| !m_dllSwScale.Load()
|| !m_dllAvFilter.Load()
) return false;
m_dllAvCodec.avcodec_register_all();
m_dllAvFilter.avfilter_register_all();
m_bSoftware = hints.software;
m_pCodecContext = m_dllAvCodec.avcodec_alloc_context();
pCodec = NULL;
if (hints.codec == CODEC_ID_H264)
{
switch(hints.profile)
{
case FF_PROFILE_H264_HIGH_10:
case FF_PROFILE_H264_HIGH_10_INTRA:
case FF_PROFILE_H264_HIGH_422:
case FF_PROFILE_H264_HIGH_422_INTRA:
case FF_PROFILE_H264_HIGH_444_PREDICTIVE:
case FF_PROFILE_H264_HIGH_444_INTRA:
case FF_PROFILE_H264_CAVLC_444:
m_bSoftware = true;
break;
}
}
#ifdef HAVE_LIBVDPAU
if(g_guiSettings.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);
VDPAU::CDecoder* vdp = new VDPAU::CDecoder();
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;
// check number of surfaces used in renderer
unsigned int surfaces = 0;
for(CDVDCodecOptions::iterator it = options.begin(); it != options.end(); it++)
{
if (it->m_name == "surfaces")
{
surfaces = std::atoi(it->m_value.c_str());
break;
}
}
if(vdp->Open(m_pCodecContext, pCodec->pix_fmts ? pCodec->pix_fmts[0] : PIX_FMT_NONE, surfaces))
{
m_pHardware = vdp;
m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
break;
}
m_pCodecContext->codec_id = CODEC_ID_NONE; // ffmpeg will complain if this has been set
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Failed to get VDPAU device");
vdp->Release();
}
}
}
#endif
if(pCodec == NULL)
pCodec = m_dllAvCodec.avcodec_find_decoder(hints.codec);
if(pCodec == NULL)
{
CLog::Log(LOGDEBUG,"CDVDVideoCodecFFmpeg::Open() Unable to find codec %d", hints.codec);
return false;
}
CLog::Log(LOGNOTICE,"CDVDVideoCodecFFmpeg::Open() Using codec: %s",pCodec->long_name ? pCodec->long_name : pCodec->name);
m_pCodecContext->opaque = (void*)this;
m_pCodecContext->debug_mv = 0;
m_pCodecContext->debug = 0;
m_pCodecContext->workaround_bugs = FF_BUG_AUTODETECT;
m_pCodecContext->get_format = GetFormat;
m_pCodecContext->codec_tag = hints.codec_tag;
#if defined(__APPLE__) && defined(__arm__)
// ffmpeg with enabled neon will crash and burn if this is enabled
m_pCodecContext->flags &= CODEC_FLAG_EMU_EDGE;
#else
//.........这里部分代码省略.........