From 5a56274cba13df5831fe15746792be433fc1baf3 Mon Sep 17 00:00:00 2001 From: Robert Swain Date: Fri, 5 Nov 2010 15:44:35 +0100 Subject: [PATCH] deinterlace: Refactor chain function This is needed to be able to output a frame from outside the chain function, i.e. in the following commit that adds flushing of the field history. --- gst/deinterlace/gstdeinterlace.c | 67 ++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/gst/deinterlace/gstdeinterlace.c b/gst/deinterlace/gstdeinterlace.c index 3c54e241f5..87380419bc 100644 --- a/gst/deinterlace/gstdeinterlace.c +++ b/gst/deinterlace/gstdeinterlace.c @@ -941,41 +941,13 @@ gst_deinterlace_do_qos (GstDeinterlace * self, GstClockTime timestamp) } static GstFlowReturn -gst_deinterlace_chain (GstPad * pad, GstBuffer * buf) +gst_deinterlace_output_frame (GstDeinterlace * self) { - GstDeinterlace *self = GST_DEINTERLACE (GST_PAD_PARENT (pad)); GstClockTime timestamp; GstFlowReturn ret = GST_FLOW_OK; gint fields_required = 0; gint cur_field_idx = 0; - GstBuffer *outbuf; - - GST_OBJECT_LOCK (self); - if (self->reconfigure) { - if (self->new_fields != -1) - self->fields = self->new_fields; - if (self->new_mode != -1) - self->mode = self->new_mode; - self->new_mode = self->new_fields = -1; - - self->reconfigure = FALSE; - GST_OBJECT_UNLOCK (self); - if (GST_PAD_CAPS (self->srcpad)) - gst_deinterlace_setcaps (self->sinkpad, GST_PAD_CAPS (self->sinkpad)); - } else { - GST_OBJECT_UNLOCK (self); - } - - if (self->still_frame_mode || self->passthrough) - return gst_pad_push (self->srcpad, buf); - - if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) { - GST_DEBUG_OBJECT (self, "DISCONT buffer, resetting history"); - gst_deinterlace_reset_history (self); - } - - gst_deinterlace_push_history (self, buf); - buf = NULL; + GstBuffer *buf, *outbuf; fields_required = gst_deinterlace_method_get_fields_required (self->method); @@ -1151,6 +1123,41 @@ gst_deinterlace_chain (GstPad * pad, GstBuffer * buf) return ret; } +static GstFlowReturn +gst_deinterlace_chain (GstPad * pad, GstBuffer * buf) +{ + GstDeinterlace *self = GST_DEINTERLACE (GST_PAD_PARENT (pad)); + + GST_OBJECT_LOCK (self); + if (self->reconfigure) { + if (self->new_fields != -1) + self->fields = self->new_fields; + if (self->new_mode != -1) + self->mode = self->new_mode; + self->new_mode = self->new_fields = -1; + + self->reconfigure = FALSE; + GST_OBJECT_UNLOCK (self); + if (GST_PAD_CAPS (self->srcpad)) + gst_deinterlace_setcaps (self->sinkpad, GST_PAD_CAPS (self->sinkpad)); + } else { + GST_OBJECT_UNLOCK (self); + } + + if (self->still_frame_mode || self->passthrough) + return gst_pad_push (self->srcpad, buf); + + if (GST_BUFFER_FLAG_IS_SET (buf, GST_BUFFER_FLAG_DISCONT)) { + GST_DEBUG_OBJECT (self, "DISCONT buffer, resetting history"); + gst_deinterlace_reset_history (self); + } + + gst_deinterlace_push_history (self, buf); + buf = NULL; + + return gst_deinterlace_output_frame (self); +} + static gint gst_greatest_common_divisor (gint a, gint b) {