From: Sejun Park Date: Thu, 3 Dec 2015 05:24:47 +0000 (+0900) Subject: Upgrade gst-omx to 1.2 with modification X-Git-Tag: submit/tizen/20151207.060420^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3941dc46ea66c5296c4e4acaac6f399f695dfa36;p=platform%2Fupstream%2Fgst-omx.git Upgrade gst-omx to 1.2 with modification Change-Id: I75c8e888965005b50771a951d57eda51e612c6c2 --- diff --git a/config/exynos/gstomx.conf b/config/exynos/gstomx.conf index 0113214..2197382 100755 --- a/config/exynos/gstomx.conf +++ b/config/exynos/gstomx.conf @@ -5,7 +5,8 @@ component-name=OMX.Exynos.MPEG2.Decoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport +src-template-caps=video/x-raw,width=(int)[1,1920],height=(int)[1,1080],framerate=(fraction)[ 0/1, MAX ],stream-format=(string)SN12 [omxdec_mpeg4] type-name=GstOMXMPEG4VideoDec @@ -14,7 +15,8 @@ component-name=OMX.Exynos.MPEG4.Decoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport +src-template-caps=video/x-raw,width=(int)[1,1920],height=(int)[1,1080],framerate=(fraction)[ 0/1, MAX ],stream-format=(string)SN12 [omxdec_h263] type-name=GstOMXH263Dec @@ -23,7 +25,8 @@ component-name=OMX.Exynos.H263.Decoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport +src-template-caps=video/x-raw,width=(int)[1,1920],height=(int)[1,1080],framerate=(fraction)[ 0/1, MAX ],stream-format=(string)SN12 [omxdec_h264] type-name=GstOMXH264Dec @@ -32,7 +35,8 @@ component-name=OMX.Exynos.AVC.Decoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport +src-template-caps=video/x-raw,width=(int)[1,1920],height=(int)[1,1080],framerate=(fraction)[ 0/1, MAX ],stream-format=(string)SN12 [omxdec_vc1] type-name=GstOMXWMVDec @@ -41,7 +45,7 @@ component-name=OMX.Exynos.WMV.Decoder rank=256 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport sink-template-caps=video/x-wmv,wmvversion=(int)3,format=(string){WMV3,WVC1},width=(int)[1,MAX],height=(int)[1,MAX] [omxenc_h264] @@ -51,7 +55,9 @@ component-name=OMX.Exynos.AVC.Encoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-disable-outport;no-component-role +sink-template-caps=video/x-raw, format=(string)SN12, width=(int) [1,1920], height=(int) [1,1080], framerate=(fraction)[0/1, MAX] +src-template-caps=video/x-h264, width=(int) [1,1920], height=(int) [1,1080], framerate=(fraction) [0/1, MAX], alignment=(string) au, stream-format = (string){ avc, byte-stream } [omxenc_mpeg4] type-name=GstOMXMPEG4VideoEnc @@ -60,7 +66,7 @@ component-name=OMX.Exynos.MPEG4.Encoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport [omxenc_h263] type-name=GstOMXH263Enc @@ -69,4 +75,4 @@ component-name=OMX.Exynos.H263.Encoder rank=258 in-port-index=0 out-port-index=1 -hacks=no-component-role +hacks=no-component-role;no-disable-outport diff --git a/configure.ac b/configure.ac index fc29bbd..f523e32 100755 --- a/configure.ac +++ b/configure.ac @@ -221,8 +221,8 @@ AC_ARG_ENABLE(Bsymbolic, LDFLAGS="${SAVED_LDFLAGS}"]) AC_ARG_WITH([omx-target], - AS_HELP_STRING([--with-omx-target],[Use this OpenMAX IL target (generic, bellagio, rpi)]), - [ac_cv_omx_target="$withval"], [ac_cv_omx_target="none"]) + AS_HELP_STRING([--with-omx-target],[Use this OpenMAX IL target (generic, bellagio, rpi, exynos, exynos64)]), + [ac_cv_omx_target="$withval"], [ac_cv_omx_target="generic"]) ac_cv_omx_target_struct_packing="none" AC_MSG_NOTICE([Using $ac_cv_omx_target as OpenMAX IL target]) @@ -237,8 +237,14 @@ case "${ac_cv_omx_target}" in bellagio) AC_DEFINE(USE_OMX_TARGET_BELLAGIO, 1, [Use Bellagio OpenMAX IL target]) ;; - none|*) - AC_ERROR([invalid OpenMAX IL target, you must specify one of --with-omx-target={generic,rpi,bellagio}]) + exynos) + AC_DEFINE(USE_OMX_TARGET_EXYNOS, 1, [Use Exynos OpenMAX IL target]) + ;; + exynos64) + AC_DEFINE(USE_OMX_TARGET_EXYNOS64, 1, [Use Exynos64 OpenMAX IL target]) + ;; + *) + AC_ERROR([invalid OpenMAX IL target]) ;; esac AM_CONDITIONAL(USE_OMX_TARGET_GENERIC, test "x$ac_cv_omx_target" = "xgeneric") @@ -400,6 +406,8 @@ tools/Makefile config/Makefile config/bellagio/Makefile config/rpi/Makefile +config/exynos/Makefile +config/exynos64/Makefile examples/Makefile examples/egl/Makefile m4/Makefile diff --git a/omx/Makefile.am b/omx/Makefile.am old mode 100644 new mode 100755 index 283bb09..e389f72 --- a/omx/Makefile.am +++ b/omx/Makefile.am @@ -76,7 +76,10 @@ libgstomx_la_CFLAGS = \ $(GST_PLUGINS_BASE_CFLAGS) \ $(GST_BASE_CFLAGS) \ $(GST_CFLAGS) \ - $(GMODULE_NO_EXPORT_CFLAGS) + $(TBM_CFLAGS) \ + $(GMODULE_NO_EXPORT_CFLAGS) \ + $(MM_COMMON_CFLAGS) + libgstomx_la_LIBADD = \ $(GST_GL_LIBS) \ $(GST_PLUGINS_BASE_LIBS) \ @@ -85,8 +88,13 @@ libgstomx_la_LIBADD = \ -lgstvideo-@GST_API_VERSION@ \ $(GST_BASE_LIBS) \ $(GST_LIBS) \ - $(GMODULE_NO_EXPORT_LIBS) -libgstomx_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) + $(TBM_LIBS) \ + $(GMODULE_NO_EXPORT_LIBS) \ + $(MM_COMMON_LIBS) +libgstomx_la_LDFLAGS = \ + $(GST_PLUGIN_LDFLAGS) \ + $(TBM_LDFLAGS) \ + $(MM_COMMON_LDFLAGS) EXTRA_DIST = \ openmax \ diff --git a/omx/gstomx.c b/omx/gstomx.c index 2497be0..b55c64d 100755 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -52,8 +52,6 @@ GST_DEBUG_CATEGORY (gstomx_debug); G_LOCK_DEFINE_STATIC (core_handles); static GHashTable *core_handles; - - GstOMXCore * gst_omx_core_acquire (const gchar * filename) { @@ -1639,18 +1637,13 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, buf->used = FALSE; buf->settings_cookie = port->settings_cookie; -#ifdef USE_TBM -#ifdef USE_MM_VIDEO_BUFFER - buf->scmn_buffer = (MMVideoBuffer*) l->data; -#else - buf->scmn_buffer = (SCMN_IMGB*) l->data; -#endif +#ifdef GST_TIZEN_MODIFICATION + buf->mm_vbuffer = (MMVideoBuffer*) l->data; #endif g_ptr_array_add (port->buffers, buf); if (buffers) { - err = OMX_UseBuffer (comp->handle, &buf->omx_buf, port->index, buf, port->port_def.nBufferSize, l->data); @@ -1715,24 +1708,23 @@ gst_omx_port_allocate_buffers (GstOMXPort * port) return err; } -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION /* NOTE: Uses comp->lock and comp->messages_lock */ OMX_ERRORTYPE -gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int eCompressionFormat) +gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr bufMgr, int eCompressionFormat) { - OMX_ERRORTYPE err = OMX_ErrorNone; guint n = 0; - GList *buffers = NULL; -#ifdef USE_MM_VIDEO_BUFFER - MMVideoBuffer *ptr = NULL; -#else - SCMN_IMGB *ptr = NULL; -#endif int y_size = 0; int uv_size = 0; + GList *buffers = NULL; + MMVideoBuffer *ptr = NULL; + GstOMXComponent *comp; + OMX_ERRORTYPE err = OMX_ErrorNone; g_return_val_if_fail (port != NULL, OMX_ErrorUndefined); + comp = port->comp; + g_mutex_lock (&port->comp->lock); /* deallocate previous allocated buffers... */ @@ -1742,70 +1734,43 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int n = port->port_def.nBufferCountActual; for(int i = 0; i < n; i++) { - -#ifdef USE_MM_VIDEO_BUFFER ptr = (MMVideoBuffer*) malloc(sizeof(MMVideoBuffer)); memset(ptr,0,sizeof(MMVideoBuffer)); - if(port->index == 0) { + if(port->index == 0) { ptr->handle.bo[0] = gst_omx_tbm_allocate_bo(bufMgr, port->port_def.nBufferSize); ptr->handle.dmabuf_fd[0] = gst_omx_tbm_get_bo_fd(ptr->handle.bo[0]); ptr->data[0] = gst_omx_tbm_get_bo_ptr(ptr->handle.bo[0]); ptr->size[0] = port->port_def.nBufferSize; ptr->type = MM_VIDEO_BUFFER_TYPE_TBM_BO; + + GST_INFO_OBJECT (comp->parent, + "Allocating %d buffer[%p] for %s port %u", i, + ptr->handle.bo[0], comp->name, (guint) port->index); } else { /* output port */ - y_size = gst_omx_calculate_y_size(eCompressionFormat, - port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight); + port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight); ptr->handle.bo[0] = gst_omx_tbm_allocate_bo(bufMgr, y_size); ptr->handle.dmabuf_fd[0] = gst_omx_tbm_get_bo_fd(ptr->handle.bo[0]); ptr->data[0] = gst_omx_tbm_get_bo_ptr(ptr->handle.bo[0]); ptr->handle.paddr[0] = ptr->data[0]; ptr->size[0] = y_size; - GST_LOG("%s size:[%d]",__FUNCTION__, y_size); - uv_size = gst_omx_calculate_uv_size(eCompressionFormat, - port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight >> 1); + port->port_def.format.video.nStride, port->port_def.format.video.nSliceHeight >> 1); ptr->handle.bo[1] = gst_omx_tbm_allocate_bo(bufMgr, uv_size); ptr->handle.dmabuf_fd[1] = gst_omx_tbm_get_bo_fd(ptr->handle.bo[1]); ptr->data[1] = gst_omx_tbm_get_bo_ptr(ptr->handle.bo[1]); ptr->size[1] = uv_size; ptr->type = MM_VIDEO_BUFFER_TYPE_DMABUF_FD; - GST_ERROR(" fd[0]:%d, bo[0]:%p fd[1]:%d, bo[1]:%p, a[0]:%p",ptr->handle.dmabuf_fd[0],ptr->handle.bo[0],ptr->handle.dmabuf_fd[1],ptr->handle.bo[1], ptr->data[0]); ptr->plane_num = 2; + GST_INFO_OBJECT (comp->parent, + "Allocating %d buffer bo[0]:%p bo[1]:%p fd[0]:%d fd[1]:%d size[0]:%d size[1]:%d for %s port %u", i, + ptr->handle.bo[0], ptr->handle.bo[0], ptr->handle.dmabuf_fd[0], ptr->handle.dmabuf_fd[1], + ptr->size[0], ptr->size[1], comp->name, (guint) port->index); } -#else - ptr = (SCMN_IMGB*) malloc(sizeof(SCMN_IMGB)); - memset(ptr,0,sizeof(SCMN_IMGB)); - if(port->index == 0) { - - ptr->bo[0] = gst_omx_tbm_allocate_bo(bufMgr, port->port_def.nBufferSize); - ptr->fd[0] = gst_omx_tbm_get_bo_fd(ptr->bo[0]); - ptr->a[0] = gst_omx_tbm_get_bo_ptr(ptr->bo[0]); - } - else { /* output port */ - - 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 = 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->y_size = y_size; - ptr->uv_size = uv_size; - ptr->buf_share_method = BUF_SHARE_METHOD_FD; - - } -#endif buffers = g_list_append(buffers,(gpointer)ptr); } @@ -1818,18 +1783,14 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int /* NOTE: Uses comp->lock and comp->messages_lock */ OMX_ERRORTYPE -gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int eCompressionFormat) +gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr bufMgr, int eCompressionFormat) { + int y_size = 0; + int uv_size = 0; OMX_ERRORTYPE err = OMX_ErrorNone; guint n = 0; GList *buffers = NULL; -#ifdef USE_MM_VIDEO_BUFFER MMVideoBuffer *ptr = NULL; -#else - SCMN_IMGB *ptr = NULL; -#endif - int y_size = 0; - int uv_size = 0; g_return_val_if_fail (port != NULL, OMX_ErrorUndefined); @@ -1841,7 +1802,6 @@ gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int n = port->port_def.nBufferCountActual; for(int i = 0; i < n; i++) { -#ifdef USE_MM_VIDEO_BUFFER ptr = (MMVideoBuffer*) malloc(sizeof(MMVideoBuffer)); memset(ptr,0,sizeof(MMVideoBuffer)); if(port->index == 1) { @@ -1853,16 +1813,6 @@ gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int ptr->size[0] = port->port_def.nBufferSize; ptr->handle_num = 1; } -#else - ptr = (SCMN_IMGB*) malloc(sizeof(SCMN_IMGB)); - memset(ptr,0,sizeof(SCMN_IMGB)); - if(port->index == 1) { - - ptr->bo[0] = gst_omx_tbm_allocate_bo(bufMgr, port->port_def.nBufferSize); - ptr->fd[0] = gst_omx_tbm_get_bo_fd(ptr->bo[0]); - ptr->a[0] = gst_omx_tbm_get_bo_ptr(ptr->bo[0]); - } -#endif buffers = g_list_append(buffers,(gpointer)ptr); } @@ -1951,20 +1901,14 @@ gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * port) "port %u", buf, comp->name, port->index); } -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION /* deallocate tbm buffers */ - if(buf->scmn_buffer != NULL) { -#ifdef USE_MM_VIDEO_BUFFER - gst_omx_tbm_deallocate_bo(buf->scmn_buffer->handle.bo[0]); + if(buf->mm_vbuffer != NULL) { + gst_omx_tbm_deallocate_bo(buf->mm_vbuffer->handle.bo[0]); if(port->index == 1) /* output port */ - gst_omx_tbm_deallocate_bo(buf->scmn_buffer->handle.bo[1]); -#else - 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]); -#endif - free(buf->scmn_buffer); - buf->scmn_buffer = NULL; + gst_omx_tbm_deallocate_bo(buf->mm_vbuffer->handle.bo[1]); + free(buf->mm_vbuffer); + buf->mm_vbuffer = NULL; } #endif /* omx_buf can be NULL if allocation failed earlier @@ -2230,7 +2174,7 @@ gst_omx_port_populate_unlocked (GstOMXPort * port) * valid anymore after the buffer was consumed */ buf->omx_buf->nFlags = 0; - GST_ERROR_OBJECT(comp->parent,"Calling OMX_FillThisBuffer. buffer[%p]. function:[%s]",buf->omx_buf,__func__); + GST_DEBUG_OBJECT(comp->parent,"Calling OMX_FillThisBuffer. buffer[%p]. function:[%s]",buf->omx_buf,__func__); err = OMX_FillThisBuffer (comp->handle, buf->omx_buf); if (err != OMX_ErrorNone) { @@ -2674,7 +2618,7 @@ gst_omx_set_default_role (GstOMXClassData * class_data, class_data->component_role = default_role; } -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION int new_calc_plane(int width, int height) { @@ -2743,18 +2687,15 @@ gst_omx_calculate_y_size(int compressionFormat, int width, int height) { case OMX_VIDEO_CodingH263: /* FALL THROUGH */ case OMX_VIDEO_CodingMPEG4: - /*size = calc_yplane(width,height);*/ size = CHOOSE_MAX_SIZE(calc_yplane(width,height),new_calc_yplane(width,height)); break; case OMX_VIDEO_CodingMPEG2: - /*size = calc_yplane(width,height);*/ size = CHOOSE_MAX_SIZE(calc_yplane(width,height),new_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);*/ size = CHOOSE_MAX_SIZE(calc_yplane(width,height),new_calc_yplane(width,height)); GST_LOG("calculating Y size of DEFAULT: height:[%d], width:[%d], size:[%d]",height,width,size); } @@ -2769,17 +2710,14 @@ gst_omx_calculate_uv_size(int compressionFormat, int width, int height) { case OMX_VIDEO_CodingH263: /* FALL THROUGH */ case OMX_VIDEO_CodingMPEG4: - /*size = calc_uvplane(width,height);*/ size = CHOOSE_MAX_SIZE(calc_uvplane(width,height),new_calc_uvplane(width,height)); break; case OMX_VIDEO_CodingMPEG2: - /*size = calc_uvplane(width,height);*/ size = CHOOSE_MAX_SIZE(calc_uvplane(width,height),new_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);*/ size = CHOOSE_MAX_SIZE(calc_uvplane(width,height),new_calc_uvplane(width,height)); GST_LOG("calculating UV size of DEFAULT: height:[%d], width:[%d], size:[%d]",height,width,size); } diff --git a/omx/gstomx.h b/omx/gstomx.h old mode 100644 new mode 100755 index 7695433..c060e56 --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -49,6 +49,12 @@ #include #include +#ifdef USE_OMX_TARGET_EXYNOS +#include +#include +#include +#endif + #ifdef USE_OMX_TARGET_RPI #include #endif @@ -128,59 +134,7 @@ typedef struct _GstOMXMessage GstOMXMessage; /* MODIFICATION */ typedef enum GOmxVendor GOmxVendor; /* check omx vender */ -/* using common scmn_imgb format */ -#define SCMN_IMGB_MAX_PLANE (4) /* max channel count */ - -/* image buffer definition - +------------------------------------------+ --- - | | ^ - | a[], p[] | | - | +---------------------------+ --- | | - | | | ^ | | - | |<---------- w[] ---------->| | | | - | | | | | | - | | | | - | | | h[] | e[] - | | | | - | | | | | | - | | | | | | - | | | v | | - | +---------------------------+ --- | | - | | v - +------------------------------------------+ --- - - |<----------------- s[] ------------------>| -*/ - -typedef struct -{ - int w[SCMN_IMGB_MAX_PLANE]; /* width of each image plane */ - int h[SCMN_IMGB_MAX_PLANE]; /* height of each image plane */ - int s[SCMN_IMGB_MAX_PLANE]; /* stride of each image plane */ - int e[SCMN_IMGB_MAX_PLANE]; /* elevation of each image plane */ - void * a[SCMN_IMGB_MAX_PLANE]; /* user space address of each image plane */ - void * p[SCMN_IMGB_MAX_PLANE]; /* physical address of each image plane, if needs */ - int cs; /* color space type of image */ - int x; /* left postion, if needs */ - int y; /* top position, if needs */ - int __dummy2; /* to align memory */ - int data[16]; /* arbitrary data */ - - int fd[SCMN_IMGB_MAX_PLANE]; /* DMABUF fd of each image plane */ - int buf_share_method; - - int y_size; /* Y plane size in case of ST12 */ - int uv_size; /* UV plane size in case of ST12 */ - //void *bo[SCMN_IMGB_MAX_PLANE]; /* Tizen buffer object of each image plane */ - tbm_bo bo[SCMN_IMGB_MAX_PLANE]; - - void *jpeg_data; /* JPEG data */ - int jpeg_size; /* JPEG size */ - - int tz_enable; /* tzmem buffer */ -} SCMN_IMGB; - -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION #define MFC_INPUT_BUFFER_PLANE 1 #define MFC_OUTPUT_BUFFER_PLANE 2 @@ -209,11 +163,7 @@ struct _TBMInputBuffer struct _TBMOutputBuffer { -#ifdef USE_MM_VIDEO_BUFFER MMVideoBuffer *tbmBuffer[MAX_OUTPUT_BUFFER]; -#else - SCMN_IMGB *tbmBuffer[MAX_OUTPUT_BUFFER]; -#endif OMX_U32 allocatedCount; GList *buffers; }; @@ -248,7 +198,7 @@ enum { OMX_EXT_COLOR_FormatNV12LFdValue = 0x7F000013 }; -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION /* Extended port settings. */ enum { OMX_IndexParamEnablePlatformSpecificBuffers = 0x7F000011 @@ -420,14 +370,9 @@ struct _GstOMXBuffer { /* TRUE if this is an EGLImage */ gboolean eglimage; -#ifdef USE_TBM -#ifdef USE_MM_VIDEO_BUFFER +#ifdef GST_TIZEN_MODIFICATION /* MMVideoBuffer array to use TBM buffers */ - MMVideoBuffer *scmn_buffer; -#else - /* SCMN_IMGB array to use TBM buffers */ - SCMN_IMGB *scmn_buffer; -#endif + MMVideoBuffer *mm_vbuffer; #endif }; @@ -490,9 +435,9 @@ OMX_ERRORTYPE gst_omx_port_set_flushing (GstOMXPort *port, GstClockTime time 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, int eCompressionFormat); -OMX_ERRORTYPE gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int eCompressionFormat); +#ifdef GST_TIZEN_MODIFICATION +OMX_ERRORTYPE gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port, tbm_bufmgr bufMgr, int eCompressionFormat); +OMX_ERRORTYPE gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port, tbm_bufmgr bufMgr, 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); @@ -509,6 +454,50 @@ gboolean gst_omx_port_is_enabled (GstOMXPort * port); void gst_omx_set_default_role (GstOMXClassData *class_data, const gchar *default_role); +#ifdef GST_TIZEN_MODIFICATION + +/*MFC Buffer alignment macros*/ +#define S5P_FIMV_DEC_BUF_ALIGN (8 * 1024) +#define S5P_FIMV_ENC_BUF_ALIGN (8 * 1024) +#define S5P_FIMV_NV12M_HALIGN 16 +#define S5P_FIMV_NV12M_LVALIGN 16 +#define S5P_FIMV_NV12M_CVALIGN 8 +#define S5P_FIMV_NV12MT_HALIGN 128 +#define S5P_FIMV_NV12MT_VALIGN 64 +#define S5P_FIMV_NV12M_SALIGN 2048 +#define S5P_FIMV_NV12MT_SALIGN 8192 + +#define ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1)) + +/* Buffer alignment defines */ +#define SZ_1M 0x00100000 +#define S5P_FIMV_D_ALIGN_PLANE_SIZE 64 + +#define S5P_FIMV_MAX_FRAME_SIZE (2 * SZ_1M) +#define S5P_FIMV_NUM_PIXELS_IN_MB_ROW 16 +#define S5P_FIMV_NUM_PIXELS_IN_MB_COL 16 + +/* Macro */ +#define ALIGN_TO_4KB(x) ((((x) + (1 << 12) - 1) >> 12) << 12) +#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d)) +#define CHOOSE_MAX_SIZE(a,b) ((a) > (b) ? (a) : (b)) + +int new_calc_plane(int width, int height); +int new_calc_yplane(int width, int height); +int new_calc_uvplane(int width, int height); + +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); +OMX_U32 gst_omx_tbm_get_bo_fd(tbm_bo bo); +OMX_PTR gst_omx_tbm_get_bo_ptr(tbm_bo bo); + +#endif /* refered by plugin_init */ GST_DEBUG_CATEGORY_EXTERN (gst_omx_video_debug_category); diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c old mode 100644 new mode 100755 index b57612d..689469e --- a/omx/gstomxbufferpool.c +++ b/omx/gstomxbufferpool.c @@ -415,6 +415,13 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, stride[1] = nstride; offset[1] = offset[0] + stride[0] * nslice; break; + case GST_VIDEO_FORMAT_SN12: + case GST_VIDEO_FORMAT_ST12: + offset[0] = 0; + stride[0] = pool->port->port_def.format.video.nStride; + offset[1] = stride[0] * pool->port->port_def.format.video.nSliceHeight; + stride[1] = pool->port->port_def.format.video.nStride; + break; default: g_assert_not_reached (); break; @@ -440,7 +447,7 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, } } - pool->need_copy = need_copy; + /*pool->need_copy = need_copy;*/ } if (pool->need_copy || pool->add_videometa) { diff --git a/omx/gstomxvideo.c b/omx/gstomxvideo.c old mode 100644 new mode 100755 index f052788..9eb6769 --- a/omx/gstomxvideo.c +++ b/omx/gstomxvideo.c @@ -75,6 +75,11 @@ gst_omx_video_get_format_from_omx (OMX_COLOR_FORMATTYPE omx_colorformat) case OMX_COLOR_Format16bitBGR565: format = GST_VIDEO_FORMAT_BGR16; break; +#ifdef GST_TIZEN_MODIFICATION + case OMX_EXT_COLOR_FormatNV12TPhysicalAddress: + format = GST_VIDEO_FORMAT_SN12; + break; +#endif default: format = GST_VIDEO_FORMAT_UNKNOWN; break; @@ -125,12 +130,12 @@ gst_omx_video_get_supported_colorformats (GstOMXPort * port, m->type = param.eColorFormat; negotiation_map = g_list_append (negotiation_map, m); GST_DEBUG_OBJECT (comp->parent, - "Component supports %s (%d) at index %u", + "Component supports %s (%x) at index %u", gst_video_format_to_string (f), param.eColorFormat, (guint) param.nIndex); } else { GST_DEBUG_OBJECT (comp->parent, - "Component supports unsupported color format %d at index %u", + "Component supports unsupported color format %x at index %u", param.eColorFormat, (guint) param.nIndex); } } diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index a69c327..32012e7 100755 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -24,7 +24,6 @@ #include "config.h" #endif -//#define CODEC_DEC_OUTPUT_DUMP #include #if defined (USE_OMX_TARGET_RPI) && defined(__GNUC__) @@ -47,6 +46,8 @@ #pragma GCC diagnostic pop #endif +//#define CODEC_DEC_OUTPUT_DUMP +#include #include #include "gstomxbufferpool.h" @@ -145,7 +146,7 @@ gst_omx_video_dec_init (GstOMXVideoDec * self) g_mutex_init (&self->drain_lock); g_cond_init (&self->drain_cond); -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION self->hTBMBufMgr = NULL; self->drm_fd = -1; #endif @@ -204,7 +205,7 @@ gst_omx_video_dec_open (GstVideoDecoder * decoder) if (!self->dec_in_port || !self->dec_out_port) return FALSE; -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION self->hTBMBufMgr = tbm_bufmgr_init(self->drm_fd); if(self->hTBMBufMgr == NULL){ @@ -310,7 +311,7 @@ gst_omx_video_dec_shutdown (GstOMXVideoDec * self) gst_omx_component_get_state (self->dec, 5 * GST_SECOND); } -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION /* uninitialize tbm buffer manager */ if(self->hTBMBufMgr != NULL){ tbm_bufmgr_deinit(self->hTBMBufMgr); @@ -451,7 +452,7 @@ decoder_output_dump(GstOMXVideoDec *self, MMVideoBuffer *outbuf) GST_ERROR_OBJECT (self, "codec dec output dump start. w = %d, h = %d", outbuf->width[0], outbuf->height[0]); - sprintf(filename, "/opt/usr/dec_output_dump_%d_%d.yuv", outbuf->stride_width[0], outbuf->height[0]); + sprintf(filename, "/tmp/dec_output_dump_%d_%d.yuv", outbuf->stride_width[0], outbuf->height[0]); fp = fopen(filename, "ab"); for (i = 0; i < outbuf->height[0]; i++) { @@ -511,57 +512,99 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self, #endif //ENS:a /* Different strides */ +#ifndef GST_TIZEN_MODIFICATION if (gst_video_frame_map (&frame, vinfo, outbuf, GST_MAP_WRITE)) { - const guint nstride = port_def->format.video.nStride; - const guint nslice = port_def->format.video.nSliceHeight; - guint src_stride[GST_VIDEO_MAX_PLANES] = { nstride, 0, }; - guint src_size[GST_VIDEO_MAX_PLANES] = { nstride * nslice, 0, }; - gint dst_width[GST_VIDEO_MAX_PLANES] = { 0, }; - gint dst_height[GST_VIDEO_MAX_PLANES] = - { GST_VIDEO_INFO_HEIGHT (vinfo), 0, }; - const guint8 *src; - guint p; - - switch (GST_VIDEO_INFO_FORMAT (vinfo)) { - case GST_VIDEO_FORMAT_ABGR: - case GST_VIDEO_FORMAT_ARGB: - dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 4; - break; - case GST_VIDEO_FORMAT_RGB16: - case GST_VIDEO_FORMAT_BGR16: - case GST_VIDEO_FORMAT_YUY2: - case GST_VIDEO_FORMAT_UYVY: - case GST_VIDEO_FORMAT_YVYU: - dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 2; - break; - case GST_VIDEO_FORMAT_GRAY8: - dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); - break; - case GST_VIDEO_FORMAT_I420: - dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); - src_stride[1] = nstride / 2; - src_size[1] = (src_stride[1] * nslice) / 2; - dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo) / 2; - dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; - src_stride[2] = nstride / 2; - src_size[2] = (src_stride[1] * nslice) / 2; - dst_width[2] = GST_VIDEO_INFO_WIDTH (vinfo) / 2; - dst_height[2] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; - break; - case GST_VIDEO_FORMAT_NV12: - dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); - src_stride[1] = nstride; - src_size[1] = src_stride[1] * nslice / 2; - dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo); - dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; - break; - case GST_VIDEO_FORMAT_NV16: - dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); - src_stride[1] = nstride; - src_size[1] = src_stride[1] * nslice; - dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo); - dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo); +#endif + const guint nstride = port_def->format.video.nStride; + const guint nslice = port_def->format.video.nSliceHeight; + guint src_stride[GST_VIDEO_MAX_PLANES] = { nstride, 0, }; + guint src_size[GST_VIDEO_MAX_PLANES] = { nstride * nslice, 0, }; + gint dst_width[GST_VIDEO_MAX_PLANES] = { 0, }; + gint dst_height[GST_VIDEO_MAX_PLANES] = + { GST_VIDEO_INFO_HEIGHT (vinfo), 0, }; + const guint8 *src; + guint p; + + switch (GST_VIDEO_INFO_FORMAT (vinfo)) { + case GST_VIDEO_FORMAT_ABGR: + case GST_VIDEO_FORMAT_ARGB: + dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 4; + break; + case GST_VIDEO_FORMAT_RGB16: + case GST_VIDEO_FORMAT_BGR16: + case GST_VIDEO_FORMAT_YUY2: + case GST_VIDEO_FORMAT_UYVY: + case GST_VIDEO_FORMAT_YVYU: + dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo) * 2; + break; + case GST_VIDEO_FORMAT_GRAY8: + dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); + break; + case GST_VIDEO_FORMAT_I420: + dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); + src_stride[1] = nstride / 2; + src_size[1] = (src_stride[1] * nslice) / 2; + dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo) / 2; + dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; + src_stride[2] = nstride / 2; + src_size[2] = (src_stride[1] * nslice) / 2; + dst_width[2] = GST_VIDEO_INFO_WIDTH (vinfo) / 2; + dst_height[2] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; + break; + case GST_VIDEO_FORMAT_NV12: + dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); + src_stride[1] = nstride; + src_size[1] = src_stride[1] * nslice / 2; + dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo); + dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo) / 2; + break; + case GST_VIDEO_FORMAT_NV16: + dst_width[0] = GST_VIDEO_INFO_WIDTH (vinfo); + src_stride[1] = nstride; + src_size[1] = src_stride[1] * nslice; + dst_width[1] = GST_VIDEO_INFO_WIDTH (vinfo); + dst_height[1] = GST_VIDEO_INFO_HEIGHT (vinfo); + break; + case GST_VIDEO_FORMAT_SN12: + case GST_VIDEO_FORMAT_ST12:{ + GstMemory *mem_imgb = NULL; + void *imgb_data = NULL; +#ifdef GST_TIZEN_MODIFICATION + MMVideoBuffer *mm_vbuffer = NULL; + mm_vbuffer = (MMVideoBuffer*)(inbuf->omx_buf->pBuffer); + mm_vbuffer->type = MM_VIDEO_BUFFER_TYPE_TBM_BO; + + if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) { + GST_LOG_OBJECT (self, "dec output buf: fd[0]:%d fd[1]:%d fd[2]:%d w[0]:%d h[0]:%d buf_share_method:%d", + mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->handle.dmabuf_fd[2], + mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->type); + } else if (mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS) { + GST_LOG_OBJECT (self, "dec output uses hw addr"); + } else { + GST_WARNING_OBJECT (self, "dec output buf has TBM_BO buf_share_method"); + } +#ifdef CODEC_DEC_OUTPUT_DUMP + decoder_output_dump(self, mm_vbuffer); +#endif +#endif + if (gst_buffer_n_memory(outbuf) < 2) { + imgb_data = g_malloc0(sizeof(*mm_vbuffer)); + mem_imgb = gst_memory_new_wrapped(0, imgb_data, sizeof(*mm_vbuffer), 0, sizeof(*mm_vbuffer), imgb_data, g_free); + gst_buffer_append_memory(outbuf, mem_imgb); + } else { + GstMapInfo imgb_info = GST_MAP_INFO_INIT; + mem_imgb = gst_buffer_peek_memory(outbuf, 1); + gst_memory_map(mem_imgb, &imgb_info, GST_MAP_WRITE); + imgb_data = imgb_info.data; + gst_memory_unmap(mem_imgb, &imgb_info); + } +#ifdef GST_TIZEN_MODIFICATION + memcpy(imgb_data, mm_vbuffer, sizeof(MMVideoBuffer)); +#endif + ret = TRUE; break; + } + default: g_assert_not_reached (); break; @@ -583,12 +626,14 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self, src += src_size[p]; } +#ifndef GST_TIZEN_MODIFICATION gst_video_frame_unmap (&frame); ret = TRUE; } else { GST_ERROR_OBJECT (self, "Can't map output buffer to frame"); goto done; } +#endif done: if (ret) { @@ -689,7 +734,6 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) if (caps) self->out_port_pool = gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->dec, port); - } #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL) if (eglimage) { @@ -851,9 +895,9 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) } was_enabled = FALSE; } -#ifdef USE_TBM - err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port, - self->dec_in_port->port_def.format.video.eCompressionFormat); +#ifdef GST_TIZEN_MODIFICATION + err = gst_omx_port_tbm_allocate_dec_buffers(port, self->hTBMBufMgr, + self->dec_in_port->port_def.format.video.eCompressionFormat); #else err = gst_omx_port_allocate_buffers (port); #endif @@ -887,14 +931,14 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) goto done; } } -#ifdef USE_TBM - err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port, +#ifdef GST_TIZEN_MODIFICATION + err = gst_omx_port_tbm_allocate_dec_buffers(port, self->hTBMBufMgr, self->dec_in_port->port_def.format.video.eCompressionFormat); #else err = gst_omx_port_allocate_buffers (port); #endif /* Can't provide buffers downstream in this case */ - //gst_caps_replace (&caps, NULL); + gst_caps_replace (&caps, NULL); } if (err != OMX_ErrorNone) { @@ -1524,7 +1568,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) GST_OMX_BUFFER_POOL (self->out_port_pool)->current_buffer_index = i; flow_ret = gst_buffer_pool_acquire_buffer (self->out_port_pool, - &outbuf, ¶ms); + &frame->output_buffer, ¶ms); if (flow_ret != GST_FLOW_OK) { flow_ret = gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame); @@ -1533,17 +1577,30 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) goto invalid_buffer; } - if (GST_OMX_BUFFER_POOL (self->out_port_pool)->need_copy) + if (GST_OMX_BUFFER_POOL (self->out_port_pool)->need_copy){ outbuf = copy_frame (&GST_OMX_BUFFER_POOL (self->out_port_pool)->video_info, outbuf); - frame->output_buffer = outbuf; flow_ret = gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame); frame = NULL; buf = NULL; + } else { + if(!gst_omx_video_dec_fill_buffer (self, buf, frame->output_buffer)) { + gst_buffer_replace (&frame->output_buffer, NULL); + flow_ret = + gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame); + frame = NULL; + gst_omx_port_release_buffer (port, buf); + goto invalid_buffer; + } + flow_ret = + gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame); + frame = NULL; + buf = NULL; + } } else { if ((flow_ret = gst_video_decoder_allocate_output_frame (GST_VIDEO_DECODER @@ -1805,9 +1862,9 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self) GstVideoFormat format; GstStructure *s; const gchar *format_str; +#ifdef GST_TIZEN_MODIFICATION gchar *format_tmp; int i; -#ifdef USE_TBM EnableGemBuffersParams gemBuffers; #endif @@ -1904,6 +1961,21 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self) gst_omx_error_to_string (err), err); } + /* set plateform specific gem buffer settings. */ + + /* Set platform specific buffer settings. to avoid plane support error.. */ +#ifdef GST_TIZEN_MODIFICATION + OMX_INIT_STRUCTURE(gemBuffers); + gemBuffers.enable = OMX_TRUE; + gemBuffers.nPortIndex = 1; + err = + 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); + } +#endif gst_caps_unref (intersection); return (err == OMX_ErrorNone); } @@ -2081,12 +2153,13 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, if (needs_disable) { if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone) return FALSE; -#ifdef USE_TBM - if(gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,self->dec_in_port, 0) != OMX_ErrorNone) +#ifdef GST_TIZEN_MODIFICATION + if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone) return FALSE; #else if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; +#endif if ((klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) { if (gst_omx_port_set_enabled (self->dec_out_port, TRUE) != OMX_ErrorNone) @@ -2123,27 +2196,47 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, return FALSE; /* Need to allocate buffers to reach Idle state */ +#ifdef GST_TIZEN_MODIFICATION + if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone) + return FALSE; + if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_out_port, self->hTBMBufMgr, + self->dec_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone) + return FALSE; +#else if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; + if (gst_omx_port_allocate_buffers (self->dec_out_port) != OMX_ErrorNone) + return FALSE; +#endif } else { + if (gst_omx_component_set_state (self->dec, OMX_StateIdle) != OMX_ErrorNone) return FALSE; /* Need to allocate buffers to reach Idle state */ +#ifdef GST_TIZEN_MODIFICATION + if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone) + return FALSE; + if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_out_port, self->hTBMBufMgr, + self->dec_in_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone) + return FALSE; +#else if (gst_omx_port_allocate_buffers (self->dec_in_port) != OMX_ErrorNone) return FALSE; if (gst_omx_port_allocate_buffers (self->dec_out_port) != OMX_ErrorNone) return FALSE; - } +#endif + } if (gst_omx_component_get_state (self->dec, GST_CLOCK_TIME_NONE) != OMX_StateIdle) return FALSE; + if (gst_omx_component_set_state (self->dec, OMX_StateExecuting) != OMX_ErrorNone) return FALSE; - GST_ERROR_OBJECT (self, "\n9. GET COMPONENT STATE\n"); + if (gst_omx_component_get_state (self->dec, GST_CLOCK_TIME_NONE) != OMX_StateExecuting) return FALSE; @@ -2346,8 +2439,8 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, GST_VIDEO_DECODER_STREAM_LOCK (self); goto reconfigure_error; } -#ifdef USE_TBM - err = gst_omx_port_tbm_allocate_dec_buffers(self->hTBMBufMgr,port, +#ifdef GST_TIZEN_MODIFICATION + err = gst_omx_port_tbm_allocate_dec_buffers(port, self->hTBMBufMgr, self->dec_in_port->port_def.format.video.eCompressionFormat); #else err = gst_omx_port_allocate_buffers (port); @@ -2401,21 +2494,17 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, buf->omx_buf->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; buf->omx_buf->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; buf->omx_buf->nFilledLen = gst_buffer_get_size (codec_data);; -#ifdef USE_TBM -#ifdef USE_MM_VIDEO_BUFFER - gst_buffer_extract (codec_data, 0, - buf->scmn_buffer->data[0] + buf->omx_buf->nOffset, - buf->omx_buf->nFilledLen); -#else + +#ifdef GST_TIZEN_MODIFICATION gst_buffer_extract (codec_data, 0, - buf->scmn_buffer->a[0] + buf->omx_buf->nOffset, + buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); -#endif #else gst_buffer_extract (codec_data, 0, buf->omx_buf->pBuffer + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); #endif + if (GST_CLOCK_TIME_IS_VALID (timestamp)) buf->omx_buf->nTimeStamp = gst_util_uint64_scale (timestamp, OMX_TICKS_PER_SECOND, GST_SECOND); @@ -2441,17 +2530,11 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, MIN (size - offset, buf->omx_buf->nAllocLen - buf->omx_buf->nOffset); GST_DEBUG_OBJECT (self, "nFilledLen %d, %p", buf->omx_buf->nFilledLen, buf->omx_buf->pBuffer); -#ifdef USE_TBM -#ifdef USE_MM_VIDEO_BUFFER +#ifdef GST_TIZEN_MODIFICATION gst_buffer_extract (frame->input_buffer, offset, - buf->scmn_buffer->data[0] + buf->omx_buf->nOffset, + buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); #else - gst_buffer_extract (frame->input_buffer, offset, - buf->scmn_buffer->a[0] + buf->omx_buf->nOffset, - buf->omx_buf->nFilledLen); -#endif -#else gst_buffer_extract (frame->input_buffer, offset, buf->omx_buf->pBuffer + buf->omx_buf->nOffset, buf->omx_buf->nFilledLen); diff --git a/omx/gstomxvideodec.h b/omx/gstomxvideodec.h old mode 100644 new mode 100755 index 8e98bf0..4e41796 --- a/omx/gstomxvideodec.h +++ b/omx/gstomxvideodec.h @@ -91,6 +91,10 @@ struct _GstOMXVideoDec gboolean draining; GstFlowReturn downstream_flow_ret; +#ifdef GST_TIZEN_MODIFICATION + gint drm_fd; + tbm_bufmgr hTBMBufMgr; +#endif #ifdef USE_OMX_TARGET_RPI GstOMXComponent *egl_render; GstOMXPort *egl_in_port, *egl_out_port; diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 29cbf4a..66398f0 100755 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -209,7 +209,7 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self) g_mutex_init (&self->drain_lock); g_cond_init (&self->drain_cond); -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION self->hTBMBufMgr = NULL; self->drm_fd = -1; #endif @@ -389,7 +389,7 @@ gst_omx_video_enc_open (GstVideoEncoder * encoder) } } } -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION self->hTBMBufMgr = tbm_bufmgr_init(self->drm_fd); if(self->hTBMBufMgr == NULL){ GST_ERROR_OBJECT (self, "TBM initialization failed."); @@ -755,8 +755,8 @@ 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, +#ifdef GST_TIZEN_MODIFICATION + err = gst_omx_port_tbm_allocate_enc_buffers(port, self->hTBMBufMgr, self->enc_in_port->port_def.format.video.eCompressionFormat); #else err = gst_omx_port_allocate_buffers (port); @@ -1119,10 +1119,8 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, case OMX_EXT_COLOR_FormatNV12LPhysicalAddress: /* FALL THROUGH */ case OMX_EXT_COLOR_FormatNV12TPhysicalAddress: -#ifdef USE_MM_VIDEO_BUFFER +#ifdef GST_TIZEN_MODIFICATION port_def.nBufferSize = sizeof(MMVideoBuffer); -#else - port_def.nBufferSize = sizeof(SCMN_IMGB); #endif break; @@ -1213,14 +1211,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, +#ifdef GST_TIZEN_MODIFICATION + if(gst_omx_port_tbm_allocate_enc_buffers(self->enc_in_port, self->hTBMBufMgr, 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 ((klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) { if (gst_omx_port_set_enabled (self->enc_out_port, TRUE) != OMX_ErrorNone) return FALSE; @@ -1252,6 +1250,7 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, return FALSE; /* Need to allocate buffers to reach Idle state */ + if (gst_omx_port_allocate_buffers (self->enc_in_port) != OMX_ErrorNone) return FALSE; } else { @@ -1260,9 +1259,21 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, return FALSE; /* Need to allocate buffers to reach Idle state */ +#ifdef GST_TIZEN_MODIFICATION + if(gst_omx_port_tbm_allocate_enc_buffers(self->enc_in_port, self->hTBMBufMgr, + 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 GST_TIZEN_MODIFICATION + if(gst_omx_port_tbm_allocate_enc_buffers(self->enc_out_port, self->hTBMBufMgr, + self->enc_out_port->port_def.format.video.eCompressionFormat) != OMX_ErrorNone) +#else if (gst_omx_port_allocate_buffers (self->enc_out_port) != OMX_ErrorNone) +#endif return FALSE; } @@ -1496,54 +1507,39 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf, case GST_VIDEO_FORMAT_SN12:{ GstMemory* ext_memory = gst_buffer_peek_memory(inbuf, 1); GstMapInfo ext_info = GST_MAP_INFO_INIT; -#ifdef USE_MM_VIDEO_BUFFER MMVideoBuffer *ext_buf = NULL; - if (!ext_memory) { - GST_WARNING_OBJECT (self, "null MMVideoBuffer pointer in hw color format. skip this."); - goto done; + + if (!ext_memory) { + GST_WARNING_OBJECT (self, "null MMVideoBuffer pointer in hw color format. skip this."); + goto done; } gst_memory_map(ext_memory, &ext_info, GST_MAP_READ); ext_buf = (MMVideoBuffer*)ext_info.data; gst_memory_unmap(ext_memory, &ext_info); - if (ext_buf != NULL && ext_buf->type == 1) { + + if (ext_buf != NULL && ext_buf->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) { + + if (ext_buf->handle.dmabuf_fd[0] == NULL) + gst_omx_tbm_get_bo_fd(ext_buf->handle.bo[0]); + + if (ext_buf->handle.dmabuf_fd[1] == NULL) + gst_omx_tbm_get_bo_fd(ext_buf->handle.bo[1]); + GST_LOG_OBJECT (self, "enc. fd[0]:%d fd[1]:%d fd[2]:%d w[0]:%d h[0]:%d buf_share_method:%d", ext_buf->handle.dmabuf_fd[0], ext_buf->handle.dmabuf_fd[1], ext_buf->handle.dmabuf_fd[2], ext_buf->width[0], ext_buf->height[0], ext_buf->type); - } else if (ext_buf != NULL && ext_buf->type == 0) { - GST_LOG_OBJECT (self, "enc input buf uses hw addr"); } else { - GST_WARNING_OBJECT (self, "enc input buf has wrong buf_share_method"); + GST_WARNING_OBJECT (self, "enc input buf has wrong buf_share_method[%d]", ext_buf->type); } outbuf->omx_buf->nAllocLen = sizeof(MMVideoBuffer); outbuf->omx_buf->nFilledLen = sizeof(MMVideoBuffer); memcpy (outbuf->omx_buf->pBuffer, ext_buf, sizeof(MMVideoBuffer)); -#else - SCMN_IMGB *ext_buf = NULL; - if (!ext_memory) { - GST_WARNING_OBJECT (self, "null SCMN_IMGB in hw color format. skip this."); - goto done; - } - - gst_memory_map(ext_memory, &ext_info, GST_MAP_READ); - ext_buf = (SCMN_IMGB*)ext_info.data; - gst_memory_unmap(ext_memory, &ext_info); - if (ext_buf != NULL && ext_buf->buf_share_method == 1) { - GST_LOG_OBJECT (self, "enc. fd[0]:%d fd[1]:%d fd[2]:%d w[0]:%d h[0]:%d buf_share_method:%d", - ext_buf->fd[0], ext_buf->fd[1], ext_buf->fd[2], ext_buf->w[0], ext_buf->h[0], ext_buf->buf_share_method); - } else if (ext_buf != NULL && ext_buf->buf_share_method == 0) { - GST_LOG_OBJECT (self, "enc input buf uses hw addr"); - } else { - GST_WARNING_OBJECT (self, "enc input buf has wrong buf_share_method"); - } #ifdef CODEC_ENC_INPUT_DUMP gst_omx_video_enc_input_dump(ext_buf); #endif - outbuf->omx_buf->nAllocLen = sizeof(SCMN_IMGB); - outbuf->omx_buf->nFilledLen = sizeof(SCMN_IMGB); - memcpy (outbuf->omx_buf->pBuffer, ext_buf, sizeof(SCMN_IMGB)); -#endif + ret = TRUE; break; } @@ -1627,8 +1623,8 @@ 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, +#ifdef GST_TIZEN_MODIFICATION + err = gst_omx_port_tbm_allocate_enc_buffers(port, self->hTBMBufMgr, self->enc_in_port->port_def.format.video.eCompressionFormat); #else err = gst_omx_port_allocate_buffers (port); diff --git a/omx/gstomxvideoenc.h b/omx/gstomxvideoenc.h index 8266d84..6dbb1c7 100755 --- a/omx/gstomxvideoenc.h +++ b/omx/gstomxvideoenc.h @@ -76,7 +76,7 @@ struct _GstOMXVideoEnc guint32 quant_b_frames; GstFlowReturn downstream_flow_ret; -#ifdef USE_TBM +#ifdef GST_TIZEN_MODIFICATION gint drm_fd; tbm_bufmgr hTBMBufMgr; #endif diff --git a/packaging/gst-omx.spec b/packaging/gst-omx.spec index b1bd259..13a5aef 100755 --- 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: 6 +Version: 1.2.0 +Release: 0 License: LGPL-2.1+ Group: Multimedia/Framework Source0: %{name}-%{version}.tar.gz @@ -26,7 +26,7 @@ cp %{SOURCE1001} . ./autogen.sh --noconfigure export CFLAGS+=" -DEXYNOS_SPECIFIC" -export CFLAGS+=" -DUSE_TBM" +export CFLAGS+=" -DGST_TIZEN_MODIFICATION" %ifarch aarch64 %configure --disable-static --prefix=/usr --with-omx-target=exynos64