mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
gldownload: Micro-optimisation. Don't check output caps on every buffer
The output caps will only change on a set_caps() call, so check if they contain the SystemMemory feature then and save some per-buffer CPU.
This commit is contained in:
parent
6714809529
commit
f02993921c
2 changed files with 16 additions and 17 deletions
|
@ -94,11 +94,18 @@ static gboolean
|
||||||
gst_gl_download_element_set_caps (GstBaseTransform * bt, GstCaps * in_caps,
|
gst_gl_download_element_set_caps (GstBaseTransform * bt, GstCaps * in_caps,
|
||||||
GstCaps * out_caps)
|
GstCaps * out_caps)
|
||||||
{
|
{
|
||||||
|
GstGLDownloadElement *dl = GST_GL_DOWNLOAD_ELEMENT (bt);
|
||||||
GstVideoInfo out_info;
|
GstVideoInfo out_info;
|
||||||
|
GstCapsFeatures *features = NULL;
|
||||||
|
|
||||||
if (!gst_video_info_from_caps (&out_info, out_caps))
|
if (!gst_video_info_from_caps (&out_info, out_caps))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
features = gst_caps_get_features (out_caps, 0);
|
||||||
|
|
||||||
|
dl->do_pbo_transfers = (!features || gst_caps_features_contains (features,
|
||||||
|
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY));
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,30 +167,20 @@ static GstFlowReturn
|
||||||
gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
|
gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt,
|
||||||
GstBuffer * inbuf, GstBuffer ** outbuf)
|
GstBuffer * inbuf, GstBuffer ** outbuf)
|
||||||
{
|
{
|
||||||
GstCaps *src_caps = gst_pad_get_current_caps (bt->srcpad);
|
GstGLDownloadElement *dl = GST_GL_DOWNLOAD_ELEMENT (bt);
|
||||||
GstCapsFeatures *features = NULL;
|
|
||||||
gint i, n;
|
gint i, n;
|
||||||
|
|
||||||
*outbuf = inbuf;
|
*outbuf = inbuf;
|
||||||
|
|
||||||
if (src_caps)
|
if (dl->do_pbo_transfers) {
|
||||||
features = gst_caps_get_features (src_caps, 0);
|
|
||||||
|
|
||||||
n = gst_buffer_n_memory (*outbuf);
|
n = gst_buffer_n_memory (*outbuf);
|
||||||
for (i = 0; i < n; i++) {
|
for (i = 0; i < n; i++) {
|
||||||
GstMemory *mem = gst_buffer_peek_memory (*outbuf, i);
|
GstMemory *mem = gst_buffer_peek_memory (*outbuf, i);
|
||||||
|
|
||||||
if (gst_is_gl_memory (mem)) {
|
|
||||||
if (!features || gst_caps_features_contains (features,
|
|
||||||
GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY)) {
|
|
||||||
if (gst_is_gl_memory_pbo (mem))
|
if (gst_is_gl_memory_pbo (mem))
|
||||||
gst_gl_memory_pbo_download_transfer ((GstGLMemoryPBO *) mem);
|
gst_gl_memory_pbo_download_transfer ((GstGLMemoryPBO *) mem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (src_caps)
|
|
||||||
gst_caps_unref (src_caps);
|
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,8 @@ struct _GstGLDownloadElement
|
||||||
{
|
{
|
||||||
/* <private> */
|
/* <private> */
|
||||||
GstGLBaseFilter parent;
|
GstGLBaseFilter parent;
|
||||||
|
|
||||||
|
gboolean do_pbo_transfers;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstGLDownloadElementClass
|
struct _GstGLDownloadElementClass
|
||||||
|
|
Loading…
Reference in a new issue