aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorprasanth kamuju <prasanth.kamuju@linaro.org>2014-09-08 14:06:34 +0530
committerprasanth kamuju <prasanth.kamuju@linaro.org>2014-09-08 14:06:34 +0530
commit6a64dab05157ba65435c73d730a533478e6e264c (patch)
treebc57b9a46a5d13b45f82ec0d8a84a50a21e3b92b
parent5f873f609b8af0a1bc53fffeb9b417d9cac79c1c (diff)
Use gstvideodecoder APIs for map and finish_frame.
For the decoder buffer, should use gstvideodecoder APIs for map and then call finish_frame to handover the decoded buffer to next element. Internally it will call gst_pad_push.
-rw-r--r--src/gstqcvideodec.c287
1 files changed, 3 insertions, 284 deletions
diff --git a/src/gstqcvideodec.c b/src/gstqcvideodec.c
index 5653c0f..b61ff2e 100644
--- a/src/gstqcvideodec.c
+++ b/src/gstqcvideodec.c
@@ -114,13 +114,11 @@ 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 gboolean gst_qcvideodec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query);
static void* video_thread (Gstqcvideodec *);
static void* async_thread (Gstqcvideodec *);
static gboolean gst_qcvideodec_set_buffers (GstVideoDecoder * decoder);
static GstFlowReturn gst_qcvideodec_decode_buffer(Gstqcvideodec *decode_context, GstBuffer * buf,GstVideoCodecFrame * frame);
-static GstStateChangeReturn gst_qcvideodec_change_state (GstElement * element,GstStateChange transition);
static pthread_mutex_t read_lock;
static int total_frames = 0;
@@ -138,84 +136,7 @@ static GstFlowReturn gst_qcvideodec_finish (GstVideoDecoder * decoder)
return GST_FLOW_OK;
}
-#if 0
-static GstStateChangeReturn gst_qcvideodec_change_state (GstElement * element,GstStateChange transition)
-{
- Gstqcvideodec *self;
- GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
- g_print("\ngst_qcvideodec_change_state Enter :: \n");
- g_return_val_if_fail (GST_IS_QCVIDEODEC(element),GST_STATE_CHANGE_FAILURE);
- self = GST_QCVIDEODEC(element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
-// if (!gst_omx_video_dec_open (self))
-// ret = GST_STATE_CHANGE_FAILURE;
- gst_qcvideodec_open(self);
- g_print("\n prasanth GST_STATE_CHANGE_NULL_TO_READY \n");
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
-/* if (self->in_port)
- gst_omx_port_set_flushing (self->in_port, FALSE);
- if (self->out_port)
- gst_omx_port_set_flushing (self->out_port, FALSE);
- self->downstream_flow_ret = GST_FLOW_OK;
- self->draining = FALSE;
- self->started = FALSE;*/
- gst_qcvideodec_set_format(self,NULL);
- g_print("\n prasanth GST_STATE_CHANGE_READY_TO_PAUSED \n");
- break;
- case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
- g_print("\n prasanth GST_STATE_CHANGE_PAUSED_TO_PLAYING \n");
- break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- /* if (self->in_port)
- gst_omx_port_set_flushing (self->in_port, TRUE);
- if (self->out_port)
- gst_omx_port_set_flushing (self->out_port, TRUE);
-
- g_mutex_lock (self->drain_lock);
- self->draining = FALSE;
- g_cond_broadcast (self->drain_cond);
- g_mutex_unlock (self->drain_lock);*/
- g_print("\n prasanth GST_STATE_CHANGE_PAUSED_TO_READY \n");
- break;
- default:
- break;
- }
-/*
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
-
- ret =
- GST_ELEMENT_CLASS (gst_omx_video_dec_parent_class)->change_state (element,
- transition);
-
- if (ret == GST_STATE_CHANGE_FAILURE)
- return ret;
- switch (transition) {
- case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- self->downstream_flow_ret = GST_FLOW_FLUSHING;
- self->started = FALSE;
-
- if (!gst_omx_video_dec_shutdown (self))
- ret = GST_STATE_CHANGE_FAILURE;
- break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- if (!gst_omx_video_dec_close (self))
- ret = GST_STATE_CHANGE_FAILURE;
- break;
- default:
- break;
- }
-*/
- return ret;
-
-}
-#endif
static gboolean gst_qcvideodec_open (GstVideoDecoder * decoder)
{
pthread_mutexattr_t init_values;
@@ -1274,150 +1195,19 @@ static void* video_thread (Gstqcvideodec *decoder_cxt)
sem_post (&decode_context->sem_synchronize);
break;
}
- // if(outbuf == NULL)
- /* if(gst_pad_is_linked (decode_context->srcpad) != TRUE)
- {
- g_print("\n ----- pad is not linked ----\n");
- }
- {
- outbuf = gst_buffer_new();
- memory = gst_allocator_alloc (NULL, outputbuffer->len, NULL);
- gst_buffer_append_memory(outbuf, memory);
- leng = gst_buffer_get_size(outbuf);
- g_print("\n--------------------------11111 leng = %d\n",leng);
- }
- gst_buffer_map (outbuf, &info, GST_MAP_WRITE);
- memcpy (info.data, outputbuffer->bufferaddr, info.size);
- // leng = gst_buffer_get_size(outbuf);
- // gst_buffer_ref(outbuf);
-
- /* if (outputBufferFile != NULL)
- {
- g_print("\nwriting data to output11.yuv file\n");
- fwrite (info.data,1,info.size,outputBufferFile);
- // fwrite (outputbuffer->bufferaddr,1,outputbuffer->len,outputBufferFile);
- }
- */
- // g_frame2 = gst_video_decoder_allocate_output_frame();
- if(first_frm !=0)
- {
g_frame = gst_video_decoder_get_frame(decode_context,first_frm);
g_print("\n ************************************************* : %d\n",first_frm);
-/* if(g_frame->output_buffer)
- {
- g_print("\n--------- g_frame->output_buffer is not null ---------\n");
- gst_buffer_unref (g_frame1->output_buffer);
- g_frame1->output_buffer = NULL;
- }
-
-
- if(first_frm == 1)
- { g_frame = g_frame1 ;}
- if(first_frm == 2)
- { g_frame = g_frame2 ;}
- if(first_frm == 3)
- { g_frame = g_frame3 ;}
- g_print("\n ************************************************* : %d\n",first_frm);
- g_print("\n video_thread writing data to output11.yuv file\n");
- g_print("\n video_thread system_frame_number : %d , %d, %d, %d \n",g_frame->system_frame_number,g_frame->decode_frame_number,g_frame->presentation_frame_number,g_frame->distance_from_sync);
- g_print("\n video_thread frame time : %lld , %lld , %lld , %lld \n",g_frame->dts,g_frame->pts,g_frame->duration,g_frame->deadline);
- g_print("\n video_thread input address : %p , %p \n",g_frame->input_buffer,g_frame->output_buffer);
- g_print("\n video_thread input size : %ld \n",decode_context->output_state->info.size);
- g_print("\n video_thread par_n : %d ,par_d : %d , fps_n : %d , fps_d : %d \n",\
- decode_context->output_state->info.par_n,\
- decode_context->output_state->info.par_d,\
- decode_context->output_state->info.fps_n,\
- decode_context->output_state->info.fps_d);
-
- caps = decode_context->output_state->caps;
- caps_data = gst_caps_to_string(caps);
- g_print("\n caps_data : %s \n",caps_data);
- g_print("\n ************************************************* **\n");
-*/
ret = gst_video_decoder_allocate_output_frame(decode_context,g_frame);
- // outbuf = gst_video_decoder_allocate_output_buffer(GST_VIDEO_DECODER (decoder_cxt));
- /* if(outbuf !=NULL)
- {
- g_print("\n memory allocated for outbuf \n");
- }
- if(ret != GST_FLOW_OK)
- {
- g_print("\n not able to allocate memory GST_FLOW_NOT_OK \n");
- }
- else
- g_print("\n !!!!!!! able to allocate memory GST_FLOW_OK : %p \n",g_frame->output_buffer);
- */
- /* if (!gst_video_frame_map (&vframe,&decode_context->output_state->info, g_frame->output_buffer,GST_MAP_READWRITE))
- {
- g_print("\n not able to map \n");
- }
- else
- g_print("\n mapped successfully \n");
-
- */
- if (!gst_buffer_map (g_frame->output_buffer, &map, GST_MAP_WRITE))
+ if (!gst_buffer_map (g_frame->output_buffer, &map, GST_MAP_WRITE))
{
g_print("\n not able to mapped successfully \n");
}
memcpy (map.data,outputbuffer->bufferaddr, map.size);
gst_buffer_unmap (g_frame->output_buffer, &map);
- // g_print("\n data copied to output buffer\n");
- ret = gst_video_decoder_finish_frame(decode_context,g_frame);
+ ret = gst_video_decoder_finish_frame(decode_context,g_frame);
- /* if(ret == GST_FLOW_CUSTOM_SUCCESS_2)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_CUSTOM_SUCCESS_2 \n");
- }
- if(ret == GST_FLOW_CUSTOM_SUCCESS_1)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_CUSTOM_SUCCESS_1 \n");
- }
- if(ret == GST_FLOW_CUSTOM_SUCCESS)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_CUSTOM_SUCCESS \n");
- }
- if(ret == GST_FLOW_OK)
- {
- g_print("\nfinish_frame-------------------------- GST_FLOW_OK \n");
- }
- if(ret == GST_FLOW_NOT_LINKED)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_NOT_LINKED \n");
- }
- if(ret == GST_FLOW_FLUSHING)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_FLUSHING \n");
- }
- if(ret == GST_FLOW_EOS)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_EOS \n");
- }
- if(ret == GST_FLOW_NOT_NEGOTIATED)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_NOT_NEGOTIATED \n");
- }
- if(ret == GST_FLOW_ERROR)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_ERROR \n");
- }
- if(ret == GST_FLOW_NOT_SUPPORTED)
- {
- g_print("\nfinish_frame -------------------------- GST_FLOW_NOT_SUPPORTED \n");
- }
- //gst_video_frame_unmap (&vframe);
- //gst_buffer_unref (g_frame1->output_buffer);
-*/
- //usleep(500*1000);
- // sem_post (&decode_context->sem_output_buf_done);
- }
- else
- {
- g_print("\n*************************************************: %d\n",first_frm);
- // g_print("\nThis is the first frame..ignore\n");
- // g_print("\n*************************************************\n");
- }
first_frm++;
tempbuffer = (struct vdec_bufferpayload *)\
outputbuffer->client_data;
@@ -1430,7 +1220,7 @@ static void* video_thread (Gstqcvideodec *decoder_cxt)
ioctl_msg.in = &fillbuffer;
ioctl_msg.out = NULL;
- //g_print("\n\nVDEC_MSG_RESP_OUTPUT_BUFFER_DONE in video thread # 4\n");
+
if (ioctl (decode_context->video_driver_fd,
VDEC_IOCTL_FILL_OUTPUT_BUFFER,&ioctl_msg) < 0)
{
@@ -1578,74 +1368,6 @@ static void* async_thread (Gstqcvideodec *decoder_cxt)
}
}
-static gboolean
-gst_qcvideodec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
-{
- GstBufferPool *pool;
- GstStructure *config;
-#if 0
-#if defined (USE_OMX_TARGET_RPI) && defined (HAVE_GST_GL)
- {
- GstCaps *caps;
- gint i, n;
- GstVideoInfo info;
-
- gst_query_parse_allocation (query, &caps, NULL);
- if (caps && gst_video_info_from_caps (&info, caps)
- && info.finfo->format == GST_VIDEO_FORMAT_RGBA) {
- gboolean found = FALSE;
- GstCapsFeatures *feature = gst_caps_get_features (caps, 0);
- /* Prefer an EGLImage allocator if available and we want to use it */
- n = gst_query_get_n_allocation_params (query);
- for (i = 0; i < n; i++) {
- GstAllocator *allocator;
- GstAllocationParams params;
-
- gst_query_parse_nth_allocation_param (query, i, &allocator, &params);
- if (allocator
- && g_strcmp0 (allocator->mem_type,
- GST_EGL_IMAGE_MEMORY_TYPE) == 0) {
- found = TRUE;
- gst_query_set_nth_allocation_param (query, 0, allocator, &params);
- while (gst_query_get_n_allocation_params (query) > 1)
- gst_query_remove_nth_allocation_param (query, 1);
- break;
- }
- }
-
- /* if try to negotiate with caps feature memory:EGLImage
- * and if allocator is not of type memory EGLImage then fails */
- if (feature
- && gst_caps_features_contains (feature,
- GST_CAPS_FEATURE_MEMORY_EGL_IMAGE) && !found) {
- return FALSE;
- }
- }
- }
-#endif
-#endif
- g_print("\n gst_qcvideodec_decide_allocation \n");
- if (!GST_VIDEO_DECODER_CLASS(gst_qcvideodec_parent_class)->decide_allocation (decoder, query))
- return FALSE;
-
- g_assert (gst_query_get_n_allocation_pools (query) > 0);
- gst_query_parse_nth_allocation_pool (query, 0, &pool, NULL, NULL, NULL);
- g_assert (pool != NULL);
-
- config = gst_buffer_pool_get_config (pool);
- if (gst_query_find_allocation_meta (query, GST_VIDEO_META_API_TYPE, NULL)) {
- gst_buffer_pool_config_add_option (config,GST_BUFFER_POOL_OPTION_VIDEO_META);
- }
- gst_buffer_pool_set_config (pool, config);
- gst_object_unref (pool);
- g_print("\n gst_qcvideodec_decide_allocation return TRUE\n");
- return TRUE;
-}
-
-
-
-
-/* GObject vmethod implementations */
/* initialize the qcvideodec's class */
static void
@@ -1669,8 +1391,6 @@ gst_qcvideodec_class_init (GstqcvideodecClass * klass)
"FIXME:Generic Template Element",
"c_kamuju <<user@hostname.org>>");
- // gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_qcvideodec_change_state);
-
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_qcvideodec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_qcvideodec_stop);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_qcvideodec_set_format);
@@ -1678,7 +1398,6 @@ 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->decide_allocation = GST_DEBUG_FUNCPTR (gst_qcvideodec_decide_allocation);
gst_element_class_add_pad_template (gstelement_class,
gst_static_pad_template_get (&src_factory));