aboutsummaryrefslogtreecommitdiffstats
path: root/meta-rcar-gen2/recipes-multimedia/gstreamer/gstreamer1.0-omx/0007-gstomxbufferpool-add-helper-to-get-omxbuffer-from-gs.patch
blob: ed9da8d08c9d4f0a2e89fd135041efdf4fdba31c (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
From 4abd8ac4f18f5baef5a23c7defdb12469192f9c5 Mon Sep 17 00:00:00 2001
From: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Date: Thu, 1 Sep 2016 17:51:30 +0300
Subject: [PATCH 07/10] gstomxbufferpool: add helper to get omxbuffer from
 gstomxbuffer


Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
---
 omx/gstomxbufferpool.c |   21 +++++++++++++++------
 omx/gstomxbufferpool.h |    2 ++
 omx/gstomxvideoenc.c   |   26 ++++++++++++++++----------
 3 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c
index d86f9d8..eb2fe9d 100644
--- a/omx/gstomxbufferpool.c
+++ b/omx/gstomxbufferpool.c
@@ -361,6 +361,17 @@ wrong_video_caps:
   }
 }
 
+GstOMXBuffer *gst_omx_buffer_get_omxbuffer (GstBuffer * buffer)
+{
+  GstOMXBuffer *omx_buf;
+
+  omx_buf =
+      gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buffer),
+      gst_omx_buffer_data_quark);
+
+  return omx_buf;
+}
+
 #if defined (HAVE_MMNGRBUF) && defined (HAVE_VIDEODEC_EXT)
 static gboolean
 gst_omx_buffer_pool_export_dmabuf (GstOMXBufferPool * pool,
@@ -697,9 +708,7 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool,
         buf = g_ptr_array_index (pool->buffers, pool->enc_buffer_index);
         g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR);
 
-        omx_buf =
-            gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buf),
-            gst_omx_buffer_data_quark);
+        omx_buf = gst_omx_buffer_get_omxbuffer(buf);
         pool->enc_buffer_index++;
         if (pool->enc_buffer_index == pool->port->port_def.nBufferCountActual)
           pool->enc_buffer_index = 0;
@@ -739,11 +748,11 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer)
   g_assert (pool->component && pool->port);
 
   if (!pool->allocating && !pool->deactivated) {
-    omx_buf =
-        gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (buffer),
-        gst_omx_buffer_data_quark);
+    omx_buf = gst_omx_buffer_get_omxbuffer(buffer);
+
     if (GST_IS_OMX_VIDEO_ENC (pool->element))
       omx_buf->exported = FALSE;
+
     if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used) {
       /* Release back to the port, can be filled again */
       err = gst_omx_port_release_buffer (pool->port, omx_buf);
diff --git a/omx/gstomxbufferpool.h b/omx/gstomxbufferpool.h
index 09cab8d..0c6f18b 100644
--- a/omx/gstomxbufferpool.h
+++ b/omx/gstomxbufferpool.h
@@ -101,6 +101,8 @@ GType gst_omx_buffer_pool_get_type (void);
 
 GstBufferPool *gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component, GstOMXPort * port);
 
+GstOMXBuffer *gst_omx_buffer_get_omxbuffer (GstBuffer * buffer);
+
 G_END_DECLS
 
 #endif /* __GST_OMX_BUFFER_POOL_H__ */
diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c
index b36c46e..e96ff28 100644
--- a/omx/gstomxvideoenc.c
+++ b/omx/gstomxvideoenc.c
@@ -1786,7 +1786,8 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
             gst_omx_error_to_string (err), err);
     }
 
-    if (self->in_port_pool) {
+    if ((self->in_port_pool) &&
+        (frame->input_buffer->pool == self->in_port_pool)) {
       GstMapInfo in_info;
       gint count = 0;
       GstOMXBufferPool *pool = GST_OMX_BUFFER_POOL (self->in_port_pool);
@@ -1795,13 +1796,15 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
        * encoder
        */
       if (!pool->deactivated) {
-        if (!gst_buffer_map (frame->input_buffer, &in_info, GST_MAP_READ)) {
-          GST_ERROR_OBJECT (self, "Can not map input buffer");
-          gst_omx_port_release_buffer (port, buf);
-          goto flow_error;
+        GstOMXBuffer *omx_buf;
+
+        omx_buf = gst_omx_buffer_get_omxbuffer(frame->input_buffer);
+        if (!omx_buf) {
+          GST_ERROR_OBJECT (self, "Can not get OMXBuffer from GstBuffer");
+          return GST_FLOW_ERROR;
         }
 
-        if (buf->omx_buf->pBuffer != in_info.data) {
+        if (buf != omx_buf) {
           gst_omx_port_release_buffer (port, buf);
           do {
             acq_ret = gst_omx_port_acquire_buffer (port, &buf);
@@ -1809,10 +1812,10 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
               GST_ERROR_OBJECT (self, "Can acquire buffer from input port");
               return GST_FLOW_ERROR;
             }
-            if (buf->omx_buf->pBuffer != in_info.data)
+            if (buf != omx_buf)
               gst_omx_port_release_buffer (port, buf);
             count += 1;
-          } while (buf->omx_buf->pBuffer != in_info.data
+          } while (buf != omx_buf
               && count < port->port_def.nBufferCountActual * 3);
         }
         if (count == port->port_def.nBufferCountActual * 3) {
@@ -1820,8 +1823,11 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder,
               "Can not get target OMXBuffer after 3 times searching");
           goto flow_error;
         }
-        buf->omx_buf->nFilledLen = in_info.size;
-        gst_buffer_unmap (frame->input_buffer, &in_info);
+        GST_DEBUG_OBJECT (self, "found target OMXBuffer %p", buf);
+        //buf->omx_buf->nFilledLen = gst_buffer_get_size (frame->input_buffer);
+        buf->omx_buf->nFilledLen = buf->omx_buf->nAllocLen - buf->omx_buf->nOffset;
+        GST_DEBUG_OBJECT (self, "set nFilledLen = %d", buf->omx_buf->nFilledLen);
+
       }
     } else {
       /* Copy the buffer content in chunks of size as requested
-- 
1.7.10.4