NvBufSurfTransform from NVBUF_COLOR_FORMAT_UYVY to NVBUF_COLOR_FORMAT_RGBA return -3

Hello,
I have small problem with NvBufSurfTransform

allocating buffers
source is NVBUF_COLOR_FORMAT_UYVY color format and destination NVBUF_COLOR_FORMAT_RGBA

NvBufSurfaceAllocateParams input_params = {0};

    input_params.params.width = _width;

    input_params.params.height = _height;

    input_params.params.layout = NVBUF_LAYOUT_PITCH;

    input_params.params.colorFormat = (NvBufSurfaceColorFormat)colorFormat;

    input_params.params.memType = NVBUF_MEM_SURFACE_ARRAY;

    input_params.memtag = NvBufSurfaceTag_NONE;

    int res = NvBufSurfaceAllocate (&_nvBuffSurface, 1, &input_params);

transformation params

memset(&transform_params, 0, sizeof(transform_params));

    transform_params.transform_flag = NVBUFSURF_TRANSFORM_FILTER; // | NVBUFSURF_TRANSFORM_FLIP;//| NVBUFSURF_TRANSFORM_CROP_SRC | NVBUFSURF_TRANSFORM_CROP_DST;

    transform_params.transform_filter = NvBufSurfTransformInter_Default;

    transform_params.transform_flip = NvBufSurfTransform_None;//userFlipToNvFlip(flip);

    transform_params_src_rect.left = 0;

    transform_params_src_rect.top = 0;

    transform_params_src_rect.width = _origWidth;

    transform_params_src_rect.height = _origHeight;

    transform_params_dst_rect.left = 0;

    transform_params_dst_rect.top = 0;

    transform_params_dst_rect.width = _finalWidth;

    transform_params_dst_rect.height = _finalHeight;

    transform_params.src_rect = &transform_params_src_rect;

    transform_params.dst_rect = &transform_params_dst_rect;

copy data from usb cam to source buffer and after try to convert to rgb

int result = Raw2NvBufSurface ((unsigned char *)data, 0, 0, _origWidth, _origHeight, surf_src);

    debug("GstirCam::onFrameReadyEx copy done [%d]", result);

    debug("after copy: src.dataPtr=%p planes=%d", surf_src->surfaceList[0].dataPtr, surf_src->surfaceList[0].planeParams.num_planes);

    if (!surf_src->surfaceList[0].dataPtr) {

        error("Source dataPtr NULL after Raw2NvBufSurface");

        // _man->release_buf(frame);

        return;

    }




     auto res = NvBufSurfTransform (surf_src, surf_dst, &transform_params);

    // result = NvBufferTransform(fd, frame->get_buf_fd(), &transform_params);

    debug("GstirCam::onFrameReadyEx to rgba transform %d", res);

Raw2NvBufSurface - always fine (return 0)
but NvBufSurfTransform always return -3
I try to build my plugin that work fine on Nano to Orin platform


➜  ~ cat /etc/nv_tegra_release

R35 (release), REVISION: 5.0, GCID: 35550185, BOARD: t186ref, EABI: aarch64, DATE: Tue Feb 20 04:46:31 UTC 2024

thanks for any help

found working example there

but have strange problem when try to copy data from usb cam to NvBufSurface with color format NVBUF_COLOR_FORMAT_UYVY and than converted to NVBUF_COLOR_FORMAT_RGBA

NvBufSurf::NvCommonTransformParams transformParams = {0};
transformParams.flag = NVBUFSURF_TRANSFORM_FILTER;
transformParams.filter = NvBufSurfTransformInter_Algo3;
auto res = NvBufSurf::NvTransform(&transformParams, fd, fd2);

after dumping buffers (raw, UYVY surface and RGBA surface) I see that all 3 files has same format and size
when I try add flip into my transform last one become flipped but also same size and format
NvBufSurf::NvCommonTransformParams transformParams = {0};
transformParams.flag = (NvBufSurfTransform_Transform_Flag)(NVBUFSURF_TRANSFORM_FILTER | NVBUFSURF_TRANSFORM_FLIP);
transformParams.filter = NvBufSurfTransformInter_Default;
transformParams.flip = NvBufSurfTransform_Rotate180;
auto res = NvBufSurf::NvTransform(&transformParams, fd, fd2);

image

also when I try change “output“ buffer format to NV12 nothing changed - same format after conversion

*surf2 - after conversion to GBA and flip

*surf. - after copy data from cam to UYVY surface

Hi,
The supported conversions are demonstrated in

/usr/src/jetson_multimedia_api/samples/07_video_convert/

Please refer to the sample for your implementation.

1 Like