代码如下:
{
   DDrawVideoData m_ddVideo;
   memset(&m_ddVideo, 0, sizeof(DDrawVideoData));
   m_ddVideo.byRGBPointerBuffer = (BYTE*)malloc(3*1280*720);
   m_ddVideo.dwCaptureMark = 1;
   ......
   if (0!= FillData(m_ddVideo))
   {   }
}int FillData(DDrawVideoData& dest)
{
  dest.byUPointerBuffer = (BYTE*)malloc(dest.dwlPitch * dest.dwHeight/2);
  if (NULL != dest.byUPointerBuffer)
  memcpy(dest.byUPointerBuffer, pFrame->data[1], pFrame->linesize[1] * _context->height/2);
  ......
}在FillData函数中,使用malloc分配内存,发现byUPointerBuffer指针指向为null,malloc分配失败;
使用new byte分配内存,memcpy出错。
大家帮忙看看问题出在哪里?

解决方案 »

  1.   

    调试中:dest.dwlPitch 为752;dest.dwHeight为576; pFrame->linesize[1]为752,_context->height为576
      

  2.   

    你这分配了两次内存呐m_ddVideo.byRGBPointerBuffer = (BYTE*)malloc(3*1280*720);
    FillData(m_ddVideo))
    int FillData(DDrawVideoData& dest)
    {
    dest.byUPointerBuffer = (BYTE*)malloc(dest.dwlPitch * dest.dwHeight/2);
    }
      

  3.   

    byRGBPointerBuffer和byUPointerBuffer是两个不同的指针
      

  4.   

    用HeapAlloc分配下吧,还有就是用完的空间就释放掉