ext: Use new flush vfunc of video codec base classes and remove reset implementations

This commit is contained in:
Sebastian Dröge 2013-08-15 15:27:48 +02:00
parent fad302b573
commit f541f94262
2 changed files with 72 additions and 27 deletions

View file

@ -81,9 +81,11 @@ static void gst_mpeg2dec_finalize (GObject * object);
/* GstVideoDecoder base class method */
static gboolean gst_mpeg2dec_open (GstVideoDecoder * decoder);
static gboolean gst_mpeg2dec_close (GstVideoDecoder * decoder);
static gboolean gst_mpeg2dec_start (GstVideoDecoder * decoder);
static gboolean gst_mpeg2dec_stop (GstVideoDecoder * decoder);
static gboolean gst_mpeg2dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean gst_mpeg2dec_reset (GstVideoDecoder * decoder, gboolean hard);
static gboolean gst_mpeg2dec_flush (GstVideoDecoder * decoder);
static GstFlowReturn gst_mpeg2dec_finish (GstVideoDecoder * decoder);
static GstFlowReturn gst_mpeg2dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
@ -114,7 +116,9 @@ gst_mpeg2dec_class_init (GstMpeg2decClass * klass)
video_decoder_class->open = GST_DEBUG_FUNCPTR (gst_mpeg2dec_open);
video_decoder_class->close = GST_DEBUG_FUNCPTR (gst_mpeg2dec_close);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_mpeg2dec_reset);
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_mpeg2dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_mpeg2dec_stop);
video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_mpeg2dec_flush);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_mpeg2dec_set_format);
video_decoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_mpeg2dec_handle_frame);
@ -194,25 +198,43 @@ gst_mpeg2dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state)
}
static gboolean
gst_mpeg2dec_reset (GstVideoDecoder * decoder, gboolean hard)
gst_mpeg2dec_start (GstVideoDecoder * decoder)
{
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
GST_DEBUG_OBJECT (mpeg2dec, "%s", hard ? "hard" : "soft");
/* reset the initial video state */
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
mpeg2_reset (mpeg2dec->decoder, hard ? 0 : 1);
return TRUE;
}
static gboolean
gst_mpeg2dec_stop (GstVideoDecoder * decoder)
{
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
mpeg2_reset (mpeg2dec->decoder, 1);
mpeg2_skip (mpeg2dec->decoder, 1);
gst_mpeg2dec_clear_buffers (mpeg2dec);
if (hard) {
if (mpeg2dec->input_state) {
gst_video_codec_state_unref (mpeg2dec->input_state);
mpeg2dec->input_state = NULL;
}
}
if (mpeg2dec->input_state)
gst_video_codec_state_unref (mpeg2dec->input_state);
mpeg2dec->input_state = NULL;
return TRUE;
}
static gboolean
gst_mpeg2dec_flush (GstVideoDecoder * decoder)
{
GstMpeg2dec *mpeg2dec = GST_MPEG2DEC (decoder);
/* reset the initial video state */
mpeg2dec->discont_state = MPEG2DEC_DISC_NEW_PICTURE;
mpeg2_reset (mpeg2dec->decoder, 0);
mpeg2_skip (mpeg2dec->decoder, 1);
gst_mpeg2dec_clear_buffers (mpeg2dec);
return TRUE;
}
@ -983,7 +1005,7 @@ gst_mpeg2dec_handle_frame (GstVideoDecoder * decoder,
GST_VIDEO_DECODER_ERROR (decoder, 1, STREAM, DECODE,
("decoding error"), ("Bad sequence header"), ret);
gst_video_decoder_drop_frame (decoder, frame);
gst_mpeg2dec_reset (decoder, FALSE);
gst_mpeg2dec_flush (decoder);
goto done;
}
break;

View file

@ -417,7 +417,9 @@ static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
);
static void gst_x264_enc_finalize (GObject * object);
static gboolean gst_x264_enc_reset (GstVideoEncoder * encoder, gboolean hard);
static gboolean gst_x264_enc_start (GstVideoEncoder * encoder);
static gboolean gst_x264_enc_stop (GstVideoEncoder * encoder);
static gboolean gst_x264_enc_flush (GstVideoEncoder * encoder);
static gboolean gst_x264_enc_init_encoder (GstX264Enc * encoder);
static void gst_x264_enc_close_encoder (GstX264Enc * encoder);
@ -596,7 +598,9 @@ gst_x264_enc_class_init (GstX264EncClass * klass)
gstencoder_class->set_format = GST_DEBUG_FUNCPTR (gst_x264_enc_set_format);
gstencoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_x264_enc_handle_frame);
gstencoder_class->reset = GST_DEBUG_FUNCPTR (gst_x264_enc_reset);
gstencoder_class->start = GST_DEBUG_FUNCPTR (gst_x264_enc_start);
gstencoder_class->stop = GST_DEBUG_FUNCPTR (gst_x264_enc_stop);
gstencoder_class->flush = GST_DEBUG_FUNCPTR (gst_x264_enc_flush);
gstencoder_class->finish = GST_DEBUG_FUNCPTR (gst_x264_enc_finish);
gstencoder_class->getcaps = GST_DEBUG_FUNCPTR (gst_x264_enc_sink_getcaps);
gstencoder_class->propose_allocation =
@ -989,24 +993,43 @@ gst_x264_enc_dequeue_all_frames (GstX264Enc * enc)
}
static gboolean
gst_x264_enc_reset (GstVideoEncoder * encoder, gboolean hard)
gst_x264_enc_start (GstVideoEncoder * encoder)
{
GstX264Enc *x264enc = GST_X264_ENC (encoder);
x264enc->current_byte_stream = GST_X264_ENC_STREAM_FORMAT_FROM_PROPERTY;
return TRUE;
}
static gboolean
gst_x264_enc_stop (GstVideoEncoder * encoder)
{
GstX264Enc *x264enc = GST_X264_ENC (encoder);
gst_x264_enc_flush_frames (x264enc, FALSE);
gst_x264_enc_close_encoder (x264enc);
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);
if (x264enc->input_state)
gst_video_codec_state_unref (x264enc->input_state);
x264enc->input_state = NULL;
return TRUE;
}
static gboolean
gst_x264_enc_flush (GstVideoEncoder * encoder)
{
GstX264Enc *x264enc = GST_X264_ENC (encoder);
gst_x264_enc_flush_frames (x264enc, FALSE);
gst_x264_enc_close_encoder (x264enc);
gst_x264_enc_dequeue_all_frames (x264enc);
gst_x264_enc_init_encoder (x264enc);
return TRUE;
}