打开微信,使用扫一扫进入页面后,点击右上角菜单,
点击“发送给朋友”或“分享到朋友圈”完成分享
【寒武纪硬件产品型号】:MLU270
【使用操作系统】必填:Kylin Linux Desktop V10(sp1)
【使用驱动版本】:neuwar-mlu270-driver-dkms_4.8.0_all.deb
【出错信息】必填*:初始化设置输入缓存和输出缓存为1,回调后输出缓存变成了5,不能强制设置为1
【操作步骤】选填:
初始化设置输入缓存和输出缓存为1
int video_decoder_hwj::initDecodeContext(videoDecodeContext *pContext){ memset(&pContext->decInfo, 0, sizeof(pContext->decInfo)); pContext->decInfo.codec = CNCODEC_H264; if(m_enc_param->codec_params.codec == work::VideoCodec::H264) { pContext->decInfo.codec = CNCODEC_H264; }else if(m_enc_param->codec_params.codec == work::VideoCodec::HEVC) { pContext->decInfo.codec = CNCODEC_HEVC; } pContext->decInfo.width = m_enc_param->width; pContext->decInfo.height = m_enc_param->height; pContext->decInfo.inputBufNum = 1; pContext->decInfo.outputBufNum = 1; pContext->decInfo.pixelFmt = cncodecPixelFormat::CNCODEC_PIX_FMT_I420; // 420 OR NV12 pContext->decInfo.progressive = 1; // callbackevent pUserdata pContext->decInfo.userContext = reinterpret_cast<void*>(this); pContext->decInfo.instance = cnvideoDecInstance::CNVIDEODEC_INSTANCE_1; pContext->decInfo.allocType = CNCODEC_BUF_ALLOC_LIB;//CNCODEC_BUF_ALLOC_APP; /* allocate input and output buffer */ if (pContext->decInfo.allocType == CNCODEC_BUF_ALLOC_APP) { pContext->decInfo.inputBuf = (cncodecDevMemory *)malloc(pContext->decInfo.inputBufNum * sizeof(cncodecDevMemory)); pContext->decInfo.outputBuf = (cncodec *)malloc(pContext->decInfo.outputBufNum * sizeof(cncodec )); pContext->outputBufMap = ( CpuAddr *)malloc(pContext->decInfo.outputBufNum * sizeof( CpuAddr)); pContext->inputBufMap = (uint64_t *)malloc(pContext->decInfo.inputBufNum * sizeof(uint64_t)); cnrtContextInit(0, getBestChannelForDecoder(0)); printf("initDecodeContext --- call allocateDecodeBuffer-------\n"); allocateDecodeBuffer(pContext); } pContext->eos = false; sem_init(&(pContext->eosSemaphore), 0, 0); return 0; }
回调后
pContext->seqinfo.minOutputBufNum 为5,强制设置pContext->decInfo.outputBufNum = 1 也不成功
int video_decoder_hwj::HandleSequenceEvent(cnvideoDecSequenceInfo *pFormat) { int ret = 0; m_pContext->seqinfo = *pFormat; updateDecodeContext(m_pContext); // start decode ret = cnvideoDecStart(m_pContext->handle,&m_pContext->decInfo); if (ret != CNCODEC_SUCCESS) { printf("cnvideoDecStart fail, ret(%d)\n", ret); return -1; } return 0; } int video_decoder_hwj::updateDecodeContext(videoDecodeContext *pContext) { printf("updateDecodeContext --------\n"); cnrtContextInit(0, getBestChannelForDecoder(0)); // release output buffer if (pContext->decInfo.allocType == CNCODEC_BUF_ALLOC_APP) { free(pContext->decInfo.outputBuf); releaseDecodeOutputBuffer(pContext); } // update decode info pContext->decInfo.codec = pContext->seqinfo.codec; pContext->decInfo.height = pContext->seqinfo.height; pContext->decInfo.width = pContext->seqinfo.width; // update exit buufer ? >1 ??????????????TODO outputBufNumMin == 5 pContext->decInfo.inputBufNum = pContext->seqinfo.minInputBufNum; pContext->decInfo.outputBufNum = pContext->seqinfo.minOutputBufNum > pContext->decInfo.outputBufNum ? pContext->seqinfo.minOutputBufNum : pContext->decInfo.outputBufNum; printf("inputBufNum-------%d output=%d width=%d height=%d \n", pContext->decInfo.inputBufNum, pContext->decInfo.outputBufNum, pContext->decInfo.width, pContext->decInfo.height); pContext->decInfo.userContext = (void *)pContext; // re-allocate output(capture) buffer if (pContext->decInfo.allocType == CNCODEC_BUF_ALLOC_APP) { pContext->decInfo.outputBuf = (cncodec *)malloc(pContext->decInfo.outputBufNum * sizeof(cncodec )); printf("updateDecodeContext --------call allocateDecodeOutputBuffer\n"); allocateDecodeOutputBuffer(pContext); } return 0; }
热门帖子
精华帖子