@lajuchenghui
Great job so far on the implementation!
I've noticed an opportunity to improve performance significantly in the H264Encoder module. Currently, in the YuvIn function, it appears that the ISP output is being copied to the encoder input. This memory copy operation can negatively impact performance, especially in high-throughput scenarios.
Here’s the relevant part of the code:
int H264Encoder::YuvIn(uint8_t *y, uint8_t *c)
{
int ret;
pInputBufInfo = dequeue(&pEncContext->mInputBufMgr.valid_quene);
LOGV("get input buf, pInputBufInfo = %p", pInputBufInfo);
if (pInputBufInfo == NULL)
{
return -1;
}
pInputBuf = &pInputBufInfo->inputbuffer;
memcpy(pInputBuf->pAddrVirY, y, ALIGN_XXB(16, encode_param.src_width) * ALIGN_XXB(16, encode_param.src_height));
memcpy(pInputBuf->pAddrVirC, c, ALIGN_XXB(16, encode_param.src_width) * ALIGN_XXB(16, encode_param.src_height / 2));
// pInputBuf->pAddrVirY = y;
// pInputBuf->pAddrVirC = c;
pInputBuf->bEnableCorp = 0;
pInputBuf->sCropInfo.nLeft = 240;
pInputBuf->sCropInfo.nTop = 240;
pInputBuf->sCropInfo.nWidth = 240;
pInputBuf->sCropInfo.nHeight = 240;
...
}
Would it be possible to use a zero-copy approach here? For example, directly assigning the ISP output buffer to the encoder input buffer (pAddrVirY and pAddrVirC) rather than copying data with memcpy. This would reduce the memory overhead and increase performance.
I understand that there might be constraints, such as alignment requirements or format differences. Could you let me know if there’s a way to enable zero-copy in this context, and if not, what the blockers are?
I also found this that do the job in V3s
Thank you, and looking forward to your insights!