const GValue * value, GParamSpec * pspec);
static gboolean theora_dec_start (GstVideoDecoder * decoder);
+static gboolean theora_dec_stop (GstVideoDecoder * decoder);
static gboolean theora_dec_set_format (GstVideoDecoder * decoder,
GstVideoCodecState * state);
-static gboolean theora_dec_reset (GstVideoDecoder * decoder, gboolean hard);
+static gboolean theora_dec_flush (GstVideoDecoder * decoder);
static GstFlowReturn theora_dec_parse (GstVideoDecoder * decoder,
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
static GstFlowReturn theora_dec_handle_frame (GstVideoDecoder * decoder,
"Benjamin Otte <otte@gnome.org>, Wim Taymans <wim@fluendo.com>");
video_decoder_class->start = GST_DEBUG_FUNCPTR (theora_dec_start);
- video_decoder_class->reset = GST_DEBUG_FUNCPTR (theora_dec_reset);
+ video_decoder_class->stop = GST_DEBUG_FUNCPTR (theora_dec_stop);
+ video_decoder_class->flush = GST_DEBUG_FUNCPTR (theora_dec_flush);
video_decoder_class->set_format = GST_DEBUG_FUNCPTR (theora_dec_set_format);
video_decoder_class->parse = GST_DEBUG_FUNCPTR (theora_dec_parse);
video_decoder_class->handle_frame =
GST_DEBUG_OBJECT (dec, "start");
GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE");
dec->have_header = FALSE;
+ dec->can_crop = FALSE;
return TRUE;
}
static gboolean
-theora_dec_reset (GstVideoDecoder * decoder, gboolean hard)
+theora_dec_stop (GstVideoDecoder * decoder)
{
GstTheoraDec *dec = GST_THEORA_DEC (decoder);
- dec->need_keyframe = TRUE;
+ GST_DEBUG_OBJECT (dec, "stop");
- if (hard) {
- th_info_clear (&dec->info);
- th_comment_clear (&dec->comment);
- if (dec->setup) {
- th_setup_free (dec->setup);
- dec->setup = NULL;
- }
- if (dec->decoder) {
- th_decode_free (dec->decoder);
- dec->decoder = NULL;
- }
+ th_info_clear (&dec->info);
+ th_comment_clear (&dec->comment);
+ if (dec->setup) {
+ th_setup_free (dec->setup);
+ dec->setup = NULL;
+ }
+ if (dec->decoder) {
+ th_decode_free (dec->decoder);
+ dec->decoder = NULL;
+ }
- if (dec->input_state) {
- gst_video_codec_state_unref (dec->input_state);
- dec->input_state = NULL;
- }
- if (dec->output_state) {
- gst_video_codec_state_unref (dec->output_state);
- dec->output_state = NULL;
- }
- dec->can_crop = FALSE;
+ if (dec->input_state) {
+ gst_video_codec_state_unref (dec->input_state);
+ dec->input_state = NULL;
+ }
+ if (dec->output_state) {
+ gst_video_codec_state_unref (dec->output_state);
+ dec->output_state = NULL;
}
+ dec->can_crop = FALSE;
+
+ return TRUE;
+}
+
+static gboolean
+theora_dec_flush (GstVideoDecoder * decoder)
+{
+ GstTheoraDec *dec = GST_THEORA_DEC (decoder);
+
+ dec->need_keyframe = TRUE;
return TRUE;
}
static gboolean theora_enc_start (GstVideoEncoder * enc);
static gboolean theora_enc_stop (GstVideoEncoder * enc);
-static gboolean theora_enc_reset (GstVideoEncoder * enc, gboolean hard);
+static gboolean theora_enc_flush (GstVideoEncoder * enc);
static gboolean theora_enc_set_format (GstVideoEncoder * enc,
GstVideoCodecState * state);
static GstFlowReturn theora_enc_handle_frame (GstVideoEncoder * enc,
gstvideo_encoder_class->start = GST_DEBUG_FUNCPTR (theora_enc_start);
gstvideo_encoder_class->stop = GST_DEBUG_FUNCPTR (theora_enc_stop);
- gstvideo_encoder_class->reset = GST_DEBUG_FUNCPTR (theora_enc_reset);
+ gstvideo_encoder_class->flush = GST_DEBUG_FUNCPTR (theora_enc_flush);
gstvideo_encoder_class->set_format =
GST_DEBUG_FUNCPTR (theora_enc_set_format);
gstvideo_encoder_class->handle_frame =
}
static gboolean
-theora_enc_reset (GstVideoEncoder * encoder, gboolean hard)
+theora_enc_flush (GstVideoEncoder * encoder)
{
GstTheoraEnc *enc = GST_THEORA_ENC (encoder);
ogg_uint32_t keyframe_force;
if (enc->encoder)
th_encode_free (enc->encoder);
- if (!hard) {
- enc->encoder = th_encode_alloc (&enc->info);
- /* We ensure this function cannot fail. */
- g_assert (enc->encoder != NULL);
- th_encode_ctl (enc->encoder, TH_ENCCTL_SET_SPLEVEL, &enc->speed_level,
- sizeof (enc->speed_level));
- th_encode_ctl (enc->encoder, TH_ENCCTL_SET_VP3_COMPATIBLE,
- &enc->vp3_compatible, sizeof (enc->vp3_compatible));
-
- rate_flags = 0;
- if (enc->drop_frames)
- rate_flags |= TH_RATECTL_DROP_FRAMES;
- if (enc->drop_frames)
- rate_flags |= TH_RATECTL_CAP_OVERFLOW;
- if (enc->drop_frames)
- rate_flags |= TH_RATECTL_CAP_UNDERFLOW;
- th_encode_ctl (enc->encoder, TH_ENCCTL_SET_RATE_FLAGS,
- &rate_flags, sizeof (rate_flags));
-
- if (enc->rate_buffer) {
- th_encode_ctl (enc->encoder, TH_ENCCTL_SET_RATE_BUFFER,
- &enc->rate_buffer, sizeof (enc->rate_buffer));
- } else {
- /* FIXME */
- }
-
- keyframe_force = enc->keyframe_auto ?
- enc->keyframe_force : enc->keyframe_freq;
- th_encode_ctl (enc->encoder, TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,
- &keyframe_force, sizeof (keyframe_force));
-
- /* Get placeholder data */
- if (enc->multipass_cache_fd
- && enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS)
- theora_enc_write_multipass_cache (enc, TRUE, FALSE);
+ enc->encoder = th_encode_alloc (&enc->info);
+ /* We ensure this function cannot fail. */
+ g_assert (enc->encoder != NULL);
+ th_encode_ctl (enc->encoder, TH_ENCCTL_SET_SPLEVEL, &enc->speed_level,
+ sizeof (enc->speed_level));
+ th_encode_ctl (enc->encoder, TH_ENCCTL_SET_VP3_COMPATIBLE,
+ &enc->vp3_compatible, sizeof (enc->vp3_compatible));
+
+ rate_flags = 0;
+ if (enc->drop_frames)
+ rate_flags |= TH_RATECTL_DROP_FRAMES;
+ if (enc->drop_frames)
+ rate_flags |= TH_RATECTL_CAP_OVERFLOW;
+ if (enc->drop_frames)
+ rate_flags |= TH_RATECTL_CAP_UNDERFLOW;
+ th_encode_ctl (enc->encoder, TH_ENCCTL_SET_RATE_FLAGS,
+ &rate_flags, sizeof (rate_flags));
+
+ if (enc->rate_buffer) {
+ th_encode_ctl (enc->encoder, TH_ENCCTL_SET_RATE_BUFFER,
+ &enc->rate_buffer, sizeof (enc->rate_buffer));
} else {
- enc->encoder = NULL;
- th_comment_clear (&enc->comment);
- th_info_clear (&enc->info);
+ /* FIXME */
+ }
- if (enc->input_state)
- gst_video_codec_state_unref (enc->input_state);
- enc->input_state = NULL;
+ keyframe_force = enc->keyframe_auto ?
+ enc->keyframe_force : enc->keyframe_freq;
+ th_encode_ctl (enc->encoder, TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,
+ &keyframe_force, sizeof (keyframe_force));
- enc->packetno = 0;
- enc->initialised = FALSE;
- }
+ /* Get placeholder data */
+ if (enc->multipass_cache_fd
+ && enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS)
+ theora_enc_write_multipass_cache (enc, TRUE, FALSE);
return TRUE;
}
g_io_channel_set_encoding (enc->multipass_cache_fd, NULL, NULL);
}
+ enc->packetno = 0;
+ enc->initialised = FALSE;
+
return TRUE;
}
GST_DEBUG_OBJECT (benc, "stop: clearing theora state");
enc = GST_THEORA_ENC (benc);
+ if (enc->encoder)
+ th_encode_free (enc->encoder);
+ enc->encoder = NULL;
+ th_comment_clear (&enc->comment);
+ th_info_clear (&enc->info);
+
+ if (enc->input_state)
+ gst_video_codec_state_unref (enc->input_state);
+ enc->input_state = NULL;
+
/* Everything else is handled in reset() */
theora_enc_clear_multipass_cache (enc);
"keyframe_frequency_force is %d, granule shift is %d",
enc->keyframe_force, enc->info.keyframe_granule_shift);
- theora_enc_reset (benc, FALSE);
+ theora_enc_flush (benc);
enc->initialised = TRUE;
return TRUE;