diff options
author | Jan Schmidt <jan@centricular.com> | 2017-08-21 06:49:02 -0700 |
---|---|---|
committer | Jan Schmidt <jan@centricular.com> | 2017-08-22 01:57:42 +1000 |
commit | f02993921c55da50042183ee495e3d2c4956fa6b (patch) | |
tree | d43864ca885ce5c690941bc1439dc65c04cfe737 /ext/gl | |
parent | 671480952911b3a98ac77746353ed71c75481882 (diff) |
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.
Diffstat (limited to 'ext/gl')
-rw-r--r-- | ext/gl/gstgldownloadelement.c | 31 | ||||
-rw-r--r-- | ext/gl/gstgldownloadelement.h | 2 |
2 files changed, 16 insertions, 17 deletions
diff --git a/ext/gl/gstgldownloadelement.c b/ext/gl/gstgldownloadelement.c index 36821df44..153a3c3f9 100644 --- a/ext/gl/gstgldownloadelement.c +++ b/ext/gl/gstgldownloadelement.c @@ -94,11 +94,18 @@ static gboolean gst_gl_download_element_set_caps (GstBaseTransform * bt, GstCaps * in_caps, GstCaps * out_caps) { + GstGLDownloadElement *dl = GST_GL_DOWNLOAD_ELEMENT (bt); GstVideoInfo out_info; + GstCapsFeatures *features = NULL; if (!gst_video_info_from_caps (&out_info, out_caps)) 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; } @@ -160,31 +167,21 @@ static GstFlowReturn gst_gl_download_element_prepare_output_buffer (GstBaseTransform * bt, GstBuffer * inbuf, GstBuffer ** outbuf) { - GstCaps *src_caps = gst_pad_get_current_caps (bt->srcpad); - GstCapsFeatures *features = NULL; + GstGLDownloadElement *dl = GST_GL_DOWNLOAD_ELEMENT (bt); gint i, n; *outbuf = inbuf; - if (src_caps) - features = gst_caps_get_features (src_caps, 0); - - n = gst_buffer_n_memory (*outbuf); - for (i = 0; i < n; i++) { - GstMemory *mem = gst_buffer_peek_memory (*outbuf, i); + if (dl->do_pbo_transfers) { + n = gst_buffer_n_memory (*outbuf); + for (i = 0; i < n; 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)) - gst_gl_memory_pbo_download_transfer ((GstGLMemoryPBO *) mem); - } + if (gst_is_gl_memory_pbo (mem)) + gst_gl_memory_pbo_download_transfer ((GstGLMemoryPBO *) mem); } } - if (src_caps) - gst_caps_unref (src_caps); - return GST_FLOW_OK; } diff --git a/ext/gl/gstgldownloadelement.h b/ext/gl/gstgldownloadelement.h index eabfeec9a..e7d4ce03a 100644 --- a/ext/gl/gstgldownloadelement.h +++ b/ext/gl/gstgldownloadelement.h @@ -43,6 +43,8 @@ struct _GstGLDownloadElement { /* <private> */ GstGLBaseFilter parent; + + gboolean do_pbo_transfers; }; struct _GstGLDownloadElementClass |