codecs: h264picture: Add more trace log
authorSeungha Yang <seungha@centricular.com>
Thu, 5 Nov 2020 09:27:11 +0000 (18:27 +0900)
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 5 Nov 2020 14:56:28 +0000 (14:56 +0000)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1768>

gst-libs/gst/codecs/gsth264decoder.c
gst-libs/gst/codecs/gsth264picture.c

index a93c059..20e6cea 100644 (file)
@@ -611,14 +611,32 @@ gst_h264_decoder_handle_frame_num_gap (GstH264Decoder * self, gint frame_num)
     return FALSE;
   }
 
+  if (priv->prev_ref_frame_num == frame_num) {
+    GST_TRACE_OBJECT (self,
+        "frame_num == PrevRefFrameNum (%d), not a gap", frame_num);
+    return TRUE;
+  }
+
+  if (((priv->prev_ref_frame_num + 1) % priv->max_frame_num) == frame_num) {
+    GST_TRACE_OBJECT (self,
+        "frame_num ==  (PrevRefFrameNum + 1) %% MaxFrameNum (%d), not a gap",
+        frame_num);
+    return TRUE;
+  }
+
+  if (gst_h264_dpb_get_size (priv->dpb) == 0) {
+    GST_TRACE_OBJECT (self, "DPB is empty, not a gap");
+    return TRUE;
+  }
+
   if (!sps->gaps_in_frame_num_value_allowed_flag) {
     /* This is likely the case where some frames were dropped.
      * then we need to keep decoding without error out */
     GST_WARNING_OBJECT (self, "Invalid frame num %d", frame_num);
   }
 
-  GST_DEBUG_OBJECT (self, "Handling frame num gap %d -> %d",
-      priv->prev_ref_frame_num, frame_num);
+  GST_DEBUG_OBJECT (self, "Handling frame num gap %d -> %d (MaxFrameNum: %d)",
+      priv->prev_ref_frame_num, frame_num, priv->max_frame_num);
 
   /* 7.4.3/7-23 */
   unused_short_term_frame_num =
@@ -708,13 +726,8 @@ gst_h264_decoder_start_current_picture (GstH264Decoder * self)
   if (priv->current_slice.nalu.idr_pic_flag)
     priv->prev_ref_frame_num = 0;
 
-  /* 7.4.3 */
-  if (frame_num != priv->prev_ref_frame_num &&
-      frame_num != (priv->prev_ref_frame_num + 1) % priv->max_frame_num &&
-      gst_h264_dpb_get_size (priv->dpb) > 0) {
-    if (!gst_h264_decoder_handle_frame_num_gap (self, frame_num))
-      return FALSE;
-  }
+  if (!gst_h264_decoder_handle_frame_num_gap (self, frame_num))
+    return FALSE;
 
   if (!gst_h264_decoder_init_current_picture (self))
     return FALSE;
index c7b2933..79a3359 100644 (file)
@@ -726,6 +726,8 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
       other = gst_h264_dpb_get_short_ref_by_pic_num (dpb, pic_num_x);
       if (other) {
         other->ref = FALSE;
+        GST_TRACE ("MMCO-1: unmark short-term ref picture %p, (poc %d)",
+            other, other->pic_order_cnt);
       } else {
         GST_WARNING ("Invalid picNumX %d for operation type 1", pic_num_x);
         return FALSE;
@@ -738,6 +740,8 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
           ref_pic_marking->long_term_pic_num);
       if (other) {
         other->ref = FALSE;
+        GST_TRACE ("MMCO-2: unmark long-term ref picture %p, (poc %d)",
+            other, other->pic_order_cnt);
       } else {
         GST_WARNING ("Invalid LongTermPicNum %d for operation type 2",
             ref_pic_marking->long_term_pic_num);
@@ -754,10 +758,10 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
 
         if (other->ref && other->long_term && other->long_term_frame_idx ==
             ref_pic_marking->long_term_frame_idx) {
-          GST_LOG ("Unmark old long-term ref pic %p (poc %d)",
-              other, other->pic_order_cnt);
           other->ref = FALSE;
           other->long_term = FALSE;
+          GST_TRACE ("MMCO-3: unmark old long-term ref pic %p (poc %d)",
+              other, other->pic_order_cnt);
           break;
         }
       }
@@ -765,8 +769,10 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
       pic_num_x = get_picNumX (picture, ref_pic_marking);
       other = gst_h264_dpb_get_short_ref_by_pic_num (dpb, pic_num_x);
       if (other) {
-        other->long_term = TRUE;;
+        other->long_term = TRUE;
         other->long_term_frame_idx = ref_pic_marking->long_term_frame_idx;
+        GST_TRACE ("MMCO-3: mark long-term ref pic %p, index %d, (poc %d)",
+            other, other->long_term_frame_idx, other->pic_order_cnt);
       } else {
         GST_WARNING ("Invalid picNumX %d for operation type 3", pic_num_x);
         return FALSE;
@@ -779,6 +785,8 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
       max_long_term_frame_idx =
           ref_pic_marking->max_long_term_frame_idx_plus1 - 1;
 
+      GST_TRACE ("MMCO-4: max_long_term_frame_idx %d", max_long_term_frame_idx);
+
       for (i = 0; i < dpb->pic_list->len; i++) {
         other = g_array_index (dpb->pic_list, GstH264Picture *, i);
 
@@ -786,6 +794,8 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
             other->long_term_frame_idx > max_long_term_frame_idx) {
           other->ref = FALSE;
           other->long_term = FALSE;
+          GST_TRACE ("MMCO-4: unmark long-term ref pic %p, index %d, (poc %d)",
+              other, other->long_term_frame_idx, other->pic_order_cnt);
         }
       }
       break;
@@ -809,7 +819,7 @@ gst_h264_dpb_perform_memory_management_control_operation (GstH264Dpb * dpb,
 
         if (other->ref && other->long_term && other->long_term_frame_idx ==
             ref_pic_marking->long_term_frame_idx) {
-          GST_LOG ("Unmark old long-term ref pic %p (poc %d)",
+          GST_TRACE ("MMCO-6: unmark old long-term ref pic %p (poc %d)",
               other, other->pic_order_cnt);
           other->ref = FALSE;
           other->long_term = FALSE;