xbmc/xbmc — pull request #521 by CrystalP (2011-11-03 03:10:47+00:00)
Title: Fix video corruption for hardware decoding of H264 streams with cropping parameters

See the issue in ticket #11499 - video corruption for BBC H264 streams.

The clips are encoded with extra lines and cropping parameters. The surfaces allocated for hardware decoding do not take the extra lines into account, which results in artefacts. The solution is to recover the proper size and use it to allocate the surfaces. The vdpau/Ion combination requires the exact size and not simply a bumped size aligned to 16 or 32.

This PR make a few members of ffmpeg's H264Context accessible in a safe manner. To avoid calculating in XBMC the size from the raw H264 fields, two new members are added to H264Context to contain the calculation result.
The DXVA patch uses the information exported by ffmpeg for the initial surface allocation and monitors any size change in the stream.

I'm not sure the optimization in the last commit is safe: is it possible that avctx->codec is not allocated when we Open() or is it possible that avctx->codec changes while we're playing a stream?

I'll be happy to take a vdpau and vaapi patch so that all platforms are merged at the same time.

The cropping for display will be the subject of another PR.