Some questions about NvJPEGDecoder::decodeToFd

Hi,when I use the decodeToFd interface to decode the jpeg image which resolution is 1920*1080,the output width param is 1920 and height param is 1080.But when I use the NvBufferGetParams interface to access the dma buffer through the output fd param, Some parameters are printed as follows:
params.width[0]=1920,params.height[0]=1088,params.width[1]=960,params.height[1]=544,params.width[2]=960,params.height[2]=544.

I find the height param in three plane is error,the correct height param is 1080。I wang to know if the NvBufferGetParams can’t access the dma buffer successfully.

Hi,
NvBiffer is hardware DMA buffer and decoded buffers are aligned. The values you see look correct.

If the decoded buffer is 32 byte aligned or 64 byte aligned, should the actual width and height of the jpeg decode output be based on the decodeToFd output interface?

Hi,I have another question .If I use the gst_buffer_map interface to map the GstBuffer (memory:NVMM,format=I420,width=1920,height=1080) contents and get the pointer to NvBufSurface,I can get the fd through the NvBufSurface pointer。I also use the NvBufferGetParams interface to access the dma buffer, Some parameters are printed as follows:
plane[0]:w=1920,h=1080,pitch=2048,offset=0,psize=2228224
plane[0]:w=960,h=540,pitch=1024,offset=2228224,psize=655360
plane[0]:w=960,h=540,pitch=1024,offset=2883584,psize=655360

Why the output width and height params are not aligned ? ,I want to know if only decoded dma buffers are aligned,what’s the rule about the dma buffer alignment through the NvBufferGetParams interface?

Hi,
It is not clear about the issue and please give more information. Do you get the DMA buffer from decodeToFd() and map it to NvBufSurface? NvbufSurface is specific for DeepStream SDK usecases and should not be compatible with jetson_multimedia_api. Not quite understand why you can do this.

sorry,I may not have made myself clear.The GstBuffer (memory:NVMM,format=I420,width=1920,height=1080)is not from decodeToFd,it is from gstreamer pipeline.I can get the dma buffer fd through the pointer to NvbufSurface.I want to compare the difference between the DMA buffer parameters obtained in these two cases。In both cases, the simple code is as follows:
case 1:
//use decodeToFd interface to decode jpg image(1920*1080) to YUV420M
decodeToFd(fd,p_jpeg_in,jpeg_len,format,width,height);
//use NvBufferGetParams interface to get dma buffer params
NvBufferGetParams(fd,&params);
//printf params
for(int i = 0;i < params.num_planes;i++)
{
printf(“plane[%d],w=%d,h=%d,pitch=%d\n”,i,
params.width[i],params.height[i],params.pitch[i]};

case2:
//GstBuffer is get from sink pad probe buffer callback //function,memory:NVMM,format=I420,width=1920,height=1080

GstBuffer *buf = (GstBuffer *)info->data;
GstMapInfo in_map_info;
NvBufSurface *in_surf = NULL;
memset(&in_map_info, 0, sizeof(in_map_info));
gst_buffer_map(buf, &in_map_info, GST_MAP_READ))
in_surf = (NvBufSurface *)in_map_info.data;
//also use NvBufferGetParams interface to get dma buffer params
ret = NvBufferGetParams(in_surf->surfaceList[0].bufferDesc, &params);
//printf params
for(int i = 0;i < params.num_planes;i++)
{
printf(“plane[%d],w=%d,h=%d,pitch=%d\n”,i,
params.width[i],params.height[i],params.pitch[i]};

The output parameters are printed as follows:
case 1:
plane[0]:w=1920,h=1088,pitch=2048
plane[1]:w=960,h=544,pitch=1024
plane[2]:w=960,h=544,pitch=1024

case 2:
plane[0]:w=1920,h=1080,pitch=2048
plane[1]:w=960,h=540,pitch=1024
plane[2]:w=960,h=540,pitch=1024

In two cases, the dma buffer is same,but case 1 output width and height are aligned, case 2 output width and height are original width and height。Why are the obtained parameters different?

There is no update from you for a period, assuming this is not an issue any more.
Hence we are closing this topic. If need further support, please open a new one.
Thanks

Hi,
Since you don’t use DeepStream SDK, we may not need to do further check on NvBufsurface. So when you get the NvBuffer through decodeToFd(), it is in 1920x1088 with valid data in 1920x1080 and garbage data in bottom 8 lines. Is this correct?