Enabling h264 encoder.
Removing unnecessary commented code.
Signed-off-by: Barun Kumar Singh <barun.singh@samsung.com>
Change-Id: Ibe9ac74078bcb96d2b0c4b7f857dfe93b7b7dce0
+[omxmpeg2videodec]
+type-name=GstOMXMPEG2VideoDec
+core-name=/usr/lib/libExynosOMX_Core.so
+component-name=OMX.Exynos.MPEG2.Decoder
+rank=256
+in-port-index=0
+out-port-index=1
+hacks=no-component-role
+
[omxmpeg4videodec]
type-name=GstOMXMPEG4VideoDec
core-name=/usr/lib/libExynosOMX_Core.so
bellagio)
AC_DEFINE(USE_OMX_TARGET_BELLAGIO, 1, [Use Bellagio OpenMAX IL target])
;;
+ odroid)
+ AC_DEFINE(USE_OMX_TARGET_ODROID, 1, [Use Odroid OpenMAX IL target])
+ ;;
*)
AC_ERROR([invalid OpenMAX IL target])
;;
AM_CONDITIONAL(USE_OMX_TARGET_GENERIC, test "x$ac_cv_omx_target" = "xgeneric")
AM_CONDITIONAL(USE_OMX_TARGET_BELLAGIO, test "x$ac_cv_omx_target" = "xbellagio")
AM_CONDITIONAL(USE_OMX_TARGET_RPI, test "x$ac_cv_omx_target" = "xrpi")
+AM_CONDITIONAL(USE_OMX_TARGET_ODROID, test "x$ac_cv_omx_target" = "xodroid")
AC_ARG_WITH([omx-struct-packing],
AS_HELP_STRING([--with-omx-struct-packing],[Force OpenMAX struct packing, (default is none)]),
dnl *** output files ***
+dnl use dri2proto
+PKG_CHECK_MODULES(DRI2PROTO, dri2proto)
+AC_SUBST(DRI2PROTO_CFLAGS)
+AC_SUBST(DRI2PROTO_LIBS)
+
+dnl drm buffer
+PKG_CHECK_MODULES(X11, x11)
+AC_SUBST(X11_LDFLAGS)
+AC_SUBST(X11_CFLAGS)
+AC_SUBST(X11_LIBS)
+PKG_CHECK_MODULES(DRI2, libdri2)
+AC_SUBST(DRI2_LDFLAGS)
+AC_SUBST(DRI2_CFLAGS)
+AC_SUBST(DRI2_LIBS)
+
+PKG_CHECK_MODULES(DRM, libdrm)
+AC_SUBST(DRM_CFLAGS)
+AC_SUBST(DRM_LIBS)
+
+PKG_CHECK_MODULES(TBM, libtbm)
+AC_SUBST(TBM_CFLAGS)
+AC_SUBST(TBM_LIBS)
+
+PKG_CHECK_MODULES(XFIXES, xfixes)
+AC_SUBST(XFIXES_LDFLAGS)
+AC_SUBST(XFIXES_CFLAGS)
+AC_SUBST(XFIXES_LIBS)
AC_CONFIG_FILES(
Makefile
omx/Makefile
buf->used = TRUE;
if (port->port_def.eDir == OMX_DirInput) {
- GST_LOG_OBJECT (comp->parent,"\n[SRI-D] Calling OMX_EmptyThisBuffer. BufHeader:[%p]\n",buf->omx_buf);
+ GST_LOG_OBJECT (comp->parent,"Calling OMX_EmptyThisBuffer. BufHeader:[%p]\n",buf->omx_buf);
err = OMX_EmptyThisBuffer (comp->handle, buf->omx_buf);
} else {
- GST_ERROR_OBJECT (comp->parent,"\n[SRI-D] Calling OMX_FillThisBuffer. BufHeader:[%p]\n",buf->omx_buf);
+ GST_LOG_OBJECT (comp->parent,"Calling OMX_FillThisBuffer. BufHeader:[%p]\n",buf->omx_buf);
err = OMX_FillThisBuffer (comp->handle, buf->omx_buf);
}
GST_DEBUG_OBJECT (comp->parent, "Released buffer %p to %s port %u: %s "
g_assert (buf->omx_buf->pAppPrivate == buf);
/* In the beginning all buffers are not owned by the component */
- GST_DEBUG_OBJECT (comp->parent, "[SRI-D]: Pushing pending_buffers, port:[%d], Buffer:[%p]",
+ GST_DEBUG_OBJECT (comp->parent, "Pushing pending_buffers, port:[%d], Buffer:[%p]",
port->index, buf);
g_queue_push_tail (&port->pending_buffers, buf);
#ifdef USE_TBM
/* NOTE: Uses comp->lock and comp->messages_lock */
OMX_ERRORTYPE
-gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port)
+gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int eCompressionFormat)
{
OMX_ERRORTYPE err = OMX_ErrorNone;
guint n = 0;
g_mutex_lock (&port->comp->lock);
- //GST_ERROR_OBJECT (port->comp->parent, "\n[SRI-D]: %s : 1",__func__);
+ /* deallocate previous allocated buffers... */
+ if(port->buffers)
+ gst_omx_port_deallocate_buffers(port);
+
n = port->port_def.nBufferCountActual;
for(int i = 0; i < n; i++) {
- //GST_ERROR_OBJECT (port->comp->parent, "\n[SRI-D]: %s : 2",__func__);
+
ptr = (SCMN_IMGB*) malloc(sizeof(SCMN_IMGB));
- //GST_ERROR_OBJECT (port->comp->parent, "\n[SRI-D]: %s : 3",__func__);
memset(ptr,0,sizeof(SCMN_IMGB));
- //GST_ERROR_OBJECT (port->comp->parent, "\n[SRI-D]: %s : 4",__func__);
if(port->index == 0) {
ptr->bo[0] = gst_omx_tbm_allocate_bo(bufMgr, port->port_def.nBufferSize);
}
else { /* output port */
- y_size = calc_plane(port->port_def.format.video.nFrameWidth,port->port_def.format.video.nFrameHeight);
+ y_size = gst_omx_calculate_y_size(eCompressionFormat,
+ port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight);
ptr->bo[0] = gst_omx_tbm_allocate_bo(bufMgr, y_size);
ptr->fd[0] = gst_omx_tbm_get_bo_fd(ptr->bo[0]);
ptr->a[0] = gst_omx_tbm_get_bo_ptr(ptr->bo[0]);
- uv_size = calc_plane(port->port_def.format.video.nFrameWidth,port->port_def.format.video.nFrameHeight >> 1);
+ uv_size = gst_omx_calculate_uv_size(eCompressionFormat,
+ port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight >> 1);
ptr->bo[1] = gst_omx_tbm_allocate_bo(bufMgr, uv_size);
ptr->fd[1] = gst_omx_tbm_get_bo_fd(ptr->bo[1]);
ptr->a[1] = gst_omx_tbm_get_bo_ptr(ptr->bo[1]);
ptr->uv_size = uv_size;
ptr->buf_share_method = BUF_SHARE_METHOD_FD;
-// GST_ERROR_OBJECT(self, "\n[SRI-D] Buffer count: [%d] Video width:[%d],Video Height:[%d]",port->port_def.nBufferCountActual,
}
- //GST_ERROR_OBJECT (port->comp->parent, "\n[SRI-D]: %s : 5",__func__);
buffers = g_list_append(buffers,(gpointer)ptr);
- //GST_ERROR_OBJECT (port->comp->parent, "\n[SRI-D]: %s : 6",__func__);
+ }
+ if(port->index == 0) {
+ GST_DEBUG_OBJECT(port->comp->parent,"Y Length:[%d], UV Length:[%d], FrameWidth:[%d],Frame Height:[%d]",
+ ptr->y_size,ptr->uv_size,port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight);
}
n = g_list_length ((GList *) buffers);
gst_omx_tbm_deallocate_bo(buf->scmn_buffer->bo[0]);
if(port->index == 1) /* output port */
gst_omx_tbm_deallocate_bo(buf->scmn_buffer->bo[1]);
+ free(buf->scmn_buffer);
+ buf->scmn_buffer = NULL;
}
#endif
/* omx_buf can be NULL if allocation failed earlier
return ALIGN(mbX * mbY, S5P_FIMV_DEC_BUF_ALIGN);
}
+int
+gst_omx_calculate_y_size(int compressionFormat, int width, int height)
+{
+ int size = 0;
+ switch(compressionFormat)
+ {
+ case OMX_VIDEO_CodingMPEG2:
+ size = calc_yplane(width,height);
+ size = size << 1; /* MFC FIX. double the calculated buffer size */
+ GST_LOG("calculating Y size of mpeg2: height:[%d], width:[%d], size:[%d]",height,width,size);
+ break;
+ case OMX_VIDEO_CodingAVC: /* FALL THROUGH */
+ default:
+ size = calc_plane(width,height);
+ GST_ERROR("calculating Y size of DEFAULT: height:[%d], width:[%d], size:[%d]",height,width,size);
+ }
+ return size;
+}
+
+int
+gst_omx_calculate_uv_size(int compressionFormat, int width, int height)
+{
+ int size = 0;
+ switch(compressionFormat)
+ {
+ case OMX_VIDEO_CodingMPEG2:
+ size = calc_uvplane(width,height);
+ size = size << 1; /* MFC FIX. double the calculated buffer size */
+ break;
+ case OMX_VIDEO_CodingAVC: /* FALL THROUGH */
+ default:
+ size = calc_plane(width,height);
+ GST_LOG("calculating UV size of DEFAULT: height:[%d], width:[%d], size:[%d]",height,width,size);
+ }
+ return size;
+}
+
tbm_bo
gst_omx_tbm_allocate_bo(tbm_bufmgr hBufmgr, int size)
{
OMX_ERRORTYPE gst_omx_port_allocate_buffers (GstOMXPort *port);
#ifdef USE_TBM
-OMX_ERRORTYPE gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port);
+OMX_ERRORTYPE gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int eCompressionFormat);
+OMX_ERRORTYPE gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int eCompressionFormat);
#endif
OMX_ERRORTYPE gst_omx_port_use_buffers (GstOMXPort *port, const GList *buffers);
OMX_ERRORTYPE gst_omx_port_use_eglimages (GstOMXPort *port, const GList *images);
int calc_plane(int width, int height);
int calc_yplane(int width, int height);
int calc_uvplane(int width, int height);
+int gst_omx_calculate_y_size(int compressionFormat, int width, int height);
+int gst_omx_calculate_uv_size(int compressionFormat, int width, int height);
tbm_bo gst_omx_tbm_allocate_bo(tbm_bufmgr hBufmgr, int size);
void gst_omx_tbm_deallocate_bo(tbm_bo bo);
was_enabled = FALSE;
}
#ifdef USE_TBM
- //GST_ERROR_OBJECT (self, "1. USE_TBM");
- err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port);
+ err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port,
+ self->dec_in_port->port_def.format.video.eCompressionFormat);
#else
- //GST_ERROR_OBJECT (self, "1. NOT USE_TBM");
err = gst_omx_port_allocate_buffers (port);
#endif
if (err != OMX_ErrorNone && min > port->port_def.nBufferCountMin) {
}
}
#ifdef USE_TBM
- //GST_ERROR_OBJECT (self, "2. USE_TBM");
- err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port);
+ err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port,
+ self->dec_in_port->port_def.format.video.eCompressionFormat);
#else
- //GST_ERROR_OBJECT (self, "2. NOT USE_TBM");
err = gst_omx_port_allocate_buffers (port);
#endif
/* Can't provide buffers downstream in this case */
/* set plateform specific gem buffer settings. */
- /* Set platform specific buffer settings. to avoid plane support error.. */\r
-#ifdef USE_TBM\r
- OMX_INIT_STRUCTURE(gemBuffers);\r
- gemBuffers.enable = OMX_TRUE;\r
- gemBuffers.nPortIndex = 1;\r
+ /* Set platform specific buffer settings. to avoid plane support error.. */
+#ifdef USE_TBM
+ OMX_INIT_STRUCTURE(gemBuffers);
+ gemBuffers.enable = OMX_TRUE;
+ gemBuffers.nPortIndex = 1;
err =
- gst_omx_component_set_parameter (self->dec,\r
- OMX_IndexParamEnablePlatformSpecificBuffers,&gemBuffers);\r
+ gst_omx_component_set_parameter (self->dec,
+ OMX_IndexParamEnablePlatformSpecificBuffers,&gemBuffers);
if (err != OMX_ErrorNone) {
GST_ERROR_OBJECT (self, "Failed to set video port format: %s (0x%08x)",
gst_omx_error_to_string (err), err);
GST_DEBUG_OBJECT (self, "Enabling component");
if (needs_disable) {
- // printf("\n[SRI-D] needs_disable");
if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone)
return FALSE;
#ifdef USE_TBM
- //GST_ERROR_OBJECT (self, "\n3. USE_TBM");
- if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_in_port) != OMX_ErrorNone)
+ if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_in_port, 0) != OMX_ErrorNone)
return FALSE;
#else
- //GST_ERROR_OBJECT (self, "\n3. NOT USE_TBM");
if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
return FALSE;
#endif
return FALSE;
/* Need to allocate buffers to reach Idle state */
- //printf("\n[SRI-D] outside needs_disable\n");
#ifdef USE_TBM
- //GST_ERROR_OBJECT (self, "\n4. USE_TBM");
- if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_in_port) != OMX_ErrorNone)
+ if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_in_port,0) != OMX_ErrorNone)
return FALSE;
#else
- //GST_ERROR_OBJECT (self, "\n4. NOT USE_TBM");
if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone)
return FALSE;
#endif
#ifdef USE_TBM
- //GST_ERROR_OBJECT (self, "\n5. USE_TBM");
- if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_out_port) != OMX_ErrorNone)
+ if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_out_port,
+ self->dec_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
return FALSE;
#else
- //GST_ERROR_OBJECT (self, "\n5. NOT USE_TBM");
if (gst_omx_port_allocate_buffers (self->dec_out_port) != OMX_ErrorNone)
return FALSE
#endif
1 * GST_SECOND) != OMX_ErrorNone)
return FALSE;
#endif
- //GST_ERROR_OBJECT (self, "\n7. GET COMPONENT STATE\n");
if (gst_omx_component_get_state (self->dec,
GST_CLOCK_TIME_NONE) != OMX_StateIdle)
return FALSE;
- //GST_ERROR_OBJECT (self, "\n8. SET COMPONENT STATE TO EXECUTING\n");
if (gst_omx_component_set_state (self->dec,
OMX_StateExecuting) != OMX_ErrorNone)
return FALSE;
}
/* Unset flushing to allow ports to accept data again */
- //GST_ERROR_OBJECT (self, "\n10. FLUSHING INPUT PORT\n");
gst_omx_port_set_flushing (self->dec_in_port, 5 * GST_SECOND, FALSE);
- //GST_ERROR_OBJECT (self, "\n11. FLUSHING OUTPUT PORT\n");
gst_omx_port_set_flushing (self->dec_out_port, 5 * GST_SECOND, FALSE);
if (gst_omx_component_get_last_error (self->dec) != OMX_ErrorNone) {
return FALSE;
}
- //GST_ERROR_OBJECT (self, "\n12. STARTING TASK AGAIN\n");
/* Start the srcpad loop again */
GST_DEBUG_OBJECT (self, "Starting task again");
goto reconfigure_error;
}
#ifdef USE_TBM
- err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port);
+ err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port,
+ self->dec_in_port->port_def.format.video.eCompressionFormat);
#else
err = gst_omx_port_allocate_buffers (port);
#endif
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
buf->omx_buf->nFilledLen = gst_buffer_get_size (codec_data);;
#ifdef USE_TBM
- //GST_ERROR_OBJECT(self,"\n[SRI-D] extract from codec_data\n");
gst_buffer_extract (codec_data, 0,
buf->scmn_buffer->a[0] + buf->omx_buf->nOffset,
buf->omx_buf->nFilledLen);
buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
buf->omx_buf->nFilledLen);
#endif
- //GST_ERROR_OBJECT(self,"\n[SRI-D] extract from codec_data SUCCESS\n");
if (GST_CLOCK_TIME_IS_VALID (timestamp))
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
/*GST_ERROR_OBJECT (self, "[SRI-D] frame->input_buffer:[%p], offset:[%d], buf->scmn_buffer->a[0]:[%p],offset:[%d], buf->omx_buf->nFilledLen:[%d]",
frame->input_buffer, offset, buf->scmn_buffer->a[0], buf->omx_buf->nOffset, buf->omx_buf->nFilledLen);*/
#ifdef USE_TBM
- //GST_ERROR_OBJECT(self,"\n[SRI-D] extract from frame->input_buffer\n");
gst_buffer_extract (frame->input_buffer, offset,
buf->scmn_buffer->a[0] + buf->omx_buf->nOffset,
buf->omx_buf->nFilledLen);
buf->omx_buf->pBuffer + buf->omx_buf->nOffset,
buf->omx_buf->nFilledLen);
#endif
- //GST_ERROR_OBJECT(self,"\n[SRI-D] extract from frame->input_buffer SUCCESS\n");
if (timestamp != GST_CLOCK_TIME_NONE) {
buf->omx_buf->nTimeStamp =
gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND);
g_mutex_init (&self->drain_lock);
g_cond_init (&self->drain_cond);
+#ifdef USE_TBM
+ self->hTBMBufMgr = NULL;
+ self->drm_fd = -1;
+#endif
}
static gboolean
}
}
}
-
+#ifdef USE_TBM
+ self->hTBMBufMgr = tbm_bufmgr_init(self->drm_fd);
+ if(self->hTBMBufMgr == NULL){
+ GST_ERROR_OBJECT (self, "TBM initialization failed.");
+ return FALSE;
+ }
+#endif
return TRUE;
}
err = gst_omx_port_set_enabled (port, TRUE);
if (err != OMX_ErrorNone)
goto reconfigure_error;
-
+#ifdef USE_TBM
+ err = gst_omx_port_tbm_allocate_enc_buffers(self->hTBMBufMgr,port,
+ self->enc_in_port->port_def.format.video.eCompressionFormat);
+#else
err = gst_omx_port_allocate_buffers (port);
+#endif
if (err != OMX_ErrorNone)
goto reconfigure_error;
GST_DEBUG_OBJECT (self, "Component supports SN12 (%d) at index %d",
param.eColorFormat, param.nIndex);
break;
+ case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
+ m = g_slice_new (VideoNegotiationMap);
+ m->format = GST_VIDEO_FORMAT_ST12;
+ m->type = param.eColorFormat;
+ negotiation_map = g_list_append (negotiation_map, m);
+ GST_DEBUG_OBJECT (self, "Component supports ST12 (%d) at index %d",
+ param.eColorFormat, param.nIndex);
+ break;
default:
GST_DEBUG_OBJECT (self,
"Component supports unsupported color format %d at index %d",
port_def.nBufferSize = sizeof(SCMN_IMGB);
break;
+ case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
+ port_def.nBufferSize = sizeof(SCMN_IMGB);
+ break;
+
default:
g_assert_not_reached ();
}
if (needs_disable) {
if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone)
return FALSE;
+#ifdef USE_TBM
+ if(gst_omx_port_tbm_allocate_enc_buffers(self->hTBMBufMgr,self->enc_in_port,
+ self->enc_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+ return FALSE;
+#else
if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
return FALSE;
+#endif
if (gst_omx_port_wait_enabled (self->enc_in_port,
5 * GST_SECOND) != OMX_ErrorNone)
return FALSE;
return FALSE;
/* Need to allocate buffers to reach Idle state */
+#ifdef USE_TBM
+ if(gst_omx_port_tbm_allocate_enc_buffers(self->hTBMBufMgr,self->enc_in_port,
+ self->enc_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
+ return FALSE;
+#else
if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone)
return FALSE;
+#endif
#ifdef EXYNOS_SPECIFIC
/*Specific for exynos processors*/
- if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone)
+ /*if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone)*/
+ if(gst_omx_port_tbm_allocate_enc_buffers(self->hTBMBufMgr,self->enc_out_port,
+ self->enc_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone)
#else
/* And disable output port */
if (gst_omx_port_set_enabled (self->enc_out_port, FALSE) != OMX_ErrorNone)
ret = TRUE;
break;
}
+ case GST_VIDEO_FORMAT_ST12:
case GST_VIDEO_FORMAT_SN12:{
SCMN_IMGB *ext_buf = NULL;
GstMemory* ext_memory = gst_buffer_peek_memory(inbuf, 1);
GST_VIDEO_ENCODER_STREAM_LOCK (self);
goto reconfigure_error;
}
-
+#ifdef USE_TBM
+ err = gst_omx_port_tbm_allocate_enc_buffers(self->hTBMBufMgr,port,
+ self->enc_in_port->port_def.format.video.eCompressionFormat);
+#else
err = gst_omx_port_allocate_buffers (port);
+#endif
if (err != OMX_ErrorNone) {
GST_VIDEO_ENCODER_STREAM_LOCK (self);
goto reconfigure_error;
guint32 quant_b_frames;
GstFlowReturn downstream_flow_ret;
+#ifdef USE_TBM
+ gint drm_fd;
+ tbm_bufmgr hTBMBufMgr;
+#endif
};
struct _GstOMXVideoEncClass
Name: gst-omx
Summary: GStreamer plug-in that allows communication with OpenMAX IL components
Version: 1.0.0
-Release: 1
+Release: 2
License: LGPL-2.1+
Group: Multimedia/Framework
Source0: %{name}-%{version}.tar.gz