【问题标题】:CUDA H.264 decoder initialization problemsCUDA H.264解码器初始化问题
【发布时间】:2012-09-24 07:50:46
【问题描述】:

我正在尝试基于 NVIDIA GPU Computing SDK 4.2 中的 cudaDecodeD3D9 示例开发多流 H.264 视频播放器。

应用程序可以正确处理一些流,但它会在 cuvidCreateDecoder 函数中为 12 个分辨率为 800x600 的流或 9 个分辨率为 1920x1080 的流引发断言 (CUDA_ERROR_OUT_OF_MEMORY)。 cudaMemGetInfo 返回 387MB(1GB 显卡)和 1.3Gb(2GB 显卡)可用内存。内存碎片会导致这种情况吗?如何使用可用内存?

VideoDecoder::VideoDecoder(const CUVIDEOFORMAT & rVideoFormat, 
                       CUcontext &rContext, 
                       cudaVideoCreateFlags eCreateFlags, 
                       CUvideoctxlock &vidCtxLock) 
: m_VidCtxLock(vidCtxLock)
{
// get a copy of the CUDA context
m_Context          = rContext;
m_VideoCreateFlags = eCreateFlags;

// Fill the decoder-create-info struct from the given video-format struct.
memset(&oVideoDecodeCreateInfo_, 0, sizeof(CUVIDDECODECREATEINFO));
        // Create video decoder
oVideoDecodeCreateInfo_.CodecType           = rVideoFormat.codec;
oVideoDecodeCreateInfo_.ulWidth             = rVideoFormat.coded_width;
oVideoDecodeCreateInfo_.ulHeight            = rVideoFormat.coded_height;
oVideoDecodeCreateInfo_.ulNumDecodeSurfaces = FrameQueue::cnMaximumSize;

        // Limit decode memory to 24MB (16M pixels at 4:2:0 = 24M bytes)
while (oVideoDecodeCreateInfo_.ulNumDecodeSurfaces * rVideoFormat.coded_width * rVideoFormat.coded_height > 16*1024*1024)
{
    oVideoDecodeCreateInfo_.ulNumDecodeSurfaces--;
}
oVideoDecodeCreateInfo_.ChromaFormat        = rVideoFormat.chroma_format;
oVideoDecodeCreateInfo_.OutputFormat        = cudaVideoSurfaceFormat_NV12;
oVideoDecodeCreateInfo_.DeinterlaceMode     = cudaVideoDeinterlaceMode_Adaptive;

        // No scaling
oVideoDecodeCreateInfo_.ulTargetWidth       = oVideoDecodeCreateInfo_.ulWidth;
oVideoDecodeCreateInfo_.ulTargetHeight      = oVideoDecodeCreateInfo_.ulHeight;
oVideoDecodeCreateInfo_.ulNumOutputSurfaces = MAX_FRAME_COUNT;  // We won't simultaneously map more than 8 surfaces
oVideoDecodeCreateInfo_.ulCreationFlags     = m_VideoCreateFlags;
oVideoDecodeCreateInfo_.vidLock             = m_VidCtxLock;

size_t available, total;
cudaMemGetInfo(&available, &total);

        // create the decoder
CUresult oResult = cuvidCreateDecoder(&oDecoder_, &oVideoDecodeCreateInfo_);
assert(CUDA_SUCCESS == oResult);
}

cuvidCreateDecoder 可以在超过 1920x1080 的分辨率下工作吗?当我尝试 2560x1920 流时 cuvidCreateDecoder 断言 CUDA_ERROR_INVALID_SOURCE。

我的环境

  • 硬件:NVidia GTX 550 Ti 1Gb、NVidia GT 610 2Gb、驱动程序版本 306.23
  • Windows 7 x64
  • Visual Studio 2010 SP1
  • Windows SDK 7.1
  • NVIDIA GPU 计算工具包 v.4.2、v.5.0
  • NVIDIA GPU 计算 SDK 4.2。

【问题讨论】:

    标签: cuda h.264 decoder


    【解决方案1】:

    有关内存问题,请参阅this answer

    关于分辨率的问题,Compute Capability 2.0 及更早的 GPU 不支持cudaDecodeD3D9 的大于 HD 的分辨率。这就是您无法解码 2560x1920 流的原因。

    Kepler GPU 可以支持更大的分辨率。

    【讨论】:

      猜你喜欢
      • 2016-10-01
      • 2015-12-12
      • 2014-05-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-13
      • 1970-01-01
      • 2012-06-22
      相关资源
      最近更新 更多