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

Also fixes #824

gst/videoparsers/gsth265parse.c
gst/videoparsers/gsth265parse.h

index 775cd24..edccb3f 100644 (file)
@@ -184,6 +184,9 @@ gst_h265_parse_reset_frame (GstH265Parse * h265parse)
   h265parse->sei_pos = -1;
   h265parse->keyframe = FALSE;
   h265parse->header = FALSE;
+  h265parse->have_vps_in_frame = FALSE;
+  h265parse->have_sps_in_frame = FALSE;
+  h265parse->have_pps_in_frame = FALSE;
   gst_adapter_clear (h265parse->frame_out);
 }
 
@@ -551,6 +554,7 @@ gst_h265_parse_process_nal (GstH265Parse * h265parse, GstH265NalUnit * nalu)
       GST_DEBUG_OBJECT (h265parse, "triggering src caps check");
       h265parse->update_caps = TRUE;
       h265parse->have_vps = TRUE;
+      h265parse->have_vps_in_frame = TRUE;
       if (h265parse->push_codec && h265parse->have_pps) {
         /* VPS/SPS/PPS found in stream before the first pre_push_frame, no need
          * to forcibly push at start */
@@ -580,6 +584,7 @@ gst_h265_parse_process_nal (GstH265Parse * h265parse, GstH265NalUnit * nalu)
       GST_DEBUG_OBJECT (h265parse, "triggering src caps check");
       h265parse->update_caps = TRUE;
       h265parse->have_sps = TRUE;
+      h265parse->have_sps_in_frame = TRUE;
       if (h265parse->push_codec && h265parse->have_pps) {
         /* SPS and PPS found in stream before the first pre_push_frame, no need
          * to forcibly push at start */
@@ -615,6 +620,7 @@ gst_h265_parse_process_nal (GstH265Parse * h265parse, GstH265NalUnit * nalu)
         h265parse->update_caps = TRUE;
       }
       h265parse->have_pps = TRUE;
+      h265parse->have_pps_in_frame = TRUE;
       if (h265parse->push_codec && h265parse->have_sps) {
         /* SPS and PPS found in stream before the first pre_push_frame, no need
          * to forcibly push at start */
@@ -1949,6 +1955,12 @@ gst_h265_parse_handle_vps_sps_pps_nals (GstH265Parse * h265parse,
   gboolean send_done = FALSE;
   GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer);
 
+  if (h265parse->have_vps_in_frame && h265parse->have_sps_in_frame
+      && h265parse->have_pps_in_frame) {
+    GST_DEBUG_OBJECT (h265parse, "VPS/SPS/PPS exist in frame, will not insert");
+    return TRUE;
+  }
+
   if (h265parse->align == GST_H265_PARSE_ALIGN_NAL) {
     /* send separate config NAL buffers */
     GST_DEBUG_OBJECT (h265parse, "- sending VPS/SPS/PPS");
index eb82f6f..d27aac3 100644 (file)
@@ -76,6 +76,11 @@ struct _GstH265Parse
   gboolean have_sps;
   gboolean have_pps;
 
+  /* per frame vps/sps/pps check for periodic push codec decision */
+  gboolean have_vps_in_frame;
+  gboolean have_sps_in_frame;
+  gboolean have_pps_in_frame;
+
   /* collected SPS and PPS NALUs */
   GstBuffer *vps_nals[GST_H265_MAX_VPS_COUNT];
   GstBuffer *sps_nals[GST_H265_MAX_SPS_COUNT];