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.

Bug in H.264 encoder

Hi,

I am using latest H264 BP Encoder, Version 01.24.00.01 for C6678.

The attached demo.c shows illegal H.264 encoder behavior.

Output is:

[C66xx_0] Demo
[C66xx_0] algNumAlloc=92069e00 nMax=9
[C66xx_0] algAlloc=92059340 n=13
[C66xx_0] n > nMax

But algAlloc() documentation says:

If successful, this function returns a positive non-zero value indicating the number of records initialized. This function can never initialize more memory records than the number returned by algNumAlloc().

So n should never be greater then nMax.

Please advice.

  • So can anyone explain this behaviour of H.264 codec? Why algNumAlloc returns 9, but algAlloc initializes 13 records?

  • Hi Andriy,

    Thanks for pointing this out. H264BP encoder on C6678 is a multi-core encoder, with a single codec library supporting both single-core and multi-core use cases. For the single-core use case, a total of 13 buffers need to be allocated, as returned by algAlloc() function. For the multi-core use case, the first 9 buffers are local to the participating cores (9 is returned by algAlloc for buffer allocation ), while the last 4 buffers are shared by multiple cores and will be allocated through a multi-core API (e.g., H264VENC_Map_Shmem in the unit test application packaged in H264BP encoder).

    So, the number of buffers returned from algAlloc() is correct. Internally, "encoderParams.mcVidEncParams->ncores" is used to decide if it is multi-core or single-core use case, and then returning the corresponding number of buffers which will be allocated by individual cores.

    On the other hand, algNumAlloc() does not have information about "encoderParams.mcVidEncParams->ncores". Currently it simply returns the number of local buffers for the multi-core use case, which is 9 as you observed. As in the H264BP encoder unit test application, since the buffers will be allocated according to the return value of algAlloc() instead of that of algNumAlloc(), functionality of the encoder will not be affected.

    Thanks,

    Hongmei

  • But still official algAlloc documentation says:

    If successful, this function returns a positive non-zero value indicating the number of records initialized. This function can never initialize more memory records than the number returned by algNumAlloc().

    You can see that H.264 encoder implementation breaks this documented rule. I believe if algNumAlloc doesn't have ncores information it should return 13, but not 9. Because algNumAlloc should return maximal possible number of records that can be initialized while algAlloc call. In this case it returns minimal number of records...

  • Hi Andiry,

    Agree that algNumAlloc should not return 9. This is a leftover when we had two codec libs, one for single core and another one for multi-core. Thanks for pointing this out.

    Regards,

    Hongmei