Modify the pitch alignment size for VIC in Jetson AGX Orin

Hi, how do I modify the pitch alignment size for VIC? It seems to be aligned at 256 bytes by default, but we need it to be aligned at 64 bytes. Thank you.

Hello @kay.lee,

That requires a change on the Kernel source files.

Depending on the Jetpack version you are using, it might change, however, you can check for TEGRA_STRIDE_ALIGNMENT on kernel/nvidia/include/media/tegra_camera_core.h for systems using VI5.

Please let us know if you require further assistance.

regards,
Andrew
Contact Us: support@proventusnova.com
www.proventusnova.com

Our Jetpack version is r35.3.1.
The value of TEGRA_STRIDE_ALIGNMENT is as follows.

/* Minimum and maximum width and height common to Tegra video input device. */
#define TEGRA_MIN_WIDTH		32U
#define TEGRA_MAX_WIDTH		32768U
#define TEGRA_MIN_HEIGHT	32U
#define TEGRA_MAX_HEIGHT	32768U
/* Width alignment */
#define TEGRA_WIDTH_ALIGNMENT	1
/* Stride alignment */
#define TEGRA_STRIDE_ALIGNMENT	1
/* Height alignment */
#define TEGRA_HEIGHT_ALIGNMENT	1
/* Size alignment */
#define TEGRA_SIZE_ALIGNMENT	0

Hello @kay.lee,

Thanks for getting back with further details.

Can you try setting define TEGRA_STRIDE_ALIGNMENT 64 ?

Please let us know how that goes.

regards,
Andrew
Embedded Software Engineer
ContactUs: support@proventusnova.com
www.proventusnova.com

hello, proventusnova, It doesn’t seem to work, the log is as follows.
nvidia@orin-1:/usr/src/jetson_multimedia_api/samples/07_video_convert$ sudo ./video_convert ./after2.yuv 2880 1860 YUYV test.yuv 2880 1860 NV12
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888
nvbuf_surf->surfaceList->planeParams.pitch[plane] = 5888

Hello @kay.lee,

That is interesting.
To be honest, we have never played with the video_convert sample before, so we are not really sure if that is an error or the expected behavior.

However, may we ask what are you trying to achieve?

We might be able to help you find another solution for the actual requirement you are looking to accomplish.

regards,
Andrew
Embedded Software Engineer

Hi, proventusnova. We want to convert a YUV422 image file descriptor (fd), continuously stored from the camera, into an NV12 image with pitch alignment using nvsurfacebuffer. Currently, the conversion works fine for 1080P images, but we are encountering issues with 2880x2860 images, as shown in the attached image. Our analysis suggests that the problem is due to the pitch being aligned to 256 bytes instead of 64 bytes. As a result, we are considering modifying the alignment byte size.

@kay.lee,

Got it.

And how are you capturing the camera into the fd ? Are you using a custom app with an API for the cameras, or something like v4l2 or GStreamer ?

regards,
Andrew
Embedded Software Engineer

By V4l2 API.

@kay.lee,

Understood.

And have you tried using GStreamer to get the images into NV12 format with nvarguscamerasrc?

Sorry for all the questions, I just want to learn more about your current situation.

regards,
Andrew
Embedded Software Engineer

Sorry for the confusion, GStreamer command is OK. but our current implementation involves allocating a DMA buffer and obtaining the camera data’s file descriptor (fd) through the V4L2 API. The format is YUV422, and we need to encode the stream to H.265. However, the recording format only supports NV12, which means we need to convert the continuously stored YUV422 image into a pitch-aligned NV12 format using nvsurfacebuffer for H.264 encoding. So, essentially, we need to convert the YUV422 images to pitch-aligned NV12 format. Thank you!

@kay.lee,

Thanks for the explanation, that’s very useful.

And I imagine you want to change the stride at capture level, so that the images arrive already aligned to the format conversion, is that right ?

Also, could you try the following control on v4l2?

v4l2-ctl -c preferred_stride=32

regards,
Andrew
Embedded Software Engineer

Thank you, I resolved it by adding below code:

fmt.fmt.pix.bytesperline = 256 * ((fmt.fmt.pix.width * 2 + 255) / 256); 
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.