decoder: h264: simplify and optimize reference frame store updates.
Simplify and optimize the update process of the reference frame store.
Use less iterations to look up existing objects. Use a cache to store
the free'd slots.
Prerequisite: the reference_objects[] array was previously arranged in
a way that the element at index i is exactly the object_surface that
corresponds to the VA surface identified by the VAPictureH264.picture_id
located at index i in the ReferenceFrames[] array.
Theory of operations:
1. Obsolete entries are removed first, i.e. entries in the internal DPB
that no longer have a match in the supplied ReferenceFrames[] array.
That obsolete entry index is stored in a local cache: free_slots[].
2. This cache is completed with entries considered as "invalid" or "not
present", sequentially while traversing the frame store for obsolete
entries. At the end of this removal process, the free_slots[] array
represents all possible indices in there that could be re-used for
new reference frames to track.
3. The list of ReferenceFrames[] objects is traversed for new entries
that are not already in the frame store. If an entry needs to be
added, it is placed at the index obtained from the next free_slots[]
element. There is no need to traverse the frame store array again,
the next available slot can be known from that free_slots[] cache.
v2: dropped the superfluous "found" variable [Yakui]
v3: renamed "free_slots" array to "free_refs", which now holds
GenFrameStore entries
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
(cherry picked from commit
70ecad1264255123df99b472891e8ee90399013c)