aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprasanth kamuju <prasanth.kamuju@linaro.org>2014-09-09 10:14:15 +0530
committerprasanth kamuju <prasanth.kamuju@linaro.org>2014-09-09 10:14:15 +0530
commit7238cdc96b628b12ada2accbf0b3a6be5f377765 (patch)
treeb0f4c83009adcda679c416d1a6586661a3a994e1
parent266a1a3a8ab6a60049d958dc638d9521b93ed9e9 (diff)
Handle End Of Stream
Receive already decoded buffers once EOS is reached
-rw-r--r--src/gstqcvideodec.c71
1 files changed, 55 insertions, 16 deletions
diff --git a/src/gstqcvideodec.c b/src/gstqcvideodec.c
index 0272f16..5a2239f 100644
--- a/src/gstqcvideodec.c
+++ b/src/gstqcvideodec.c
@@ -109,6 +109,7 @@ static gboolean gst_qcvideodec_set_format (GstVideoDecoder * decoder,GstVideoCod
static gboolean gst_qcvideodec_close (GstVideoDecoder * decoder);
static GstFlowReturn gst_qcvideodec_handle_frame (GstVideoDecoder * decoder,GstVideoCodecFrame * frame);
static GstFlowReturn gst_qcvideodec_finish (GstVideoDecoder * decoder);
+//static GstFlowReturn gst_qcvideodec_parse(GstVideoDecoder *decoder,GstVideoCodecFrame *frame,GstAdapter *adapter,gboolean at_eos);
static void* video_thread (void *);
static void* async_thread (void *);
@@ -119,13 +120,47 @@ int free_buffer ( enum vdec_buffer buffer_dir,Gstqcvideodec *decoder_context);
int reconfig =0;
static struct vdec_bufferpayload *temp_input_buffer = NULL;
-
-static GstFlowReturn gst_qcvideodec_finish (GstVideoDecoder * decoder)
+gboolean Completed_frm_decode = FALSE;
+static GstFlowReturn gst_qcvideodec_finish(GstVideoDecoder *decoder)
{
-
- g_print("\n\ngst_qcvideodec_finish ***************-----------------****************\n\n");
+ int i =0;
+ struct vdec_input_frameinfo frameinfo;
+ Gstqcvideodec *dec = GST_QCVIDEODEC (decoder);
+ struct vdec_ioctl_msg ioctl_msg = {NULL,NULL};
+
+ GST_VIDEO_DECODER_STREAM_UNLOCK (dec);
+
+ for(i=0;i<dec->output_buffer.mincount;i++)
+ {
+ GST_VIDEO_DECODER_STREAM_LOCK (dec);
+ frameinfo.flags |= VDEC_BUFFERFLAG_EOS;
+ frameinfo.bufferaddr = temp_input_buffer->bufferaddr;
+ frameinfo.offset = 0;
+ frameinfo.pmem_fd = temp_input_buffer->pmem_fd;
+ frameinfo.pmem_offset = temp_input_buffer->offset;
+ frameinfo.datalen = 0;
+ frameinfo.client_data = (struct vdec_bufferpayload *)\
+ temp_input_buffer;
+
+ ioctl_msg.in = &frameinfo;
+ ioctl_msg.out = NULL;
+ if(Completed_frm_decode == TRUE)
+ {
+ g_print("\n\nReceived all the decoded output buffers : ");
+ GST_VIDEO_DECODER_STREAM_UNLOCK (dec);
+ break;
+ }
+ if (ioctl(dec->video_driver_fd,VDEC_IOCTL_DECODE_FRAME,
+ &ioctl_msg) < 0)
+ {
+ g_print("\n\nVDEC_IOCTL_DECODE_FRAME Failed \n");
+ break;
+ }
+ GST_VIDEO_DECODER_STREAM_UNLOCK (dec);
+ sem_wait(&dec->sem_input_buf_done);
+ }/* for loop */
+ g_print("\n\ngst_qcvideodec_finish returned :: \n");
return GST_FLOW_OK;
-
}
static gboolean gst_qcvideodec_open (GstVideoDecoder * decoder)
@@ -982,12 +1017,12 @@ static void* video_thread (void *context)
struct vdec_fillbuffer_cmd fillbuffer;
struct vdec_output_frameinfo *outputbuffer = NULL;
struct vdec_bufferpayload *tempbuffer = NULL;
- int first_frm = 0;
GstMapInfo map = GST_MAP_INFO_INIT;
GstFlowReturn ret = GST_FLOW_OK;
GstVideoDecoder *decoder_cxt = (GstVideoDecoder *)context;
Gstqcvideodec *decode_context = GST_QCVIDEODEC (decoder_cxt);
GstVideoCodecFrame *g_frame = NULL ;
+ int frm_count = 0;
g_print("\n video thread created successfully");
if (decode_context == NULL)
@@ -1024,18 +1059,19 @@ static void* video_thread (void *context)
break;
case VDEC_MSG_RESP_INPUT_BUFFER_DONE:
-
+ // GST_VIDEO_DECODER_STREAM_LOCK (decoder_cxt);
temp_input_buffer = (struct vdec_bufferpayload *)queueitem->clientdata;
if (temp_input_buffer == NULL)
{
- g_print("\n FATAL ERROR input buffer address is bad : %p",queueitem->clientdata);
+ g_print("\n -------- FATAL ERROR input buffer address is bad : %p",queueitem->clientdata);
sem_post (&decode_context->sem_synchronize);
- break;
+ // break;
}
/*To-do read the next frame*/
- g_print("\nVDEC_MSG_RESP_INPUT_BUFFER_DONE Input buffer done for index ");
+ g_print("\nVDEC_MSG_RESP_INPUT_BUFFER_DONE Input buffer done for index ");
sem_post(&decode_context->sem_input_buf_done);
+ // GST_VIDEO_DECODER_STREAM_LOCK (decoder_cxt);
break;
case VDEC_MSG_EVT_CONFIG_CHANGED:
@@ -1074,12 +1110,13 @@ static void* video_thread (void *context)
if (outputbuffer->len == 0)
{
g_print("\n Filled Length is zero Close decoding");
+ Completed_frm_decode = TRUE;
sem_post (&decode_context->sem_synchronize);
- break;
+ // break;
}
-
- g_frame = gst_video_decoder_get_frame(GST_VIDEO_DECODER(decode_context),first_frm);
- g_print("\n VDEC_MSG_RESP_OUTPUT_BUFFER_DONE decoded buffer count: %d\n",first_frm);
+
+ g_frame = gst_video_decoder_get_frame(GST_VIDEO_DECODER(decode_context),frm_count);
+ g_print("\n VDEC_MSG_RESP_OUTPUT_BUFFER_DONE for the buffer index : %d and len : %d\n",frm_count,outputbuffer->len);
if(g_frame != NULL)
{
ret = gst_video_decoder_allocate_output_frame(GST_VIDEO_DECODER(decode_context),g_frame);
@@ -1090,7 +1127,7 @@ static void* video_thread (void *context)
ret = gst_video_decoder_finish_frame(GST_VIDEO_DECODER(decode_context),g_frame);
}
}
- first_frm++;
+ frm_count++;
tempbuffer = (struct vdec_bufferpayload *)\
outputbuffer->client_data;
@@ -1177,7 +1214,7 @@ static void* async_thread (void *context)
}
else
{
- g_print("\n\nasync_thread ioctl read next msg code : %d",vdec_msg.msgcode);
+ // g_print("\n\nasync_thread ioctl read next msg code : %d",vdec_msg.msgcode);
switch (vdec_msg.msgcode)
{
case VDEC_MSG_RESP_FLUSH_INPUT_DONE:
@@ -1280,6 +1317,8 @@ gst_qcvideodec_class_init (GstqcvideodecClass * klass)
video_decoder_class->close = GST_DEBUG_FUNCPTR (gst_qcvideodec_close);
video_decoder_class->handle_frame = GST_DEBUG_FUNCPTR (gst_qcvideodec_handle_frame);
video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_qcvideodec_finish);
+ //video_decoder_class->parse = GST_DEBUG_FUNCPTR (gst_qcvideodec_parse);
+
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_factory));