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:46:58 +02:00
parent d0ab9172c5
commit 2e8af6973f
11 changed files with 44 additions and 111 deletions

View file

@ -89,7 +89,7 @@ static gboolean daala_dec_start (GstVideoDecoder * decoder);
static gboolean daala_dec_stop (GstVideoDecoder * decoder);
static gboolean daala_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean daala_dec_reset (GstVideoDecoder * decoder, gboolean hard);
static gboolean daala_dec_flush (GstVideoDecoder * decoder);
static GstFlowReturn daala_dec_parse (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
static GstFlowReturn daala_dec_handle_frame (GstVideoDecoder * decoder,
@ -117,7 +117,7 @@ gst_daala_dec_class_init (GstDaalaDecClass * klass)
video_decoder_class->start = GST_DEBUG_FUNCPTR (daala_dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (daala_dec_stop);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (daala_dec_reset);
video_decoder_class->flush = GST_DEBUG_FUNCPTR (daala_dec_flush);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (daala_dec_set_format);
video_decoder_class->parse = GST_DEBUG_FUNCPTR (daala_dec_parse);
video_decoder_class->handle_frame =
@ -137,7 +137,7 @@ gst_daala_dec_init (GstDaalaDec * dec)
}
static void
gst_daala_dec_reset (GstDaalaDec * dec)
daala_dec_reset (GstDaalaDec * dec)
{
dec->need_keyframe = TRUE;
}
@ -152,7 +152,7 @@ daala_dec_start (GstVideoDecoder * decoder)
daala_comment_clear (&dec->comment);
GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE");
dec->have_header = FALSE;
gst_daala_dec_reset (dec);
daala_dec_reset (dec);
return TRUE;
}
@ -169,7 +169,7 @@ daala_dec_stop (GstVideoDecoder * decoder)
dec->setup = NULL;
daala_decode_free (dec->decoder);
dec->decoder = NULL;
gst_daala_dec_reset (dec);
daala_dec_reset (dec);
if (dec->input_state) {
gst_video_codec_state_unref (dec->input_state);
dec->input_state = NULL;
@ -182,14 +182,6 @@ daala_dec_stop (GstVideoDecoder * decoder)
return TRUE;
}
/* FIXME : Do we want to handle hard resets differently ? */
static gboolean
daala_dec_reset (GstVideoDecoder * bdec, gboolean hard)
{
gst_daala_dec_reset (GST_DAALA_DEC (bdec));
return TRUE;
}
static GstFlowReturn
daala_dec_parse (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos)
@ -338,7 +330,8 @@ daala_handle_type_packet (GstDaalaDec * dec)
/* If we have a default PAR, see if the decoder specified a different one */
if (par_num == 1 && par_den == 1 &&
(dec->info.pixel_aspect_numerator != 0 && dec->info.pixel_aspect_denominator != 0)) {
(dec->info.pixel_aspect_numerator != 0
&& dec->info.pixel_aspect_denominator != 0)) {
par_num = dec->info.pixel_aspect_numerator;
par_den = dec->info.pixel_aspect_denominator;
}
@ -355,15 +348,13 @@ daala_handle_type_packet (GstDaalaDec * dec)
dec->info.plane_info[0].ydec == 0 &&
dec->info.plane_info[1].xdec == 1 &&
dec->info.plane_info[1].ydec == 1 &&
dec->info.plane_info[2].xdec == 1 &&
dec->info.plane_info[2].ydec == 1) {
dec->info.plane_info[2].xdec == 1 && dec->info.plane_info[2].ydec == 1) {
fmt = GST_VIDEO_FORMAT_I420;
} else if (dec->info.nplanes == 3 && dec->info.plane_info[0].xdec == 0 &&
dec->info.plane_info[0].ydec == 0 &&
dec->info.plane_info[1].xdec == 0 &&
dec->info.plane_info[1].ydec == 0 &&
dec->info.plane_info[2].xdec == 0 &&
dec->info.plane_info[2].ydec == 0) {
dec->info.plane_info[2].xdec == 0 && dec->info.plane_info[2].ydec == 0) {
fmt = GST_VIDEO_FORMAT_Y444;
} else {
goto unsupported_format;
@ -440,8 +431,7 @@ header_read_error:
/* Allocate buffer and copy image data into Y444 format */
static GstFlowReturn
daala_handle_image (GstDaalaDec * dec, od_img * img,
GstVideoCodecFrame * frame)
daala_handle_image (GstDaalaDec * dec, od_img * img, GstVideoCodecFrame * frame)
{
GstVideoDecoder *decoder = GST_VIDEO_DECODER (dec);
gint width, height, stride;
@ -467,10 +457,8 @@ daala_handle_image (GstDaalaDec * dec, od_img * img,
goto invalid_frame;
for (comp = 0; comp < 3; comp++) {
width =
GST_VIDEO_FRAME_COMP_WIDTH (&vframe, comp);
height =
GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, comp);
width = GST_VIDEO_FRAME_COMP_WIDTH (&vframe, comp);
height = GST_VIDEO_FRAME_COMP_HEIGHT (&vframe, comp);
stride = GST_VIDEO_FRAME_COMP_STRIDE (&vframe, comp);
dest = GST_VIDEO_FRAME_COMP_DATA (&vframe, comp);
@ -643,7 +631,8 @@ daala_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query)
GstBufferPool *pool;
GstStructure *config;
if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder, query))
if (!GST_VIDEO_DECODER_CLASS (parent_class)->decide_allocation (decoder,
query))
return FALSE;
g_assert (gst_query_get_n_allocation_pools (query) > 0);

View file

@ -87,6 +87,7 @@ G_DEFINE_TYPE (GstDaalaEnc, gst_daala_enc, GST_TYPE_VIDEO_ENCODER);
static gboolean daala_enc_start (GstVideoEncoder * enc);
static gboolean daala_enc_stop (GstVideoEncoder * enc);
static gboolean daala_enc_flush (GstVideoEncoder * enc);
static gboolean daala_enc_set_format (GstVideoEncoder * enc,
GstVideoCodecState * state);
static GstFlowReturn daala_enc_handle_frame (GstVideoEncoder * enc,
@ -137,6 +138,7 @@ gst_daala_enc_class_init (GstDaalaEncClass * klass)
gstvideo_encoder_class->start = GST_DEBUG_FUNCPTR (daala_enc_start);
gstvideo_encoder_class->stop = GST_DEBUG_FUNCPTR (daala_enc_stop);
gstvideo_encoder_class->flush = GST_DEBUG_FUNCPTR (daala_enc_flush);
gstvideo_encoder_class->set_format = GST_DEBUG_FUNCPTR (daala_enc_set_format);
gstvideo_encoder_class->handle_frame =
GST_DEBUG_FUNCPTR (daala_enc_handle_frame);
@ -174,7 +176,7 @@ daala_enc_finalize (GObject * object)
}
static void
daala_enc_reset (GstDaalaEnc * enc)
daala_enc_flush (GstDaalaEnc * enc)
{
int quant;
@ -200,9 +202,8 @@ daala_enc_start (GstVideoEncoder * benc)
GST_DEBUG_OBJECT (benc, "start: init daala");
enc = GST_DAALA_ENC (benc);
daala_info_init (&enc->info);
daala_comment_init (&enc->comment);
enc->packetno = 0;
enc->initialised = FALSE;
return TRUE;
}
@ -222,6 +223,10 @@ daala_enc_stop (GstVideoEncoder * benc)
daala_comment_clear (&enc->comment);
daala_info_clear (&enc->info);
if (enc->input_state)
gst_video_codec_state_unref (enc->input_state);
enc->input_state = NULL;
enc->initialised = FALSE;
return TRUE;
@ -356,7 +361,7 @@ daala_enc_set_format (GstVideoEncoder * benc, GstVideoCodecState * state)
gst_video_codec_state_unref (enc->input_state);
enc->input_state = gst_video_codec_state_ref (state);
daala_enc_reset (enc);
daala_enc_flush (enc);
enc->initialised = TRUE;
return TRUE;

View file

@ -32,8 +32,6 @@ static gboolean gst_openjpeg_dec_start (GstVideoDecoder * decoder);
static gboolean gst_openjpeg_dec_stop (GstVideoDecoder * decoder);
static gboolean gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean gst_openjpeg_dec_reset (GstVideoDecoder * decoder,
gboolean hard);
static GstFlowReturn gst_openjpeg_dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
static gboolean gst_openjpeg_dec_decide_allocation (GstVideoDecoder * decoder,
@ -91,7 +89,6 @@ gst_openjpeg_dec_class_init (GstOpenJPEGDecClass * klass)
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_openjpeg_dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_openjpeg_dec_stop);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_openjpeg_dec_reset);
video_decoder_class->set_format =
GST_DEBUG_FUNCPTR (gst_openjpeg_dec_set_format);
video_decoder_class->handle_frame =
@ -190,21 +187,6 @@ gst_openjpeg_dec_set_format (GstVideoDecoder * decoder,
return TRUE;
}
static gboolean
gst_openjpeg_dec_reset (GstVideoDecoder * decoder, gboolean hard)
{
GstOpenJPEGDec *self = GST_OPENJPEG_DEC (decoder);
GST_DEBUG_OBJECT (self, "Resetting");
if (self->output_state) {
gst_video_codec_state_unref (self->output_state);
self->output_state = NULL;
}
return TRUE;
}
static void
fill_frame_packed8_4 (GstVideoFrame * frame, opj_image_t * image)
{

View file

@ -82,8 +82,6 @@ static gboolean gst_openjpeg_enc_start (GstVideoEncoder * encoder);
static gboolean gst_openjpeg_enc_stop (GstVideoEncoder * encoder);
static gboolean gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
GstVideoCodecState * state);
static gboolean gst_openjpeg_enc_reset (GstVideoEncoder * encoder,
gboolean hard);
static GstFlowReturn gst_openjpeg_enc_handle_frame (GstVideoEncoder * encoder,
GstVideoCodecFrame * frame);
static gboolean gst_openjpeg_enc_propose_allocation (GstVideoEncoder * encoder,
@ -189,7 +187,6 @@ gst_openjpeg_enc_class_init (GstOpenJPEGEncClass * klass)
video_encoder_class->start = GST_DEBUG_FUNCPTR (gst_openjpeg_enc_start);
video_encoder_class->stop = GST_DEBUG_FUNCPTR (gst_openjpeg_enc_stop);
video_encoder_class->reset = GST_DEBUG_FUNCPTR (gst_openjpeg_enc_reset);
video_encoder_class->set_format =
GST_DEBUG_FUNCPTR (gst_openjpeg_enc_set_format);
video_encoder_class->handle_frame =
@ -655,21 +652,6 @@ gst_openjpeg_enc_set_format (GstVideoEncoder * encoder,
return TRUE;
}
static gboolean
gst_openjpeg_enc_reset (GstVideoEncoder * encoder, gboolean hard)
{
GstOpenJPEGEnc *self = GST_OPENJPEG_ENC (encoder);
GST_DEBUG_OBJECT (self, "Resetting");
if (self->output_state) {
gst_video_codec_state_unref (self->output_state);
self->output_state = NULL;
}
return TRUE;
}
static opj_image_t *
gst_openjpeg_enc_fill_image (GstOpenJPEGEnc * self, GstVideoFrame * frame)
{

View file

@ -60,8 +60,6 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
#define gst_rsv_dec_parent_class parent_class
G_DEFINE_TYPE (GstRsvgDec, gst_rsvg_dec, GST_TYPE_VIDEO_DECODER);
static gboolean gst_rsvg_dec_reset (GstVideoDecoder * decoder, gboolean hard);
static gboolean gst_rsvg_dec_stop (GstVideoDecoder * decoder);
static gboolean gst_rsvg_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
@ -95,26 +93,17 @@ gst_rsvg_dec_class_init (GstRsvgDecClass * klass)
gobject_class->finalize = gst_rsvg_dec_finalize;
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_rsvg_dec_stop);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_rsvg_dec_reset);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_rsvg_dec_set_format);
video_decoder_class->parse = GST_DEBUG_FUNCPTR (gst_rsvg_dec_parse);
video_decoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_rsvg_dec_handle_frame);
}
static void
dec_reset (GstRsvgDec * rsvg)
{
rsvg->fps_n = 0;
rsvg->fps_d = 1;
}
static void
gst_rsvg_dec_init (GstRsvgDec * rsvg)
{
GstVideoDecoder *decoder = GST_VIDEO_DECODER (rsvg);
gst_video_decoder_set_packetized (decoder, FALSE);
dec_reset (rsvg);
}
static void
@ -124,16 +113,6 @@ gst_rsvg_dec_finalize (GObject * object)
}
static gboolean
gst_rsvg_dec_reset (GstVideoDecoder * decoder, gboolean hard)
{
GstRsvgDec *dec = GST_RSVG_DEC (decoder);
dec_reset (dec);
return TRUE;
}
#define CAIRO_UNPREMULTIPLY(a,r,g,b) G_STMT_START { \
b = (a > 0) ? MIN ((b * 255 + a / 2) / a, 255) : 0; \
g = (a > 0) ? MIN ((g * 255 + a / 2) / a, 255) : 0; \
@ -374,12 +353,11 @@ static gboolean
gst_rsvg_dec_stop (GstVideoDecoder * decoder)
{
GstRsvgDec *rsvg = GST_RSVG_DEC (decoder);
if (rsvg->input_state) {
gst_video_codec_state_unref (rsvg->input_state);
rsvg->input_state = NULL;
}
gst_rsvg_dec_reset (decoder, TRUE);
return TRUE;
}

View file

@ -56,7 +56,6 @@ struct _GstRsvgDec
GList *pending_events;
gint fps_n, fps_d;
GstClockTime first_timestamp;
guint64 frame_count;

View file

@ -83,7 +83,7 @@ static void gst_schro_dec_finalize (GObject * object);
static gboolean gst_schro_dec_start (GstVideoDecoder * dec);
static gboolean gst_schro_dec_stop (GstVideoDecoder * dec);
static gboolean gst_schro_dec_reset (GstVideoDecoder * dec, gboolean hard);
static gboolean gst_schro_dec_flush (GstVideoDecoder * dec);
static GstFlowReturn gst_schro_dec_parse (GstVideoDecoder *
base_video_decoder, GstVideoCodecFrame * frame, GstAdapter * adapter,
gboolean at_eos);
@ -135,7 +135,7 @@ gst_schro_dec_class_init (GstSchroDecClass * klass)
base_video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_schro_dec_start);
base_video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_schro_dec_stop);
base_video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_schro_dec_reset);
base_video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_schro_dec_flush);
base_video_decoder_class->parse = GST_DEBUG_FUNCPTR (gst_schro_dec_parse);
base_video_decoder_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_schro_dec_handle_frame);
@ -168,17 +168,16 @@ gst_schro_dec_stop (GstVideoDecoder * dec)
}
static gboolean
gst_schro_dec_reset (GstVideoDecoder * dec, gboolean hard)
gst_schro_dec_flush (GstVideoDecoder * dec)
{
GstSchroDec *schro_dec;
schro_dec = GST_SCHRO_DEC (dec);
GST_DEBUG ("reset");
GST_DEBUG ("flush");
if (schro_dec->decoder) {
if (schro_dec->decoder)
schro_decoder_reset (schro_dec->decoder);
}
return TRUE;
}

View file

@ -79,8 +79,7 @@ static gboolean gst_amc_video_dec_start (GstVideoDecoder * decoder);
static gboolean gst_amc_video_dec_stop (GstVideoDecoder * decoder);
static gboolean gst_amc_video_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean gst_amc_video_dec_reset (GstVideoDecoder * decoder,
gboolean hard);
static gboolean gst_amc_video_dec_flush (GstVideoDecoder * decoder);
static GstFlowReturn gst_amc_video_dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
static GstFlowReturn gst_amc_video_dec_finish (GstVideoDecoder * decoder);
@ -478,7 +477,7 @@ gst_amc_video_dec_class_init (GstAmcVideoDecClass * klass)
videodec_class->stop = GST_DEBUG_FUNCPTR (gst_amc_video_dec_stop);
videodec_class->open = GST_DEBUG_FUNCPTR (gst_amc_video_dec_open);
videodec_class->close = GST_DEBUG_FUNCPTR (gst_amc_video_dec_close);
videodec_class->reset = GST_DEBUG_FUNCPTR (gst_amc_video_dec_reset);
videodec_class->flush = GST_DEBUG_FUNCPTR (gst_amc_video_dec_flush);
videodec_class->set_format = GST_DEBUG_FUNCPTR (gst_amc_video_dec_set_format);
videodec_class->handle_frame =
GST_DEBUG_FUNCPTR (gst_amc_video_dec_handle_frame);
@ -1444,13 +1443,13 @@ gst_amc_video_dec_set_format (GstVideoDecoder * decoder,
}
static gboolean
gst_amc_video_dec_reset (GstVideoDecoder * decoder, gboolean hard)
gst_amc_video_dec_flush (GstVideoDecoder * decoder)
{
GstAmcVideoDec *self;
self = GST_AMC_VIDEO_DEC (decoder);
GST_DEBUG_OBJECT (self, "Resetting decoder");
GST_DEBUG_OBJECT (self, "Flushing decoder");
if (!self->started) {
GST_DEBUG_OBJECT (self, "Codec not started yet");
@ -1476,7 +1475,7 @@ gst_amc_video_dec_reset (GstVideoDecoder * decoder, gboolean hard)
gst_pad_start_task (GST_VIDEO_DECODER_SRC_PAD (self),
(GstTaskFunction) gst_amc_video_dec_loop, decoder, NULL);
GST_DEBUG_OBJECT (self, "Reset decoder");
GST_DEBUG_OBJECT (self, "Flushed decoder");
return TRUE;
}

View file

@ -35,7 +35,7 @@ static gboolean gst_mfc_dec_start (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_stop (GstVideoDecoder * decoder);
static gboolean gst_mfc_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
static gboolean gst_mfc_dec_reset (GstVideoDecoder * decoder, gboolean hard);
static gboolean gst_mfc_dec_flush (GstVideoDecoder * decoder);
static GstFlowReturn gst_mfc_dec_finish (GstVideoDecoder * decoder);
static GstFlowReturn gst_mfc_dec_handle_frame (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame);
@ -114,7 +114,7 @@ gst_mfc_dec_class_init (GstMFCDecClass * klass)
video_decoder_class->start = GST_DEBUG_FUNCPTR (gst_mfc_dec_start);
video_decoder_class->stop = GST_DEBUG_FUNCPTR (gst_mfc_dec_stop);
video_decoder_class->finish = GST_DEBUG_FUNCPTR (gst_mfc_dec_finish);
video_decoder_class->reset = GST_DEBUG_FUNCPTR (gst_mfc_dec_reset);
video_decoder_class->flush = GST_DEBUG_FUNCPTR (gst_mfc_dec_flush);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (gst_mfc_dec_set_format);
video_decoder_class->negotiate = GST_DEBUG_FUNCPTR (gst_mfc_dec_negotiate);
video_decoder_class->decide_allocation =
@ -290,11 +290,11 @@ done:
}
static gboolean
gst_mfc_dec_reset (GstVideoDecoder * decoder, gboolean hard)
gst_mfc_dec_flush (GstVideoDecoder * decoder)
{
GstMFCDec *self = GST_MFC_DEC (decoder);
GST_DEBUG_OBJECT (self, "Resetting");
GST_DEBUG_OBJECT (self, "Flushing");
if (self->context)
mfc_dec_flush (self->context);

View file

@ -497,7 +497,7 @@ render_fail:
static gboolean
gst_vdp_h264_dec_reset (GstVideoDecoder * video_decoder, gboolean hard)
gst_vdp_h264_dec_flush (GstVideoDecoder * video_decoder)
{
GstVdpH264Dec *h264_dec = GST_VDP_H264_DEC (video_decoder);
@ -574,7 +574,7 @@ gst_vdp_h264_dec_class_init (GstVdpH264DecClass * klass)
video_decoder_class->start = gst_vdp_h264_dec_start;
video_decoder_class->stop = gst_vdp_h264_dec_stop;
video_decoder_class->reset = gst_vdp_h264_dec_reset;
video_decoder_class->flush = gst_vdp_h264_dec_flush;
video_decoder_class->set_format = gst_vdp_h264_dec_set_format;

View file

@ -461,7 +461,7 @@ render_fail:
}
static gboolean
gst_vdp_mpeg_dec_reset (GstVideoDecoder * video_decoder, gboolean hard)
gst_vdp_mpeg_dec_flush (GstVideoDecoder * video_decoder)
{
GstVdpMpegDec *mpeg_dec = GST_VDP_MPEG_DEC (video_decoder);
@ -530,7 +530,7 @@ gst_vdp_mpeg_dec_class_init (GstVdpMpegDecClass * klass)
video_decoder_class->start = gst_vdp_mpeg_dec_start;
video_decoder_class->stop = gst_vdp_mpeg_dec_stop;
video_decoder_class->reset = gst_vdp_mpeg_dec_reset;
video_decoder_class->flush = gst_vdp_mpeg_dec_flush;
video_decoder_class->handle_frame = gst_vdp_mpeg_dec_handle_frame;
video_decoder_class->set_format = gst_vdp_mpeg_dec_set_format;