mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 10:11:08 +00:00
video{en,de}coder: Add new flush vfunc as a replacement for reset
This commit is contained in:
parent
9df036c216
commit
146bb1a153
4 changed files with 32 additions and 10 deletions
|
@ -864,13 +864,11 @@ gst_video_decoder_flush (GstVideoDecoder * dec, gboolean hard)
|
|||
klass->reset (dec, hard);
|
||||
}
|
||||
|
||||
/* FIXME make some more distinction between hard and soft,
|
||||
* but subclass may not be prepared for that */
|
||||
/* FIXME perhaps also clear pending frames ?,
|
||||
* but again, subclass may still come up with one of those */
|
||||
if (!hard) {
|
||||
/* TODO ? finish/drain some stuff */
|
||||
} else {
|
||||
if (klass->flush) {
|
||||
klass->flush (dec);
|
||||
}
|
||||
|
||||
if (hard) {
|
||||
gst_segment_init (&dec->input_segment, GST_FORMAT_UNDEFINED);
|
||||
gst_segment_init (&dec->output_segment, GST_FORMAT_UNDEFINED);
|
||||
gst_video_decoder_clear_queues (dec);
|
||||
|
|
|
@ -242,6 +242,9 @@ struct _GstVideoDecoder
|
|||
* Propose buffer allocation parameters for upstream elements.
|
||||
* Subclasses should chain up to the parent implementation to
|
||||
* invoke the default handler.
|
||||
* @flush: Optional.
|
||||
* Flush all remaining data from the decoder without
|
||||
* pushing it downstream. Since: 1.2
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @handle_frame needs to be overridden, and @set_format
|
||||
|
@ -290,8 +293,10 @@ struct _GstVideoDecoderClass
|
|||
|
||||
gboolean (*propose_allocation) (GstVideoDecoder *decoder, GstQuery * query);
|
||||
|
||||
gboolean (*flush) (GstVideoDecoder *decoder);
|
||||
|
||||
/*< private >*/
|
||||
void *padding[GST_PADDING_LARGE];
|
||||
void *padding[GST_PADDING_LARGE-1];
|
||||
};
|
||||
|
||||
GType gst_video_decoder_get_type (void);
|
||||
|
|
|
@ -298,7 +298,6 @@ gst_video_encoder_class_init (GstVideoEncoderClass * klass)
|
|||
static gboolean
|
||||
gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard)
|
||||
{
|
||||
GstVideoEncoderClass *klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
||||
GstVideoEncoderPrivate *priv = encoder->priv;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
|
@ -355,6 +354,21 @@ gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* Always call reset() in one way or another after this */
|
||||
static gboolean
|
||||
gst_video_encoder_flush (GstVideoEncoder * encoder)
|
||||
{
|
||||
GstVideoEncoderClass *klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
|
||||
gboolean ret = TRUE;
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||
if (klass->flush)
|
||||
ret = klass->flush (encoder);
|
||||
|
||||
GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_video_encoder_init (GstVideoEncoder * encoder, GstVideoEncoderClass * klass)
|
||||
{
|
||||
|
@ -1000,6 +1014,7 @@ gst_video_encoder_sink_event_default (GstVideoEncoder * encoder,
|
|||
}
|
||||
case GST_EVENT_FLUSH_STOP:{
|
||||
GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
|
||||
gst_video_encoder_flush (encoder);
|
||||
gst_segment_init (&encoder->input_segment, GST_FORMAT_TIME);
|
||||
gst_segment_init (&encoder->output_segment, GST_FORMAT_TIME);
|
||||
gst_video_encoder_reset (encoder, FALSE);
|
||||
|
|
|
@ -211,6 +211,9 @@ struct _GstVideoEncoder
|
|||
* Propose buffer allocation parameters for upstream elements.
|
||||
* Subclasses should chain up to the parent implementation to
|
||||
* invoke the default handler.
|
||||
* @flush: Optional.
|
||||
* Flush all remaining data from the encoder without
|
||||
* pushing it downstream. Since: 1.2
|
||||
*
|
||||
* Subclasses can override any of the available virtual methods or not, as
|
||||
* needed. At minimum @handle_frame needs to be overridden, and @set_format
|
||||
|
@ -260,9 +263,10 @@ struct _GstVideoEncoderClass
|
|||
|
||||
gboolean (*propose_allocation) (GstVideoEncoder * encoder,
|
||||
GstQuery * query);
|
||||
gboolean (*flush) (GstVideoEncoder *encoder);
|
||||
|
||||
/*< private >*/
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE];
|
||||
gpointer _gst_reserved[GST_PADDING_LARGE-1];
|
||||
};
|
||||
|
||||
GType gst_video_encoder_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue