NvBuffer Transform fails with YUV420_ER format. Ratio of downsampling 2

I am using the below code to compare NvBufferTransform() for two different color formats: NvColorFormats_YUV420 and NvColorFormats_YUV420_ER. With all sets of different creation and transform params, transform passes with YUV420 but fails with YUV420_ER.

/* Comparision of NvBufferTransform for two different color formats (YUV420 and YUV420_ER) */
bool Transform(NvBufferCreateParams& params, NvBufferTransformParams& transformParams) {
  int srcDmabuf;
  int dstDmabuf;

  // Create NvBuffer with input params
  if (0 != NvBufferCreateEx(&srcDmabuf, &params) || 0 != NvBufferCreateEx(&dstDmabuf, &params)) {
    std::cout << "Unable to create NvBuffers with the input params!" << std::endl;
  }

  // setting src and dst rect
  transformParams.src_rect = NvBufferRect{0, 0, uint32_t(params.width), uint32_t(params.height)};
  transformParams.dst_rect = NvBufferRect{0, 0, uint32_t((params.width) / 2), uint32_t((params.height) / 2)};

  // Transform NvBuffer with input params
  if (0 != NvBufferTransform(srcDmabuf, dstDmabuf, &transformParams)) {
    return false;
  }

  //Destroy the NvBuffer
  if((0 != NvBufferDestroy(srcDmabuf)) || 0 != NvBufferDestroy(dstDmabuf)){
    std::cout << "Unable to destroy NvBuffers!" << std::endl;    
  } 

  return true;
}

int main(int argc, char* argv[]) {
  NvBufferCreateParams params{};
  NvBufferTransformParams transformParams{};

  // NvBufferCreate Params: NvPayloadType, NvBufferLayout, NvColorFormat
  params.width = 4096;
  params.height = 2048;
  params.payloadType = NvBufferPayload_SurfArray;
  std::vector<NvBufferLayout> layoutTypes{NvBufferLayout_Pitch, NvBufferLayout_BlockLinear};

  // NvBufferTransformParams: NvTransformFilter
  transformParams.transform_flag = NVBUFFER_TRANSFORM_FILTER;
  std::vector<NvBufferTransform_Filter> transformFilters{
      NvBufferTransform_Filter_Nearest, NvBufferTransform_Filter_Bilinear, NvBufferTransform_Filter_5_Tap,
      NvBufferTransform_Filter_10_Tap,  NvBufferTransform_Filter_Smart,    NvBufferTransform_Filter_Nicest};

  // YUV420: for different transform filters
  params.colorFormat = NvBufferColorFormat_YUV420;
  std::cout << "------------------------[NvBuffer Transform Test: YUV420]------------------------"
            << std::endl;
  for (int i = 0; i < layoutTypes.size(); i++) {
    params.layout = layoutTypes.at(i);
    std::string layoutTypeName = GetLayoutTypeName(i);
    for (int j = 0; j < transformFilters.size(); j++) {
      transformParams.transform_filter = transformFilters.at(j);
      std::string transformFilterName = GetTransformFilterName(j);
      std::string result = Transform(params, transformParams) ? "PASS" : "FAIL";
      std::cout << "Transform Result: " + result + ", Mem Layout Type: " + layoutTypeName +
                       ", Transorm Filter: " + transformFilterName
                << std::endl;
    }
  }

  std::cout << std::endl;

  // YUV420_ER: for different transform filters
  params.colorFormat = NvBufferColorFormat_YUV420_ER;
  std::cout << "------------------------[NvBuffer Transform Test: YUV420_ER]------------------------"
            << std::endl;
  for (int i = 0; i < layoutTypes.size(); i++) {
    params.layout = layoutTypes.at(i);
    std::string layoutTypeName = GetLayoutTypeName(i);
    for (int j = 0; j < transformFilters.size(); j++) {
      transformParams.transform_filter = transformFilters.at(j);
      std::string transformFilterName = GetTransformFilterName(j);
      std::string result = Transform(params, transformParams) ? "PASS" : "FAIL";
      std::cout << "Transform Result: " + result + ", Mem Layout Type: " + layoutTypeName +
                       ", Transorm Filter: " + transformFilterName
                << std::endl;
    }
  }

  return 0;
}

My input width and height is 4096x2048. Below is the output which throws: NvDdkVicConfigure Failed nvbuffer_transform Failed.

------------------------[NvBuffer Transform Test: YUV420]------------------------
Transform Result: PASS, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Nearest
Transform Result: PASS, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Bilinear
Transform Result: PASS, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_5_Tap
Transform Result: PASS, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_10_Tap
Transform Result: PASS, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Smart
Transform Result: PASS, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Nicest
Transform Result: PASS, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Nearest
Transform Result: PASS, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Bilinear
Transform Result: PASS, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_5_Tap
Transform Result: PASS, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_10_Tap
Transform Result: PASS, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Smart
Transform Result: PASS, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Nicest

------------------------[NvBuffer Transform Test: YUV420_ER]------------------------
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Nearest
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Bilinear
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_5_Tap
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_10_Tap
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Smart
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_Pitch, Transorm Filter: NvBufferTransform_Filter_Nicest
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Nearest
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Bilinear
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_5_Tap
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_10_Tap
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Smart
NvDdkVicConfigure Failed
nvbuffer_transform Failed
Transform Result: FAIL, Mem Layout Type: NvBufferLayout_BlockLinear, Transorm Filter: NvBufferTransform_Filter_Nicest

Hi,
The hardware converter does not support YUV420_ER to YUV420 conversion. If you need this in your use-case, please use software converter to get exact result.

Other cases should work well with this prebuilt lib:
Jetson/L4T/r32.7.x patches - eLinux.org

[MMAPI] 07_video_convert sample result not match as expected

Please apply it and give it a try.

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