Wrong YUV 4:4:4 format with H264 Lossless encoding

Hello,

We would like to use the H264 encoder of Jetson to encode a YUV 4:4:4 (Y444 or NV24) with lossless feature and High444 predictive profile but we have some issues with the result: for both NV24 and Y444, the encoder is reading the buffer as a YUV 4:2:0 instead of a YUV 4:4:4 while the NvBuffer provided is allocated as a YUV444!..

In checking the H264 output, we can notice that the profile is not PREDICTIVE but INTRA with YUV 4:2:0 as shown in the ffplay command output below:

$ ffplay test.h264
...
Input #0, h264, from 'test.h264':  0KB vq=    0KB sq=    0B f=0/0   
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: h264 (High 4:4:4 Intra), yuv420p(progressive), 1280x720, 25 fps, 25 tbr, 1200k tbn
    nan M-V:    nan fd=   0 aq=    0KB vq=    0KB sq=    0B f=0/0   

To reproduce with Jetson 36.3 or 35.4.1:

# Generate a YUV 4:4:4 multi-planar file (Y444
gst-launch-1.0 videotestsrc num-buffers=10 ! video/x-raw,format=Y444,width=1280,height=720 ! filesink location=/tmp/test.yuv

# Encode with multi-planar
./video_encode /tmp/test.yuv 1280 720 H264 /tmp/test.h264 --elossless -p high444

# Generate a YUV 4:4:4 semi-planar file (NV24)
gst-launch-1.0 videotestsrc num-buffers=10 ! video/x-raw,format=NV24,width=1280,height=720 ! filesink location=/tmp/test.yuv

# Encode the file
./video_encode /tmp/test.yuv 1280 720 H264 /tmp/test.h264 --elossless -p high444 --sp

Then, check the output with ffplay:

ffplay /tmp/test.h264

The expected output would be:

# Encode the YUV 4:4:4 multi-planar (Y444) with x264
gst-launch-1.0 filesrc location=/tmp/test.yuv ! rawvideoparse format=y444 width=1280 height=720 ! x264enc quantizer=0 pass=4 ! filesink location=/tmp/test.h264

# Check expected output:
#  -> Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv444p(tv, bt709, progressive), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 1200k tbn
ffplay /tmp/test.h264

Can you double check this issue?
Thank you very much!

Best regards,

Alex

Hi,
We can observe the issue. Will check the issue further.

Since we support lossless encoding/decoding in H265, you may consider use H265. May refer to
Can tx2nx decode YUV444? - #3 by DaneLLL

In H264 we support encoding only.

Hi DaneLLL,

Thank you for your quick reply!

I have checked with H265 and I confirm it works with the -cf 3 parameter to force usage of YUV 4:4:4.

# Encode with multi-planar
./video_encode /tmp/test.yuv 1280 720 H265 /tmp/test.h265 -cf 3 --elossless --max-perf

I think we will continue with H265 since it seems to support YUV 4:2:0 as well for lossless compression and we don’t have strong constraints on decoder side!

Best regards,

Alex

1 Like

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