Incorporating review comments. 98/43798/2
authorBarun Kumar Singh <barun.singh@samsung.com>
Tue, 14 Jul 2015 06:36:43 +0000 (12:06 +0530)
committerBarun Kumar Singh <barun.singh@samsung.com>
Tue, 14 Jul 2015 09:22:02 +0000 (14:52 +0530)
Adding MMVideoBuffer support and fixing plane size calculation for H264
Signed-off-by: Barun Kumar Singh <barun.singh@samsung.com>
Change-Id: I7c7a85386a561956d1ea81119ec9b1ac48fc9b26

configure.ac
omx/Makefile.am [changed mode: 0755->0644]
omx/gstomx.c
omx/gstomx.h
omx/gstomxvideodec.c
omx/gstomxvideoenc.c [changed mode: 0755->0644]
packaging/gst-omx.spec

index fbf2769..71dd24b 100644 (file)
@@ -336,6 +336,10 @@ PKG_CHECK_MODULES(TBM, libtbm)
 AC_SUBST(TBM_CFLAGS)
 AC_SUBST(TBM_LIBS)
 
+PKG_CHECK_MODULES(MM_COMMON, mm-common)
+AC_SUBST(MM_COMMON_CFLAGS)
+AC_SUBST(MM_COMMON_LIBS)
+
 AC_CONFIG_FILES(
 Makefile
 omx/Makefile
old mode 100755 (executable)
new mode 100644 (file)
index 3b7f541..b182506
@@ -52,12 +52,16 @@ endif
 
 libgstomx_la_CFLAGS = \
        -DGST_USE_UNSTABLE_API=1 \
+       $(CFLAGS) \
        $(OMX_INCLUDEPATH) \
        $(GST_PLUGINS_BASE_CFLAGS) \
        $(GST_BASE_CFLAGS) \
        $(GST_CFLAGS) \
-       $(TBM_CFLAGS)
-#      $(DRM_SLP_CFLAGS)
+       $(TBM_CFLAGS) \
+       $(MM_COMMON_CFLAGS)
+
+libgstomx_la_CFLAGS += -DUSE_MM_VIDEO_BUFFER
+
 libgstomx_la_LIBADD = \
        $(GST_PLUGINS_BASE_LIBS) \
        -lgstaudio-@GST_API_VERSION@ \
@@ -65,12 +69,13 @@ libgstomx_la_LIBADD = \
        -lgstvideo-@GST_API_VERSION@ \
        $(GST_BASE_LIBS) \
        $(GST_LIBS) \
-       $(TBM_LIBS)
-#      $(DRM_SLP_LIBS)
+       $(TBM_LIBS) \
+       $(MM_COMMON_LIBS)
+
 libgstomx_la_LDFLAGS = \
        $(GST_PLUGIN_LDFLAGS) \
-       $(TBM_LDFLAGS)
-#      $(DRM_SLP_LDFLAGS)
+       $(TBM_LDFLAGS) \
+       $(MM_COMMON_LDFLAGS)
 
 
 EXTRA_DIST = \
index e5b7617..c67d336 100644 (file)
@@ -1662,8 +1662,12 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port,
     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
+#endif
 
     g_ptr_array_add (port->buffers, buf);
 
@@ -1741,7 +1745,11 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int
   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;
 
@@ -1757,6 +1765,43 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int
 
   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) {
+
+          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->handle.paddr[0] = ptr->data[0];
+          ptr->size[0] = port->port_def.nBufferSize;
+          ptr->type = MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS;
+      }
+      else { /* output port */
+
+          y_size = gst_omx_calculate_y_size(eCompressionFormat,
+              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->handle.paddr[0] = gst_omx_tbm_get_bo_ptr(ptr->handle.bo[0]);
+          ptr->data[0] = ptr->handle.paddr[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);
+          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->handle.paddr[1] = ptr->data[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",ptr->handle.dmabuf_fd[0],ptr->handle.bo[0],ptr->handle.dmabuf_fd[1],ptr->handle.bo[1]);
+          ptr->plane_num = 2;
+
+      }
+#else
       ptr = (SCMN_IMGB*) malloc(sizeof(SCMN_IMGB));
       memset(ptr,0,sizeof(SCMN_IMGB));
       if(port->index == 0) {
@@ -1784,12 +1829,9 @@ gst_omx_port_tbm_allocate_dec_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int
           ptr->buf_share_method = BUF_SHARE_METHOD_FD;
 
       }
+#endif
       buffers = g_list_append(buffers,(gpointer)ptr);
   }
-  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);
   err = gst_omx_port_allocate_buffers_unlocked (port, buffers, NULL, n);
@@ -1805,7 +1847,11 @@ gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int
   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;
 
@@ -1819,6 +1865,19 @@ 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) {
+
+          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->handle.paddr[0] = gst_omx_tbm_get_bo_ptr(ptr->handle.bo[0]);
+          ptr->type = MM_VIDEO_BUFFER_TYPE_PHYSICAL_ADDRESS;
+          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) {
@@ -1827,7 +1886,6 @@ gst_omx_port_tbm_allocate_enc_buffers (tbm_bufmgr bufMgr, GstOMXPort * port, int
           ptr->fd[0] = gst_omx_tbm_get_bo_fd(ptr->bo[0]);
           ptr->a[0] = gst_omx_tbm_get_bo_ptr(ptr->bo[0]);
       }
-#if 0
 #endif
       buffers = g_list_append(buffers,(gpointer)ptr);
   }
@@ -1920,10 +1978,15 @@ gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * port)
 #ifdef USE_TBM
     /* 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(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;
     }
@@ -2687,6 +2750,32 @@ gst_omx_set_default_role (GstOMXClassData * class_data,
 
 #ifdef USE_TBM
 
+int new_calc_plane(int width, int height)
+{
+    int mbX, mbY;
+
+    mbX = DIV_ROUND_UP(width, S5P_FIMV_NUM_PIXELS_IN_MB_ROW);
+    mbY = DIV_ROUND_UP(height, S5P_FIMV_NUM_PIXELS_IN_MB_COL);
+
+    if (width * height < S5P_FIMV_MAX_FRAME_SIZE)
+      mbY = (mbY + 1) / 2 * 2;
+
+    return ((mbX * S5P_FIMV_NUM_PIXELS_IN_MB_COL) *
+     (mbY * S5P_FIMV_NUM_PIXELS_IN_MB_ROW));
+}
+
+int new_calc_yplane(int width, int height)
+{
+    return (ALIGN_TO_4KB(new_calc_plane(width, height) +
+              S5P_FIMV_D_ALIGN_PLANE_SIZE));
+}
+
+int new_calc_uvplane(int width, int height)
+{
+    return (ALIGN_TO_4KB((new_calc_plane(width, height) >> 1) +
+              S5P_FIMV_D_ALIGN_PLANE_SIZE));
+}
+
 int
 calc_plane(int width, int height)
 {
@@ -2728,17 +2817,20 @@ 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 = 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 = 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);
-        GST_ERROR("calculating Y size of DEFAULT: height:[%d], width:[%d], size:[%d]",height,width,size);
+        /*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);
     }
     return size;
 }
@@ -2751,15 +2843,18 @@ 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 = 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 = 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 = 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);
     }
     return size;
index 37918a0..b53bc7d 100644 (file)
@@ -26,6 +26,7 @@
 #include <gmodule.h>
 #include <gst/gst.h>
 #include <string.h>
+#include <mm_types.h>
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -198,7 +199,11 @@ 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;
 };
@@ -400,9 +405,14 @@ struct _GstOMXBuffer {
   gboolean eglimage;
 
 #ifdef USE_TBM
+#ifdef USE_MM_VIDEO_BUFFER
+  /* MMVideoBuffer array to use TBM buffers */
+   MMVideoBuffer *scmn_buffer;
+#else
   /* SCMN_IMGB array to use TBM buffers */
   SCMN_IMGB *scmn_buffer;
 #endif
+#endif
 };
 
 struct _GstOMXClassData {
@@ -495,6 +505,23 @@ void              gst_omx_set_default_role (GstOMXClassData *class_data, const g
 
 #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);
index e409d43..c8600ed 100644 (file)
@@ -430,6 +430,7 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
           stride[2] = pool->port->port_def.format.video.nStride / 2;
           break;
         case GST_VIDEO_FORMAT_NV12:
+        case GST_VIDEO_FORMAT_SN12:
         case GST_VIDEO_FORMAT_ST12:
           offset[0] = 0;
           stride[0] = pool->port->port_def.format.video.nStride;
@@ -1150,11 +1151,25 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
       ret = TRUE;
       break;
     }
+    case GST_VIDEO_FORMAT_SN12:
     case GST_VIDEO_FORMAT_ST12:{
-        SCMN_IMGB *out_imgb = NULL;
         GstMemory *mem_imgb = NULL;
         void *imgb_data = NULL;
-
+#ifdef USE_MM_VIDEO_BUFFER
+        MMVideoBuffer *out_imgb = NULL;
+        out_imgb = (MMVideoBuffer*)(inbuf->omx_buf->pBuffer);
+        out_imgb->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
+        if (out_imgb->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",
+                  out_imgb->handle.dmabuf_fd[0], out_imgb->handle.dmabuf_fd[1], out_imgb->handle.dmabuf_fd[2],
+                  out_imgb->width[0], out_imgb->height[0], out_imgb->type);
+        } else if (out_imgb->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");
+        }
+#else
+        SCMN_IMGB *out_imgb = NULL;
         out_imgb = (SCMN_IMGB*)(inbuf->omx_buf->pBuffer);
         if (out_imgb->buf_share_method == BUF_SHARE_METHOD_FD) {
           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",
@@ -1164,6 +1179,7 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
         } else {
           GST_WARNING_OBJECT (self, "dec output buf has wrong buf_share_method");
         }
+#endif
         if (gst_buffer_n_memory(outbuf) < 2) {
             imgb_data = g_malloc0(sizeof(*out_imgb));
             mem_imgb = gst_memory_new_wrapped(0, imgb_data, sizeof(*out_imgb), 0, sizeof(*out_imgb), imgb_data, g_free);
@@ -1175,7 +1191,11 @@ gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
             imgb_data = imgb_info.data;
             gst_memory_unmap(mem_imgb, &imgb_info);
         }
+#ifdef USE_MM_VIDEO_BUFFER
+        memcpy(imgb_data, out_imgb, sizeof(MMVideoBuffer));
+#else
         memcpy(imgb_data, out_imgb, sizeof(SCMN_IMGB));
+#endif
         ret = TRUE;
         break;
     }
@@ -1207,7 +1227,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
 {
   OMX_ERRORTYPE err = OMX_ErrorNone;
   GstOMXPort *port;
-  GstBufferPool *pool;
+  GstBufferPool *pool = NULL;
   GstStructure *config;
   gboolean eglimage = FALSE, add_videometa = FALSE;
   GstCaps *caps = NULL;
@@ -1221,7 +1241,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
   /* FIXME: Enable this once there's a way to request downstream to
    * release all our buffers, e.g.
    * http://cgit.freedesktop.org/~wtay/gstreamer/log/?h=release-pool */
-  if (FALSE && pool) {
+  if (pool) {
     GstAllocator *allocator;
 
     config = gst_buffer_pool_get_config (pool);
@@ -1255,9 +1275,12 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
     GST_DEBUG_OBJECT (self, "No pool available, not negotiated yet");
   }
 
-  if (caps)
+  min = max = port->port_def.nBufferCountMin;
+  if (caps){
+    GST_LOG_OBJECT(self,"gst-omx: Creating our own outport buffer pool. min:[%d], max:[%d]",min,max);
     self->out_port_pool =
         gst_omx_buffer_pool_new (GST_ELEMENT_CAST (self), self->dec, port);
+  }
 
   /* TODO: Implement EGLImage handling and usage of other downstream buffers */
 
@@ -1326,7 +1349,7 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self)
       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) {
@@ -1479,9 +1502,15 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
         format = GST_VIDEO_FORMAT_NV12;
         break;
       case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
-        GST_ERROR_OBJECT (self, "Output is ST12 (%d)",
+#ifdef USE_MM_VIDEO_BUFFER
+        GST_LOG_OBJECT (self, "Output is SN12 (%d)",
+            port_def.format.video.eColorFormat);
+        format = GST_VIDEO_FORMAT_SN12;
+#else
+        GST_LOG_OBJECT (self, "Output is ST12 (%d)",
             port_def.format.video.eColorFormat);
         format = GST_VIDEO_FORMAT_ST12;
+#endif
         break;
       default:
         GST_ERROR_OBJECT (self, "Unsupported color format: %d",
@@ -1629,6 +1658,14 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
         gst_omx_port_release_buffer (port, buf);
         goto invalid_buffer;
       }
+      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;
@@ -1913,11 +1950,19 @@ gst_omx_video_dec_get_supported_colorformats (GstOMXVideoDec * self)
           break;
         case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
             m = g_slice_new (VideoNegotiationMap);
+#ifdef USE_MM_VIDEO_BUFFER
+            m->format = GST_VIDEO_FORMAT_SN12;
+            m->type = param.eColorFormat;
+            negotiation_map = g_list_append (negotiation_map, m);
+            GST_DEBUG_OBJECT (self, "Component supports SN12 (%d) at index %d",
+                param.eColorFormat, param.nIndex);
+#else
             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);
+#endif
             break;
 
         default:
@@ -1946,7 +1991,9 @@ gst_omx_video_dec_negotiate (GstOMXVideoDec * self)
   const gchar *format_str;
   gchar *format_tmp;
   int i;
+#ifdef USE_TBM
   EnableGemBuffersParams gemBuffers;
+#endif
 
   GST_DEBUG_OBJECT (self, "Trying to negotiate a video format with downstream");
 
@@ -2452,6 +2499,10 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
       goto flow_error;
     }
 
+    /* clear codec_data. MFC is not able to handle this in case of mpeg4. */
+    if (self->codec_data)
+      gst_buffer_replace (&self->codec_data, NULL);
+
     if (self->codec_data) {
       GST_DEBUG_OBJECT (self, "Passing codec data to the component");
 
@@ -2467,9 +2518,15 @@ 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
+#ifdef USE_MM_VIDEO_BUFFER
+      gst_buffer_extract (codec_data, 0,
+          buf->scmn_buffer->handle.paddr[0] + buf->omx_buf->nOffset,
+          buf->omx_buf->nFilledLen);
+#else
       gst_buffer_extract (codec_data, 0,
           buf->scmn_buffer->a[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,
@@ -2501,9 +2558,15 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
     GST_DEBUG_OBJECT (self, "nFilledLen %d, %p", buf->omx_buf->nFilledLen, buf->omx_buf->pBuffer);
 
 #ifdef USE_TBM
+#ifdef USE_MM_VIDEO_BUFFER
+     gst_buffer_extract (frame->input_buffer, offset,
+          buf->scmn_buffer->handle.paddr[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,
old mode 100755 (executable)
new mode 100644 (file)
index 640102e..25c1481
@@ -1244,12 +1244,13 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder,
           ((port_def.format.video.nFrameHeight + 1) / 2));
       break;
 
-    case OMX_EXT_COLOR_FormatNV12LPhysicalAddress:
-        port_def.nBufferSize = sizeof(SCMN_IMGB);
-        break;
-
+    case OMX_EXT_COLOR_FormatNV12LPhysicalAddress: /* FALL THROUGH */
     case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
+#ifdef USE_MM_VIDEO_BUFFER
+        port_def.nBufferSize = sizeof(MMVideoBuffer);
+#else
         port_def.nBufferSize = sizeof(SCMN_IMGB);
+#endif
         break;
 
     default:
@@ -1554,9 +1555,32 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
     }
     case GST_VIDEO_FORMAT_ST12:
     case GST_VIDEO_FORMAT_SN12:{
-        SCMN_IMGB *ext_buf = NULL;
         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;
+        }
+
+        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) {
+          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");
+        }
+
+        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;
@@ -1577,6 +1601,7 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf,
         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;
     }
index 401cd9c..88a5d82 100644 (file)
@@ -11,6 +11,7 @@ BuildRequires:  which
 BuildRequires:  pkgconfig(gstreamer-1.0)
 BuildRequires:  pkgconfig(gstreamer-plugins-base-1.0)
 BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(mm-common)
 
 %description
 gst-openmax is a GStreamer plug-in that allows communication with OpenMAX IL components.