videodecoder: Reset last_timestamp_out on new segment

Reset last_timestamp_out when applying the output segment
change, to avoid decoder confusion over new timestamp timelines when
a seamless segment change happens.

Move some locks/unlocks to later when they're actually needed.

https://bugzilla.gnome.org/show_bug.cgi?id=734617
This commit is contained in:
Jan Schmidt 2014-08-08 20:01:20 +10:00
parent 14d79a3a47
commit 946dc6b09f
2 changed files with 8 additions and 7 deletions

View file

@ -892,19 +892,18 @@ gst_video_decoder_push_event (GstVideoDecoder * decoder, GstEvent * event)
{ {
GstSegment segment; GstSegment segment;
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
gst_event_copy_segment (event, &segment); gst_event_copy_segment (event, &segment);
GST_DEBUG_OBJECT (decoder, "segment %" GST_SEGMENT_FORMAT, &segment); GST_DEBUG_OBJECT (decoder, "segment %" GST_SEGMENT_FORMAT, &segment);
if (segment.format != GST_FORMAT_TIME) { if (segment.format != GST_FORMAT_TIME) {
GST_DEBUG_OBJECT (decoder, "received non TIME newsegment"); GST_DEBUG_OBJECT (decoder, "received non TIME newsegment");
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
break; break;
} }
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
decoder->output_segment = segment; decoder->output_segment = segment;
decoder->priv->last_timestamp_out = GST_CLOCK_TIME_NONE;
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder); GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
break; break;
} }
@ -1122,8 +1121,6 @@ gst_video_decoder_sink_event_default (GstVideoDecoder * decoder,
{ {
GstSegment segment; GstSegment segment;
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
gst_event_copy_segment (event, &segment); gst_event_copy_segment (event, &segment);
if (segment.format == GST_FORMAT_TIME) { if (segment.format == GST_FORMAT_TIME) {
@ -1153,11 +1150,12 @@ gst_video_decoder_sink_event_default (GstVideoDecoder * decoder,
gst_event_unref (event); gst_event_unref (event);
event = gst_event_new_segment (&segment); event = gst_event_new_segment (&segment);
} else { } else {
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
goto newseg_wrong_format; goto newseg_wrong_format;
} }
} }
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
priv->base_timestamp = GST_CLOCK_TIME_NONE; priv->base_timestamp = GST_CLOCK_TIME_NONE;
priv->base_picture_number = 0; priv->base_picture_number = 0;
@ -1600,9 +1598,11 @@ gst_video_decoder_sink_query_default (GstVideoDecoder * decoder,
gint64 src_val, dest_val; gint64 src_val, dest_val;
gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val); gst_query_parse_convert (query, &src_fmt, &src_val, &dest_fmt, &dest_val);
GST_VIDEO_DECODER_STREAM_LOCK (decoder);
res = res =
gst_video_encoded_video_convert (priv->bytes_out, priv->time, src_fmt, gst_video_encoded_video_convert (priv->bytes_out, priv->time, src_fmt,
src_val, &dest_fmt, &dest_val); src_val, &dest_fmt, &dest_val);
GST_VIDEO_DECODER_STREAM_UNLOCK (decoder);
if (!res) if (!res)
goto error; goto error;
gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val); gst_query_set_convert (query, src_fmt, src_val, dest_fmt, dest_val);

View file

@ -214,7 +214,8 @@ struct _GstVideoDecoder
* @handle_frame: Provides input data frame to subclass. * @handle_frame: Provides input data frame to subclass.
* @finish: Optional. * @finish: Optional.
* Called to request subclass to dispatch any pending remaining * Called to request subclass to dispatch any pending remaining
* data (e.g. at EOS). * data (e.g. at EOS or segment end). Sub-classes should be prepared
* to handle new data afterward, or seamless segment processing will break.
* @sink_event: Optional. * @sink_event: Optional.
* Event handler on the sink pad. This function should return * Event handler on the sink pad. This function should return
* TRUE if the event was handled and should be discarded * TRUE if the event was handled and should be discarded