[vlc-devel] [RFC PATCH 04/13] iomx: implement OMX_UseBuffer

Thomas Guillem guillem at archos.com
Thu Jun 26 14:05:52 CEST 2014


---
 modules/codec/omxil/iomx.cpp |   36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/modules/codec/omxil/iomx.cpp b/modules/codec/omxil/iomx.cpp
index b399018..6866771 100644
--- a/modules/codec/omxil/iomx.cpp
+++ b/modules/codec/omxil/iomx.cpp
@@ -31,6 +31,10 @@
 
 #define PREFIX(x) I ## x
 
+#if ANDROID_API >= 11
+#define HAS_USE_BUFFER
+#endif
+
 using namespace android;
 
 class IOMXContext {
@@ -76,6 +80,9 @@ public:
 class OMXBuffer {
 public:
     sp<MemoryDealer> dealer;
+#ifdef HAS_USE_BUFFER
+    sp<GraphicBuffer> graphicBuffer;
+#endif
     IOMX::buffer_id id;
 };
 
@@ -153,6 +160,9 @@ static OMX_ERRORTYPE iomx_allocate_buffer(OMX_HANDLETYPE component, OMX_BUFFERHE
 {
     OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate;
     OMXBuffer* info = new OMXBuffer;
+#ifdef HAS_USE_BUFFER
+    info->graphicBuffer = NULL;
+#endif
     info->dealer = new MemoryDealer(size + 4096); // Do we need to keep this around, or is it kept alive via the IMemory that references it?
     sp<IMemory> mem = info->dealer->allocate(size);
     int ret = ctx->iomx->allocateBufferWithBackup(node->node, port_index, mem, &info->id);
@@ -168,6 +178,27 @@ static OMX_ERRORTYPE iomx_allocate_buffer(OMX_HANDLETYPE component, OMX_BUFFERHE
     return OMX_ErrorNone;
 }
 
+#ifdef HAS_USE_BUFFER
+static OMX_ERRORTYPE iomx_use_buffer(OMX_HANDLETYPE component, OMX_BUFFERHEADERTYPE **bufferptr, OMX_U32 port_index, OMX_PTR app_private, OMX_U32 size, OMX_U8* data)
+{
+    OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate;
+    OMXBuffer* info = new OMXBuffer;
+    info->dealer = NULL;
+    info->graphicBuffer = new GraphicBuffer((ANativeWindowBuffer*) data, false);
+    int ret = ctx->iomx->useGraphicBuffer(node->node, port_index, info->graphicBuffer, &info->id);
+    if (ret != OK)
+        return OMX_ErrorUndefined;
+    OMX_BUFFERHEADERTYPE *buffer = (OMX_BUFFERHEADERTYPE*) calloc(1, sizeof(OMX_BUFFERHEADERTYPE));
+    *bufferptr = buffer;
+    buffer->pPlatformPrivate = info;
+    buffer->pAppPrivate = app_private;
+    buffer->nAllocLen = size;
+    buffer->pBuffer = data;
+    node->buffers.push_back(buffer);
+    return OMX_ErrorNone;
+}
+#endif
+
 static OMX_ERRORTYPE iomx_free_buffer(OMX_HANDLETYPE component, OMX_U32 port, OMX_BUFFERHEADERTYPE *buffer)
 {
     OMXNode* node = (OMXNode*) ((OMX_COMPONENTTYPE*)component)->pComponentPrivate;
@@ -261,6 +292,11 @@ OMX_ERRORTYPE PREFIX(OMX_GetHandle)(OMX_HANDLETYPE *handle_ptr, OMX_STRING compo
     component->FillThisBuffer = iomx_fill_this_buffer;
     component->GetState = iomx_get_state;
     component->AllocateBuffer = iomx_allocate_buffer;
+#ifdef HAS_USE_BUFFER
+    component->UseBuffer = iomx_use_buffer;
+#else
+    component->UseBuffer = NULL;
+#endif
     component->ComponentRoleEnum = iomx_component_role_enum;
     component->GetExtensionIndex = iomx_get_extension_index;
     component->SetConfig = iomx_set_config;
-- 
1.7.10.4


-- 


This email and any files transmitted with it are confidential and are 
intended solely for the use of the individual or entity to which they are 
addressed. Access to this e-mail by anyone else is unauthorised. If you are 
not the intended recipient, any disclosure, copying, distribution or any 
action taken or omitted to be taken in reliance on it, is prohibited. 
E-mail messages are not necessarily secure. Archos does not accept 
responsibility for any changes made to this message after it was sent.



More information about the vlc-devel mailing list