From 1ba383679644db3253883fdddb23e47678fcc62a Mon Sep 17 00:00:00 2001 From: Sejun Park Date: Fri, 13 Jul 2018 17:15:14 +0900 Subject: [PATCH] Fix bugs after applying tizen allocator Change-Id: Ie7bee8f11f6a84893181097c7d61d221263730bb --- omx/gstomx.c | 45 ++++++++++++++------------- omx/gstomx.h | 3 ++ omx/gstomxaacdec.c | 0 omx/gstomxaacdec.h | 0 omx/gstomxamrdec.c | 0 omx/gstomxamrdec.h | 0 omx/gstomxanalogaudiosink.c | 0 omx/gstomxanalogaudiosink.h | 0 omx/gstomxaudiodec.c | 0 omx/gstomxaudiodec.h | 0 omx/gstomxaudioenc.c | 0 omx/gstomxaudiosink.c | 0 omx/gstomxaudiosink.h | 0 omx/gstomxbufferpool.c | 75 +++++++++++++++++++++++++++++++++++---------- omx/gstomxbufferpool.h | 0 omx/gstomxh264enc.c | 0 omx/gstomxh264enc.h | 0 omx/gstomxhdmiaudiosink.c | 0 omx/gstomxhdmiaudiosink.h | 0 omx/gstomxmp3dec.c | 0 omx/gstomxmp3dec.h | 0 omx/gstomxvideo.c | 0 omx/gstomxvideo.h | 0 omx/gstomxvideodec.c | 65 +++++++++++++++++++++++++++++++-------- omx/gstomxvideodec.h | 0 omx/gstomxvideoenc.c | 51 ++++++++---------------------- omx/gstomxvideoenc.h | 0 27 files changed, 150 insertions(+), 89 deletions(-) mode change 100755 => 100644 omx/gstomx.c mode change 100755 => 100644 omx/gstomx.h mode change 100755 => 100644 omx/gstomxaacdec.c mode change 100755 => 100644 omx/gstomxaacdec.h mode change 100755 => 100644 omx/gstomxamrdec.c mode change 100755 => 100644 omx/gstomxamrdec.h mode change 100755 => 100644 omx/gstomxanalogaudiosink.c mode change 100755 => 100644 omx/gstomxanalogaudiosink.h mode change 100755 => 100644 omx/gstomxaudiodec.c mode change 100755 => 100644 omx/gstomxaudiodec.h mode change 100755 => 100644 omx/gstomxaudioenc.c mode change 100755 => 100644 omx/gstomxaudiosink.c mode change 100755 => 100644 omx/gstomxaudiosink.h mode change 100755 => 100644 omx/gstomxbufferpool.c mode change 100755 => 100644 omx/gstomxbufferpool.h mode change 100755 => 100644 omx/gstomxh264enc.c mode change 100755 => 100644 omx/gstomxh264enc.h mode change 100755 => 100644 omx/gstomxhdmiaudiosink.c mode change 100755 => 100644 omx/gstomxhdmiaudiosink.h mode change 100755 => 100644 omx/gstomxmp3dec.c mode change 100755 => 100644 omx/gstomxmp3dec.h mode change 100755 => 100644 omx/gstomxvideo.c mode change 100755 => 100644 omx/gstomxvideo.h mode change 100755 => 100644 omx/gstomxvideodec.c mode change 100755 => 100644 omx/gstomxvideodec.h mode change 100755 => 100644 omx/gstomxvideoenc.c mode change 100755 => 100644 omx/gstomxvideoenc.h diff --git a/omx/gstomx.c b/omx/gstomx.c old mode 100755 new mode 100644 index 6b1a23e..affb656 --- a/omx/gstomx.c +++ b/omx/gstomx.c @@ -1735,6 +1735,9 @@ gst_omx_port_allocate_buffers_unlocked (GstOMXPort * port, OMX_UseBuffer (comp->handle, &buf->omx_buf, port->index, buf, port->port_def.nBufferSize, l->data); buf->eglimage = FALSE; +#ifdef TIZEN_FEATURE_OMX + buf->surface = l->data; +#endif } else if (images) { err = OMX_UseEGLImage (comp->handle, &buf->omx_buf, port->index, buf, @@ -1804,11 +1807,10 @@ gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port) gint num = 0; gint i = 0 , j = 0; GList *buffers = NULL; - tbm_surface_h surface[MAX_INPUT_BUFFER]; + tbm_surface_h buffer[MAX_INPUT_BUFFER]; GstOMXComponent *comp; OMX_ERRORTYPE err = OMX_ErrorNone; OMX_CONFIG_RECTTYPE rect; - gpointer buffer; g_return_val_if_fail (port != NULL, OMX_ErrorUndefined); @@ -1835,21 +1837,17 @@ gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port) if (port->use_buffer) { for (i = 0; i < port->port_def.nBufferCountActual; i++) { - surface[i] = tbm_surface_create (rect.nWidth, rect.nHeight, TBM_FORMAT_NV12); - if (!surface[i]) { + buffer[i] = tbm_surface_internal_create_with_flags (rect.nWidth, rect.nHeight, TBM_FORMAT_NV12, TBM_BO_WC); + if (!buffer[i]) { g_mutex_unlock (&port->comp->lock); goto error; } - if (port->index == 0) - buffer = tbm_bo_get_handle (tbm_surface_internal_get_bo (surface[i], 0), TBM_DEVICE_CPU).ptr; - else - buffer = surface[i]; - buffers = g_list_append (buffers, (gpointer) buffer); + buffers = g_list_append (buffers, (gpointer) buffer[i]); GST_INFO_OBJECT (comp->parent, "Allocating %d buffer surface : %p for %s port %u", - i, buffer, comp->name, (guint) port->index); + i, buffer[i], comp->name, (guint) port->index); } } @@ -1863,9 +1861,9 @@ gst_omx_port_tbm_allocate_dec_buffers (GstOMXPort * port) error: for (i = 0; i < port->port_def.nBufferCountActual; i++) { - if (surface[i]) { - tbm_surface_destroy (surface[i]); - surface[i] = NULL; + if (buffer[i]) { + tbm_surface_internal_destroy (buffer[i]); + buffer[i] = NULL; } } g_list_free (buffers); @@ -1881,7 +1879,7 @@ gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port) gint num = 0; GList *buffers = NULL; tbm_bo_handle handle_bo; - tbm_surface_h surface[MAX_INPUT_BUFFER]; + tbm_surface_h buffer[MAX_INPUT_BUFFER]; g_return_val_if_fail (port != NULL, OMX_ErrorUndefined); @@ -1893,12 +1891,14 @@ gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port) if (port->use_buffer) { for (i = 0; i < port->port_def.nBufferCountActual; i++) { - surface[i] = tbm_surface_create (port->port_def.format.video.nFrameWidth, port->port_def.format.video.nFrameHeight, TBM_FORMAT_NV12); - if (!surface[i]) { + buffer[i] = tbm_surface_internal_create_with_flags (port->port_def.format.video.nFrameWidth, + port->port_def.format.video.nFrameHeight, TBM_FORMAT_NV12, TBM_BO_WC); + if (!buffer[i]) { g_mutex_unlock (&port->comp->lock); goto error; } - buffers = g_list_append (buffers, (gpointer) surface[i]); + + buffers = g_list_append (buffers, (gpointer) buffer[i]); } } @@ -1912,9 +1912,9 @@ gst_omx_port_tbm_allocate_enc_buffers (GstOMXPort * port) error: for (i = 0; i < port->port_def.nBufferCountActual; i++) { - if (surface[i]) { - tbm_surface_destroy (surface[i]); - surface[i] = NULL; + if (buffer[i]) { + tbm_surface_internal_destroy (buffer[i]); + buffer[i] = NULL; } } g_list_free (buffers); @@ -2011,7 +2011,10 @@ gst_omx_port_deallocate_buffers_unlocked (GstOMXPort * port) comp->name, buf, buf->omx_buf->pBuffer); tmp = OMX_FreeBuffer (comp->handle, port->index, buf->omx_buf); - +#ifdef TIZEN_FEATURE_OMX + if (buf->surface) + tbm_surface_internal_destroy (buf->surface); +#endif if (tmp != OMX_ErrorNone) { GST_ERROR_OBJECT (comp->parent, "Failed to deallocate buffer %d of %s port %u: %s (0x%08x)", i, diff --git a/omx/gstomx.h b/omx/gstomx.h old mode 100755 new mode 100644 index 4a6641d..e16fbaa --- a/omx/gstomx.h +++ b/omx/gstomx.h @@ -339,6 +339,9 @@ struct _GstOMXBuffer { /* TRUE if this is an EGLImage */ gboolean eglimage; +#ifdef TIZEN_FEATURE_OMX + tbm_surface_h surface; +#endif }; struct _GstOMXClassData { diff --git a/omx/gstomxaacdec.c b/omx/gstomxaacdec.c old mode 100755 new mode 100644 diff --git a/omx/gstomxaacdec.h b/omx/gstomxaacdec.h old mode 100755 new mode 100644 diff --git a/omx/gstomxamrdec.c b/omx/gstomxamrdec.c old mode 100755 new mode 100644 diff --git a/omx/gstomxamrdec.h b/omx/gstomxamrdec.h old mode 100755 new mode 100644 diff --git a/omx/gstomxanalogaudiosink.c b/omx/gstomxanalogaudiosink.c old mode 100755 new mode 100644 diff --git a/omx/gstomxanalogaudiosink.h b/omx/gstomxanalogaudiosink.h old mode 100755 new mode 100644 diff --git a/omx/gstomxaudiodec.c b/omx/gstomxaudiodec.c old mode 100755 new mode 100644 diff --git a/omx/gstomxaudiodec.h b/omx/gstomxaudiodec.h old mode 100755 new mode 100644 diff --git a/omx/gstomxaudioenc.c b/omx/gstomxaudioenc.c old mode 100755 new mode 100644 diff --git a/omx/gstomxaudiosink.c b/omx/gstomxaudiosink.c old mode 100755 new mode 100644 diff --git a/omx/gstomxaudiosink.h b/omx/gstomxaudiosink.h old mode 100755 new mode 100644 diff --git a/omx/gstomxbufferpool.c b/omx/gstomxbufferpool.c old mode 100755 new mode 100644 index 55d5008..01ab671 --- a/omx/gstomxbufferpool.c +++ b/omx/gstomxbufferpool.c @@ -38,7 +38,7 @@ typedef struct _GstOMXMemoryAllocatorClass GstOMXMemoryAllocatorClass; struct _GstOMXMemory { - GstMemory mem; + GstTizenMemory mem; GstOMXBuffer *buf; }; @@ -76,17 +76,48 @@ gst_omx_memory_allocator_free (GstAllocator * allocator, GstMemory * mem) g_slice_free (GstOMXMemory, omem); } +#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 + static gpointer gst_omx_memory_map (GstMemory * mem, gsize maxsize, GstMapFlags flags) { +#ifdef TIZEN_FEATURE_OMX + int err; + gpointer data = NULL; + tbm_surface_info_s info; + GstTizenMemory *tmem = (GstTizenMemory *)mem; + + g_mutex_lock (&tmem->lock); + err = tbm_surface_map (tmem->surface, TBM_SURF_OPTION_WRITE|TBM_SURF_OPTION_READ, &info); + if (err == TBM_SURFACE_ERROR_NONE) + data = info.planes[0].ptr; + g_mutex_unlock (&tmem->lock); + + return data; +#else GstOMXMemory *omem = (GstOMXMemory *) mem; return omem->buf->omx_buf->pBuffer + omem->mem.offset; +#endif } static void gst_omx_memory_unmap (GstMemory * mem) { +#ifdef TIZEN_FEATURE_OMX + GstTizenMemory *tmem = (GstTizenMemory *)mem; + + g_mutex_lock (&tmem->lock); + tbm_surface_unmap (tmem->surface); + g_mutex_unlock (&tmem->lock); +#endif } static GstMemory * @@ -454,10 +485,12 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, #ifdef TIZEN_FEATURE_OMX tbm_surface_h surface; GstMapInfo map; + uint32_t _offset = 0; + uint32_t _stride = 0; surface = (tbm_surface_h) omx_buf->omx_buf->pBuffer; - mem = gst_tizen_allocator_alloc_surface (pool->allocator, &pool->video_info, surface, NULL, NULL); + mem = gst_tizen_allocator_alloc_surface (pool->allocator, &pool->video_info, surface, omx_buf, _destroy_tbm_surface); #else mem = gst_omx_memory_allocator_alloc (pool->allocator, 0, omx_buf); #endif @@ -486,13 +519,17 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, stride[1] = nstride; offset[1] = offset[0] + stride[0] * nslice; break; +#ifdef TIZEN_FEATURE_OMX 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; + tbm_surface_internal_get_plane_data (surface, 0, NULL, &_offset, &_stride); + offset[0] = _offset; + stride[0] = _stride; + tbm_surface_internal_get_plane_data (surface, 1, NULL, &_offset, &_stride); + offset[1] = _offset; + stride[1] = _stride; break; +#endif default: g_assert_not_reached (); break; @@ -527,11 +564,16 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, /* We always add the videometa. It's the job of the user * to copy the buffer if pool->need_copy is TRUE */ - gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE, + GstVideoMeta *meta; + + meta = gst_buffer_add_video_meta_full (buf, GST_VIDEO_FRAME_FLAG_NONE, GST_VIDEO_INFO_FORMAT (&pool->video_info), GST_VIDEO_INFO_WIDTH (&pool->video_info), GST_VIDEO_INFO_HEIGHT (&pool->video_info), GST_VIDEO_INFO_N_PLANES (&pool->video_info), offset, stride); + + meta->map = gst_omx_video_memory_map; + meta->unmap = gst_omx_video_memory_unmap; } } @@ -540,8 +582,8 @@ gst_omx_buffer_pool_alloc_buffer (GstBufferPool * bpool, *buffer = buf; - pool->num_buffers++; - GST_DEBUG_OBJECT (pool, "alloc buffers : %d %d", pool->num_buffers, pool->current_buffer_index); + g_atomic_int_inc (&pool->num_buffers); + GST_DEBUG_OBJECT (pool, "alloc buffers : %p (%d/%d)", buf, pool->current_buffer_index, pool->num_buffers); pool->current_buffer_index++; return GST_FLOW_OK; @@ -565,8 +607,7 @@ gst_omx_buffer_pool_free_buffer (GstBufferPool * bpool, GstBuffer * buffer) GST_BUFFER_POOL_CLASS (gst_omx_buffer_pool_parent_class)->free_buffer (bpool, buffer); - GST_DEBUG_OBJECT (pool, "free buffers : %d %d", pool->num_buffers, pool->current_buffer_index); - pool->num_buffers--; + GST_DEBUG_OBJECT (pool, "free buffers : %p", buffer); } static GstFlowReturn @@ -581,16 +622,16 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool, g_return_val_if_fail (pool->current_buffer_index != -1, GST_FLOW_ERROR); + g_atomic_int_add (&pool->num_buffers, -1); buf = g_ptr_array_index (pool->buffers, pool->current_buffer_index); g_return_val_if_fail (buf != NULL, GST_FLOW_ERROR); *buffer = buf; - pool->num_buffers--; - GST_DEBUG_OBJECT (pool, "acquire buffers : %d %d", pool->num_buffers, pool->current_buffer_index); + GST_DEBUG_OBJECT (pool, "acquire buffers : %p (%d/%d)", buf, pool->current_buffer_index, pool->num_buffers); ret = GST_FLOW_OK; /* If it's our own memory we have to set the sizes */ if (!pool->other_pool) { - GstMemory *mem = gst_buffer_peek_memory (*buffer, 0); + GstMemory *mem = gst_buffer_peek_memory (buf, 0); #ifdef TIZEN_FEATURE_OMX GstOMXBuffer *omx_buf; @@ -603,7 +644,7 @@ gst_omx_buffer_pool_acquire_buffer (GstBufferPool * bpool, && g_strcmp0 (mem->allocator->mem_type, GST_OMX_MEMORY_TYPE) == 0); /* We already have a pointer to the GstOMXBuffer, no need to retrieve it from the qdata */ - omx_buf = ((GstOMXMemory *) mem)->buf; + omx_buf = ((GstTizenMemory *) mem)->user_data; } mem->size = omx_buf->omx_buf->nFilledLen; @@ -640,8 +681,8 @@ gst_omx_buffer_pool_release_buffer (GstBufferPool * bpool, GstBuffer * buffer) gst_omx_buffer_data_quark); if (pool->port->port_def.eDir == OMX_DirOutput && !omx_buf->used) { /* Release back to the port, can be filled again */ - pool->num_buffers++; - GST_DEBUG_OBJECT (pool, "release buffers : %d %d", pool->num_buffers, pool->current_buffer_index); + g_atomic_int_inc (&pool->num_buffers); + GST_DEBUG_OBJECT (pool, "release buffers : %p (%d/%d)", buffer, pool->current_buffer_index, pool->num_buffers); err = gst_omx_port_release_buffer (pool->port, omx_buf); if (err != OMX_ErrorNone) { GST_ELEMENT_ERROR (pool->element, LIBRARY, SETTINGS, (NULL), diff --git a/omx/gstomxbufferpool.h b/omx/gstomxbufferpool.h old mode 100755 new mode 100644 diff --git a/omx/gstomxh264enc.c b/omx/gstomxh264enc.c old mode 100755 new mode 100644 diff --git a/omx/gstomxh264enc.h b/omx/gstomxh264enc.h old mode 100755 new mode 100644 diff --git a/omx/gstomxhdmiaudiosink.c b/omx/gstomxhdmiaudiosink.c old mode 100755 new mode 100644 diff --git a/omx/gstomxhdmiaudiosink.h b/omx/gstomxhdmiaudiosink.h old mode 100755 new mode 100644 diff --git a/omx/gstomxmp3dec.c b/omx/gstomxmp3dec.c old mode 100755 new mode 100644 diff --git a/omx/gstomxmp3dec.h b/omx/gstomxmp3dec.h old mode 100755 new mode 100644 diff --git a/omx/gstomxvideo.c b/omx/gstomxvideo.c old mode 100755 new mode 100644 diff --git a/omx/gstomxvideo.h b/omx/gstomxvideo.h old mode 100755 new mode 100644 diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c old mode 100755 new mode 100644 index 0e546b6..aba21e3 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -86,6 +86,7 @@ static OMX_ERRORTYPE gst_omx_video_dec_deallocate_output_buffers (GstOMXVideoDec * self); #ifdef TIZEN_FEATURE_OMX +static gboolean gst_omx_video_dec_acquire_request_flush_event (GstOMXVideoDec * self, GstEvent ** flush_request_event); static gboolean gst_omx_video_dec_handle_event (GstVideoDecoder * decoder, GstEvent *event); #endif @@ -470,7 +471,7 @@ decoder_output_dump (GstOMXVideoDec *self, Gstbuffer *buffer) { int i = 0; char filename[100]={0}; - FILE *fp = null; + FILE *fp = NULL; tbm_surface_h surface; tbm_surface_info_s info; gstmemory *mem = gst_buffer_peek_memory (buffer, 0); @@ -493,7 +494,7 @@ decoder_output_dump (GstOMXVideoDec *self, Gstbuffer *buffer) return; } - for (i = 0; i < info.hkeight; i++) { + for (i = 0; i < info.height; i++) { fwrite (temp, info.width, 1, fp); temp += info.planes[0].stride; } @@ -972,9 +973,11 @@ gst_omx_video_dec_allocate_output_buffers (GstOMXVideoDec * self) if (caps) { config = gst_buffer_pool_get_config (self->out_port_pool); - if (add_videometa) - gst_buffer_pool_config_add_option (config, - GST_BUFFER_POOL_OPTION_VIDEO_META); +#ifndef TIZEN_FEATURE_OMX + if (add_videometa) +#endif + gst_buffer_pool_config_add_option (config, + GST_BUFFER_POOL_OPTION_VIDEO_META); gst_buffer_pool_config_set_params (config, caps, self->dec_out_port->port_def.nBufferSize, min, max); @@ -1373,6 +1376,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) OMX_ERRORTYPE err; #ifdef TIZEN_FEATURE_OMX GstMessage *msg = NULL; + GstEvent *flush_request_event = NULL; #endif #if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL) @@ -1407,7 +1411,15 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) /* Reallocate all buffers */ if (acq_return == GST_OMX_ACQUIRE_BUFFER_RECONFIGURE && gst_omx_port_is_enabled (port)) { - +#ifdef TIZEN_FEATURE_OMX + if (gst_omx_video_dec_acquire_request_flush_event (self, &flush_request_event)) { + if (!gst_pad_send_event(GST_VIDEO_DECODER_SRC_PAD (self), flush_request_event)) { + GST_ERROR_OBJECT (self, "flush request event doesn't send"); + flush_request_event = NULL; + goto reconfigure_error; + } + } +#endif err = gst_omx_port_set_enabled (port, FALSE); if (err != OMX_ErrorNone) goto reconfigure_error; @@ -1561,16 +1573,18 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) outbuf = copy_frame (&GST_OMX_BUFFER_POOL (self->out_port_pool)->video_info, outbuf); - } else { outbuf = gst_video_decoder_allocate_output_buffer (GST_VIDEO_DECODER (self)); + if (!gst_omx_video_dec_fill_buffer (self, buf, outbuf)) { gst_buffer_unref (outbuf); gst_omx_port_release_buffer (port, buf); goto invalid_buffer; } } + + flow_ret = gst_pad_push (GST_VIDEO_DECODER_SRC_PAD (self), outbuf); } else if (buf->omx_buf->nFilledLen > 0 || buf->eglimage) { if (self->out_port_pool) { @@ -1591,6 +1605,7 @@ gst_omx_video_dec_loop (GstOMXVideoDec * self) flow_ret = gst_buffer_pool_acquire_buffer (self->out_port_pool, &frame->output_buffer, ¶ms); + if (flow_ret != GST_FLOW_OK) { flow_ret = gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame); @@ -1599,16 +1614,16 @@ 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; + frame->output_buffer = outbuf; - flow_ret = + flow_ret = gst_video_decoder_finish_frame (GST_VIDEO_DECODER (self), frame); - frame = NULL; - buf = NULL; + frame = NULL; + buf = NULL; } else { if (!gst_omx_video_dec_fill_buffer (self, buf, frame->output_buffer)) { gst_buffer_replace (&frame->output_buffer, NULL); @@ -2812,6 +2827,32 @@ gst_omx_video_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query) #ifdef TIZEN_FEATURE_OMX static gboolean +gst_omx_video_dec_acquire_request_flush_event (GstOMXVideoDec * self, GstEvent ** flush_request_event) +{ + GstEvent *event; + + GST_DEBUG_OBJECT (self, "flush buffer request"); + + if (self->out_port_pool) { + if (gst_buffer_pool_is_active(self->out_port_pool)) { + event = gst_event_new_custom(GST_EVENT_CUSTOM_DOWNSTREAM, + gst_structure_new_empty("tizen/flush-buffer")); + + *flush_request_event = event; + + GST_DEBUG_OBJECT (self, "flush buffer requested"); + return TRUE; + } else { + GST_DEBUG_OBJECT (self, "the out port pool has not yet been activated"); + return FALSE; + } + } else { + GST_DEBUG_OBJECT (self, "the output port has not yet been activated"); + return FALSE; + } +} + +static gboolean gst_omx_video_dec_handle_event (GstVideoDecoder * decoder, GstEvent * event) { diff --git a/omx/gstomxvideodec.h b/omx/gstomxvideodec.h old mode 100755 new mode 100644 diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c old mode 100755 new mode 100644 index 8e2f179..5ffcabc --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -212,11 +212,11 @@ gst_omx_video_enc_init (GstOMXVideoEnc * self) g_mutex_init (&self->drain_lock); g_cond_init (&self->drain_cond); } -/* + #ifdef CODEC_ENC_INPUT_DUMP static inline void -gst_omx_video_enc_input_dump (MMVideoBuffer *inbuf) +gst_omx_video_enc_input_dump (GstBuffer *inbuf) { char *temp = (char *)inbuf->data[0]; int i = 0; @@ -243,7 +243,7 @@ gst_omx_video_enc_input_dump (MMVideoBuffer *inbuf) fclose(fp); } #endif -*/ + static gboolean gst_omx_video_enc_open (GstVideoEncoder * encoder) { @@ -1552,48 +1552,21 @@ gst_omx_video_enc_fill_buffer (GstOMXVideoEnc * self, GstBuffer * inbuf, ret = TRUE; break; } -/* +#ifdef TIZEN_FEATURE_OMX case GST_VIDEO_FORMAT_ST12: - case GST_VIDEO_FORMAT_SN12: - { - GstMemory* ext_memory = gst_buffer_peek_memory(inbuf, 1); - GstMapInfo ext_info = GST_MAP_INFO_INIT; - MMVideoBuffer *mm_vbuffer = 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); - mm_vbuffer = (MMVideoBuffer*)ext_info.data; - gst_memory_unmap(ext_memory, &ext_info); - - if (mm_vbuffer != NULL && mm_vbuffer->type == MM_VIDEO_BUFFER_TYPE_TBM_BO) { - mm_vbuffer->handle.dmabuf_fd[0] = tbm_bo_get_handle (mm_vbuffer->handle.bo[0], TBM_DEVICE_MM).u32; - mm_vbuffer->handle.dmabuf_fd[1] = tbm_bo_get_handle (mm_vbuffer->handle.bo[1], TBM_DEVICE_MM).u32; - mm_vbuffer->data[0] = tbm_bo_get_handle (mm_vbuffer->handle.bo[0], TBM_DEVICE_CPU).ptr; - mm_vbuffer->data[1] = tbm_bo_get_handle (mm_vbuffer->handle.bo[1], TBM_DEVICE_CPU).ptr; - - GST_LOG_OBJECT (self, "enc. fd[0]:%d fd[1]:%d a[0]:%p, a[1]:%p, w[0]:%d h[0]:%d %d, %d, buf_share_method:%d", - mm_vbuffer->handle.dmabuf_fd[0], mm_vbuffer->handle.dmabuf_fd[1], mm_vbuffer->data[0], mm_vbuffer->data[1], - mm_vbuffer->width[0], mm_vbuffer->height[0], mm_vbuffer->width[1], mm_vbuffer->height[1], mm_vbuffer->type); - - outbuf->omx_buf->nAllocLen = sizeof (MMVideoBuffer); - outbuf->omx_buf->nFilledLen = sizeof (MMVideoBuffer); - memcpy (outbuf->omx_buf->pBuffer, mm_vbuffer, sizeof (MMVideoBuffer)); - } else { - GST_WARNING_OBJECT (self, "enc input has wrong buf"); - } - + case GST_VIDEO_FORMAT_SN12: { + GstMemory *mem = gst_buffer_peek_memory (inbuf, 0); + outbuf->omx_buf->pBuffer = gst_tizen_memory_get_surface (mem); + outbuf->omx_buf->nAllocLen = tbm_surface_internal_get_size (gst_tizen_memory_get_surface (mem)); + outbuf->omx_buf->nFilledLen = tbm_surface_internal_get_size (gst_tizen_memory_get_surface (mem)); #ifdef CODEC_ENC_INPUT_DUMP - gst_omx_video_enc_input_dump(mm_vbuffer); + gst_omx_video_enc_input_dump (inbuf); #endif - ret = TRUE; break; } -*/ +#endif + default: GST_ERROR_OBJECT (self, "Unsupported format"); goto done; diff --git a/omx/gstomxvideoenc.h b/omx/gstomxvideoenc.h old mode 100755 new mode 100644 -- 2.7.4