theora: Use new video codec base classes' flush vfunc
This commit is contained in:
parent
695675ab7e
commit
5bd27953b4
@ -99,9 +99,10 @@ static void theora_dec_set_property (GObject * object, guint prop_id,
|
|||||||
const GValue * value, GParamSpec * pspec);
|
const GValue * value, GParamSpec * pspec);
|
||||||
|
|
||||||
static gboolean theora_dec_start (GstVideoDecoder * decoder);
|
static gboolean theora_dec_start (GstVideoDecoder * decoder);
|
||||||
|
static gboolean theora_dec_stop (GstVideoDecoder * decoder);
|
||||||
static gboolean theora_dec_set_format (GstVideoDecoder * decoder,
|
static gboolean theora_dec_set_format (GstVideoDecoder * decoder,
|
||||||
GstVideoCodecState * state);
|
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,
|
static GstFlowReturn theora_dec_parse (GstVideoDecoder * decoder,
|
||||||
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
|
GstVideoCodecFrame * frame, GstAdapter * adapter, gboolean at_eos);
|
||||||
static GstFlowReturn theora_dec_handle_frame (GstVideoDecoder * decoder,
|
static GstFlowReturn theora_dec_handle_frame (GstVideoDecoder * decoder,
|
||||||
@ -183,7 +184,8 @@ gst_theora_dec_class_init (GstTheoraDecClass * klass)
|
|||||||
"Benjamin Otte <otte@gnome.org>, Wim Taymans <wim@fluendo.com>");
|
"Benjamin Otte <otte@gnome.org>, Wim Taymans <wim@fluendo.com>");
|
||||||
|
|
||||||
video_decoder_class->start = GST_DEBUG_FUNCPTR (theora_dec_start);
|
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->set_format = GST_DEBUG_FUNCPTR (theora_dec_set_format);
|
||||||
video_decoder_class->parse = GST_DEBUG_FUNCPTR (theora_dec_parse);
|
video_decoder_class->parse = GST_DEBUG_FUNCPTR (theora_dec_parse);
|
||||||
video_decoder_class->handle_frame =
|
video_decoder_class->handle_frame =
|
||||||
@ -215,18 +217,18 @@ theora_dec_start (GstVideoDecoder * decoder)
|
|||||||
GST_DEBUG_OBJECT (dec, "start");
|
GST_DEBUG_OBJECT (dec, "start");
|
||||||
GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE");
|
GST_DEBUG_OBJECT (dec, "Setting have_header to FALSE");
|
||||||
dec->have_header = FALSE;
|
dec->have_header = FALSE;
|
||||||
|
dec->can_crop = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
theora_dec_reset (GstVideoDecoder * decoder, gboolean hard)
|
theora_dec_stop (GstVideoDecoder * decoder)
|
||||||
{
|
{
|
||||||
GstTheoraDec *dec = GST_THEORA_DEC (decoder);
|
GstTheoraDec *dec = GST_THEORA_DEC (decoder);
|
||||||
|
|
||||||
dec->need_keyframe = TRUE;
|
GST_DEBUG_OBJECT (dec, "stop");
|
||||||
|
|
||||||
if (hard) {
|
|
||||||
th_info_clear (&dec->info);
|
th_info_clear (&dec->info);
|
||||||
th_comment_clear (&dec->comment);
|
th_comment_clear (&dec->comment);
|
||||||
if (dec->setup) {
|
if (dec->setup) {
|
||||||
@ -247,7 +249,16 @@ theora_dec_reset (GstVideoDecoder * decoder, gboolean hard)
|
|||||||
dec->output_state = NULL;
|
dec->output_state = NULL;
|
||||||
}
|
}
|
||||||
dec->can_crop = FALSE;
|
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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ G_DEFINE_TYPE (GstTheoraEnc, gst_theora_enc, GST_TYPE_VIDEO_ENCODER);
|
|||||||
|
|
||||||
static gboolean theora_enc_start (GstVideoEncoder * enc);
|
static gboolean theora_enc_start (GstVideoEncoder * enc);
|
||||||
static gboolean theora_enc_stop (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,
|
static gboolean theora_enc_set_format (GstVideoEncoder * enc,
|
||||||
GstVideoCodecState * state);
|
GstVideoCodecState * state);
|
||||||
static GstFlowReturn theora_enc_handle_frame (GstVideoEncoder * enc,
|
static GstFlowReturn theora_enc_handle_frame (GstVideoEncoder * enc,
|
||||||
@ -222,7 +222,7 @@ gst_theora_enc_class_init (GstTheoraEncClass * klass)
|
|||||||
|
|
||||||
gstvideo_encoder_class->start = GST_DEBUG_FUNCPTR (theora_enc_start);
|
gstvideo_encoder_class->start = GST_DEBUG_FUNCPTR (theora_enc_start);
|
||||||
gstvideo_encoder_class->stop = GST_DEBUG_FUNCPTR (theora_enc_stop);
|
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 =
|
gstvideo_encoder_class->set_format =
|
||||||
GST_DEBUG_FUNCPTR (theora_enc_set_format);
|
GST_DEBUG_FUNCPTR (theora_enc_set_format);
|
||||||
gstvideo_encoder_class->handle_frame =
|
gstvideo_encoder_class->handle_frame =
|
||||||
@ -358,7 +358,7 @@ theora_enc_finalize (GObject * object)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
theora_enc_reset (GstVideoEncoder * encoder, gboolean hard)
|
theora_enc_flush (GstVideoEncoder * encoder)
|
||||||
{
|
{
|
||||||
GstTheoraEnc *enc = GST_THEORA_ENC (encoder);
|
GstTheoraEnc *enc = GST_THEORA_ENC (encoder);
|
||||||
ogg_uint32_t keyframe_force;
|
ogg_uint32_t keyframe_force;
|
||||||
@ -374,7 +374,6 @@ theora_enc_reset (GstVideoEncoder * encoder, gboolean hard)
|
|||||||
if (enc->encoder)
|
if (enc->encoder)
|
||||||
th_encode_free (enc->encoder);
|
th_encode_free (enc->encoder);
|
||||||
|
|
||||||
if (!hard) {
|
|
||||||
enc->encoder = th_encode_alloc (&enc->info);
|
enc->encoder = th_encode_alloc (&enc->info);
|
||||||
/* We ensure this function cannot fail. */
|
/* We ensure this function cannot fail. */
|
||||||
g_assert (enc->encoder != NULL);
|
g_assert (enc->encoder != NULL);
|
||||||
@ -409,18 +408,6 @@ theora_enc_reset (GstVideoEncoder * encoder, gboolean hard)
|
|||||||
if (enc->multipass_cache_fd
|
if (enc->multipass_cache_fd
|
||||||
&& enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS)
|
&& enc->multipass_mode == MULTIPASS_MODE_FIRST_PASS)
|
||||||
theora_enc_write_multipass_cache (enc, TRUE, FALSE);
|
theora_enc_write_multipass_cache (enc, TRUE, FALSE);
|
||||||
} else {
|
|
||||||
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;
|
|
||||||
|
|
||||||
enc->packetno = 0;
|
|
||||||
enc->initialised = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -457,6 +444,9 @@ theora_enc_start (GstVideoEncoder * benc)
|
|||||||
g_io_channel_set_encoding (enc->multipass_cache_fd, NULL, NULL);
|
g_io_channel_set_encoding (enc->multipass_cache_fd, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enc->packetno = 0;
|
||||||
|
enc->initialised = FALSE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,6 +458,16 @@ theora_enc_stop (GstVideoEncoder * benc)
|
|||||||
GST_DEBUG_OBJECT (benc, "stop: clearing theora state");
|
GST_DEBUG_OBJECT (benc, "stop: clearing theora state");
|
||||||
enc = GST_THEORA_ENC (benc);
|
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() */
|
/* Everything else is handled in reset() */
|
||||||
theora_enc_clear_multipass_cache (enc);
|
theora_enc_clear_multipass_cache (enc);
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ theora_enc_set_format (GstVideoEncoder * benc, GstVideoCodecState * state)
|
|||||||
"keyframe_frequency_force is %d, granule shift is %d",
|
"keyframe_frequency_force is %d, granule shift is %d",
|
||||||
enc->keyframe_force, enc->info.keyframe_granule_shift);
|
enc->keyframe_force, enc->info.keyframe_granule_shift);
|
||||||
|
|
||||||
theora_enc_reset (benc, FALSE);
|
theora_enc_flush (benc);
|
||||||
enc->initialised = TRUE;
|
enc->initialised = TRUE;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user