decoder: h264: allocate reference frames earlier, if needed.
Sometimes, a dummy frame comes from the codec layer and it is used
as a reference, per the comment in the existing code. Even though
this looks suspicious, keep this criterion but make sure to try
allocating the VA surface, if needed, earlier in the function that
sanity checks the parameters for decoding the current frame.
This makes it possible to fail at a much earlier time, and actually
make it possible to return a sensible error code to the upper layer.
Also fix the reference_objects[] array elements to be an exact 1:1
match for ReferenceFrames[] array elements, including possible but
unlikely holes in it. The former array holds object_surface structs
corresponding to the VA surfaces present in the ReferenceFrames[]
array and identified by VAPictureH264.picture_id.
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit
5a12ccda3f77d03b6ffa8249d607c03e4dc8161f)