From a4a89275f834554d8fd890ff723231a7f474ff17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 25 Jul 2013 11:01:20 +0200 Subject: [PATCH] x264enc: React properly to flushing/resetting the encoder https://bugzilla.gnome.org/show_bug.cgi?id=656007 --- ext/x264/gstx264enc.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/ext/x264/gstx264enc.c b/ext/x264/gstx264enc.c index b04a94794c..e4631d41b9 100644 --- a/ext/x264/gstx264enc.c +++ b/ext/x264/gstx264enc.c @@ -429,7 +429,6 @@ static void gst_x264_enc_flush_frames (GstX264Enc * encoder, gboolean send); static GstFlowReturn gst_x264_enc_encode_frame (GstX264Enc * encoder, x264_picture_t * pic_in, GstVideoCodecFrame * input_frame, int *i_nal, gboolean send); -static gboolean gst_x264_enc_stop (GstVideoEncoder * encoder); static gboolean gst_x264_enc_set_format (GstVideoEncoder * video_enc, GstVideoCodecState * state); static gboolean gst_x264_enc_propose_allocation (GstVideoEncoder * encoder, @@ -594,7 +593,6 @@ gst_x264_enc_class_init (GstX264EncClass * klass) gobject_class->get_property = gst_x264_enc_get_property; gobject_class->finalize = gst_x264_enc_finalize; - gstencoder_class->stop = GST_DEBUG_FUNCPTR (gst_x264_enc_stop); gstencoder_class->set_format = GST_DEBUG_FUNCPTR (gst_x264_enc_set_format); gstencoder_class->handle_frame = GST_DEBUG_FUNCPTR (gst_x264_enc_handle_frame); @@ -927,8 +925,6 @@ gst_x264_enc_init (GstX264Enc * encoder) encoder->x264param.pf_log = gst_x264_enc_log_callback; encoder->x264param.p_log_private = encoder; encoder->x264param.i_log_level = X264_LOG_DEBUG; - - gst_x264_enc_reset (GST_VIDEO_ENCODER (encoder), FALSE); } typedef struct @@ -997,15 +993,17 @@ gst_x264_enc_reset (GstVideoEncoder * encoder, gboolean hard) { GstX264Enc *x264enc = GST_X264_ENC (encoder); - if (hard) { - gst_x264_enc_flush_frames (x264enc, FALSE); - gst_x264_enc_close_encoder (x264enc); - } + gst_x264_enc_flush_frames (x264enc, FALSE); + gst_x264_enc_close_encoder (x264enc); - if (x264enc->input_state) - gst_video_codec_state_unref (x264enc->input_state); - x264enc->input_state = NULL; - x264enc->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY; + if (hard) { + if (x264enc->input_state) + gst_video_codec_state_unref (x264enc->input_state); + x264enc->input_state = NULL; + x264enc->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY; + } else { + gst_x264_enc_init_encoder (x264enc); + } gst_x264_enc_dequeue_all_frames (x264enc); @@ -1937,12 +1935,6 @@ gst_x264_enc_flush_frames (GstX264Enc * encoder, gboolean send) && x264_encoder_delayed_frames (encoder->x264enc) > 0); } -static gboolean -gst_x264_enc_stop (GstVideoEncoder * encoder) -{ - return gst_x264_enc_reset (encoder, TRUE); -} - static void gst_x264_enc_reconfig (GstX264Enc * encoder) {