From 274f3024758fa13a59b650a97e70efc916fc94e9 Mon Sep 17 00:00:00 2001 From: Sebastian Dröge Date: Thu, 18 Apr 2013 09:58:09 +0200 Subject: videoencoder: Simply setcaps function --- gst-libs/gst/video/gstvideoencoder.c | 38 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 616614c0e..25c96d5ea 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -566,7 +566,6 @@ gst_video_encoder_setcaps (GstVideoEncoder * encoder, GstCaps * caps) GstVideoEncoderClass *encoder_class; GstVideoCodecState *state; gboolean ret; - gboolean samecaps = FALSE; encoder_class = GST_VIDEO_ENCODER_GET_CLASS (encoder); @@ -589,29 +588,24 @@ gst_video_encoder_setcaps (GstVideoEncoder * encoder, GstCaps * caps) if (G_UNLIKELY (!state)) goto parse_fail; - if (encoder->priv->input_state) - samecaps = - gst_video_info_is_equal (&state->info, - &encoder->priv->input_state->info); - - if (!samecaps) { - /* arrange draining pending frames */ - gst_video_encoder_drain (encoder); - - /* and subclass should be ready to configure format at any time around */ - ret = encoder_class->set_format (encoder, state); - if (ret) { - if (encoder->priv->input_state) - gst_video_codec_state_unref (encoder->priv->input_state); - encoder->priv->input_state = state; - } else - gst_video_codec_state_unref (state); + if (encoder->priv->input_state + && gst_video_info_is_equal (&state->info, + &encoder->priv->input_state->info)) { + gst_video_codec_state_unref (state); + goto caps_not_changed; + } + + /* arrange draining pending frames */ + gst_video_encoder_drain (encoder); + + /* and subclass should be ready to configure format at any time around */ + ret = encoder_class->set_format (encoder, state); + if (ret) { + if (encoder->priv->input_state) + gst_video_codec_state_unref (encoder->priv->input_state); + encoder->priv->input_state = state; } else { - /* no need to stir things up */ - GST_DEBUG_OBJECT (encoder, - "new video format identical to configured format"); gst_video_codec_state_unref (state); - ret = TRUE; } GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder); -- cgit v1.2.3