After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 795145 - appsink: Reuse sample object in pull_sample if possible
appsink: Reuse sample object in pull_sample if possible
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
unspecified
Other All
: Normal enhancement
: 1.15.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on: 795144
Blocks:
 
 
Reported: 2018-04-10 22:59 UTC by Mathieu Duponchelle
Modified: 2018-04-19 14:21 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
appsink: Reuse sample object in pull_sample if possible (6.09 KB, patch)
2018-04-10 22:59 UTC, Mathieu Duponchelle
none Details | Review
appsink: Reuse sample object in pull_sample if possible (6.13 KB, patch)
2018-04-11 17:08 UTC, Mathieu Duponchelle
none Details | Review
appsink: Reuse sample object in pull_sample if possible (6.10 KB, patch)
2018-04-11 21:03 UTC, Mathieu Duponchelle
none Details | Review
appsink: Reuse sample object in pull_sample if possible (6.29 KB, patch)
2018-04-12 14:15 UTC, Mathieu Duponchelle
committed Details | Review

Description Mathieu Duponchelle 2018-04-10 22:59:51 UTC
See commit message
Comment 1 Mathieu Duponchelle 2018-04-10 22:59:57 UTC
Created attachment 370760 [details] [review]
appsink: Reuse sample object in pull_sample if possible

Simple optimization to reduce memory allocations.
Comment 2 Sebastian Dröge (slomo) 2018-04-11 08:41:31 UTC
Review of attachment 370760 [details] [review]:

::: gst-libs/gst/app/gstappsink.c
@@ +824,3 @@
+          }
+          priv->sample =
+              gst_sample_new (NULL, priv->last_caps, &priv->last_segment, NULL);

See my comment on the other bug, we could easily also update the segment, caps, etc.

While this does not make much of a difference, it would make the code here more consistent and does not really complicate anything... while it makes the GstSample API more consistent (why would you be able to only change the buffer but not e.g. the segment?)
Comment 3 Mathieu Duponchelle 2018-04-11 17:08:51 UTC
Created attachment 370816 [details] [review]
appsink: Reuse sample object in pull_sample if possible

Simple optimization to reduce memory allocations.
Comment 4 Mathieu Duponchelle 2018-04-11 17:15:11 UTC
Thanks, I was hesitant to add all that API for no particular reason FWIW, appsink's code is cleaner that way indeed.
Comment 5 Sebastian Dröge (slomo) 2018-04-11 19:07:17 UTC
Review of attachment 370816 [details] [review]:

::: gst-libs/gst/app/gstappsink.c
@@ +812,3 @@
           GST_DEBUG_OBJECT (appsink, "activating caps %" GST_PTR_FORMAT, caps);
           gst_caps_replace (&priv->last_caps, caps);
+          gst_sample_set_caps (priv->sample, priv->last_caps);

Why would the sample be writable here and below?
Comment 6 Mathieu Duponchelle 2018-04-11 21:03:53 UTC
Created attachment 370822 [details] [review]
appsink: Reuse sample object in pull_sample if possible

Simple optimization to reduce memory allocations.
Comment 7 Sebastian Dröge (slomo) 2018-04-12 07:15:25 UTC
Review of attachment 370822 [details] [review]:

::: gst-libs/gst/app/gstappsink.c
@@ +812,3 @@
           GST_DEBUG_OBJECT (appsink, "activating caps %" GST_PTR_FORMAT, caps);
           gst_caps_replace (&priv->last_caps, caps);
+          gst_sample_set_caps (priv->sample, priv->last_caps);

Why would the sample always be writable here and for the segment event?
Comment 8 Mathieu Duponchelle 2018-04-12 14:11:11 UTC
(In reply to Sebastian Dröge (slomo) from comment #7)
> Why would the sample always be writable here and for the segment event?

Because that's a mistake, updating, thanks
Comment 9 Mathieu Duponchelle 2018-04-12 14:15:58 UTC
Created attachment 370859 [details] [review]
appsink: Reuse sample object in pull_sample if possible

Simple optimization to reduce memory allocations.
Comment 10 Sebastian Dröge (slomo) 2018-04-19 06:13:16 UTC
Let's get this in then? :)
Comment 11 Mathieu Duponchelle 2018-04-19 14:20:58 UTC
Attachment 370859 [details] pushed as d00e0b6 - appsink: Reuse sample object in pull_sample if possible