From 921816400bf3ad65f8978a50569a7d87ef05c806 Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 16 Nov 2015 08:22:14 -0300 Subject: [PATCH] baseparse: simplify code a bit Avoid repeated checks for testing if a buffer is a header --- libs/gst/base/gstbaseparse.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index f8f4380010..f83c86d835 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -980,19 +980,21 @@ static GstFlowReturn gst_base_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame) { GstBuffer *buffer = frame->buffer; - gboolean is_header = GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER); - if (!GST_BUFFER_PTS_IS_VALID (buffer) && !is_header && - GST_CLOCK_TIME_IS_VALID (parse->priv->next_pts)) { - GST_BUFFER_PTS (buffer) = parse->priv->next_pts; - } - if (!GST_BUFFER_DTS_IS_VALID (buffer) && !is_header && - GST_CLOCK_TIME_IS_VALID (parse->priv->next_dts)) { - GST_BUFFER_DTS (buffer) = parse->priv->next_dts; - } - if (!GST_BUFFER_DURATION_IS_VALID (buffer) && !is_header && - GST_CLOCK_TIME_IS_VALID (parse->priv->frame_duration)) { - GST_BUFFER_DURATION (buffer) = parse->priv->frame_duration; + /* Avoid updating timestamps of header buffers */ + if (!GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_HEADER)) { + if (!GST_BUFFER_PTS_IS_VALID (buffer) && + GST_CLOCK_TIME_IS_VALID (parse->priv->next_pts)) { + GST_BUFFER_PTS (buffer) = parse->priv->next_pts; + } + if (!GST_BUFFER_DTS_IS_VALID (buffer) && + GST_CLOCK_TIME_IS_VALID (parse->priv->next_dts)) { + GST_BUFFER_DTS (buffer) = parse->priv->next_dts; + } + if (!GST_BUFFER_DURATION_IS_VALID (buffer) && + GST_CLOCK_TIME_IS_VALID (parse->priv->frame_duration)) { + GST_BUFFER_DURATION (buffer) = parse->priv->frame_duration; + } } return GST_FLOW_OK; }