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.

C66x H.264 decoder Max Width/Height Settings

The current H.264 decoder implementation has parameters for max width and max height, which caused serious limitations on our system.

First of all, these parameters are named as "maximum width" and "maximum height", but they actually do not mean that exactly.  It looks like the code does check maximum width, but does not check maximum height. The code checks maximum_width * maximum_height though. These make the parameters hard to handle.

Secondly, these parameters do not conform to standards. H.264 levels contain limits for maximum number of macro blocks, but not max width/height.  For instance, for level 2.0, the maximum number of macro blocks is 396, which is the number of macro blocks of a CIF picture; if max width/height is set to 704/576 which is way bigger than a CIF picture, we still cannot decode a picture that is 768*128, even though that is a very legitimate 2.0 picture.

Ideally, the decoder should not have these parameters at all. If some pre-allocated buffers are too small for pictures with weird dimensions, the decoder should release old buffers and allocate new ones. 

As suggested by CouthIT, we can do some work-around with the existing implementation:

For instance, for level 2.0, 

   (a) We can set max width to 1056 and max height to 96, so that number of MB's are 396, this will require 69 KB of L2SRAM.

    or

    (b) We can set max width to 1584 and max height to 64, so that number of MB's are 396, this will require 77 KB of L2SRAM .

This work-around would work for most cases, but still would have its limits, and would not handle all the cases of extreme dimensions, and it needs special handling for each profile/level on our system.

I hope this problem can be fixed soon.

 

Thanks,

Daniel

 

 

 

 

  • Daniel,

    I assume your application is a streaming application and not file2file. Usually, the image width and height information is exchanged during RTSP/SIP etc negotiation. Not sure what control stack is running in your scenario. 

    In case the w, h information cannot be found from negotiation protocol, one easy approach  could be that the SPS/PPS be decoded to find out the actual width/height, then close channel and re-open (i.e. recreate the codec) with actual w,h. The downside with this is that you'd lose the first GOP as there is no way to rewind a network stream. 

    Regards,

    Vivek

  • Hi Vivek,

    Yes, our application is a RTP streaming application. But no,  the width and height info is not part of SIP/SDP negotiation, and there is no way for us to know width/height beforehand.  H.264/RTP allows picture width and height to be changed in the middle of a stream. For example,  an application running on iPhone can change its WxH from AxB to BxA when screen orientation is changed.

    Decoding SPS/PPS first may be a good workaround. When parsing PPS, if it fails due to picture width/height changes, we can re-initialize the decoder, and re-decode the whole frame.  I will give that a try.

    Daniel

     

  • ok thanks for the details. Please try re-initializing the decoder and let us know if that works. The reason for suggesting it is that it is not trivial to do memory management if we don't know the worst case image width and height upfront. There is no MMU, garbage collection and it is difficult to handle memory fragmentation. 

  • Hi Daniel, please let us know if proposed workaround work ok in your system or if you have further questions.

    thank you,

    Paula

  • Hi Paula, 

    I haven't got chance to do that, but I am sure it will work. I was wondering if there was a better solution.

    Thank you for your support.

    Daniel