This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

  • TI Thinks Resolved

TMS320DM6437: DM6437 H264 Image problem

Part Number: TMS320DM6437

Hi,

      The task is as follows, you need to implement the transfer of H264 bitstream on the platform of DM6437.

The original image has a size of 704х448 in the format XDM_YUV_422ILE

 

 

The system configuration is as follows:

SYS/BIOS 6.41.4.54

NDK 2.24.3.35

XDAIS 7.21.1.07

xdctools_3_30_04_52

CODEC dm6446_h264enc_02_02_00_02

 #define IMAGE_WIDTH_ENCODE 704

#define IMAGE_HEIGHT_ENCODE 448

   params->encodingPreset         = XDM_DEFAULT       ;

   params->rateControlPreset     = IVIDEO_LOW_DELAY   ;

   params->dataEndianness         = XDM_BYTE           ;

   params->maxInterFrameInterval = 1                ;

   params->inputContentType       = IVIDEO_PROGRESSIVE ;

   params->reconChromaFormat     = XDM_CHROMA_NA;

 

   params->maxWidth = IMAGE_WIDTH_ENCODE;

   params->maxHeight = IMAGE_HEIGHT_ENCODE;

   params->maxFrameRate = 30000;

   params->maxBitRate = 2048000;

   params->inputChromaFormat = XDM_YUV_422ILE;

 

   dynamicParams->inputWidth     = params.maxWidth;

   dynamicParams->inputHeight     = params.maxHeight;

   dynamicParams->refFrameRate   = params.maxFrameRate ;

   dynamicParams->targetFrameRate = params.maxFrameRate ;

   dynamicParams->targetBitRate   = params.maxBitRate   ;

   dynamicParams->generateHeader = XDM_ENCODE_AU       ;

   dynamicParams->captureWidth   = 0                   ;

   dynamicParams->forceFrame     = IVIDEO_NA_FRAME;

   dynamicParams->mbDataFlag = 0;

   dynamicParams->interFrameInterval = 1;

   dynamicParams->intraFrameInterval = 30;

 

void H264_test(unsigned int *size, unsigned char **buffer)

{

   IVIDENC1_Status         status;

   IVIDENC1_InArgs         inArgs;

   IVIDENC1_OutArgs         outArgs;

 

   IVIDENC1_Fxns           *ividEncfxns = NULL;

 

   XDAS_Int8 ii;

 

   XDAS_Int8* pInputBuf   [XDM_MAX_IO_BUFFERS];

   XDAS_Int8* pOutputBuf [XDM_MAX_IO_BUFFERS];

 

   IVIDEO1_BufDescIn inputBufDesc;

   XDM_BufDesc outputBufDesc;

 

   XDAS_UInt32 bytesGenerated;

   XDAS_UInt32 frameCount;

   XDAS_Int32 retVal;

 

 

   XDAS_Int32 groupId, numAlgs;

   IALG_Handle handleArray[NUM_ALGS];

   IDMA3_Fxns* dmaFxns[NUM_ALGS];

 

   TestApp_EnableCache();

 

   setInitParams(&params);

 

   params.size                 = sizeof(IVIDENC1_Params);

   status.size                 = sizeof(IVIDENC1_Status);

   dynamicParams.size           = sizeof(IVIDENC1_DynamicParams);

   inArgs.size                 = sizeof(IVIDENC1_InArgs);

   outArgs.size                 = sizeof(IVIDENC1_OutArgs);

 

   frameCount                  = 0;

 

   printf("\nCreating Algorithm Instance...\n");

 

   handle = (IALG_Handle)ALG_create ((IALG_Fxns *)&H264VENC_TI_IH264VENC, (IALG_Handle)NULL, (IALG_Params *) &params);

 

   if (handle == NULL)

   {

          printf("Failed to Create Instance...\n Exiting for this configuration..\n");

          return;

   }

 

   ividEncfxns = (IVIDENC1_Fxns *)handle->fxns;

 

   printf("\nAlgorithm Instance Creation Done...\n");

 

   qdma_setup();

 

 

#ifdef ENABLE_DMAN3

   DMAN3_PARAMS.paRamBaseIndex = DMAN3_PARAMBASE_H264;

   DMAN3_PARAMS.numQdmaChannels = DMAN3_TOTALCHANNELS_H264;

   DMAN3_PARAMS.qdmaChannels   = DMAN3_QDMA_CHANNELS_H264;

   DMAN3_PARAMS.numPaRamEntries = DMAN3_NUMPARAMENTRIES_H264;

 

   numAlgs                     = NUM_ALGS;

   groupId                     = 0;

 

   DMAN3_PARAMS.numPaRamGroup[groupId] = DMAN3_NUMPARAMENTRIES_H264;

 

   DMAN3_init();

 

   handleArray[0] = (IALG_Handle) handle;

   dmaFxns[0]     = &H264VENC_TI_IDMA3;

 

   if (DMAN3_grantDmaChannels(groupId, handleArray, dmaFxns, numAlgs) != DMAN3_SOK)

   {

          printf("Problem adding algorithm's dma resources");

          printf("... Exiting for this configuration... \n");

          return;

   }

#endif

 

   setDynamicParams(&dynamicParams);

 

   inputBufDesc.bufDesc[0].buf = (XDAS_Int8 *)pInputBuf;

   outputBufDesc.bufs= (XDAS_Int8 **)pOutputBuf;

 

   handle->fxns->algActivate(handle);

 

   ividEncfxns->control((IVIDENC1_Handle)handle,

                 XDM_GETBUFINFO,

                 (IVIDENC1_DynamicParams *)&dynamicParams,

                 (IVIDENC1_Status *)&status);

 

   handle->fxns->algDeactivate(handle);

 

   inputBufDesc.numBufs = status.bufInfo.minNumInBufs;

   inputBufDesc.bufDesc[0].buf     = inputData;

   inputBufDesc.bufDesc[0].bufSize = status.bufInfo.minInBufSize[0];

 

   for(ii=0; ii < (status.bufInfo.minNumInBufs - 1); ii++)

   {

          inputBufDesc.bufDesc[ii+1].buf = inputBufDesc.bufDesc[ii].buf +

                       status.bufInfo.minInBufSize[ii];

 

          inputBufDesc.bufDesc[ii+1].bufSize =

                       status.bufInfo.minInBufSize[ii +1];

   }

 

   outputBufDesc.numBufs     = status.bufInfo.minNumOutBufs;

   outputBufDesc.bufs[0]     = outputData;

   outputBufDesc.bufSizes[0] = status.bufInfo.minOutBufSize[0];

 

   for(ii=0; ii< (status.bufInfo.minNumOutBufs-1); ii++)

   {

          outputBufDesc.bufs[ii+1] = outputBufDesc.bufs[ii] +

                       status.bufInfo.minOutBufSize[ii];

 

          outputBufDesc.bufSizes[ii+1] =

                       status.bufInfo.minOutBufSize[ii+1];

   }

 

   ividEncfxns = (IVIDENC1_Fxns *)handle->fxns;

 

   bytesGenerated = 0;

 

   inputBufDesc.frameWidth = IMAGE_WIDTH_ENCODE;

   inputBufDesc.frameHeight = IMAGE_HEIGHT_ENCODE;

   inputBufDesc.framePitch = IMAGE_WIDTH_ENCODE*2;

 

   memset(outputData, 0x00, sizeof(outputData));

   memset(inputData, 0x00, sizeof(inputData));

   memset(outputFile, 0x00, sizeof(outputFile));

 

   do

   {

          if(get_crop_frame())

          {

 

                 memcpy(inputData, get_crop_frame()->img_data, IMAGE_WIDTH_ENCODE*IMAGE_HEIGHT_ENCODE*2);

 

                 memset(inputData, k * 0x10, sizeof(inputData));

 

                inputBufDesc.numBufs = 1;

                 inputBufDesc.bufDesc[0].buf     = inputData;

                 inputBufDesc.bufDesc[0].bufSize = IMAGE_WIDTH_ENCODE*IMAGE_HEIGHT_ENCODE*2;

 

                 BCACHE_wbInv(inputBufDesc.bufDesc[0].buf,

                              inputBufDesc.bufDesc[0].bufSize,

                              TRUE);

          }

 

          BCACHE_wbInvAll(); /* No need to call BCACHE_wait() */

 

 

          handle->fxns->algActivate(handle);

 

          int code = ividEncfxns->control((IVIDENC1_Handle)handle, XDM_SETPARAMS,

                       (IVIDENC1_DynamicParams *)&dynamicParams, (IVIDENC1_Status *)&status);

 

          if(status.extendedError == 0)

          {

                 retVal = ividEncfxns->process((IVIDENC1_Handle)handle,

                              (IVIDEO1_BufDescIn *)&inputBufDesc,

                              (XDM_BufDesc *)&outputBufDesc,

                              (IVIDENC1_InArgs *)&inArgs,

                              (IVIDENC1_OutArgs *)&outArgs);

          }

          else

          {

                 retVal = XDM_EFAIL;

          }

          printf("Process: %d %d\n", status.extendedError, retVal);

 

          if(retVal == XDM_EFAIL)

          {

                 printf("Process function returned an Error... \n");

                 printf("Exiting with error code %0x... \n",

                              outArgs.extendedError);

                 break;

          }

 

          ividEncfxns->control((IVIDENC1_Handle)handle,

                       XDM_GETSTATUS,

                       (IVIDENC1_DynamicParams *)&dynamicParams,

                       (IVIDENC1_Status *)&status);

 

          handle->fxns->algDeactivate(handle);

 

          BCACHE_wbInvAll(); /* No need to call BCACHE_wait() */

 

          if(outArgs.reconBufs.numBufs)

          {

                 printf("Encoded Frame # %d \n", frameCount);

                 printf("#bytesGenerated: %d\n", outArgs.bytesGenerated);

                 frameCount++;

          }

 

          memcpy(&outputFile[bytesGenerated], outArgs.encodedBuf.buf, outArgs.bytesGenerated);

 

          bytesGenerated += outArgs.bytesGenerated;

 

          if (frameCount >= framesToEncode)

          {

                 printf("Specified number of Frames Encoded...\n");

                 break;

          }

 

   } while(1);

 

   printf("all bytesGenerated: %d\n", bytesGenerated);

 

   *size = bytesGenerated;

   *buffer = (unsigned char*)&outputFile[0];

 

 

#ifdef ENABLE_DMAN3

   if (DMAN3_releaseDmaChannels( handleArray, dmaFxns, numAlgs) != DMAN3_SOK)

   {

          printf("Problem removing algorithm's dma resources...\n" );

          printf("Exiting for this configuration... ");

          return;

   }

 

   DMAN3_exit();

#endif //C6000

 

   ALG_delete (handle);

 

   if(frameCount == 0)

   {

          frameCount = 1;

   }

 

   printf("-------------- SUMMARY --------------------\n");

   printf(" Total number of Frames         = %d\n",

                 (XDAS_UInt32)frameCount);

   printf(" Bit Rate at %d frames/Sec       = %d Kbps\n",params.maxFrameRate,(

                 XDAS_UInt32)(((bytesGenerated*8*params.maxFrameRate)/frameCount)/1000));

   printf(" Width and Height               = %d, %d \n",

                 dynamicParams.inputWidth, dynamicParams.inputHeight);

   printf (" --------------   END   --------------------\n");

}

 

The output of the codec is as follows:

 

Creating Algorithm Instance...

 

Algorithm Instance Creation Done...

Process: 0 0

Encoded Frame # 0

#bytesGenerated: 295756

Process: 0 0

Encoded Frame # 1

#bytesGenerated: 279736

Specified number of Frames Encoded...

all bytesGenerated: 575492

-------------- SUMMARY --------------------

Total number of Frames         = 2

Bit Rate at 1000 frames/Sec       = 154484 Kbps

Width and Height               = 704, 448

--------------   END   --------------------

  videostream.zip

How can the situation be remedied?

  • Hi Zorg,

    For any detailed software support, bug fixes, or enhancements to TI software, please contact any of the select partners recommended below.

    e2e.ti.com/.../622094

    Regards,
    Pavel



  • In reply to Pavel Botev:

    Closing this.

     


     Please make sure you read the forum guidelines first.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.