|
我在使用RV1126的rga做YUV420P和RGB32格式转换, 2560*1440的图像,转换过程7ms,速度比ffmpeg的 sws_scale 提升了5~6倍,但转换完的数据buffer给Qt使用, Qt 的QImage速度会变慢5~6倍。代码如下:
- int ret = 0;
- int srcWidth,srcHeight,srcFormat;
- int dstWidth,dstHeight,dstFormat;
- int m_iWidth, m_iHeight;
- /********** SrcInfo set **********/
- srcWidth = 2560;
- srcHeight = 1440;
- srcFormat = RK_FORMAT_YCrCb_420_P;
- /********** DstInfo set **********/
- dstWidth = 2560;
- dstHeight = 1440;
- dstFormat = RK_FORMAT_RGBA_8888;//RK_FORMAT_BGRA_8888;//RK_FORMAT_RGBA_8888; //RK_FORMAT_BGRA_8888 //RK_FORMAT_BGRX_8888
- static rga_info_t src;
- static rga_info_t dst;
- if(m_bInitCapFinish==false)
- {
- m_bInitCapFinish = true;
- m_iWidth = srcWidth;
- m_iHeight = srcHeight;
- ret = m_pRGA->RkRgaInit();
- ret = m_pRGA->RkRgaGetAllocBuffer(&m_fBoSrc, m_iWidth, m_iHeight, 32);
- ret = m_pRGA->RkRgaGetAllocBuffer(&m_fBoDst, m_iWidth, m_iHeight, 32);
- m_pRGA->RkRgaGetMmap(&m_fBoSrc);
- m_pRGA->RkRgaGetMmap(&m_fBoDst);
- memset(&src, 0, sizeof(rga_info_t));
- src.fd = -1;
- src.mmuFlag = 1;
- memset(&dst, 0, sizeof(rga_info_t));
- dst.fd = -1;
- dst.mmuFlag = 1;
- ret = m_pRGA->RkRgaGetBufferFd(&m_fBoSrc, &src.fd);
- qDebug() << "src.fd = "<<src.fd;
- if (ret) {
- qDebug() <<"rgaGetsrcFd fail :" <<strerror(errno);
- }
- ret = m_pRGA->RkRgaGetBufferFd(&m_fBoDst, &dst.fd);
- qDebug() << "src.fd = "<<dst.fd;
- if (ret) {
- qDebug()<<"rgaGetdstFd error :" << strerror(errno);
- }
- rga_set_rect(&src.rect, 0,0,m_iWidth,m_iHeight,m_iWidth/*stride*/,m_iHeight,srcFormat);
- rga_set_rect(&dst.rect, 0,0,m_iWidth,m_iHeight,m_iWidth/*stride*/,m_iHeight,dstFormat);
- }
- QTime timert;
- timert.start();
- av_image_copy_to_buffer((uint8_t*)m_fBoSrc.ptr, m_fBoSrc.size, m_pFrame->data, m_pFrame->linesize,
- AV_PIX_FMT_YUV420P, 2560, 1440, 1);
- ret = m_pRGA->RkRgaBlit(&src, &dst, NULL);
- int32_t time2 = timert.elapsed();
- qDebug() <<"rga sw" <<__LINE__ <<"time" <<time2<<" ms" << "ret" << ret <<m_fBoDst.size;
- //把这个RGB数据 用QImage加载
- QImage tmpImgt((uint8_t*)m_fBoDst.ptr, 2560, 1440, QImage::Format_RGB32); //Format_RGBA8888
- static uint32_t cntt = 0;
- if (cntt++ >= 2)
- {
- timert.start();
- QImage imaget = tmpImgt.copy();
- int32_t time2 = timert.elapsed();
- qDebug() <<"rga copy" <<__LINE__ <<"time" <<time2<<" ms";
- emit sig_GetOneFrame(imaget); //发送信号
- cntt = 0;
- }
|
|