From: Barun Kumar Singh Date: Mon, 18 May 2015 11:19:01 +0000 (+0530) Subject: Incorporating MPEG2 review comments. X-Git-Tag: submit/tizen/20150520.110617~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=693bc4091d8cf1b2c38e21c43885a93b34986832;p=platform%2Fupstream%2Fgst-omx.git Incorporating MPEG2 review comments. Enabling h264 encoder. Removing unnecessary commented code. Signed-off-by: Barun Kumar Singh Change-Id: Ibe9ac74078bcb96d2b0c4b7f857dfe93b7b7dce0 --- diff --git a/config/odroid/gstomx.conf b/config/odroid/gstomx.conf index 5b1cbc2..5675d97 100755 --- a/config/odroid/gstomx.conf +++ b/config/odroid/gstomx.conf @@ -1,3 +1,12 @@ +[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 diff --git a/configure.ac b/configure.ac index 3125eb4..8f33a99 100644 --- a/configure.ac +++ b/configure.ac @@ -206,6 +206,9 @@ case "${ac_cv_omx_target}" in 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]) ;; @@ -213,6 +216,7 @@ esac 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)]), @@ -325,6 +329,33 @@ AC_SUBST(GST_PLUGIN_LDFLAGS) 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 diff --git a/omx/gstomx.c b/omx/gstomx.c index 849933b..ff9c240 100644 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1418,10 +1418,10 @@ gst_omx_port_release_buffer (GstOMXPort * port, GstOMXBuffer * buf) 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 " @@ -1705,7 +1705,7 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, 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); @@ -1742,7 +1742,7 @@ gst_omx_port_allocate_buffers (GstOMXPort * port) #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; @@ -1755,15 +1755,16 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port) 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); @@ -1772,12 +1773,14 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port) } 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]); @@ -1786,11 +1789,12 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port) 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); @@ -1885,6 +1889,8 @@ gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * port) 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 @@ -2679,6 +2685,43 @@ calc_uvplane(int width, int height) 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) { diff --git a/omx/gstomx.h b/omx/gstomx.h index 97537a6..5508123 100644 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -462,7 +462,8 @@ gboolean gst_omx_port_is_flushing (GstOMXPort *port); 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); @@ -497,6 +498,8 @@ void gst_omx_set_default_role (GstOMXClassData *class_data, const g 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); diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index 37edd8f..7073a5a 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -1291,10 +1291,9 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) 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) { @@ -1321,10 +1320,9 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) } } #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 */ @@ -2049,14 +2047,14 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self) /* set plateform specific gem buffer settings. */ - /* Set platform specific buffer settings. to avoid plane support error.. */ -#ifdef USE_TBM - OMX_INIT_STRUCTURE(gemBuffers); - gemBuffers.enable = OMX_TRUE; - gemBuffers.nPortIndex = 1; + /* 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, - OMX_IndexParamEnablePlatformSpecificBuffers,&gemBuffers); + 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); @@ -2195,15 +2193,12 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, 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 @@ -2222,23 +2217,19 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, 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 @@ -2252,11 +2243,9 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, 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; @@ -2267,9 +2256,7 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, } /* 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) { @@ -2279,7 +2266,6 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, return FALSE; } - //GST_ERROR_OBJECT (self, "\n12. STARTING TASK AGAIN\n"); /* Start the srcpad loop again */ GST_DEBUG_OBJECT (self, "Starting task again"); @@ -2426,7 +2412,8 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, 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 @@ -2480,7 +2467,6 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, 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); @@ -2489,7 +2475,6 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, 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); @@ -2518,7 +2503,6 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, /*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); @@ -2527,7 +2511,6 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, 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); diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 8489703..640102e 100755 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -211,6 +211,10 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self) 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 @@ -357,7 +361,13 @@ gst_omx_video_enc_open (GstVideoEncoder * encoder) } } } - +#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; } @@ -810,8 +820,12 @@ gst_omx_video_enc_loop (GstOMXVideoEnc * self) 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; @@ -1091,6 +1105,14 @@ gst_omx_video_enc_get_supported_colorformats (GstOMXVideoEnc * self) 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", @@ -1226,6 +1248,10 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, port_def.nBufferSize = sizeof(SCMN_IMGB); break; + case OMX_EXT_COLOR_FormatNV12TPhysicalAddress: + port_def.nBufferSize = sizeof(SCMN_IMGB); + break; + default: g_assert_not_reached (); } @@ -1260,8 +1286,14 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, 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; @@ -1272,12 +1304,20 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, 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) @@ -1512,6 +1552,7 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf, 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); @@ -1626,8 +1667,12 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder, 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; diff --git a/omx/gstomxvideoenc.h b/omx/gstomxvideoenc.h index d17ea27..9ac7f17 100755 --- a/omx/gstomxvideoenc.h +++ b/omx/gstomxvideoenc.h @@ -79,6 +79,10 @@ struct _GstOMXVideoEnc guint32 quant_b_frames; GstFlowReturn downstream_flow_ret; +#ifdef USE_TBM + gint drm_fd; + tbm_bufmgr hTBMBufMgr; +#endif }; struct _GstOMXVideoEncClass diff --git a/packaging/gst-omx.spec b/packaging/gst-omx.spec index d6e22ee..4f72867 100644 --- a/packaging/gst-omx.spec +++ b/packaging/gst-omx.spec @@ -1,7 +1,7 @@ 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