我从 Video_Codec_SDK_8.0.14 测试了 nv 编解码器 SDK 项目“NvDecodeD3D11”。当我编译它时,错误发生在 cuvidCtxLockCreate(&g_CtxLock, g_oContext);
它表示访问冲突执行位置 0x0000000000000000 意味着 g_CtxLock 为 NULL。我该如何解决?
您可以从这里下载源代码:https ://developer.nvidia.com/designworks/video_codec_sdk/downloads/v8.0
我使用VS 2013在x64平台编译配置。
void initCudaVideo()
{
// bind the context lock to the CUDA context
CUresult result = cuvidCtxLockCreate(&g_CtxLock, g_oContext);
CUVIDEOFORMATEX oFormatEx;
memset(&oFormatEx, 0, sizeof(CUVIDEOFORMATEX));
oFormatEx.format = g_stFormat;
if (result != CUDA_SUCCESS)
{
printf("cuvidCtxLockCreate failed: %d\n", result);
assert(0);
}
CUVIDEOFORMAT videoFormat = g_pVideoSource->format();
CUVIDDECODECAPS videoDecodeCaps = {};
videoDecodeCaps.eCodecType = videoFormat.codec;
videoDecodeCaps.eChromaFormat = videoFormat.chroma_format;
videoDecodeCaps.nBitDepthMinus8 = videoFormat.bit_depth_luma_minus8;
if (cuvidGetDecoderCaps(&videoDecodeCaps) != CUDA_SUCCESS)
{
printf("cuvidGetDecoderCaps failed: %d\n", result);
return;
}
if (!videoDecodeCaps.bIsSupported) {
printf("Error: This video format isn't supported on the selected GPU.");
exit(1);;
}
// If XxY is max supported resolution for a codec on a GPU and YxX resolution
// is also supported then Max Supported width is Max(X, Y) and Max supported height is Max(X, Y)
// But Max supported MBCount is XxY / 256.
// E.g. 4096x2304 is max supported resolution and 2304x4096 is also supported then
// Max Width = 4096, Max Height = 4096, But Max supported MB Count = 4096*2304 / 256 = 36864
printf("This video format is supported on the selected GPU. \n"
" Min resolution supported : %dx%d\n"
" Max width supported : %d\n"
" Max height supported : %d\n"
" Max macroblocks supported: %d\n", videoDecodeCaps.nMinWidth, videoDecodeCaps.nMinHeight,
videoDecodeCaps.nMaxWidth, videoDecodeCaps.nMaxHeight, videoDecodeCaps.nMaxMBCount);
std::unique_ptr<VideoDecoder> apVideoDecoder(new VideoDecoder(g_pVideoSource->format(), g_oContext, g_eVideoCreateFlags, g_CtxLock));
std::unique_ptr<VideoParser> apVideoParser(new VideoParser(apVideoDecoder.get(), g_pFrameQueue, &oFormatEx));
g_pVideoSource->setParser(*apVideoParser.get());
g_pVideoParser = apVideoParser.release();
g_pVideoDecoder = apVideoDecoder.release();
// Create a Stream ID for handling Readback
if (g_bReadback)
{
checkCudaErrors(cuStreamCreate(&g_ReadbackSID, 0));
checkCudaErrors(cuStreamCreate(&g_KernelSID, 0));
printf("> initCudaVideo()\n");
printf(" CUDA Streams (%s) <g_ReadbackSID = %p>\n", ((g_ReadbackSID == 0) ? "Disabled" : "Enabled"), g_ReadbackSID);
printf(" CUDA Streams (%s) <g_KernelSID = %p>\n", ((g_KernelSID == 0) ? "Disabled" : "Enabled"), g_KernelSID);
}
}