This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Gstomx_h264enc allocatebuffer and useBuffer

Hi  all :

   I have the ics 4.3 and omap4430.The gstomx_h264enc  in the  android 2.3  have  omx_usebuffer ,but the function  can not get the OMX_BUFFERHEADERTYPE pointer . the code is

            GstBuffer * gst_buf =  NULL;
            ERROR(port, "%s(%d)--%s IS_DECODER_OUTPORT",__FILE__,__LINE__,__FUNCTION__);
              android_native_buffer_t* native_buf = NULL;
              if (port->buffer_alloc){
                gst_buf  = port->buffer_alloc (port, port->allocate_len);
                if (gst_buf  == NULL){
                      ERROR(port, "Allocate failed : %d / %d, status=%d ", i, param.nBufferCountActual,port->out_buf_status[i]);
                      break;
                }
                native_buf = (android_native_buffer_t* )GST_BUFFER_DATA(gst_buf);
                if (native_buf == NULL){
                      ERROR(port, "Allocate failed : %d / %d, status=%d ", i, param.nBufferCountActual,port->out_buf_status[i]);
                      break;
                }
                memcpy(&(port->native_buffer[i]), native_buf, sizeof(android_native_buffer_t));
            }
              OMX_INDEXTYPE index;
              if (OMX_GetExtensionIndex(port->core->omx_handle,("OMX.google.android.index.useAndroidNativeBuffer2"),&index) == OMX_ErrorNone)
              {
             OMX_ERRORTYPE err = OMX_UseBuffer (port->core->omx_handle,
                               &port->buffers[i],
                               port->port_index,
                               gst_buf ,
                               port->allocate_len,
                               (OMX_U8*)native_buf->handle);
             g_return_if_fail (port->buffers[i]);
             if (err ){
               ERROR(port, "OMX_UseBuffer failed, err=0x%x", err);
               return;
             }
             port->out_buf_status[i] = OWNED_BY_US;
             OMX_BUFFERHEADERTYPE *omx_buffer = port->buffers[i];
             omx_buffer->nAllocLen   = GST_BUFFER_SIZE (gst_buf);
             omx_buffer->nOffset     = 0;
             omx_buffer->nFlags      = 0;
             DEBUG (port, "%d/%d, omx_buffer=%p, pAppPrivate=%p, data=%p, status=%d",i, port->num_buffers,port->buffers[i], omx_buffer->pAppPrivate,omx_buffer->pAppPrivate? GST_BUFFER_DATA(omx_buffer->pAppPrivate): NULL,port->out_buf_status[i]);  

if i want to use the omx_usebuffer function  what should i do ?

I have read the android camera app code  and find  the app use the omx_allocatebuffer  on the in_put port .what is the difference between the omx_usebuffer and omx_allocatebuffer function on the buffer and configuration?  what should i do if i want to use the oma_allocatebuffer to replace omx_usebuffer? Thank you very much.

 BR

Aaron

  • There were some changes about ION layer in code, try reading the way that buffers are allocated using ION in next file,

    ./4AI.1.7/mydroid/hardware/ti/domx/domx/omx_proxy_common/src/omx_proxy_common.c

    the function is PROXY_AllocateBuffer, and chec about stride, LINUX_PAGE_SIZE and useION, it is the closest code I could find that shows it.