mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-30 21:51:09 +00:00
deinterlace: Simplify setcaps
The current code never uses upstream negotiation so the code can be significantly simplified.
This commit is contained in:
parent
6402556157
commit
6607cdcc08
2 changed files with 30 additions and 55 deletions
|
@ -564,8 +564,6 @@ gst_deinterlace_init (GstDeinterlace * self, GstDeinterlaceClass * klass)
|
|||
GST_DEBUG_FUNCPTR (gst_deinterlace_src_query));
|
||||
gst_pad_set_getcaps_function (self->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_deinterlace_getcaps));
|
||||
gst_pad_set_setcaps_function (self->srcpad,
|
||||
GST_DEBUG_FUNCPTR (gst_deinterlace_setcaps));
|
||||
gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
|
||||
|
||||
self->mode = DEFAULT_MODE;
|
||||
|
@ -645,14 +643,6 @@ gst_deinterlace_reset (GstDeinterlace * self)
|
|||
|
||||
gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED);
|
||||
|
||||
if (self->sink_caps)
|
||||
gst_caps_unref (self->sink_caps);
|
||||
self->sink_caps = NULL;
|
||||
|
||||
if (self->src_caps)
|
||||
gst_caps_unref (self->src_caps);
|
||||
self->src_caps = NULL;
|
||||
|
||||
if (self->request_caps)
|
||||
gst_caps_unref (self->request_caps);
|
||||
self->request_caps = NULL;
|
||||
|
@ -1002,13 +992,15 @@ gst_deinterlace_output_frame (GstDeinterlace * self, gboolean flushing)
|
|||
GST_DEBUG_OBJECT (self, "deinterlacing top field");
|
||||
|
||||
/* create new buffer */
|
||||
ret = gst_pad_alloc_buffer (self->srcpad,
|
||||
GST_BUFFER_OFFSET_NONE, self->frame_size, self->src_caps, &outbuf);
|
||||
ret =
|
||||
gst_pad_alloc_buffer (self->srcpad, GST_BUFFER_OFFSET_NONE,
|
||||
self->frame_size, GST_PAD_CAPS (self->srcpad), &outbuf);
|
||||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
if (self->src_caps != GST_BUFFER_CAPS (outbuf) &&
|
||||
!gst_caps_is_equal (self->src_caps, GST_BUFFER_CAPS (outbuf))) {
|
||||
if (GST_PAD_CAPS (self->srcpad) != GST_BUFFER_CAPS (outbuf)
|
||||
&& !gst_caps_is_equal (GST_PAD_CAPS (self->srcpad),
|
||||
GST_BUFFER_CAPS (outbuf))) {
|
||||
gst_caps_replace (&self->request_caps, GST_BUFFER_CAPS (outbuf));
|
||||
GST_DEBUG_OBJECT (self, "Upstream wants new caps %" GST_PTR_FORMAT,
|
||||
self->request_caps);
|
||||
|
@ -1019,7 +1011,7 @@ gst_deinterlace_output_frame (GstDeinterlace * self, gboolean flushing)
|
|||
if (!outbuf)
|
||||
return GST_FLOW_ERROR;
|
||||
|
||||
gst_buffer_set_caps (outbuf, self->src_caps);
|
||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (self->srcpad));
|
||||
}
|
||||
|
||||
g_return_val_if_fail (self->history_count - 1 -
|
||||
|
@ -1080,13 +1072,15 @@ gst_deinterlace_output_frame (GstDeinterlace * self, gboolean flushing)
|
|||
GST_DEBUG_OBJECT (self, "deinterlacing bottom field");
|
||||
|
||||
/* create new buffer */
|
||||
ret = gst_pad_alloc_buffer (self->srcpad,
|
||||
GST_BUFFER_OFFSET_NONE, self->frame_size, self->src_caps, &outbuf);
|
||||
ret =
|
||||
gst_pad_alloc_buffer (self->srcpad, GST_BUFFER_OFFSET_NONE,
|
||||
self->frame_size, GST_PAD_CAPS (self->srcpad), &outbuf);
|
||||
if (ret != GST_FLOW_OK)
|
||||
return ret;
|
||||
|
||||
if (self->src_caps != GST_BUFFER_CAPS (outbuf) &&
|
||||
!gst_caps_is_equal (self->src_caps, GST_BUFFER_CAPS (outbuf))) {
|
||||
if (GST_PAD_CAPS (self->srcpad) != GST_BUFFER_CAPS (outbuf)
|
||||
&& !gst_caps_is_equal (GST_PAD_CAPS (self->srcpad),
|
||||
GST_BUFFER_CAPS (outbuf))) {
|
||||
gst_caps_replace (&self->request_caps, GST_BUFFER_CAPS (outbuf));
|
||||
GST_DEBUG_OBJECT (self, "Upstream wants new caps %" GST_PTR_FORMAT,
|
||||
self->request_caps);
|
||||
|
@ -1097,7 +1091,7 @@ gst_deinterlace_output_frame (GstDeinterlace * self, gboolean flushing)
|
|||
if (!outbuf)
|
||||
return GST_FLOW_ERROR;
|
||||
|
||||
gst_buffer_set_caps (outbuf, self->src_caps);
|
||||
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (self->srcpad));
|
||||
}
|
||||
|
||||
g_return_val_if_fail (self->history_count - 1 -
|
||||
|
@ -1391,10 +1385,7 @@ gst_deinterlace_setcaps (GstPad * pad, GstCaps * caps)
|
|||
{
|
||||
gboolean res = TRUE;
|
||||
GstDeinterlace *self = GST_DEINTERLACE (gst_pad_get_parent (pad));
|
||||
GstPad *otherpad;
|
||||
GstCaps *othercaps;
|
||||
|
||||
otherpad = (pad == self->srcpad) ? self->sinkpad : self->srcpad;
|
||||
GstCaps *srccaps;
|
||||
|
||||
res =
|
||||
gst_video_format_parse_caps (caps, &self->format, &self->width,
|
||||
|
@ -1410,57 +1401,45 @@ gst_deinterlace_setcaps (GstPad * pad, GstCaps * caps)
|
|||
if (!self->passthrough && self->fields == GST_DEINTERLACE_ALL) {
|
||||
gint fps_n = self->fps_n, fps_d = self->fps_d;
|
||||
|
||||
if (!gst_fraction_double (&fps_n, &fps_d, otherpad != self->srcpad))
|
||||
if (!gst_fraction_double (&fps_n, &fps_d, FALSE))
|
||||
goto invalid_caps;
|
||||
|
||||
othercaps = gst_caps_copy (caps);
|
||||
srccaps = gst_caps_copy (caps);
|
||||
|
||||
gst_caps_set_simple (othercaps, "framerate", GST_TYPE_FRACTION, fps_n,
|
||||
gst_caps_set_simple (srccaps, "framerate", GST_TYPE_FRACTION, fps_n,
|
||||
fps_d, NULL);
|
||||
} else {
|
||||
othercaps = gst_caps_ref (caps);
|
||||
srccaps = gst_caps_ref (caps);
|
||||
}
|
||||
|
||||
if (otherpad == self->srcpad && self->mode != GST_DEINTERLACE_MODE_DISABLED) {
|
||||
othercaps = gst_caps_make_writable (othercaps);
|
||||
gst_caps_set_simple (othercaps, "interlaced", G_TYPE_BOOLEAN, FALSE, NULL);
|
||||
if (self->mode != GST_DEINTERLACE_MODE_DISABLED) {
|
||||
srccaps = gst_caps_make_writable (srccaps);
|
||||
gst_caps_set_simple (srccaps, "interlaced", G_TYPE_BOOLEAN, FALSE, NULL);
|
||||
}
|
||||
|
||||
gst_deinterlace_reset_history (self, FALSE);
|
||||
|
||||
if (!gst_pad_set_caps (otherpad, othercaps))
|
||||
if (!gst_pad_set_caps (self->srcpad, srccaps))
|
||||
goto caps_not_accepted;
|
||||
|
||||
self->frame_size =
|
||||
gst_video_format_get_size (self->format, self->width, self->height);
|
||||
|
||||
if (G_LIKELY (self->fps_n != 0)) {
|
||||
if (self->fields == GST_DEINTERLACE_ALL && otherpad == self->srcpad)
|
||||
self->field_duration =
|
||||
gst_util_uint64_scale (GST_SECOND, self->fps_d, self->fps_n);
|
||||
else
|
||||
self->field_duration =
|
||||
gst_util_uint64_scale (GST_SECOND, self->fps_d, 2 * self->fps_n);
|
||||
} else {
|
||||
self->field_duration = 0;
|
||||
}
|
||||
|
||||
if (pad == self->sinkpad) {
|
||||
gst_caps_replace (&self->sink_caps, caps);
|
||||
gst_caps_replace (&self->src_caps, othercaps);
|
||||
} else {
|
||||
gst_caps_replace (&self->src_caps, caps);
|
||||
gst_caps_replace (&self->sink_caps, othercaps);
|
||||
}
|
||||
|
||||
gst_deinterlace_set_method (self, self->method_id);
|
||||
gst_deinterlace_method_setup (self->method, self->format, self->width,
|
||||
self->height);
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "Set caps: %" GST_PTR_FORMAT, caps);
|
||||
GST_DEBUG_OBJECT (pad, "Other caps: %" GST_PTR_FORMAT, othercaps);
|
||||
GST_DEBUG_OBJECT (pad, "Sink caps: %" GST_PTR_FORMAT, caps);
|
||||
GST_DEBUG_OBJECT (pad, "Src caps: %" GST_PTR_FORMAT, srccaps);
|
||||
|
||||
gst_caps_unref (othercaps);
|
||||
gst_caps_unref (srccaps);
|
||||
|
||||
done:
|
||||
|
||||
|
@ -1474,8 +1453,8 @@ invalid_caps:
|
|||
|
||||
caps_not_accepted:
|
||||
res = FALSE;
|
||||
GST_ERROR_OBJECT (pad, "Caps not accepted: %" GST_PTR_FORMAT, othercaps);
|
||||
gst_caps_unref (othercaps);
|
||||
GST_ERROR_OBJECT (pad, "Caps not accepted: %" GST_PTR_FORMAT, srccaps);
|
||||
gst_caps_unref (srccaps);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
|
|
@ -129,10 +129,6 @@ struct _GstDeinterlace
|
|||
gdouble proportion;
|
||||
GstClockTime earliest_time;
|
||||
|
||||
/* Upstream negotiation stuff */
|
||||
GstCaps *sink_caps;
|
||||
GstCaps *src_caps;
|
||||
|
||||
GstCaps *request_caps;
|
||||
|
||||
gboolean reconfigure;
|
||||
|
|
Loading…
Reference in a new issue