Part Number:TMS320DM368
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