NvBufSurfTransform failed with error -3 while converting buffer

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) : JETSON
• DeepStream Version : 6.0.1
• JetPack Version (valid for Jetson only): Jetpack 5.0.2 GA [L4T 35.1.0]
• TensorRT Version: 8.4.0
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

I am working on a demo that demonstrates the usage of NvBufSurfTransform, here is the core code:


void Test() {
  uint32_t width = 1920;
  uint32_t height = 1080;

  uint32_t dst_width = 640;
  uint32_t dst_height = 360;
  NvBufSurfaceCreateParams params1 = {
      .gpuId = 0,
      .width = width,
      .height = height,
      .size = 0,
      .isContiguous = true,
      .colorFormat = NVBUF_COLOR_FORMAT_RGBA,
      .layout = NVBUF_LAYOUT_PITCH,
      .memType = NVBUF_MEM_SURFACE_ARRAY,
  };
  NvBufSurface *surface1 = NULL;
  int ret = NvBufSurfaceCreate(&surface1, 1, &params1);
  if(ret != 0 || !surface1) {
    exit(-1);
  }

  ret = NvBufSurfaceMemSet (surface1, -1, -1, 255);
  if(ret != 0) {
    exit(-1);
  }

  NvBufSurfaceCreateParams params2 = {
      .gpuId = 0,
      .width = dst_width,
      .height = dst_height,
      .size = 0,
      .isContiguous = true,
      .colorFormat = NVBUF_COLOR_FORMAT_RGBA,
      .layout = NVBUF_LAYOUT_PITCH,
      .memType = NVBUF_MEM_SURFACE_ARRAY,
  };
  NvBufSurface *surface2 = NULL;
  ret = NvBufSurfaceCreate(&surface2, 1, &params2);
  if(ret != 0 || !surface2) {
    exit(-1);
  }

  NvBufSurfTransformRect src_rect, dst_rect;

  src_rect.top   = 0;
  src_rect.left  = 0;
  src_rect.width = width;
  src_rect.height = height;

  dst_rect.top   = 0;
  dst_rect.left  = 0;
  dst_rect.width = dst_width;
  dst_rect.height = dst_height;

  NvBufSurfTransformParams nvbufsurface_params;
  memset(&nvbufsurface_params, 0, sizeof(nvbufsurface_params));
	nvbufsurface_params.src_rect = &src_rect;
	nvbufsurface_params.dst_rect = &dst_rect;
	nvbufsurface_params.transform_filter = NvBufSurfTransformInter_Default;
	nvbufsurface_params.transform_flag =  NVBUFSURF_TRANSFORM_CROP_SRC | NVBUFSURF_TRANSFORM_CROP_DST | NVBUFSURF_TRANSFORM_FILTER;

  NvBufSurfTransformConfigParams transform_config_params;
  memset(&transform_config_params, 0, sizeof(transform_config_params));
	transform_config_params.compute_mode = NvBufSurfTransformCompute_Default;
	ret = NvBufSurfTransformSetSessionParams (&transform_config_params);
  if(ret != 0) {
    exit(-1);
  }

  ret = NvBufSurfaceMemSet (surface2, -1, -1, 0);
  if(ret != 0) {
    exit(-1);
  }
  ret = NvBufSurfTransform (surface1, surface2, &nvbufsurface_params);
  
  if (ret != NvBufSurfTransformError_Success) {
     printf ("NvBufSurfTransform failed with error %d while converting buffer\n", ret);
  }
 
}

When I running the demo, the NvBufSurfTransform will return -3, that is NvBufSurfTransformError_Invalid_Params. Then I further set DBG_NVBUFSURFTRANSFORM in my env, the logs is here:

/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1620: NvBufSurfTransformSessionCreate=> Session created 0xaaaaff557ba0 (nil)
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1741: libnvbufsurf_transform_init=> Init lib 0xaaaaff557ba0
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:566: taskTrim=> Starting clean up thread
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1620: NvBufSurfTransformSessionCreate=> Session created 0xaaaaff6125e0 (nil)
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1790: NvBufSurfTransformSetSessionParams=> No session associated created 0xaaaaff6125e0 for thread=281472958662912
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:2208: NvBufSurfTransformAsync=> src buffers are empty NULL
NvBufSurfTransform failed with error -3 while converting buffer
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1652: libnvbufsurf_transform_deinit=> Deinit lib
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:1644: NvBufSurfTransformSessionDestroy=> Session destroyed 0xaaaaff557ba0
/dvs/git/dirty/git-master_linux/nvutils/nvbufsurftransform/nvbufsurftransform.cpp:601: taskTrim=> Exiting Clean up thread

Solved by set surface1->numFilled to 1.

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