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.

Linux/DRA746: whether 264 decoder can get width and height from sps/pps

Part Number: DRA746


Tool/software: Linux

hi.

in omapdrmtest/viddec3test.c, test should set the right width and height to ti h264 decoder, otherwise decoder can not work.

But, in normal playback, client just set sps/pps to decoder and decoder parses width and height from sps/pps.

So my question is:  if i want to pass sps/pps to ti decoder, ti decoder whether can parse them and how.

  • Hi gao,
    Yes, in viddec3test case, demuxer parses and gets the correct width and height hence explicitly sending SPS/PPS header to decoder to know the width, height is not required.
    If your client appllication wants to know the resolution of stream, sending SPS/PPS to decoder is the only way.
    Refer Appendix D: Parse Header Support of the H264-Decoder-User-Guide.pdf. It has information on the procedure.

    This UserGuide will be available in IPUMM. Path is
    /extrel/ti/ivahd_codecs/packages/ti/sdo/codecs/h264vdec/docs

    Ram
  • thank you sam. i got it but i still have some problems.
    Refer Appendix D: Parse Header Support of the H264-Decoder-User-Guide.pdf
    first client application needs to perform a XDM_SETPARAMS control call with dynamicParams->decodeHeader = XDM_PARSE_HEADER. Sequence of operations on the application side typically is as follows:
    1. Decoder_Create
    2. Control call (XDM_SETPARAMS) to configure decoder in parse
    header mode
    3. Process call to decoder which shall decode SPS+PPS
    4. Control call (XDM_GETBUFINFO) to understand buffer
    requirements
    5. Allocate buffers of size exactly needed to decode this particular bit
    stream
    6. Control call (XDM_SETPARAMS) to configure decoder in normal
    mode (dynamicParams->decodeHeader = XDM_DECODE_AU)
    7. Process calls to decode frames

    but i still cannot get width and height of the stream from step 4(XDM_GETBUFINFO control) , which are meaningful to application side.
    only i can get minNumInBufs/minNumOutBufs/minInBufSize/minOutBufSize which are in struct XDM1_AlgBufInfo.

    i hope 264 decoder can parse w/h from sps/pps if stream format is change(such as width/height/min output buffer count) and notify them to application side, so application re-create surface to display.
  • Hi Gao,
    Status structure from where you get minNumInBufs etc also has elements outputWidth and outputHeight.
    This should have the width and height of the stream. Can you check?

    Ram
  • If outputWidth and outputHeight are not correct values with XDM_GETBUFINFO, try with XDM_GETSTATUS first
  • Hi Sam, it seems not work.

    I taken the following steps:
    1. setup dynamic param with XDM_PARSE_HEADER
    2. allocate one input buffer(XDM2_BufDesc* ) to store sps/pps data and in args(VIDDEC3_InArgs*) , which is the same with normal decoding procedure
    3. allocate out args(VIDDEC3_OutArgs*), but i did not allocate output buffer which seems unnecessary to me
    4. call VIDDEC3_process(mCodec, mInBufs, mOutBufs, mInArgs, mOutArgs)
    5. call VIDENC2_control(mCodec, XDM_GETSTATUS, (VIDENC2_DynamicParams *) mDynParams, (VIDENC2_Status *) mH264Status) mH264Status is allocated before.
    6. call VIDDEC3_control(mCodec, XDM_GETBUFINFO, mDynParams, (VIDDEC3_Status*) mStatus)
    but it does not work from the following logcat:
    ===================================================
    11-02 13:18:46.284 4978 4988 D DecoderH264: [TI] (decoder_h264.cc, decodeInfo, 211)VIDDEC3_control - XDM_GETSTATUS err -1 maxNumDisplayBufs 0, outputWidth 0, outputHeight 0

    11-02 13:18:46.284 4978 4988 D DecoderH264: [TI] (decoder_h264.cc, decodeInfo, 221)VIDDEC3_control - XDM_GETBUFINFO err 0 status minNumInBufs 1, minNumOutBufs 2, minInBufSize 2500000, minOutBufSize[0] 896, minOutBufSize[1] 896

    11-02 13:18:46.284 4978 4988 D DecoderH264: [TI] (decoder_h264.cc, decodeInfo, 227)VIDDEC3_control - XDM_GETBUFINFO err 0 maxNumDisplayBufs 22, outputWidth 0, outputHeight 0
    ==================================================================
    The maxNumDisplayBufs is not right for width/height 768x320, and outputWidth and outputHeight are not right also.
    Did I set the wrong value to input/output or inArgs/outArgs, and how to set it.

    thank you.
  • sorry, i set the wrong value toXDM_GETSTATUS for control. it's ok now.
    but maxNumDisplayBufs is 22 for certain 264 stream, whose number is larger than the max reference frame count(16)
  • Hi Gao,
    maxNumDisplayBufs depends on displaydelay also and not only num_ref_frames. In Decoder_Create(), application can set the displayDealy.
    If it is set to IVIDDEC3_DISPLAY_DELAY_AUTO as done in viddec3test of omapdrmtest, decoder decides the display-delay.
    Client applications can set displayDealay to IVIDDEC3_DISPLAY_DELAY_X (where X is 1 to 16).

    If you look at viddec3test.c, it doesn't use maxNumDisplayBufs .
    It calculates the display buffers as
    decoder->num_outBuf = MIN(16, 32768 / ((width/16) * (height/16))) + 3;
    This is based on the H264 spec ,higher the resolution lesser will be number of reference frames.

    Ram
  • Thank you sam.
    I have antother question. How to detect resolution change of stream.
    I know there is a error number called IH264VDEC_ERR_PICSIZECHANGE, which is returned by codec when stream's resolution is changed.
    Whether the following steps to play resolution changed media file are ok:
    1. Call VIDDEC3_process, and until to detect the return value is IH264VDEC_ERR_PICSIZECHANGE
    2. Set input buffer to EOS in order to drain out the output buffers
    3. detect w/h from the new sps/pps, re-create engine and codec

    Is that ok?
  • Hi Gao,
    There is no need to re-create the codec when resolution change happens. Application will have to flush out all buffers and re-allocate the buffers for new resolution.

    Refer Appendix G of the H264Decoder userGuide
  • Thank you ram.
    I have another problem.

    In normal procedure:
    1. call VIDDEC3_process to decoder
    2. ret numBufs of XDM2_BufDesc to 0, and inputID of IVIDDEC3_InArgs NULL, call XDM_FLUSH to control
    3. repeatedly to call VIDDEC3_process to get all the rest cached output buffers

    My application needs to find one free output buffer every time, than call VIDDEC3_process.
    can i call VIDDEC3_process once to got all the output buffer?
  • Hi Gao,
    First three steps you mentioned here is for decode and playback till EOS.

    I didn't understand your case. Is your application running out of buffers? After decode_create() and GetBUFINFO call, if application allocates the displaybuffers as suggested , there won't be issue with buffer drain.

    Can you please give few details ?

    Ram
  • Hi ram
    Take decoding and playback till EOS as example.
    When input buffer encounters EOS, Setting numBufs of XDM2_BufDesc to 0 and inputID of IVIDDEC3_InArgs NULL, then call XDM_FLUSH once and call VIDDEC3_process repeatedly to drain all the output buffers.

    The question is I should find one free output buffer and call VIDDEC3_process each time, which is complex for application.
    Whether calling VIDDEC3_process once then get all the output buffers once is OK? but it seems not work
  • HI Gao,
    Decoder can give only one output buffer though outArgs->outputID[0] but can release maximum 16 reference buffers locked via freeBufID[].
    For this reason, after XDM_FLUSH, VIDDEC3_process will have to called multiple times to get the display Buffers in display order.

    Ram
  • Hi Ram,
    I have another problem.

    Application sometimes gets DCE_EIPC_CALL_FAIL error code from decoder, but it does not affect decoding procedure.
    I can not figure out what's the meaming of that error code? How can i fix the error.

    =============
    libdce_linux.c:115: dce_buf_lock Error: ERROR: Failed eError == DCE_EOK error val -5MmRpc_use: Error: unable to declare buffer use
    ==============
  • Hi Gao,

    You will observe this error 

    dce_buf_lock Error: ERROR: Failed eError == DCE_EOK error val -5MmRpc_use: Error: unable to declare buffer use

    when a buffer which is not released yet using dce_buf_unlock() and application is trying to submit the same buffer with dce_buf_lock() call.

    Is it reproduced consistently for a specific stream at a specific frame or is it random?

    Ram

  • It is not random and it's always occur at specific frame if format change happened in certain stream.
  • Hi Gao,
    I didn't understand what is meant by format change. Does it mean changing from h264 to mpeg4 etc?
    When this is being done is FLUSH applied and unlocking all freeBufID{} buffers happening with dce_buf_unlock().

    Is there a way to reproduce it easily with existing viddec3test or some know applications?

    Ram
  • Hi Ram,
    thank you for your patience, now my application is ok with 264 stream format.
    But, i have another question with mpeg4 format. I want to parse the stream header to get the width and height.
    Refering to appendix Dof MPEG4 decoder user guide, Parsing the header from mpeg4 stream seems not work well, whose procedure is the same as 264 stream.
    calling VIDDEC3_process and return -1 error, and extendedError is XDM_UNSUPPORTEDPARAM. I cannot find the root cause.
    The stream header containing VOS + VO + VOL +VOP is below,
    11-13 21:09:04.698 17839 17847 D hexDump: 0000: 00, 00, 01, b0, f5, 00, 00, 01, b5, 09, 00, 00, 01, 00, 00, 00,
    11-13 21:09:04.698 17839 17847 D hexDump: 0010: 01, 20, 00, 84, 5d, 4c, 28, a0, 21, e0, a3, 1f, 00, 00, 01, b6
    Is the stream is right or not?
  • Hello,

    Please create a new topic for a new issue/question.

    BR
    Margarita