Hardware Accelerated JPEG encode/decode on Jetson Xavier JP 5.1.3

Hi,
It looks like you don’t use default rootfs with Ubuntu 20.04 desktop. Please share your full steps so that we can set up developer kit try. And it would be great you can try all-default Jetpack 5.1.3.

The rootfs was installed by flashing via the SDK Manager. No custom rootfs was used. What is the reason for the Could not get EGL display connection messages during testing on our side?

It appears the encode does not work correctly based on the image you provided in your testing. What is wrong with the provided sample application code that causing the resulting JPEG to be distorted?

Hi,
We would need to replicate Could not get EGL display connection message and check further. It is uncertain why you hit it on developer kit and we do not. Please share the full steps so that we can replicate it in developer kit.

After flashing these steps are taken to prepare the system:

# install cmake
sudo apt update && sudo apt install -y cmake

# dependencies update
sudo apt install -y cuda-toolkit-11-4
sudo apt install -y -f ./cuda-repo-l4t-11-4-local_11.4.19-1_arm64.deb
sudo apt-get remove --auto-remove libgstreamer-opencv1.0-0 libopencv-*
sudo apt install -y -f ./libalpropencvgpu4_4.5.5-200420240324133246_arm64.deb
sudo apt install -y -f ./libalpropencvgpu-dev_4.5.5-200420240324133246_arm64.deb
sudo apt install -y -f ./nvidia-l4t-jetson-multimedia-api_35.5.0-20240219203809_arm64.deb
sudo apt install -y -f ./deepstream-6.3_6.3.0-1_arm64.deb

# libnvjpeg patch
wget -O r35_5_TEST_libnvjpeg_1.zip https://forums.developer.nvidia.com/uploads/short-url/nz3uWYNzgYxH82gXw2b2IQM4K5d.zip
unzip r35_5_TEST_libnvjpeg_1.zip
sudo mv libnvjpeg.so /usr/lib/aarch64-linux-gnu/tegra/

After unzipping the sample application:

mkdir build && cd build
cmake …
make

After successfully building, the test is run:

./test_jpeg </path/to/input.jpg> </path/to/output.jpg>

We get these results on both developer kit boards and production boards:

nvbufsurface: Could not get EGL display connection
nvbufsurface: Can't get EGL display
NvBufSurfaceMapEglImage() FAILED, ret: -1
Test encode FAILED

You indicated that you were not getting this error but that you were getting a corrupt output image:
b

Hi,
Please do clean re-flash and run the commands to set up:

$ sudo apt update
$ sudo apt install cmake
$ sudo apt install nvidia-jetpack
$ sudo apt install ./deepstream-6.3_6.3.0-1_arm64.deb
$ sudo apt -y purge *libopencv*
$ sudo apt install ./libalpropencvgpu4_4.5.5-200420240324133246_arm64.deb
$ sudo apt install ./libalpropencvgpu-dev_4.5.5-200420240324133246_arm64.deb

And see if no issue in executing NvBufSurfaceMapEglImage()

After following your instructions, the same error occurs:

nvbufsurftransform: Could not get EGL display connection
NvMMLiteOpen : Block : BlockType = 277
NvMMLiteBlockCreate : Block : BlockType = 277
Decoded input jpeg file: /test/nvidia/image_00000.jpg, size: 368640
nvbufsurface: Could not get EGL display connection
nvbufsurface: Can't get EGL display
NvBufSurfaceMapEglImage() FAILED, ret: -1
Test encode FAILED

Hi,
Which setup is your developer kit:

1. Xavier NX module with SD slot(SD card size >= 32GB)
2. Xavier NX module with eMMC and rootfs in NVMe SSD card

We are using an Orin AGX 32gb version developer kit board flashed to the EMMC

Hi,
The topic is moved to AGX Orin category. It was in Xavier NX category, so we thought you use Xavier NX.

We don’t observe the failure on both Jetpack 5.1.3/Xavier NX and AGX Orin developer kit. And for Orin series, the latest release is Jetpack 6.0GA. Not sure if you can try this version.

We are using a Jetson device in production. We are only testing the hwaccel JPEG encoding/decoding on the Orin Developer Kit Board because the same code failed on our Orin devices and we only had access to the Orin Developer Kit Board.

Hi,
Please share full steps you execute to download the Jetpack release, extract the BSP and rootfs, and flash AGX Orin developer kit. Probably there is deviation in the steps of flashing system image, triggering the issue.

Using the command line version of the SDK Manager

Hi,
Please try the manual steps to flash AGX Orin developer kit and see if it works:

  1. Download the packages to host PC(in Ubuntu 18.04 or 20.04)

Jetson Linux | NVIDIA Developer
Driver Package (BSP)
Sample Root Filesystem

  1. Extract the packages:
$ sudo tar xpf jetson_linux_r35.5.0_aarch64.tbz2
$ cd Linux_for_Tegra/rootfs/
Linux_for_Tegra/rootfs$ sudo tar xpf ../../tegra_linux_sample-root-filesystem_r35.5.0_aarch64.tbz2
Linux_for_Tegra/rootfs$ ../
Linux_for_Tegra$ sudo ../../apply_binaries.sh
  1. Let AGX Orin enter recovery mode and connect to host PC
  2. Flash the system image
Linux_for_Tegra$ sudo ./flash.sh jetson-agx-orin-devkit mmcblk0p1

Flashed the device using the instructions above and installed the dependencies using

$ sudo apt update
$ sudo apt install cmake
$ sudo apt install nvidia-jetpack
$ sudo apt install ./deepstream-6.3_6.3.0-1_arm64.deb
$ sudo apt -y purge *libopencv*
$ sudo apt install ./libalpropencvgpu4_4.5.5-200420240324133246_arm64.deb
$ sudo apt install ./libalpropencvgpu-dev_4.5.5-200420240324133246_arm64.deb

The issue still occurs when running the sample code:

nvbufsurftransform: Could not get EGL display connection
NvMMLiteOpen : Block : BlockType = 277
NvMMLiteBlockCreate : Block : BlockType = 277
Decoded input jpeg file: /home/rekor/denczek/nvidia/image_00000.jpg, size: 368640
nvbufsurface: Could not get EGL display connection
nvbufsurface: Can't get EGL display
NvBufSurfaceMapEglImage() FAILED, ret: -1
Test encode FAILED

Hi,
Please try the sample and see if the issue is still present:

/usr/src/jetson_multimedia_api/samples/03_video_cuda_enc

root@desktop:/usr/src/jetson_multimedia_api/samples/03_video_cuda_enc# ./video_cuda_enc
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
nvbufsurftransform: Could not get EGL display connection
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
MoTTY X11 proxy: Unsupported authorisation protocol
init EGL display failed

Hi,
We don’t see this print in our setup:

MoTTY X11 proxy: Unsupported authorisation protocol

Do you know why it gets printed? Or do you have more detail about MoTTY X11?

Using a headless setup via a MobaXterm SSH connection to the device from a Windows PC.

Hi,
It looks like MobaXterm has some setup to DISPLAY which triggers the issue. Please use uart console, or have Ubuntu host PC to open a terminal window and login AGX Orin developer kit through ssh.

Using PowerShell to SSH into the device resolved the error but the output JPEG image is still distorted using the supplied sample code. Same results that you obtained testing the sample code:
b

jpeg-hwaccel.zip (22.2 KB)