Does NvMedia IJPE Encoder support taking RGBA as input?

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
1.9.3.10904
other

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

Hi,

I tried to construct a jpeg encoder based on NvMedia with this parameter:

    status = PopulateNvSciBufAttrList(
            RGBA_8bit,
            m_width,
            m_height,
            true,                           /* needCpuAccess */
            NvSciBufImage_PitchLinearType,
            2,  /* RGBA image is stored in 1 plane, YUV normally in 2 */
            NvSciBufAccessPerm_ReadWrite,
            256U, // lumaBaseAddressAlign
            NvSciColorStd_SENSOR_RGBA,
            NvSciBufScan_ProgressiveType,
            bufAttributeList);
if (NVMEDIA_STATUS_OK != status) {
        LOG_ERR("NVDrive: Failed to populate attributes\n");
    }

    err = NvSciBufAttrListReconcile(&bufAttributeList, 1U,
            &bufReconciledList, &bufConflictList);
    if (err != NvSciError_Success) {
        LOG_ERR("NVDrive: Reconciliation for input frame failed\n");
    }
    ijpeCtx = NvMediaIJPECreate(bufReconciledList,               
                                n_inputs,                        // maxOutputBuffering
                                MAX_BITSTREAM_SIZE,              // maxBitstreamBytes
                                NVMEDIA_JPEG_INSTANCE_0);        // HW instance id

If I use RGBA_8bit as input, there will be an error when executing NvMediaIJPECreate(): Failed to get buffer attributes. If I replace RGBA_8bit with any yuv format, it would simply work. So my question is, does nvmedia IJPE support RGBA as input? How should I make this work?

Any help is appreciated. Thanks

Thanks for sharing your code snippet and explanation of the error.

Could you provide the full command line you used to execute your code and the complete output?

The whole related code is below

/********************************* Initialization *********************************/
    // Initialize NvMedia structures
    err = NvSciBufModuleOpen(&bufModule);
    err = NvSciSyncModuleOpen(&syncModule);
    err = NvSciSyncCpuWaitContextAlloc(syncModule, &cpuWaitContext);

    imageSize = m_width * m_height * 3;
    LOG_DBG("NVDrive: Encode start, imageSize=%d\n", imageSize);

    err = NvSciBufAttrListCreate(bufModule, &bufAttributeList);
    status = NvMediaIJPEFillNvSciBufAttrList(NVMEDIA_JPEG_INSTANCE_0, bufAttributeList);

     status = PopulateNvSciBufAttrList(
             RGBA_8bit,
            m_width,
             m_height,
            true,                           /* needCpuAccess */
             NvSciBufImage_PitchLinearType,
             2,                             /* RGBA image is stored in 1 plane, YUV normally in 2 */
             NvSciBufAccessPerm_ReadWrite, /* access permission */
             256U,                        /* normally doesn't matter for sensor RGBA images, jsut use the default one */
             NvSciColorStd_SENSOR_RGBA,
            NvSciBufScan_ProgressiveType,  /* default scanType */
             bufAttributeList);

    err = NvSciBufAttrListReconcile(&bufAttributeList, 1U,
            &bufReconciledList, &bufConflictList);
    appBuffer = static_cast<NvMediaAppBuffer*>(malloc(sizeof(NvMediaAppBuffer)));
    memset(appBuffer, 0x0, sizeof(NvMediaAppBuffer));
    err = NvSciBufObjAlloc(bufReconciledList, &appBuffer->bufObj);
    ijpeCtx = NvMediaIJPECreate(bufReconciledList,               
                                n_inputs,                        // maxOutputBuffering
                                MAX_BITSTREAM_SIZE,              // maxBitstreamBytes
                                NVMEDIA_JPEG_INSTANCE_0);        // HW instance id

    /* The reconciled list is needed for later */
    NvSciBufAttrListFree(bufAttributeList);
    NvSciBufAttrListFree(bufConflictList);

    status = sAllocEOFNvSciSyncObj(ijpeCtx, syncModule, &eofSyncObj);
    status = NvMediaIJPERegisterNvSciSyncObj(ijpeCtx, NVMEDIA_EOFSYNCOBJ, eofSyncObj);
    status = NvMediaIJPESetNvSciSyncObjforEOF(ijpeCtx, eofSyncObj);

/*********************************Image Processing*********************************/
        // Convert dwImage from CUDA to NvMedia     
        CHECK_DW_ERROR_NOTHROW(dwImageStreamer_producerSend(m_cuda_image, m_streamerCUDA2NvMedia[inputNum]));
        CHECK_DW_ERROR(dwImageStreamer_consumerReceive(&m_nvmedia_image, 1000, m_streamerCUDA2NvMedia[inputNum]));
        
        dwImage_getNvMedia(&dw_nvmedia_image, m_nvmedia_image);
        appBuffer->bufObj = dw_nvmedia_image->imgBuf;

        // Compress image
        status = NvMediaIJPEFeedFrame(ijpeCtx, appBuffer->bufObj, nvmedia_compress_quality, NVMEDIA_JPEG_INSTANCE_0);

        // Rest of code

After some tests, it seems that
NvMediaIJPECreate()
only supports images who has only 2 planes. If I set 1 plane for RGBA

status = PopulateNvSciBufAttrList(
            RGBA_8bit,
            m_width,
            m_height,
            true,                           /* needCpuAccess */
            NvSciBufImage_PitchLinearType,
            1,   // planes
            NvSciBufAccessPerm_ReadWrite,
            256U, // lumaBaseAddressAlign
            NvSciColorStd_SENSOR_RGBA,
            NvSciBufScan_ProgressiveType,
            bufAttributeList); 

or 3 planes for YUV planar

status = PopulateNvSciBufAttrList(
            YUV444P_8bit,
            m_width,
            m_height,
            true,                           /* needCpuAccess */
            NvSciBufImage_PitchLinearType,
            3,  // planes
            NvSciBufAccessPerm_ReadWrite,
            256U, // lumaBaseAddressAlign
            NvSciColorStd_SENSOR_RGBA,
            NvSciBufScan_ProgressiveType,
            bufAttributeList); 

It will show this error
Unsupported number of planes - 1 Unsupported buffer attributes
Unsupported number of planes - 3 Unsupported buffer attributes

But RGBA only has 1 plane, correct?

The Tegra NVJPG HW-based JPEG encoder accepts only 2 input formats:

  • YUV420 planar
  • YUV420 semi-planar i.e. NV12

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