Brightness differences on conversion BGRx to NV12

Hi

When working with gstreamers nvvidconv we found some quite noticeable brightness differences when converting from BGRx to NV12 (or any other YUV format)

I got the following 2 gstreamer pipelines:

The first converts a BGR image/video using only gstreamer elements:

gst-launch-1.0 -v \
  filesrc location=some.png \
  ! pngdec \
  ! 'video/x-raw,framerate=0/1' \
  ! videoconvert \
  ! 'video/x-raw,format=BGRx' \
  ! videoconvert \
  ! 'video/x-raw,format=I420' \
  ! jpegenc \
  ! filesink location=videoconvert.jpeg

The second pipeline does the same using nvvidconv

gst-launch-1.0 -v \
  filesrc location=some.png \
  ! pngdec \
  ! 'video/x-raw,framerate=0/1' \
  ! videoconvert \
  ! 'video/x-raw,format=BGRx' \
  ! nvvidconv \
  ! 'video/x-raw(memory:NVMM),format=BGRx' \
  ! nvvidconv \
  ! 'video/x-raw(memory:NVMM),format=I420' \
  ! nvvidconv \
  ! 'video/x-raw,format=I420' \
  ! jpegenc \
  ! filesink location=nvvidconv.jpeg

I did a bunch more pipelines and constellations. However as soon as nvvidconv does the BGRxYUV conversion the image brightness is off.
I also played around with colorimetry and other codecs and sinks.

Analyzing the images gave the following color information:

Original:

colorimetry-original-cropped

videoconvert:

colorimetry-videoconvert-cropped

and finally nvvidconv:

colorimetry-nvvidconv-cropped

So I concluded that for some reason nvvidconv compresses the colorspace, which in turn changes the brightness.

Is my conclusion correct?
Is this actually a bug? or am I doing something wrong?
Is there a possibility to use the full color-range so the brightness of original and the `nvvidconv`` pictures are the same?

Im using jetpack 5.1

Thanks for your time!
Cheers
Markus

Hi,
The deviation may be from linear and non-linear conversions. It is linear conversion while using hardware converter. And it may be non-linear conversion while using videoconvert plugin. For comparison, please try to convert to RGBA.

Thanks for your quick and great feedback. Re-converting it back to BGRx actually showed the same image as before.

Further investigations showed me that nvvidconv uses NvBufSurfTransform for conversion of BGRx to YUV using the VIC chip.

However, I could not find any information on the conversion matrix.
Could you tell me what exact matrix is used to convert from BGR to NV12… or a related one.

I’m asking because I’m trying to get another software to create the same results as nvvidconv.
To do so I’m using bt601 and now I’m looking for the color quantization ranges.

Cheers,
Markus

Sorry, to be annoying.

I’d admire it a lot if you could provide the color-conversion matrix used by the VIC when doing BGRx to YCbCr.

Cheers,
Markus

Hi,
Please

  1. Download source code of nvvidconv plugin from the link:

Jetson Linux 35.2.1 | NVIDIA Developer
Driver Package (BSP) Sources

  1. Modify the format to NVBUF_COLOR_FORMAT_YUV420_ER
  if (GST_VIDEO_INFO_IS_YUV (info)) {
    switch (GST_VIDEO_FORMAT_INFO_FORMAT (info->finfo)) {
      case GST_VIDEO_FORMAT_I420:
        *pix_fmt = NVBUF_COLOR_FORMAT_YUV420_ER;
        break;
  1. Rebuild/replace nvvidconv plugin

By default the plugin handles formats in limited range [16,235]. It seems like it is full range [0,255] in your comparison. Please convert to YUV420 full range and check.

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