From 4f7fe897b9be77c983f935538d30a5c90cecc947 Mon Sep 17 00:00:00 2001 From: Seungha Yang Date: Fri, 23 Nov 2018 11:28:44 +0900 Subject: [PATCH] h264parse: Don't duplicate SPS/PPS per config-interval if exists Don't need to manually insert SPS/PPS since inband data could be useable. Fixes #824 --- gst/videoparsers/gsth264parse.c | 9 +++++++++ gst/videoparsers/gsth264parse.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index 903d204ade..f308d174df 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -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"); diff --git a/gst/videoparsers/gsth264parse.h b/gst/videoparsers/gsth264parse.h index 137c2cdc7a..61a996d17d 100644 --- a/gst/videoparsers/gsth264parse.h +++ b/gst/videoparsers/gsth264parse.h @@ -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 */