NVIDIA VIDEO CODEC SDK - Lossless

Hi,

Is there someone who know what “lossless H264” mode means in the following matrix : https://developer.nvidia.com/nvidia-video-codec-sdk#NVENCFeatures

I see in the table that YUV 4:2:0 and YUV 4:4:4 are supported for the H264 codec.
However what “H.264 (AVCHD) LOSSLESS” means ? Is it a direct RGB support instead of a YUV/NV12 format ?

Does it exist any example code which illustrates the use of direct ARGB encoding ?

Thanks in advance for your help,

See you,
Vince

Pretty sure the lossless just means “lossless” encode quality which isn’t usually very useful.

Docs about the mode itself are sparse but there’s this in the API:

uint32_t NV_ENC_CONFIG_H264::qpPrimeYZeroTransformBypassFlag
[in]: To enable lossless encode set this to 1, set QP to 0 and RC_mode to NV_ENC_PARAMS_RC_CONSTQP
and profile to HIGH_444_PREDICTIVE_PROFILE. Check support for lossless encoding using NV_ENC_CAPS_-
SUPPORT_LOSSLESS_ENCODE caps.

There’s also the preset

NV_ENC_PRESET_LOSSLESS_HP_GUID

which I’d assume handles the various settings needed.

No idea about ARGB input, I would assume you’re gonna need to convert it to YUV for the encoder.

Hi VelaK,

Thanks for your answer but we are not talking about the same thing.
Indeed, there exists a lossless mode as encoder preset but this is not the lossless format I’m targeting.

Actually, the nvidia matrix seems to indicate that a lossless encoding format exists. YUV420 and YUV444 both imply a loss of information in 8bits/channel. YUV420 and YUV444 in 10bits/channel are not available for H264 so I’m wondering what is the H264 lossless encoding format.

Considering the NVENC_DA-06209-001_v08.pdf file, which can be founded in the doc directory of the nvidia video codec SDK 7, H264 seems to accept ARGB input since Kepler family.

I’m a looking for an example with this format because it could be a real lossless encoding format if the encoder does not implicitly convert images to NV12 nor YUV 8bits format.

See you,
Vince

Ah, I see. I was looking around for lossless in the api and that’s all I saw.

You could try modifying the example projects and change the NV_ENC_BUFFER_FORMAT to NV_ENC_BUFFER_FORMAT_ABGR10 / NV_ENC_BUFFER_FORMAT_ABGR / NV_ENC_BUFFER_FORMAT_ARGB / NV_ENC_BUFFER_FORMAT_ARGB10 and see if it works.

AllocateIOBuffers() in the VideoEncoder.cpp example I’d imagine would be the place to start.

I have used directly RGB input instead of YUV/NV12 format.
First you have to change NV_ENC_BUFFER_FORMAT to NV_ENC_BUFFER_FORMAT_ARGB and you have to copy RGB data buffer to EncodeBuffer input surface.

Hi,

Thank you both for your replies.

ssharma01oct, do you find that the resulting H264 file is actually formated in ARGB ?
I made the test to and the file is recognized as a YUV420 high predictive format by ffprobe.
I suppose that the video framework makes an implicit conversion in order to recover a YUV format…

See you,
Vince

Another question is, does the hardware decoder support another format other than the YUV420 for H264 ?

See you,
Vince

Hello Vince,I am not sure about this if encoder internally converted the ARGB format to YUV. Because i did not make test for this.
I just use the ARGB input stream as a input buffer and directly copy (without any conversion) on EncodeBuffer input surface and get the output in h264 format.If nvEncEncodePicture() internally converting the format ,i can’t say anything about it.

H.264 video encoding, as per the standard, only supports YUV encoding. There is no way to directly “encode” RGB using H.264.

The input format NV_ENC_BUFFER_FORMAT_ARGB is only supported for convenience. The driver internally converts the data into YUV420 and then encodes it using NVENC.

Hi,

Ok I see, thanks for your reply.

Vince

Actually it converts it internally to NV12.

Hi,

In our tests, lossless h264 is only truly lossless using yuv444 as input.

We’d like to have lossless compression with RGB as input (to aid in testing our pipeline). I’m assuming this doesn’t currently work because as @Abhijit_Patait mentioned, it internally converts RGB input to yuv420.

Would it be possible to allow an internal lossless RGB -> YUV (I guess yuv444?) conversion so that the entire pipeline could be lossless? Are there plans to allow for this? If not, can I make a feature request?

I too am trying to support lossless encoding in UE4 and am finding it very difficult.

I’m using NV_ENC_PRESET_LOSSLESS_HP_GUID, NV_ENC_H264_PROFILE_HIGH_444_GUID, NV_ENC_LEVEL_H264_52, a qpPrimeYZeroTransformBypassFlag of 1, qp of 0, rate control of constqp, a min bit rate of 100Mbit and a max bit rate of 150Mbit to feed WebRTC in chrome. These settings are accepted by nvEnc, but nothing is showing in Chrome. The bit rate rarely goes above 20Mbit

Any suggestions?

Cheers
John