video{en,de}coder: Add new flush vfunc as a replacement for reset

This commit is contained in:
Sebastian Dröge 2013-08-15 12:44:56 +02:00
parent 9df036c216
commit 146bb1a153
4 changed files with 32 additions and 10 deletions

View file

@ -864,13 +864,11 @@ gst_video_decoder_flush (GstVideoDecoder * dec, gboolean hard)
klass->reset (dec, hard); klass->reset (dec, hard);
} }
/* FIXME make some more distinction between hard and soft, if (klass->flush) {
* but subclass may not be prepared for that */ klass->flush (dec);
/* FIXME perhaps also clear pending frames ?, }
* but again, subclass may still come up with one of those */
if (!hard) { if (hard) {
/* TODO ? finish/drain some stuff */
} else {
gst_segment_init (&dec->input_segment, GST_FORMAT_UNDEFINED); gst_segment_init (&dec->input_segment, GST_FORMAT_UNDEFINED);
gst_segment_init (&dec->output_segment, GST_FORMAT_UNDEFINED); gst_segment_init (&dec->output_segment, GST_FORMAT_UNDEFINED);
gst_video_decoder_clear_queues (dec); gst_video_decoder_clear_queues (dec);

View file

@ -242,6 +242,9 @@ struct _GstVideoDecoder
* Propose buffer allocation parameters for upstream elements. * Propose buffer allocation parameters for upstream elements.
* Subclasses should chain up to the parent implementation to * Subclasses should chain up to the parent implementation to
* invoke the default handler. * 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 * Subclasses can override any of the available virtual methods or not, as
* needed. At minimum @handle_frame needs to be overridden, and @set_format * 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 (*propose_allocation) (GstVideoDecoder *decoder, GstQuery * query);
gboolean (*flush) (GstVideoDecoder *decoder);
/*< private >*/ /*< private >*/
void *padding[GST_PADDING_LARGE]; void *padding[GST_PADDING_LARGE-1];
}; };
GType gst_video_decoder_get_type (void); GType gst_video_decoder_get_type (void);

View file

@ -298,7 +298,6 @@ gst_video_encoder_class_init (GstVideoEncoderClass * klass)
static gboolean static gboolean
gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard) gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard)
{ {
GstVideoEncoderClass *klass = GST_VIDEO_ENCODER_GET_CLASS (encoder);
GstVideoEncoderPrivate *priv = encoder->priv; GstVideoEncoderPrivate *priv = encoder->priv;
gboolean ret = TRUE; gboolean ret = TRUE;
@ -355,6 +354,21 @@ gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard)
return ret; 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 static void
gst_video_encoder_init (GstVideoEncoder * encoder, GstVideoEncoderClass * klass) 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:{ case GST_EVENT_FLUSH_STOP:{
GST_VIDEO_ENCODER_STREAM_LOCK (encoder); GST_VIDEO_ENCODER_STREAM_LOCK (encoder);
gst_video_encoder_flush (encoder);
gst_segment_init (&encoder->input_segment, GST_FORMAT_TIME); gst_segment_init (&encoder->input_segment, GST_FORMAT_TIME);
gst_segment_init (&encoder->output_segment, GST_FORMAT_TIME); gst_segment_init (&encoder->output_segment, GST_FORMAT_TIME);
gst_video_encoder_reset (encoder, FALSE); gst_video_encoder_reset (encoder, FALSE);

View file

@ -211,6 +211,9 @@ struct _GstVideoEncoder
* Propose buffer allocation parameters for upstream elements. * Propose buffer allocation parameters for upstream elements.
* Subclasses should chain up to the parent implementation to * Subclasses should chain up to the parent implementation to
* invoke the default handler. * 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 * Subclasses can override any of the available virtual methods or not, as
* needed. At minimum @handle_frame needs to be overridden, and @set_format * needed. At minimum @handle_frame needs to be overridden, and @set_format
@ -260,9 +263,10 @@ struct _GstVideoEncoderClass
gboolean (*propose_allocation) (GstVideoEncoder * encoder, gboolean (*propose_allocation) (GstVideoEncoder * encoder,
GstQuery * query); GstQuery * query);
gboolean (*flush) (GstVideoEncoder *encoder);
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING_LARGE]; gpointer _gst_reserved[GST_PADDING_LARGE-1];
}; };
GType gst_video_encoder_get_type (void); GType gst_video_encoder_get_type (void);