diff options
-rw-r--r-- | gst/videoparsers/gsth264parse.c | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/gst/videoparsers/gsth264parse.c b/gst/videoparsers/gsth264parse.c index f60f175a0..f7a56e2c3 100644 --- a/gst/videoparsers/gsth264parse.c +++ b/gst/videoparsers/gsth264parse.c @@ -195,8 +195,10 @@ gst_h264_parse_reset_frame (GstH264Parse * h264parse) } static void -gst_h264_parse_reset (GstH264Parse * h264parse) +gst_h264_parse_reset_stream_info (GstH264Parse * h264parse) { + gint i; + h264parse->width = 0; h264parse->height = 0; h264parse->fps_num = 0; @@ -205,19 +207,32 @@ gst_h264_parse_reset (GstH264Parse * h264parse) h264parse->upstream_par_d = -1; h264parse->parsed_par_n = 0; h264parse->parsed_par_d = 0; - gst_buffer_replace (&h264parse->codec_data, NULL); - gst_buffer_replace (&h264parse->codec_data_in, NULL); - h264parse->nal_length_size = 4; - h264parse->packetized = FALSE; - h264parse->transform = FALSE; + h264parse->have_pps = FALSE; + h264parse->have_sps = FALSE; h264parse->align = GST_H264_PARSE_ALIGN_NONE; h264parse->format = GST_H264_PARSE_FORMAT_NONE; - h264parse->last_report = GST_CLOCK_TIME_NONE; + h264parse->transform = FALSE; + h264parse->nal_length_size = 4; + h264parse->packetized = FALSE; h264parse->push_codec = FALSE; - h264parse->have_pps = FALSE; - h264parse->have_sps = FALSE; + + gst_buffer_replace (&h264parse->codec_data, NULL); + gst_buffer_replace (&h264parse->codec_data_in, NULL); + + gst_h264_parse_reset_frame (h264parse); + + for (i = 0; i < GST_H264_MAX_SPS_COUNT; i++) + gst_buffer_replace (&h264parse->sps_nals[i], NULL); + for (i = 0; i < GST_H264_MAX_PPS_COUNT; i++) + gst_buffer_replace (&h264parse->pps_nals[i], NULL); +} + +static void +gst_h264_parse_reset (GstH264Parse * h264parse) +{ + h264parse->last_report = GST_CLOCK_TIME_NONE; h264parse->dts = GST_CLOCK_TIME_NONE; h264parse->ts_trn_nb = GST_CLOCK_TIME_NONE; @@ -230,7 +245,7 @@ gst_h264_parse_reset (GstH264Parse * h264parse) h264parse->discont = FALSE; - gst_h264_parse_reset_frame (h264parse); + gst_h264_parse_reset_stream_info (h264parse); } static gboolean @@ -257,17 +272,11 @@ gst_h264_parse_start (GstBaseParse * parse) static gboolean gst_h264_parse_stop (GstBaseParse * parse) { - guint i; GstH264Parse *h264parse = GST_H264_PARSE (parse); GST_DEBUG_OBJECT (parse, "stop"); gst_h264_parse_reset (h264parse); - for (i = 0; i < GST_H264_MAX_SPS_COUNT; i++) - gst_buffer_replace (&h264parse->sps_nals[i], NULL); - for (i = 0; i < GST_H264_MAX_PPS_COUNT; i++) - gst_buffer_replace (&h264parse->pps_nals[i], NULL); - gst_h264_nal_parser_free (h264parse->nalparser); return TRUE; @@ -2079,12 +2088,20 @@ gst_h264_parse_set_caps (GstBaseParse * parse, GstCaps * caps) guint format, align, off; GstH264NalUnit nalu; GstH264ParserResult parseres; + GstCaps *old_caps; h264parse = GST_H264_PARSE (parse); /* reset */ h264parse->push_codec = FALSE; + old_caps = gst_pad_get_current_caps (GST_BASE_PARSE_SINK_PAD (parse)); + if (old_caps) { + if (!gst_caps_is_equal (old_caps, caps)) + gst_h264_parse_reset_stream_info (h264parse); + gst_caps_unref (old_caps); + } + str = gst_caps_get_structure (caps, 0); /* accept upstream info if provided */ |