I would like to see a non-const getPixelsPtr method so that I can load the image data directly from another API.
I set the image size with the create method, I then would like to pass the address return by getPixelsPtr to the ffmpeg image convert methods so that it loads my image directly. Currently I have to create a temporary location and then call he loadfrommemory This results in an extra memcpy that I would like to avoid. I would like to pass the getPixelsPtr directly into the avpicture_fill method directly. Below is how I would use it.
thoughts?
IMAGE_PTR_T pImage = m_ImageCache.create(dPTS,
m_pAVStrm->codec->width, m_pAVStrm->codec->height);
ffmpeg::avpicture_fill(&pict, pImage->image.getPixelsPtr(), ffmpeg::PIX_FMT_RGBA,
m_pAVStrm->codec->width, m_pAVStrm->codec->height);
m_pImgConvertCtx = ffmpeg::sws_getCachedContext(m_pImgConvertCtx,
m_pAVStrm->codec->width, m_pAVStrm->codec->height, m_pAVStrm->codec->pix_fmt, // src size / fmt
m_pAVStrm->codec->width, m_pAVStrm->codec->height, ffmpeg::PIX_FMT_RGBA, // dest size / fmt
SWS_FAST_BILINEAR, NULL, NULL, NULL);
if (m_pImgConvertCtx == 0)
{
throw std::runtime_error("Cannot initialize the conversion context");
}
sws_scale(m_pImgConvertCtx, pFrame->data, pFrame->linesize,
0, m_pAVStrm->codec->height, pict.data, pict.linesize);