h264parse: Don't duplicate SPS/PPS per config-interval if exists
authorSeungha Yang <seungha.yang@navercorp.com>
Fri, 23 Nov 2018 02:28:44 +0000 (11:28 +0900)
committerNicolas Dufresne <nicolas@ndufresne.ca>
Fri, 30 Nov 2018 02:19:17 +0000 (02:19 +0000)
Don't need to manually insert SPS/PPS since inband data could be useable.

Fixes #824

gst/videoparsers/gsth264parse.c
gst/videoparsers/gsth264parse.h

index 903d204..f308d17 100644 (file)
@@ -196,6 +196,8 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse)
   h264parse->header = FALSE;
   h264parse->frame_start = FALSE;
   h264parse->aud_insert = TRUE;
+  h264parse->have_sps_in_frame = FALSE;
+  h264parse->have_pps_in_frame = FALSE;
   gst_adapter_clear (h264parse->frame_out);
 }
 
@@ -743,6 +745,7 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
       GST_DEBUG_OBJECT (h264parse, "triggering src caps check");
       h264parse->update_caps = TRUE;
       h264parse->have_sps = TRUE;
+      h264parse->have_sps_in_frame = TRUE;
       if (h264parse->push_codec && h264parse->have_pps) {
         /* SPS and PPS found in stream before the first pre_push_frame, no need
          * to forcibly push at start */
@@ -777,6 +780,7 @@ gst_h264_parse_process_nal (GstH264Parse * h264parse, GstH264NalUnit * nalu)
         h264parse->update_caps = TRUE;
       }
       h264parse->have_pps = TRUE;
+      h264parse->have_pps_in_frame = TRUE;
       if (h264parse->push_codec && h264parse->have_sps) {
         /* SPS and PPS found in stream before the first pre_push_frame, no need
          * to forcibly push at start */
@@ -2314,6 +2318,11 @@ gst_h264_parse_handle_sps_pps_nals (GstH264Parse * h264parse,
   gboolean send_done = FALSE;
   GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
+  if (h264parse->have_sps_in_frame && h264parse->have_pps_in_frame) {
+    GST_DEBUG_OBJECT (h264parse, "SPS/PPS exist in frame, will not insert");
+    return TRUE;
+  }
+
   if (h264parse->align == GST_H264_PARSE_ALIGN_NAL) {
     /* send separate config NAL buffers */
     GST_DEBUG_OBJECT (h264parse, "- sending SPS/PPS");
index 137c2cd..61a996d 100644 (file)
@@ -85,6 +85,10 @@ struct _GstH264Parse
   gboolean have_sps;
   gboolean have_pps;
 
+  /* per frame sps/pps check for periodic push codec decision */
+  gboolean have_sps_in_frame;
+  gboolean have_pps_in_frame;
+
   gboolean sent_codec_tag;
 
   /* collected SPS and PPS NALUs */