From 0603e442ce1457cc9b7cf757dec937cc16fdb37e Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 24 Jul 2017 13:52:35 +0200 Subject: [PATCH] omxvideodec/enc: delay allocation after the allocation query Allocating OMX components buffers in set_format() is too early. Doing it when receiving the first buffers will allow the element to use the information from the allocation query and/or the first incoming buffer to pick to best allocation mode. Tested on raspberry pi with dynamic resolution changes on decoder and encoder input. https://bugzilla.gnome.org/show_bug.cgi?id=785967 --- omx/gstomxvideodec.c | 9 ++++++--- omx/gstomxvideoenc.c | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/omx/gstomxvideodec.c b/omx/gstomxvideodec.c index ffa8281634..31be4df473 100644 --- a/omx/gstomxvideodec.c +++ b/omx/gstomxvideodec.c @@ -2282,9 +2282,6 @@ gst_omx_video_dec_set_format (GstVideoDecoder * decoder, gst_buffer_replace (&self->codec_data, state->codec_data); self->input_state = gst_video_codec_state_ref (state); - if (!gst_omx_video_dec_enable (self)) - return FALSE; - self->downstream_flow_ret = GST_FLOW_OK; return TRUE; } @@ -2404,6 +2401,12 @@ gst_omx_video_dec_handle_frame (GstVideoDecoder * decoder, gst_video_decoder_drop_frame (GST_VIDEO_DECODER (self), frame); return GST_FLOW_OK; } + + if (gst_omx_port_is_flushing (self->dec_out_port)) { + if (!gst_omx_video_dec_enable (self)) + return FALSE; + } + GST_DEBUG_OBJECT (self, "Starting task"); gst_pad_start_task (GST_VIDEO_DECODER_SRC_PAD (self), (GstTaskFunction) gst_omx_video_dec_loop, decoder, NULL); diff --git a/omx/gstomxvideoenc.c b/omx/gstomxvideoenc.c index 10ae3b5f66..65d7fc5086 100644 --- a/omx/gstomxvideoenc.c +++ b/omx/gstomxvideoenc.c @@ -1283,9 +1283,6 @@ gst_omx_video_enc_set_format (GstVideoEncoder * encoder, gst_video_codec_state_unref (self->input_state); self->input_state = gst_video_codec_state_ref (state); - if (!gst_omx_video_enc_enable (self)) - return FALSE; - self->downstream_flow_ret = GST_FLOW_OK; return TRUE; } @@ -1519,6 +1516,11 @@ gst_omx_video_enc_handle_frame (GstVideoEncoder * encoder, } if (!self->started) { + if (gst_omx_port_is_flushing (self->enc_out_port)) { + if (!gst_omx_video_enc_enable (self)) + return FALSE; + } + GST_DEBUG_OBJECT (self, "Starting task"); gst_pad_start_task (GST_VIDEO_ENCODER_SRC_PAD (self), (GstTaskFunction) gst_omx_video_enc_loop, self, NULL);