#pragma GCC diagnostic pop
#endif
+//#define CODEC_DEC_OUTPUT_DUMP
+#include <stdio.h>
#include <string.h>
#include "gstomxbufferpool.h"
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
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){
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);
return ret;
}
+#ifdef CODEC_DEC_OUTPUT_DUMP /* for decoder output dump */
+static inline void
+decoder_output_dump(GstOMXVideoDec *self, MMVideoBuffer *outbuf)
+{
+ char *temp = (char *)outbuf->data[0];
+ int i = 0;
+ char filename[100]={0};
+ FILE *fp = NULL;
+ int ret =0;
+
+ GST_ERROR_OBJECT (self, "codec dec output dump start. w = %d, h = %d", outbuf->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++) {
+ ret = fwrite(temp, outbuf->width[0], 1, fp);
+ temp += outbuf->stride_width[0];
+ }
+
+ temp = (char *)outbuf->data[1];
+
+ for(i = 0; i < outbuf->height[1]; i++) {
+ ret = fwrite(temp, outbuf->width[1], 1, fp);
+ temp += outbuf->stride_width[1];
+ }
+
+ GST_ERROR_OBJECT (self,"codec dec output dumped!! ret = %d", ret);
+ fclose(fp);
+}
+#endif
+
static gboolean
gst_omx_video_dec_fill_buffer (GstOMXVideoDec * self,
GstOMXBuffer * inbuf, GstBuffer * outbuf)
case GST_VIDEO_FORMAT_ST12:{
GstMemory *mem_imgb = NULL;
void *imgb_data = NULL;
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
MMVideoBuffer *mm_vbuffer = NULL;
mm_vbuffer = (MMVideoBuffer*)(inbuf->omx_buf->pBuffer);
mm_vbuffer->type = MM_VIDEO_BUFFER_TYPE_TBM_BO;
imgb_data = imgb_info.data;
gst_memory_unmap(mem_imgb, &imgb_info);
}
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
memcpy(imgb_data, mm_vbuffer, sizeof(MMVideoBuffer));
#endif
ret = TRUE;
}
was_enabled = FALSE;
}
-#ifdef USE_TBM
+#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
goto done;
}
}
-#ifdef USE_TBM
+#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
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);
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
GstVideoFormat format;
GstStructure *s;
const gchar *format_str;
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
gchar *format_tmp;
int i;
EnableGemBuffersParams gemBuffers;
/* set plateform specific gem buffer settings. */
/* Set platform specific buffer settings. to avoid plane support error.. */
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
OMX_INIT_STRUCTURE(gemBuffers);
gemBuffers.enable = OMX_TRUE;
gemBuffers.nPortIndex = 1;
if (needs_disable) {
if (gst_omx_port_set_enabled (self->dec_in_port, TRUE) != OMX_ErrorNone)
return FALSE;
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
if(gst_omx_port_tbm_allocate_dec_buffers(self->dec_in_port, self->hTBMBufMgr, 0) != OMX_ErrorNone)
return FALSE;
#else
GST_LOG_OBJECT (self, "Negotiation failed, will get output format later");
if (!(klass->cdata.hacks & GST_OMX_HACK_NO_DISABLE_OUTPORT)) {
+#ifndef GST_TIZEN_MODIFICATION
/* Disable output port */
if (gst_omx_port_set_enabled (self->dec_out_port, FALSE) != OMX_ErrorNone)
return FALSE;
if (gst_omx_port_wait_enabled (self->dec_out_port,
1 * GST_SECOND) != OMX_ErrorNone)
return FALSE;
-
+#endif
if (gst_omx_component_set_state (self->dec,
OMX_StateIdle) != OMX_ErrorNone)
return FALSE;
/* Need to allocate buffers to reach Idle state */
-#ifdef USE_TBM
+#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,
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 USE_TBM
+#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,
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)
GST_VIDEO_DECODER_STREAM_LOCK (self);
goto reconfigure_error;
}
-#ifdef USE_TBM
+#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
buf->omx_buf->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME;
buf->omx_buf->nFilledLen = gst_buffer_get_size (codec_data);;
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
gst_buffer_extract (codec_data, 0,
buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
buf->omx_buf->nFilledLen);
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 GST_TIZEN_MODIFICATION
gst_buffer_extract (frame->input_buffer, offset,
buf->mm_vbuffer->data[0] + buf->omx_buf->nOffset,
buf->omx_buf->nFilledLen);
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
}
}
}
-#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.");
err = gst_omx_port_set_enabled (port, TRUE);
if (err != OMX_ErrorNone)
goto reconfigure_error;
-#ifdef USE_TBM
+#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
case OMX_EXT_COLOR_FormatNV12LPhysicalAddress: /* FALL THROUGH */
case OMX_EXT_COLOR_FormatNV12TPhysicalAddress:
-#ifdef USE_TBM
+#ifdef GST_TIZEN_MODIFICATION
port_def.nBufferSize = sizeof(MMVideoBuffer);
#endif
break;
if (needs_disable) {
if (gst_omx_port_set_enabled (self->enc_in_port, TRUE) != OMX_ErrorNone)
return FALSE;
-#ifdef USE_TBM
+#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;
return FALSE;
/* Need to allocate buffers to reach Idle state */
-#ifdef USE_TBM
+#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;
return FALSE;
#endif
-#ifdef USE_TBM
+#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
GST_VIDEO_ENCODER_STREAM_LOCK (self);
goto reconfigure_error;
}
-#ifdef USE_TBM
+#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