h264: add flag to compile with strict DPB ordering mode.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 16 Oct 2012 14:52:04 +0000 (16:52 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 16 Nov 2012 15:50:30 +0000 (16:50 +0100)
Allow build with strict DPB ordering mode whereby evicted entries
are replaced by the next entries, in order instead of optimizing
it away with the last entry in the DPB.

This is only useful for debugging purpose, against a reference SW
decoder for example.

gst-libs/gst/vaapi/gstvaapidecoder_h264.c

index 9dfd38d..8785923 100644 (file)
@@ -37,6 +37,9 @@
 #define DEBUG 1
 #include "gstvaapidebug.h"
 
+/* Defined to 1 if strict ordering of DPB is needed. Only useful for debug */
+#define USE_STRICT_DPB_ORDERING 0
+
 typedef struct _GstVaapiPictureH264             GstVaapiPictureH264;
 typedef struct _GstVaapiPictureH264Class        GstVaapiPictureH264Class;
 typedef struct _GstVaapiSliceH264               GstVaapiSliceH264;
@@ -369,9 +372,13 @@ static void
 dpb_remove_index(GstVaapiDecoderH264 *decoder, guint index)
 {
     GstVaapiDecoderH264Private * const priv = decoder->priv;
-    guint num_pictures = --priv->dpb_count;
+    guint i, num_pictures = --priv->dpb_count;
 
-    if (index != num_pictures)
+    if (USE_STRICT_DPB_ORDERING) {
+        for (i = index; i < num_pictures; i++)
+            gst_vaapi_picture_replace(&priv->dpb[i], priv->dpb[i + 1]);
+    }
+    else if (index != num_pictures)
         gst_vaapi_picture_replace(&priv->dpb[index], priv->dpb[num_pictures]);
     gst_vaapi_picture_replace(&priv->dpb[num_pictures], NULL);
 }