From 9d309a3e06f249284332c9f41362c91665d8bf09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 18 Apr 2013 09:58:09 +0200 Subject: [PATCH] videoencoder: Simply setcaps function --- gst-libs/gst/video/gstvideoencoder.c | 40 ++++++++++++---------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 1cfb3916a3..4a8b6dd76a 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); - } else { - /* no need to stir things up */ - GST_DEBUG_OBJECT (encoder, - "new video format identical to configured format"); + 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 { gst_video_codec_state_unref (state); - ret = TRUE; } GST_VIDEO_ENCODER_STREAM_UNLOCK (encoder);