omxdecoder: Fix crash and blocking issue 27/274827/3 accepted/tizen/unified/20220512.144515 submit/tizen/20220512.075702
authorJeongmo Yang <jm80.yang@samsung.com>
Tue, 10 May 2022 06:38:14 +0000 (15:38 +0900)
committerJeongmo Yang <jm80.yang@samsung.com>
Thu, 12 May 2022 07:32:03 +0000 (16:32 +0900)
- Set proper foreign memory mode
- Set valid video info when start decoding
- Set valid pointer for tbm surface
- Remove duplicated release code for tbm surface
- Exclude upstream code to set omx buffer flag

[Version] 1.20.0-22
[Issue Type] Bug fix

Change-Id: I48bb2a68d7ba52c8bf37688b64a127d59c679462
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
packaging/gstreamer.spec
subprojects/gst-omx/omx/gstomx.c
subprojects/gst-omx/omx/gstomxallocator.c
subprojects/gst-omx/omx/gstomxbufferpool.c
subprojects/gst-omx/omx/gstomxvideodec.c

index 1c0a79b..605aa02 100644 (file)
@@ -60,7 +60,7 @@
 
 Name:           %{_name}
 Version:        1.20.0
-Release:        21
+Release:        22
 Summary:        Streaming-Media Framework Runtime
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
index 1e12150..b3a100b 100644 (file)
@@ -3134,8 +3134,11 @@ gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * port)
 
       tmp = OMX_FreeBuffer (comp->handle, port->index, buf->omx_buf);
 #ifdef TIZEN_FEATURE_OMX
-      if (buf->surface)
+      if (buf->surface) {
+        GST_INFO_OBJECT (comp->parent, "destroy surface %p", buf->surface);
         tbm_surface_internal_destroy (buf->surface);
+        buf->surface = NULL;
+      }
 #endif
       if (tmp != OMX_ErrorNone) {
         GST_ERROR_OBJECT (comp->parent,
index f625d9b..030e7b4 100644 (file)
@@ -437,15 +437,6 @@ beach:
   return ret;
 }
 
-#ifdef TIZEN_FEATURE_OMX
-static void
-_destroy_tbm_surface (tbm_surface_h surface)
-{
-  GST_DEBUG ("destroy surface %p", surface);
-  tbm_surface_internal_destroy (surface);
-}
-#endif
-
 /* installed as the GstMiniObject::dispose function of the acquired GstMemory */
 static gboolean
 gst_omx_allocator_memory_dispose (GstMemory * mem)
@@ -544,7 +535,10 @@ gst_omx_allocator_allocate (GstOMXAllocator * allocator, gint index,
     {
       tbm_surface_h surface = (tbm_surface_h) omx_buf->omx_buf->pBuffer;
       mem->foreign_mem = gst_tizen_allocator_alloc_surface (allocator->foreign_allocator,
-        &allocator->video_info, surface, omx_buf, (GDestroyNotify)_destroy_tbm_surface);
+          &allocator->video_info, surface, NULL, NULL);
+      gst_mini_object_set_qdata (GST_MINI_OBJECT (mem->foreign_mem),
+          GST_OMX_MEMORY_QUARK, mem, NULL);
+      install_mem_dispose (mem);
       break;
     }
 #endif
index 2b10353..34ef158 100644 (file)
@@ -218,10 +218,18 @@ gst_omx_buffer_pool_start (GstBufferPool * bpool)
   else if (pool->output_mode == GST_OMX_BUFFER_MODE_DMABUF)
     /* Exporting dmabuf */
     mode = GST_OMX_ALLOCATOR_FOREIGN_MEM_DMABUF;
+#ifdef TIZEN_FEATURE_OMX
+  else if (pool->output_mode == GST_OMX_BUFFER_MODE_TBM)
+    /* TizenBufferManager */
+    mode = GST_OMX_ALLOCATOR_FOREIGN_MEM_TBM;
+#endif
   else
     /* Exporting normal buffers */
     mode = GST_OMX_ALLOCATOR_FOREIGN_MEM_NONE;
 
+#ifdef TIZEN_FEATURE_OMX
+  GST_INFO_OBJECT (bpool, "foreign memory mode %d", mode);
+#endif
   if (!gst_omx_allocator_configure (pool->allocator, min, mode))
     return FALSE;
 
@@ -314,6 +322,9 @@ gst_omx_buffer_pool_set_config (GstBufferPool * bpool, GstStructure * config)
         GST_BUFFER_POOL_OPTION_VIDEO_META);
 
     pool->video_info = info;
+#ifdef TIZEN_FEATURE_OMX
+    pool->allocator->video_info = pool->video_info;
+#endif
   }
 
   if (pool->caps)
@@ -412,7 +423,8 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
     gsize offset[GST_VIDEO_MAX_PLANES] = { 0, };
     gint stride[GST_VIDEO_MAX_PLANES] = { nstride, 0, };
 #ifdef TIZEN_FEATURE_OMX
-    tbm_surface_h surface = NULL;
+    GstOMXBuffer *omx_buf = g_ptr_array_index (pool->allocator->port->buffers, pool->current_buffer_index);
+    tbm_surface_h surface = (tbm_surface_h) omx_buf->omx_buf->pBuffer;
     uint32_t _offset = 0;
     uint32_t _stride = 0;
 #endif
@@ -446,9 +458,16 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool,
       case GST_VIDEO_FORMAT_SN12:
       case GST_VIDEO_FORMAT_ST12:
         tbm_surface_internal_get_plane_data (surface, 0, NULL, &_offset, &_stride);
+
+        GST_INFO_OBJECT (pool, "[%p] plane[0] offset[%u], stride[%u]", surface, _offset, _stride);
+
         offset[0] = _offset;
         stride[0] = _stride;
+
         tbm_surface_internal_get_plane_data (surface, 1, NULL, &_offset, &_stride);
+
+        GST_INFO_OBJECT (pool, "[%p] plane[1] offset[%u], stride[%u]", surface, _offset, _stride);
+
         offset[1] = _offset;
         stride[1] = _stride;
         break;
@@ -748,7 +767,7 @@ gst_omx_buffer_pool_new (GstElement * element, GstOMXComponent * component,
   pool->output_mode = output_mode;
   pool->allocator = gst_omx_allocator_new (component, port);
 #ifdef TIZEN_FEATURE_OMX
-  pool->allocator->video_info = pool->video_info;
+  GST_INFO_OBJECT (pool, "output mode %d", pool->output_mode);
 #endif
 
   g_signal_connect_object (pool->allocator, "omxbuf-released",
index 573e1c9..1e0a781 100644 (file)
@@ -1871,12 +1871,6 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self)
   port = self->dec_out_port;
 #endif
 
-#if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
-  port = self->eglimage ? self->egl_out_port : self->dec_out_port;
-#else
-  port = self->dec_out_port;
-#endif
-
   acq_return = gst_omx_port_acquire_buffer (port, &buf, GST_OMX_WAIT);
   if (acq_return == GST_OMX_ACQUIRE_BUFFER_ERROR) {
     goto component_error;
@@ -3410,8 +3404,12 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder,
     if (first_ouput_buffer && GST_VIDEO_CODEC_FRAME_IS_SYNC_POINT (frame))
       buf->omx_buf->nFlags |= OMX_BUFFERFLAG_SYNCFRAME;
 
+#ifndef TIZEN_FEATURE_OMX
+    /* This was added from upstream,
+       but it causes blocking issue when seek on TW3 target. */
     if (header)
       buf->omx_buf->nFlags |= OMX_BUFFERFLAG_CODECCONFIG;
+#endif
 
     /* TODO: Set flags
      *   - OMX_BUFFERFLAG_DECODEONLY for buffers that are outside