pixfmt of buffer created by NvBufferCreate inconsistency

Hello,
I’m using NvBufferCreate to create a buffer, but the pixfmt of the created buffer is inconsist with the input value.
I supposed to create a buffer with format NvBufferColorFormat_ARGB32(10), but after buffer created, I get params and print the params.pixel_format, it is NvBufferColorFormat_Invalid(11).
Is there something wrong with my usage?

if (NvBufferCreate(&fd, ctx->width, ctx->height, NvBufferLayout_Pitch, NvBufferColorFormat_ARGB32) == -1)
{
    printf("\"%s\" failed to create NvBuffer",  ctx->devnode);
    return NV_ERR;
}

if (NvBufferGetParams(fd, &params) == -1) 
{
    printf("\"%s\" failed to get NvBuffer parameters",	ctx->devnode);
    return NV_ERR;
}
printf("params.pixel_format %x in pixfmt %d", params.pixel_format, NvBufferColorFormat_ARGB32);

I’m using 28.1
ps, definition in nvbuf_utils.h

typedef enum
{
NvBufferColorFormat_YUV420,
NvBufferColorFormat_YVU420,
NvBufferColorFormat_NV12,
NvBufferColorFormat_NV21,
NvBufferColorFormat_UYVY,
NvBufferColorFormat_VYUY,
NvBufferColorFormat_YUYV,
NvBufferColorFormat_YVYU,
NvBufferColorFormat_ABGR32,
NvBufferColorFormat_XRGB32,
NvBufferColorFormat_ARGB32,
NvBufferColorFormat_Invalid,
} NvBufferColorFormat;

hello hm05flash,

did you saw any suspicious failures for the buffer creation.
please check the buffer surface type instead.
for example,

nvbuf_ptr->Payload.Surfaces.Surfaces[0]

please also check the [L4T Multimedia API Reference] for more details.
thanks

Hi JerryChang,
Thanks for your advice. There is not any failures for the buffer creation.
BTW, in multimedia API 28.1, I couldn’t find the 'Payload ’ member in structure ‘NvBuffer’.

Thanks

hello hm05flash,

you should get the NvMMBuffer pointer from the NvBuffer file descriptor.
then you should be able to access the NvMMBuffer.
thanks

Hello JerryChang,
I couldn’t find the function NvBufferFromFd() in the API document. Is it a new function from 28.2 or later?
There is only NvBufferMemMap() functioin.

Thanks for your kindly reply.

hello hm05flash,

could you please backup the libnvbuf_utils.so binary and replace it with the attachment (Jul25_topic1037665_libnvbuf_utils.so).
here’s some debug message included, please try to reproduce the issue again to gather some debug prints.
thanks
Jul25_topic1037665.tar.gz (11.4 KB)

Thank you JerryChang,
I’ll try it.

Thank you JerryChang,
I’ll try it.

Hello JerryChang,
I replaced the libnvbuf_utils.so and ran my project. Attachment is the log.
After the NvBufferCreate() function, I printed the params.pixel_format and it’s 11(means invalid).
The print is like

(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_buffers_init()" line 243 [WRN]: params.pitch[0] 5120 xxxxxxx params->pixel_format 11

Hello JerryChang,
Attachment fails to upload. So I list part of the log. Thanks.

(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_dev_init()" line 415 [WRN]: "/dev/video0" capture ouput format: (1280 x 720)  stride: 5120, imagesize: 3686400, field is 1
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 1 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 4308672800 Line(435)
(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_buffers_init()" line 243 [WRN]: params.pitch[0] 5120 xxxxxxx params->pixel_format 11
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 1 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 4308672800 Line(435)
(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_buffers_init()" line 243 [WRN]: params.pitch[0] 5120 xxxxxxx params->pixel_format 11
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 1 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 4308672800 Line(435)
(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_buffers_init()" line 243 [WRN]: params.pitch[0] 5120 xxxxxxx params->pixel_format 11
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 1 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 4308672800 Line(435)
(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_buffers_init()" line 243 [WRN]: params.pitch[0] 5120 xxxxxxx params->pixel_format 11
(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp cap_dev_start()" line 447 [WRN]: "/dev/video0" capture start work ...
(trace) Fri May  6 05:41:31 2016:"od_task.c base_funcs()" line 570 [WRN]: v4l2_cap, real_time_rst start
(trace) Fri May  6 05:41:31 2016:"pthread_nv_cap.cpp v4l2_cap_realtime_set()" line 574 [WRN]: "/dev/video0" v4l2 cap 
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 1 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 4308672800 Line(435)
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 3 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 43086251016 Line(459)
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 1 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 4308672800 Line(435)
[debug] nvbuf_utils: NvBufferGetParams: num_planes= 3 Line(418)
[debug] nvbuf_utils: Surfaces ColorFormat: 43086251016 Line(459)
(trace) Fri May  6 05:41:31 2016:"crosslink.c cross_init()" line 115 [ERR]: load success
(trace) Fri May  6 05:41:32 2016:"crosslink.c cross_init()" line 130 [ERR]: CROSSLINK index 0 ver: 0.1

hello hm05flash,

after checking the internal sources, we only support below pixel formats so far.
NvBufferColorFormat_UYVY
NvBufferColorFormat_VYUY
NvBufferColorFormat_YUYV
NvBufferColorFormat_YVYU
NvBufferColorFormat_ABGR32

hence it is expect to report invalid formats for NvBufferColorFormat_ARGB32
I’m going to have internal investigation,
will get back to you while we come out some conclusions,
thanks

Hello JerryChang,
Got it! Thanks.

hello hm05flash,

we had change to add ARGB32 supports,
could you please replace the binary to test your use-case again with the attachment, (Aug09_Topic1037665.tar.gz)
thanks
Aug09_Topic1037665.tar.gz (11.3 KB)

Hi JerryChang,
Thanks, I’ll try this binary and reply the result.