Hi All,
I am trying to decode a live IP Camera stream using the Vdec2 H.264 decoder on the DM368, but I am having trouble with buffers.
I basically followed the encodedecode example application provided with the DVSDK.
What I am seeing is the decoder is asking for 10 buffers for one camera (720P), but a different camera (1080P) it's asking for 17 buffers.
Now, as I understand, from the documentation:
The maximum number of buffers
that is required by the codec. The
maximum number of buffers can be
IVIDDEC2_MAX_IO_BUFFERS .
In this decoder implementation it is
always set to 17, if levelLimit
field of IVIDDEC2_Params is not
set. However, in case levelLimit
is set to an appropriate valid value,
maxNumDisplayBufs is derived
based on levelLimit,
maxWidth and maxHeight
fields of IVIDDEC2_Params.
Code:
params.maxWidth = Dmai_roundUp(IWIDTH_MAX, BUF_LINE_ALIGN); params.maxHeight = Dmai_roundUp(IHEIGHT_MAX, BUF_HEIGHT_ALIGN); params.forceChromaFormat = XDM_YUV_420SP; params.size = sizeof(IH264VDEC_Params); extnParams.viddecParams = params; extnParams.displayDelay = 0; extnParams.levelLimit = LEVEL_4_2; extnParams.disableHDVICPeveryFrame = 0; extnParams.inputDataMode = IH264VDEC_TI_ENTIREFRAME; extnParams.sliceFormat = IH264VDEC_TI_BYTESTREAM; extnParams.frame_closedloop_flag = 0; dynParams.displayWidth = params.maxWidth; // line-length is not correctly interpreted by codec, should set the displayWidth parameter. dynParams.frameOrder = IVIDDEC2_DECODE_ORDER; // try this dynParams.frameSkipMode = IVIDEO_NO_SKIP; dynParams.decodeHeader = XDM_DECODE_AU; // Create Decoder (XDM 1.2) hVd2 = Vdec2_create(argsp->engine, "h264dec", (VIDDEC2_Params*)&extnParams, &dynParams); if (hVd2 == NULL) { error("[DEC] Failed (h264dec)"); cleanup(THREAD_FAILURE); } debug("[DEC] Number of codec buffers requested by Decoder [at creation]: %d - [level=%d, maxWidth=%d, maxHeight=%d]", Vdec2_getMinOutBufs(hVd2), extnParams.levelLimit, params.maxWidth, params.maxHeight);
The output from the application is:
[DEC] Number of codec buffers requested by Decoder [at creation]: 17 - [level=42, maxWidth=1920, maxHeight=1088]
I get the same value when calling Vdec2_getMinOutBufs(hVd2) after decoding the first frame.
Analysing the stream shows the profile value to be: 4d002a -- which translates to Main Profile (77), no constraints, Level 4.2.
Why is it asking for 17 buffers? How is value this calculated?
Thanks,
Martin