mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
glcolorconvert: Improve passthrough check when no conversion is needed.
Make the passthrough check contingent on only the fields we can modify being unchanged, and pre-compute it when caps change instead of checking on each buffer. Makes the passthrough more lenient if consumers are lax about making input and output caps complete.
This commit is contained in:
parent
343947f383
commit
c2450a28f5
2 changed files with 44 additions and 1 deletions
|
@ -574,6 +574,35 @@ gst_gl_color_convert_reset (GstGLColorConvert * convert)
|
|||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gst_gl_color_convert_can_passthrough (GstVideoInfo * in, GstVideoInfo * out)
|
||||
{
|
||||
gint i;
|
||||
|
||||
if (GST_VIDEO_INFO_FORMAT (in) != GST_VIDEO_INFO_FORMAT (out))
|
||||
return FALSE;
|
||||
if (GST_VIDEO_INFO_WIDTH (in) != GST_VIDEO_INFO_WIDTH (out))
|
||||
return FALSE;
|
||||
if (GST_VIDEO_INFO_HEIGHT (in) != GST_VIDEO_INFO_HEIGHT (out))
|
||||
return FALSE;
|
||||
if (GST_VIDEO_INFO_SIZE (in) != GST_VIDEO_INFO_SIZE (out))
|
||||
return FALSE;
|
||||
|
||||
for (i = 0; i < in->finfo->n_planes; i++) {
|
||||
if (in->stride[i] != out->stride[i])
|
||||
return FALSE;
|
||||
if (in->offset[i] != out->offset[i])
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!gst_video_colorimetry_is_equal (&in->colorimetry, &out->colorimetry))
|
||||
return FALSE;
|
||||
if (in->chroma_site != out->chroma_site)
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gst_gl_color_convert_set_caps_unlocked (GstGLColorConvert * convert,
|
||||
GstCaps * in_caps, GstCaps * out_caps)
|
||||
|
@ -619,6 +648,19 @@ _gst_gl_color_convert_set_caps_unlocked (GstGLColorConvert * convert,
|
|||
convert->out_info = out_info;
|
||||
convert->initted = FALSE;
|
||||
|
||||
/* If input and output are identical, pass through directly */
|
||||
convert->passthrough =
|
||||
_gst_gl_color_convert_can_passthrough (&in_info, &out_info);
|
||||
#ifndef GST_DISABLE_GST_DEBUG
|
||||
if (G_UNLIKELY (convert->passthrough))
|
||||
GST_DEBUG_OBJECT (convert,
|
||||
"Configuring passthrough mode for same in/out caps");
|
||||
else {
|
||||
GST_DEBUG_OBJECT (convert, "Color converting %" GST_PTR_FORMAT
|
||||
" to %" GST_PTR_FORMAT, in_caps, out_caps);
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -730,7 +772,7 @@ _gst_gl_color_convert_perform_unlocked (GstGLColorConvert * convert,
|
|||
g_return_val_if_fail (convert != NULL, FALSE);
|
||||
g_return_val_if_fail (inbuf, FALSE);
|
||||
|
||||
if (gst_video_info_is_equal (&convert->in_info, &convert->out_info))
|
||||
if (G_UNLIKELY (convert->passthrough))
|
||||
return gst_buffer_ref (inbuf);
|
||||
|
||||
convert->inbuf = inbuf;
|
||||
|
|
|
@ -53,6 +53,7 @@ struct _GstGLColorConvert
|
|||
GstVideoInfo out_info;
|
||||
|
||||
gboolean initted;
|
||||
gboolean passthrough;
|
||||
|
||||
GstBuffer * inbuf;
|
||||
GstBuffer * outbuf;
|
||||
|
|
Loading…
Reference in a new issue