static void setup_input_buffer (GstOmxBaseFilter21 *self, GstBuffer *buf, int sink_num) { int j; gint i = sink_num; if (GST_IS_OMXBUFFERTRANSPORT (buf)) { OMX_PARAM_PORTDEFINITIONTYPE param; GOmxPort *port, *in_port; /* retrieve incoming buffer port information */ port = GST_GET_OMXPORT (buf); /* Check if output port has set always_copy */ if (port->always_copy != TRUE) { /* configure input buffer size to match with upstream buffer */ G_OMX_PORT_GET_DEFINITION (self->in_port[i], ¶m); param.nBufferSize = GST_BUFFER_SIZE (buf); param.nBufferCountActual = port->num_buffers; G_OMX_PORT_SET_DEFINITION (self->in_port[i], ¶m); /* allocate resource to save the incoming buffer port pBuffer pointer in * OmxBufferInfo structure. */ in_port = self->in_port[i]; in_port->share_buffer_info = malloc (sizeof(OmxBufferInfo)); if(in_port->share_buffer_info == NULL){ GST_ERROR_OBJECT (self, "omx: failed to malloc share_buffer_info"); } in_port->share_buffer_info->pBuffer = malloc (sizeof(int) * port->num_buffers); if(in_port->share_buffer_info->pBuffer == NULL){ GST_ERROR_OBJECT (self, "omx: failed to malloc share_buffer_info->pBuffer"); } for (j=0; j < port->num_buffers; j++) { in_port->share_buffer_info->pBuffer[j] = port->buffers[j]->pBuffer; } /* disable omx_allocate alloc flag, so that we can fall back to shared method */ self->in_port[i]->omx_allocate = FALSE; self->in_port[i]->always_copy = FALSE; return; } } /* ask openmax to allocate input buffer */ self->in_port[i]->omx_allocate = TRUE; self->in_port[i]->always_copy = TRUE; GST_INFO_OBJECT (self, "omx: setup input buffer - end"); }
static void setup_input_buffer (GstOmxBaseFilter2 *self, GstBuffer *buf) { if (GST_IS_OMXBUFFERTRANSPORT (buf)) { OMX_PARAM_PORTDEFINITIONTYPE param; GOmxPort *port, *in_port; gint i, shift = 0; /* retrieve incoming buffer port information */ port = GST_GET_OMXPORT (buf); /* configure input buffer size to match with upstream buffer */ G_OMX_PORT_GET_DEFINITION (self->in_port, ¶m); printf("this input params: %dx%d,%d %d %d\n", param.format.video.nFrameWidth, param.format.video.nFrameHeight, param.format.video.nStride, param.nBufferSize, param.nBufferCountActual); if (GST_GET_OMXBUFFER(buf)) { printf("incoming buffer: nFilledLen: %d, nOffset: %d nFlags: %x\n", GST_GET_OMXBUFFER(buf)->nFilledLen, GST_GET_OMXBUFFER(buf)->nOffset, GST_GET_OMXBUFFER(buf)->nFlags); } param.nBufferSize = GST_BUFFER_SIZE (buf); if (self->input_fields_separately) param.nBufferCountActual = port->num_buffers * 2; else param.nBufferCountActual = port->num_buffers; G_OMX_PORT_SET_DEFINITION (self->in_port, ¶m); /* allocate resource to save the incoming buffer port pBuffer pointer in * OmxBufferInfo structure. */ in_port = self->in_port; in_port->share_buffer_info = malloc (sizeof(OmxBufferInfo)); if (self->input_fields_separately) { int t1, t2; t1 = GST_GET_OMXBUFFER(buf)->nOffset / param.format.video.nStride; t2 = t1 + t1 + ((param.format.video.nFrameHeight + 7) & 0xFFFFFFF8); t1 = t2 * param.format.video.nStride; self->second_field_offset = ( GST_GET_OMXBUFFER(buf)->nFilledLen + GST_GET_OMXBUFFER(buf)->nOffset ) / 3; if (self->second_field_offset != t1) { printf("Second field offset does not look right... correcting it from %d to %d\n", self->second_field_offset, t1); self->second_field_offset = t1; } in_port->share_buffer_info->pBuffer = malloc (sizeof(int) * port->num_buffers * 2); for (i=0; i < port->num_buffers; i++) { in_port->share_buffer_info->pBuffer[i<<1] = port->buffers[i]->pBuffer; in_port->share_buffer_info->pBuffer[(i<<1)+1] = port->buffers[i]->pBuffer + self->second_field_offset; } } else { in_port->share_buffer_info->pBuffer = malloc (sizeof(int) * port->num_buffers); for (i=0; i < port->num_buffers; i++) { in_port->share_buffer_info->pBuffer[i] = port->buffers[i]->pBuffer; } } /* disable omx_allocate alloc flag, so that we can fall back to shared method */ self->in_port->omx_allocate = FALSE; self->in_port->always_copy = FALSE; } else { /* ask openmax to allocate input buffer */ self->in_port->omx_allocate = TRUE; self->in_port->always_copy = TRUE; self->input_fields_separately = FALSE; } }