summaryrefslogtreecommitdiff
blob: 27c7daacf52e05e4ed3d50a8730fe0c56b554f81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
From 45650b7b1dfcaaa2b165a6d263b6dc74449c501c Mon Sep 17 00:00:00 2001
From: Rob Clark <rob@ti.com>
Date: Wed, 26 May 2010 14:42:40 -0500
Subject: [PATCH 5/5] basetransform: don't do unnecessary pad_alloc()

Don't allocate a buffer in passthrough mode.
---
 libs/gst/base/gstbasetransform.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c
index 57192ab..1416b8e 100644
--- a/libs/gst/base/gstbasetransform.c
+++ b/libs/gst/base/gstbasetransform.c
@@ -2188,14 +2188,26 @@ gst_base_transform_handle_buffer (GstBaseTransform * trans, GstBuffer * inbuf,
 
 no_qos:
 
-  /* first try to allocate an output buffer based on the currently negotiated
-   * format. While we call pad-alloc we could renegotiate the srcpad format or
-   * have a new suggestion for upstream buffer-alloc. 
-   * In any case, outbuf will contain a buffer suitable for doing the configured
-   * transform after this function. */
-  ret = gst_base_transform_prepare_output_buffer (trans, inbuf, outbuf);
-  if (G_UNLIKELY (ret != GST_FLOW_OK))
-    goto no_buffer;
+  if (trans->passthrough) {
+    /* I'm not yet sure if we should bypass allocating output buffer in case of
+     * passthrough, or if I should override the prepare_output_buffer vmethod..
+     * I think the argument for always doing buffer allocation is to give a
+     * chance for upstream caps-renegotiation.. except I think the existing
+     * gst_base_transform_buffer_alloc() which itself does a pad_alloc() should
+     * be sufficient..
+     */
+    GST_DEBUG_OBJECT (trans, "reuse input buffer");
+    *outbuf = inbuf;
+  } else {
+    /* first try to allocate an output buffer based on the currently negotiated
+     * format. While we call pad-alloc we could renegotiate the srcpad format or
+     * have a new suggestion for upstream buffer-alloc.
+     * In any case, outbuf will contain a buffer suitable for doing the configured
+     * transform after this function. */
+    ret = gst_base_transform_prepare_output_buffer (trans, inbuf, outbuf);
+    if (G_UNLIKELY (ret != GST_FLOW_OK))
+      goto no_buffer;
+  }
 
   /* now perform the needed transform */
   if (trans->passthrough) {
-- 
1.7.1