From b1e442236f0cfc90db3e8208371977fceab2885e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 15 Aug 2013 15:08:05 +0200 Subject: [PATCH] ext: Use new flush vfunc of video codec base classes and remove reset implementations --- ext/jpeg/gstjpegdec.c | 29 +++++++++++++++++++---------- ext/jpeg/gstjpegenc.c | 13 +------------ ext/libpng/gstpngdec.c | 21 ++++++++------------- ext/vpx/gstvp8dec.c | 8 ++++---- ext/vpx/gstvp9dec.c | 8 ++++---- 5 files changed, 36 insertions(+), 43 deletions(-) diff --git a/ext/jpeg/gstjpegdec.c b/ext/jpeg/gstjpegdec.c index a8c0bfd9ff..79a2da0686 100644 --- a/ext/jpeg/gstjpegdec.c +++ b/ext/jpeg/gstjpegdec.c @@ -98,8 +98,9 @@ static void gst_jpeg_dec_get_property (GObject * object, guint prop_id, static gboolean gst_jpeg_dec_set_format (GstVideoDecoder * dec, GstVideoCodecState * state); +static gboolean gst_jpeg_dec_start (GstVideoDecoder * bdec); static gboolean gst_jpeg_dec_stop (GstVideoDecoder * bdec); -static gboolean gst_jpeg_dec_reset (GstVideoDecoder * bdec, gboolean hard); +static gboolean gst_jpeg_dec_flush (GstVideoDecoder * bdec); static GstFlowReturn gst_jpeg_dec_parse (GstVideoDecoder * bdec, GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos); static GstFlowReturn gst_jpeg_dec_handle_frame (GstVideoDecoder * bdec, @@ -168,8 +169,9 @@ gst_jpeg_dec_class_init (GstJpegDecClass * klass) "Codec/Decoder/Image", "Decode images from JPEG format", "Wim Taymans "); + vdec_class->start = gst_jpeg_dec_start; vdec_class->stop = gst_jpeg_dec_stop; - vdec_class->reset = gst_jpeg_dec_reset; + vdec_class->flush = gst_jpeg_dec_flush; vdec_class->parse = gst_jpeg_dec_parse; vdec_class->set_format = gst_jpeg_dec_set_format; vdec_class->handle_frame = gst_jpeg_dec_handle_frame; @@ -1268,7 +1270,21 @@ gst_jpeg_dec_decide_allocation (GstVideoDecoder * bdec, GstQuery * query) } static gboolean -gst_jpeg_dec_reset (GstVideoDecoder * bdec, gboolean hard) +gst_jpeg_dec_start (GstVideoDecoder * bdec) +{ + GstJpegDec *dec = (GstJpegDec *) bdec; + + dec->saw_header = FALSE; + dec->parse_entropy_len = 0; + dec->parse_resync = FALSE; + + gst_video_decoder_set_packetized (bdec, FALSE); + + return TRUE; +} + +static gboolean +gst_jpeg_dec_flush (GstVideoDecoder * bdec) { GstJpegDec *dec = (GstJpegDec *) bdec; @@ -1277,13 +1293,6 @@ gst_jpeg_dec_reset (GstVideoDecoder * bdec, gboolean hard) dec->parse_resync = FALSE; dec->saw_header = FALSE; - if (hard) { - dec->parse_entropy_len = 0; - dec->parse_resync = FALSE; - - gst_video_decoder_set_packetized (bdec, FALSE); - } - return TRUE; } diff --git a/ext/jpeg/gstjpegenc.c b/ext/jpeg/gstjpegenc.c index d3dfbaf311..3f5b282797 100644 --- a/ext/jpeg/gstjpegenc.c +++ b/ext/jpeg/gstjpegenc.c @@ -80,7 +80,6 @@ static void gst_jpegenc_get_property (GObject * object, guint prop_id, static gboolean gst_jpegenc_start (GstVideoEncoder * benc); static gboolean gst_jpegenc_stop (GstVideoEncoder * benc); -static gboolean gst_jpegenc_reset (GstVideoEncoder * benc, gboolean hard); static gboolean gst_jpegenc_set_format (GstVideoEncoder * encoder, GstVideoCodecState * state); static GstFlowReturn gst_jpegenc_handle_frame (GstVideoEncoder * encoder, @@ -161,7 +160,6 @@ gst_jpegenc_class_init (GstJpegEncClass * klass) venc_class->start = gst_jpegenc_start; venc_class->stop = gst_jpegenc_stop; - venc_class->reset = gst_jpegenc_reset; venc_class->set_format = gst_jpegenc_set_format; venc_class->handle_frame = gst_jpegenc_handle_frame; venc_class->propose_allocation = gst_jpegenc_propose_allocation; @@ -303,16 +301,6 @@ gst_jpegenc_init (GstJpegEnc * jpegenc) jpegenc->idct_method = JPEG_DEFAULT_IDCT_METHOD; } -static gboolean -gst_jpegenc_reset (GstVideoEncoder * benc, gboolean hard) -{ - GstJpegEnc *enc = (GstJpegEnc *) benc; - - enc->sof_marker = -1; - - return TRUE; -} - static void gst_jpegenc_finalize (GObject * object) { @@ -614,6 +602,7 @@ gst_jpegenc_start (GstVideoEncoder * benc) enc->line[0] = NULL; enc->line[1] = NULL; enc->line[2] = NULL; + enc->sof_marker = -1; return TRUE; } diff --git a/ext/libpng/gstpngdec.c b/ext/libpng/gstpngdec.c index 2436d9907c..f51c91af99 100644 --- a/ext/libpng/gstpngdec.c +++ b/ext/libpng/gstpngdec.c @@ -42,12 +42,12 @@ GST_DEBUG_CATEGORY_STATIC (pngdec_debug); #define GST_CAT_DEFAULT pngdec_debug static gboolean gst_pngdec_libpng_init (GstPngDec * pngdec); -static gboolean gst_pngdec_reset (GstVideoDecoder * decoder, gboolean hard); static GstFlowReturn gst_pngdec_caps_create_and_set (GstPngDec * pngdec); static gboolean gst_pngdec_start (GstVideoDecoder * decoder); static gboolean gst_pngdec_stop (GstVideoDecoder * decoder); +static gboolean gst_pngdec_flush (GstVideoDecoder * decoder); static gboolean gst_pngdec_set_format (GstVideoDecoder * Decoder, GstVideoCodecState * state); static GstFlowReturn gst_pngdec_parse (GstVideoDecoder * decoder, @@ -92,7 +92,7 @@ gst_pngdec_class_init (GstPngDecClass * klass) vdec_class->start = gst_pngdec_start; vdec_class->stop = gst_pngdec_stop; - vdec_class->reset = gst_pngdec_reset; + vdec_class->flush = gst_pngdec_flush; vdec_class->set_format = gst_pngdec_set_format; vdec_class->parse = gst_pngdec_parse; vdec_class->handle_frame = gst_pngdec_handle_frame; @@ -382,16 +382,11 @@ gst_pngdec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame) pngdec->current_frame_map.data, pngdec->current_frame_map.size); if (pngdec->image_ready) { - if (1) { - /* Reset ourselves for the next frame */ - gst_pngdec_reset (decoder, TRUE); - GST_LOG_OBJECT (pngdec, "setting up callbacks for next frame"); - png_set_progressive_read_fn (pngdec->png, pngdec, - user_info_callback, user_endrow_callback, user_end_callback); - } else { - GST_LOG_OBJECT (pngdec, "sending EOS"); - pngdec->ret = GST_FLOW_EOS; - } + /* Reset ourselves for the next frame */ + gst_pngdec_flush (decoder); + GST_LOG_OBJECT (pngdec, "setting up callbacks for next frame"); + png_set_progressive_read_fn (pngdec->png, pngdec, + user_info_callback, user_endrow_callback, user_end_callback); pngdec->image_ready = FALSE; } else { /* An error happened and we have to unmap */ @@ -629,7 +624,7 @@ gst_pngdec_stop (GstVideoDecoder * decoder) /* Clean up the libpng structures */ static gboolean -gst_pngdec_reset (GstVideoDecoder * decoder, gboolean hard) +gst_pngdec_flush (GstVideoDecoder * decoder) { gst_pngdec_libpng_clear ((GstPngDec *) decoder); gst_pngdec_libpng_init ((GstPngDec *) decoder); diff --git a/ext/vpx/gstvp8dec.c b/ext/vpx/gstvp8dec.c index 6ba2ce865e..d583e1f4e3 100644 --- a/ext/vpx/gstvp8dec.c +++ b/ext/vpx/gstvp8dec.c @@ -106,7 +106,7 @@ static gboolean gst_vp8_dec_start (GstVideoDecoder * decoder); static gboolean gst_vp8_dec_stop (GstVideoDecoder * decoder); static gboolean gst_vp8_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state); -static gboolean gst_vp8_dec_reset (GstVideoDecoder * decoder, gboolean hard); +static gboolean gst_vp8_dec_flush (GstVideoDecoder * decoder); static GstFlowReturn gst_vp8_dec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame); static gboolean gst_vp8_dec_decide_allocation (GstVideoDecoder * decoder, @@ -184,7 +184,7 @@ gst_vp8_dec_class_init (GstVP8DecClass * klass) base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_vp8_dec_start); base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_vp8_dec_stop); - base_video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_vp8_dec_reset); + base_video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_vp8_dec_flush); base_video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_vp8_dec_set_format); base_video_decoder_class->handle_frame = @@ -324,11 +324,11 @@ gst_vp8_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state) } static gboolean -gst_vp8_dec_reset (GstVideoDecoder * base_video_decoder, gboolean hard) +gst_vp8_dec_flush (GstVideoDecoder * base_video_decoder) { GstVP8Dec *decoder; - GST_DEBUG_OBJECT (base_video_decoder, "reset"); + GST_DEBUG_OBJECT (base_video_decoder, "flush"); decoder = GST_VP8_DEC (base_video_decoder); diff --git a/ext/vpx/gstvp9dec.c b/ext/vpx/gstvp9dec.c index 208796a40f..b5babc2cb3 100644 --- a/ext/vpx/gstvp9dec.c +++ b/ext/vpx/gstvp9dec.c @@ -106,7 +106,7 @@ static gboolean gst_vp9_dec_start (GstVideoDecoder * decoder); static gboolean gst_vp9_dec_stop (GstVideoDecoder * decoder); static gboolean gst_vp9_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state); -static gboolean gst_vp9_dec_reset (GstVideoDecoder * decoder, gboolean hard); +static gboolean gst_vp9_dec_flush (GstVideoDecoder * decoder); static GstFlowReturn gst_vp9_dec_handle_frame (GstVideoDecoder * decoder, GstVideoCodecFrame * frame); static gboolean gst_vp9_dec_decide_allocation (GstVideoDecoder * decoder, @@ -184,7 +184,7 @@ gst_vp9_dec_class_init (GstVP9DecClass * klass) base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_vp9_dec_start); base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_vp9_dec_stop); - base_video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_vp9_dec_reset); + base_video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_vp9_dec_flush); base_video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_vp9_dec_set_format); base_video_decoder_class->handle_frame = @@ -324,11 +324,11 @@ gst_vp9_dec_set_format (GstVideoDecoder * decoder, GstVideoCodecState * state) } static gboolean -gst_vp9_dec_reset (GstVideoDecoder * base_video_decoder, gboolean hard) +gst_vp9_dec_flush (GstVideoDecoder * base_video_decoder) { GstVP9Dec *decoder; - GST_DEBUG_OBJECT (base_video_decoder, "reset"); + GST_DEBUG_OBJECT (base_video_decoder, "flush"); decoder = GST_VP9_DEC (base_video_decoder);