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.
Hi,
I am trying to decode an H.264 byte stream, previously encoded by the official encoder, in order to re-encode it using a different bitrate. Actually I was trying to re-encode a stream from a different encoder, but since it did not work, I tried to use the same native H.264 encoder that we use all the time, just to check that the decoder is working properly and that I know how to use it.
Unfortunately, it is not working for me. The decoder initializes fine and after not long it identifies the video resolution correctly. It also sends a few images, which I then feed directly to the encoder with the same parameters, just a different bitrate. However, the images are not recognizable. I should probably assume at this stage that there is some buffer mismatch, perhaps the Y and UV, width and pitch are not passed correctly. But the problems are seen in the log, where almost every call to VIDDEC2_process ends with return code of -1 and some extended error that I get from the status. The common errors are 0x200 (applied concealment) , 0x600 (+insufficient data), etc. The number of consumed bytes is only sometimes related to the length, sometimes more, sometimes less.
HD-Decoding causes the VIDDEC2_process to crash, so I am only trying VGA at this time.
The video decoder is initialized with the following parameters:
IVIDDEC2_Params &vdpParams = m_hvdpParams.viddecParams;
vdpParams.size = sizeof( m_hvdpParams );
vdpParams.maxHeight = MAX_HEIGHT;
vdpParams.maxWidth = MAX_WIDTH;
vdpParams.maxFrameRate = MAX_FRATE * 1000;
vdpParams.maxBitRate = MAX_BITRATE;
vdpParams.dataEndianness = XDM_BYTE;
vdpParams.forceChromaFormat = XDM_YUV_420SP;
m_hvdpParams.displayDelay = 0;
m_hvdpParams.hdvicpHandle = NULL;
m_hvdpParams.disableHDVICPeveryFrame = 0;
m_hvdpParams.levelLimit = LEVEL_4_2;
m_hvdpParams.frame_closedloop_flag = 0;
m_hvdpParams.inputDataMode = IH264VDEC_TI_ENTIREFRAME;
m_hvdpParams.sliceFormat = IH264VDEC_TI_BYTESTREAM;
IVIDDEC2_DynamicParams &vddpDynamicParams = m_hvddDynamicParams.viddecDynamicParams;
vddpDynamicParams.size = sizeof( m_hvddDynamicParams );
vddpDynamicParams.decodeHeader = XDM_DECODE_AU;
vddpDynamicParams.displayWidth = 0;
vddpDynamicParams.frameSkipMode = IVIDEO_NO_SKIP;
vddpDynamicParams.frameOrder = IVIDDEC2_DISPLAY_ORDER;
vddpDynamicParams.newFrameFlag = XDAS_FALSE;
vddpDynamicParams.mbDataFlag = XDAS_FALSE;
m_hvddDynamicParams.getDataFxn = NULL;
m_hvddDynamicParams.dataSyncHandle = NULL;
m_hvddDynamicParams.resetHDVICPeveryFrame = 1;
m_hVideoDecoder = VIDDEC2_create( m_hEngine, "h264dec", &vdpParams );
I have tried to parse the NAL units myself and feed them separately.
I have also tried to just give it a buffer with any NAL units inside and try to progress according to the number of bytes consumed.
Can you tell me what I am doing wrong or what is the right way to use the H.264 decoder?
Thanks,
Gadi
Hi Gadi,
Gadi Bergman said:The decoder initializes fine and after not long it identifies the video resolution correctly. It also sends a few images, which I then feed directly to the encoder with the same parameters, just a different bitrate. However, the images are not recognizable
Could you check by dumping the decoder output before feeding directly to the encoder. Since decoder is throwing insufficient data error, Stream might be corrupted.May be this decoder dump should give you some clue. You can also use the sample test application in the package for this experiment @(dm365_h264dec_02_00_00_13_production/dm365_h264dec_02_00_00_13_production/packages/ti/sdo/codecs/h264dec/apps/client/).
Did you try freshly encoding a stream instead of using the existing one?
Hi Gadi,
Can you please share the bitstream(elementary .264 file) which you using?
Dear Gadi,
Thanks for sharing the stream.
Here i see the stream starts with P-frame which has SPS&PPS info. But the I-frame doesn't have any any SPS&PPS information.
This is not expected behaviour!. Can you please check why is it encoded so?
I-frame should have SPS&PPS information.
Dear Prashanth,
Thank you for finding this bug in our system involving the order of SPS and PPS with relation to the I-Frame.
Here is a new file with hopefully a fix to this problem: H.264 Example File
However, this does not change the fact that I still cannot decode this file without tons of errors and see anything recognizable after re-encoding it.
Are you capable of decoding it with the TI DM36x H.264 Decoder? If so, can you tell me what I should do in terms of decoder parameters, NAL unit parsing, how to supply the input buffers to the decoder, etc?