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.

DM365 h264 decode problem

Hi all:

     Now, I am debugging h264 decode on dm365 platform with dvsdk_2_10_01_18.I meet this strange problem:

    1. The first frame(IDR) decode succeed, but the image larger.  (1280x720->1344x768)

    2.Since the second frame decode failed, the failed code is 0xC000(outArgs.decodedBufs.extendedError )

My codec parameters as follows:

const VIDENC1_Params h264enc_fix_params_default = {
        sizeof(VIDENC1_Params),                   /* size */
        XDM_DEFAULT,                                      /* encodingPreset */
        IVIDEO_LOW_DELAY,                            /* rateControlPreset */
        720,                                                            /* maxHeight */
        1280,                                                          /* maxWidth */
        30000,                                                       /* maxFrameRate */
        6000000,                                                  /* maxBitRate */
        XDM_BYTE,                                              /* dataEndianness */
        0,                                                                /* maxInterFrameInterval */
        XDM_YUV_420SP,                                  /* inputChromaFormat */
        IVIDEO_PROGRESSIVE,                      /* inputContentType */
        XDM_CHROMA_NA                               /* reconChromaFormat */
};

const VIDENC1_DynamicParams h264enc_var_params_default = {
        sizeof(IVIDENC1_DynamicParams),   /* size */
        720,                                                             /* inputHeight */
        1280,                                                           /* inputWidth */
        30000,                                                        /* refFrameRate */
        30000,                                                        /* targetFrameRate */
        6000000,                                                   /* targetBitRate */
        30,                                                               /* intraFrameInterval */
        XDM_ENCODE_AU,                                /* generateHeader */
        0,                                                                 /* captureWidth */
        IVIDEO_NA_FRAME,                               /* forceFrame */
        1,                                                                 /* interFrameInterval */
        0                                                                  /* mbDataFlag */
};

const VIDDEC2_Params h264dec_fix_params_default = {
        sizeof(VIDDEC2_Params),             /* size */
        720,                                                      /* maxHeight */
        1280,                                                    /* maxWidth */
        30000,                                                 /* maxFrameRate */
        6000000,                                            /* maxBitRate */
        XDM_BYTE,                                       /* dataEndianess */
        XDM_YUV_420SP,                           /* forceChromaFormat */
};

const VIDDEC2_DynamicParams h264dec_var_params_default = {
        sizeof(VIDDEC2_DynamicParams),      /* size */
        XDM_DECODE_AU,                                  /* decodeHeader */
        1280,                                                            /* displayWidth */
        IVIDEO_NO_SKIP,                                     /* frameSkipMode */
        IVIDDEC2_DISPLAY_ORDER,               /* frameOrder */
        0,                                                                  /* newFrameFlag */
        0,                                                                  /* mbDataFlag */
};

 

 

 

 

 

  • Hi,

    Have you integrated the latest H.264 decoder from  http://software-dl.ti.com/dsps/dsps_public_sw/codecs/DM36x/index_FDS.html which has support upto 1080P ?  The original decoder packed in DVSDK 2.10 only supported upto 720P.

    regards

    Yashwant

  • Hi,

         Thank you!But I only need 720p(1280*720).I know dvsdk_2_10_01_18 can support 720p.My problem is h264 decode 720p h264 file failed!Please he;p me check the config parameters:

     

    const VIDENC1_Params h264enc_fix_params_default =  {
                              sizeof(VIDENC1_Params),           /* size */
                              XDM_DEFAULT,                               /* encodingPreset */
                              IVIDEO_LOW_DELAY,                     /* rateControlPreset */
                              720,                                                     /* maxHeight */
                             1280,                                                    /* maxWidth */
                             30000,                                                 /* maxFrameRate */
                             6000000,                                            /* maxBitRate */
                             XDM_BYTE,                                       /* dataEndianness */
                             0,                                                         /* maxInterFrameInterval */
                            XDM_YUV_420SP,                            /* inputChromaFormat */
                            IVIDEO_PROGRESSIVE,                /* inputContentType */
                            XDM_CHROMA_NA                          /* reconChromaFormat */
        };

        const VIDENC1_DynamicParams h264enc_var_params_default = {
            sizeof(IVIDENC1_DynamicParams),   /* size */
            720,                                                  /* inputWidth */
            30000,                                             /* refFrameRate */
            30000,                                             /* targetFrameRate */
            6000000,                                         /* targetBitRate */
            30,                                                    /* intraFrameInterval */
            XDM_ENCODE_AU,                     /* generateHeader */
            0,                                                      /* captureWidth */
            IVIDEO_NA_FRAME,                    /* forceFrame */
            1,                                                      /* interFrameInterval */
            0                                                       /* mbDataFlag */
    };


    const VIDDEC2_Params h264dec_fix_params_default = {
            sizeof(VIDDEC2_Params),             /* size */
            720,                                                      /* maxHeight */
            1280,                                                    /* maxWidth */
            30000,                                                 /* maxFrameRate */
            6000000,                                            /* maxBitRate */
            XDM_BYTE,                                        /* dataEndianess */
            XDM_YUV_420SP,                            /* forceChromaFormat */
    };

    const VIDDEC2_DynamicParams h264dec_var_params_default = {
            sizeof(VIDDEC2_DynamicParams),      /* size */
            XDM_DECODE_AU,                                  /* decodeHeader */
            1280,                                                            /* displayWidth */
            IVIDEO_NO_SKIP,                                     /* frameSkipMode */
            IVIDDEC2_DISPLAY_ORDER,              /* frameOrder */
            0,                                                                 /* newFrameFlag */
            0,                                                                 /* mbDataFlag */
    };

     

          Thank you!Give my best wishes to you!

  • Hi li guipan,

    Config parameters looks fine, as Yashwant mentioned can you please upgrade your codec with latest available at  http://software-dl.ti.com/dsps/dsps_public_sw/codecs/DM36x/index_FDS.html? and check if issue still persists.

     

    Thanks,

    Veeranna

  • Hi,

      Thank you!Now I have download the lateest dm365_h264dec_02_00_00_11_production.bin, but I don't know how to update it!Coulde you give me some guide?

     Thank you!Give my best wishes to you!

  • Hi,

    Please extract package from dm365_h264dec_02_00_00_11_production.bin file.Inside package dm365_h264dec_02_00_00_11_production\packages\ti\sdo\codecs\ you will find 'h264dec' folder please copy this and paste  to /dvsdk_2_10_01_18/dm365_codecs_01_00_06/packages/ti/sdo/codecs directory. And please set proper values for all config parameters. If you are using extended params there are new extended params in 02.00 decoder, set valid values for them and  build dvsdk.

    For information on params please refer interface file 'ih264vdec.h', userguide and testapp provided with package. testapp is in  ....\..\codecs\h264dec\apps directory.

     

    Thanks,

    Veeranna

  • Hi,

               Thank you!But the problem is still exist!There is my h264 decode source code , please help me check if there is problem?

     

    struct viddec_desc {
            const char                                  *name;       /** */
            VIDDEC2_Handle                    handle;      /** */
            VIDDEC2_Params                   fix_params;  /**perment params */
            VIDDEC2_DynamicParams   var_params;  /**dynamic params */
            XDM1_BufDesc                        buffer_in;   /**input buffer*/
            XDM_BufDesc                           buffer_out;  /**output buffer*/
            XDAS_Int8                                 *outbuf[XDM_MAX_IO_BUFFERS];
            XDAS_Int32                               outbufsize[XDM_MAX_IO_BUFFERS];
    };

     

    static struct viddec_desc h264dec;

     

    int h264dec_init(struct viddec_desc          *h264dec,
                                  struct engine_desc          *engine,
                                  const char                           *name,
                                  const VIDDEC2_Params        *fix_p,
                                  const VIDDEC2_DynamicParams *var_p)
    {
            VIDDEC2_Handle h = NULL;
            VIDDEC2_Status vidStatus;
            XDAS_Int32     status;
            XDM1_BufDesc   buf_in;
            XDM_BufDesc    buf_out;
            VIDDEC2_Params        fix;
            VIDDEC2_DynamicParams var;

            if (fix_p == NULL) {
                    fix = h264dec_fix_params_default;
            } else {
                    fix = *fix_p;
            }
            if (var_p == NULL) {
                    var = h264dec_var_params_default;
            } else {
                    var = *var_p;
            }

            h = VIDDEC2_create(engine->handle, (char *)name, &fix);
            if (h == NULL) {
                    GT_1trace(local_gtmask, GT_7CLASS, "create viddec \"%s\" error\n", name);
                    return -1;
            }

            vidStatus.size = sizeof(VIDDEC2_Status);
            status = VIDDEC2_control(h, XDM_SETPARAMS, &var, &vidStatus);
            if (status != VIDDEC2_EOK) {
                    VIDDEC2_delete(h);
                     GT_0trace(local_gtmask, GT_7CLASS, "XDM_SETPARAMS error\n");
                    return -1;
            }

            buf_out.bufs = h264dec->outbuf;
            buf_out.bufSizes = h264dec->outbufsize;
            status = viddec_getbufinfo(h, &var, &buf_in,  &buf_out);
            if (status < 0) {
                    VIDDEC2_delete(h);
                    return -1;
            }

            buf_in.numBufs = 1;
            status = contig_buffer_alloc(&buf_in);
            if (status < 0) {
                    VIDDEC2_delete(h);
                     GT_0trace(local_gtmask, GT_7CLASS, "GET BUFFER INFO error\n");
                    return -1;
            }

            status = contig_buffer_alloc2(&buf_out);
            if (status < 0) {
                    VIDDEC2_delete(h);
                     GT_0trace(local_gtmask, GT_7CLASS, "GET BUFFER INFO error\n");
                    return -1;
            }

            h264dec->handle     = h;
            h264dec->name       = name;
            h264dec->fix_params = fix;
            h264dec->var_params = var;
            h264dec->buffer_in  = buf_in;
            h264dec->buffer_out = buf_out;

            return 0;
    }

    /**
     * @fn     int h264dec_process(struct viddec_desc *h264dec,
     *                            int h264_len,
     *                            int *yuv_len,
     *                            int *width,
     *                            int *height,
     *                            int *stride)
     * @brief      h264 decode process
     * @param  [in]  h264dec 
     * @param  [in]  h264_len h264 data length
     * @param  [out] yuv_len yuv420 data length
     * @param  [out] width   image width
     * @param  [out] height  image height
     * @param  [out] stride 
     * @note
     * @note  
     * @return
     */
    int h264dec_process(struct viddec_desc *h264dec,
                       int h264_len,
                       int *yuv_len,
                       int *width,
                       int *height,
                       int *stride)
    {
            VIDDEC2_InArgs   inArgs;
            VIDDEC2_OutArgs  outArgs;
            XDM1_BufDesc     inBufDesc;
            XDM_BufDesc     outBufDesc;
            XDAS_Int32       status;
            VIDDEC2_Status   vidStatus;

            vidStatus.size = sizeof(VIDDEC2_Status);
            status = VIDDEC2_control(h264dec->handle, XDM_RESET, &h264dec->var_params, &vidStatus);
            if (status != VIDDEC2_EOK) {
                     GT_0trace(local_gtmask, GT_7CLASS, "XDM_GETSTATUS error\n");
                     return -1;
            }

            inBufDesc  = h264dec->buffer_in;
            outBufDesc = h264dec->buffer_out;
            inBufDesc.descs[0].bufSize = h264_len; /**check the parameters*/
            inBufDesc.numBufs = 1;

            inArgs.size             = sizeof(VIDDEC2_InArgs);
            inArgs.numBytes         = h264_len;
            inArgs.inputID          = 1;
            outArgs.size            = sizeof(VIDDEC2_OutArgs);

            status = VIDDEC2_process(h264dec->handle, &inBufDesc, &outBufDesc, &inArgs, &outArgs);
            if (status != VIDDEC2_EOK) {
                    GT_2trace(local_gtmask, GT_7CLASS,
                              "VIDDEC2_process() failed with error (%d ext: 0x%x)\n",
                              (Int)status, (Uns) outArgs.decodedBufs.extendedError);
                    return -1;
            }
            printf("outBufDesc.bufSizes=%d outBufDesc.numBufs=%d\n", (int)*outBufDesc.bufSizes, (int)outBufDesc.numBufs);
            printf("outArgs.size=%d numbufs=%d framPitch=%d width=%d height=%d outBufsInUseFlag = %d\n",
                   (int)outArgs.size, (int)outArgs.decodedBufs.numBufs,
                   (int)outArgs.decodedBufs.framePitch, (int)outArgs.decodedBufs.frameWidth,
                   (int)outArgs.decodedBufs.frameHeight, (int)outArgs.outBufsInUseFlag);
            //printf("outArgs.size=%d outArgs.displayBufs[1].bufDesc[0].bufsize=%d\n", (int)outArgs.size,
            //       (int)outArgs.displayBufs[1].bufDesc[0].bufSize);
            *stride  = outArgs.decodedBufs.framePitch;
            *width   = outArgs.decodedBufs.frameWidth;
            *height  = outArgs.decodedBufs.frameHeight;
            *yuv_len = (*width) * (*height) * 2;
          #if 1
          FILE *fp = fopen("dec2_process.raw", "wb");
          if (fp != NULL)
          {
                 printf("outArgs.decodedBufs.bufDesc[0].bufSize=%d, outArgs.decodedBufs.bufDesc[1].bufSize=%d\n",
                         (int)outArgs.decodedBufs.bufDesc[0].bufSize, (int)outArgs.decodedBufs.bufDesc[1].bufSize);
                 fwrite(outArgs.decodedBufs.bufDesc[0].buf, outArgs.decodedBufs.bufDesc[0].bufSize, 1, fp);
                 fwrite(outArgs.decodedBufs.bufDesc[1].buf, outArgs.decodedBufs.bufDesc[1].bufSize, 1, fp);
                 //fwrite(outBufDesc.bufs[1], *yuv_len-*outBufDesc.bufSizes, 1, fp);
          }
          fclose(fp);
          #endif

          return 0;
    }

    /**
     * @fn     int h264dec_exit(struct viddec_desc *h264dec)
     * @brief  close h264dec
     * @param  [in] h264dec
     * @return  success
     */
    int h264dec_exit(struct viddec_desc *h264dec)
    {
            VIDDEC2_delete(h264dec->handle);
            contig_buffer_free(&h264dec->buffer_in);
            contig_buffer_free2(&h264dec->buffer_out);
            return 0;
    }

    int decode(const void *h264_buf, int h264_len,
               void *uyvy_buf, int *uyvy_len,
               int *width, int *height, int *stride)
    {
          memcpy(h264dec.buffer_in.descs[0].buf, h264_buf, h264_len);

          if (h264dec_process(&h264dec, h264_len, uyvy_len,
                              width, height, stride) != 0)
          {
                    printf("h264dec_process failed!\n");
                    return -1;
          }

          #if 1
          FILE *fp = fopen("dec.raw", "wb");
          if (fp != NULL)
          {
                 fwrite(h264dec.buffer_out.bufs[0], (*stride)*(*height), 1, fp);
          }
          fclose(fp);
          #endif
          int len = (((*stride)*(*height))<<1)/3;
          memcpy(uyvy_buf, h264dec.buffer_out.bufs[0], *h264dec.buffer_out.bufSizes);
          memcpy(uyvy_buf + *h264dec.buffer_out.bufSizes, h264dec.buffer_out.bufs[1],
                 len - *h264dec.buffer_out.bufSizes);
          return 0;
    }

     

    Thank you!Give my best wishes to you!

  • Hi,

    You should not use outArgs.decodedBufs to display or file write the decoder output. And you can't use frameHeight and width from buffer property these size includes padding size. You should use outArgs.displayBufs for positive nonzero outputID vlaue.

    Can you please refer testapp file 'TestAppDecoder_ih264_arm926.c'  present at 'packages\ti\sdo\codecs\h264dec\apps\client\test\src'. If you haven't run this standalone testapp it will be good if you run this.

    And there is relation between displaybuff and displaydelay parameter, you can refer following doc for more info http://focus.ti.com/lit/an/sprab88/sprab88.pdf

    Thanks,

    Veeranna

  • Hi,

       Thank you!But when I add this code in h264dec_process() function:

            int bufIdx = 0;
            for (bufIdx = 0; bufIdx < IVIDDEC2_MAX_IO_BUFFERS && outArgs.outputID[bufIdx] > 0; bufIdx++)
            {

                            printf("outArgs.size=%d outArgs.displayBufs[%d].frameWidth=%d frameHeight\n", (int)outArgs.size,
                            bufIdx, (int)outArgs.displayBufs[bufIdx].frameWidth, (int)outArgs.displayBufs[bufIdx].frameHeight);
            }

            This code can't been exec!This mean outArgs.outputID[bufIdx] is zero!I can't find where the problem is?Can you give me some help?

    Thank you!Give my best wishes to you!

  • Hi, Veeranna

           Thank you for your patiently explaining! Now, the h264 decode is right, but outArgs.outputID[] is still zero and this code

    {
                XDAS_UInt32 outcount;
                XDAS_UInt32 TempOPId;

                for(outcount = 0; outArgs.outputID[outcount] != 0; outcount++)
                {
                    TempOPId = outArgs.outputID[outcount];
                    printf("OutBufId = %d", outArgs.outputID[outcount]);
                    printf("Frame Ht = %d\n",outArgs.displayBufs[outcount].frameHeight);
                    printf("Frame Wdth = %d\n",outArgs.displayBufs[outcount].frameWidth);
                    printf("Frame Pitch = %d\n",outArgs.displayBufs[outcount].framePitch);
                    printf("Buffer Size = %d\n",outArgs.displayBufs[outcount].bufDesc[0].bufSize);
                }

      }

    can't be executed.I don't know the reason, Could you give me some clues?

    Thank you ! Give my best wishes to you!

     


  • Hi,

    You are using base param mode, so decoder mode will be universal and value of displayDelay will be 16. After 16 frames decode, outputID will set to valid value. 

    Please refer testapp to know how it handled, other option will be use extended params and set displayDelay to 0. You can refer doc   http://focus.ti.com/lit/an/sprab88/sprab88.pdf   to know more about relation between outputID and displayDelay.

     

    Thanks,

    Veeranna