diff options
author | Michael Smith <msmith@xiph.org> | 2007-04-19 16:58:53 +0000 |
---|---|---|
committer | Michael Smith <msmith@xiph.org> | 2007-04-19 16:58:53 +0000 |
commit | 38db14cb22aace013f415df19fe725e2527d0283 (patch) | |
tree | 313e97f44b9eb13cfb24a8fc77e63e4325af899b | |
parent | 674dcc1b4e7af12aaa74975f300735a9a70465a7 (diff) |
ext/theora/: Track initialisation state; don't try to use encoder state if we're not initialised (it'll segfault).
Original commit message from CVS:
* ext/theora/gsttheoraenc.h:
* ext/theora/theoraenc.c: (theora_enc_sink_setcaps),
(theora_enc_sink_event), (theora_enc_change_state):
Track initialisation state; don't try to use encoder state if we're
not initialised (it'll segfault).
-rw-r--r-- | ChangeLog | 8 | ||||
m--------- | common | 0 | ||||
-rw-r--r-- | ext/theora/gsttheoraenc.h | 1 | ||||
-rw-r--r-- | ext/theora/theoraenc.c | 21 |
4 files changed, 22 insertions, 8 deletions
@@ -1,3 +1,11 @@ +2007-04-19 Michael Smith <msmith@fluendo.com> + + * ext/theora/gsttheoraenc.h: + * ext/theora/theoraenc.c: (theora_enc_sink_setcaps), + (theora_enc_sink_event), (theora_enc_change_state): + Track initialisation state; don't try to use encoder state if we're + not initialised (it'll segfault). + 2007-04-18 Stefan Kost <ensonic@users.sf.net> * tests/check/pipelines/.cvsignore: diff --git a/common b/common -Subproject 380281f0da9caa065cfe99a458b3538cc3f5d71 +Subproject 765d03a88492fb4ac81d70457f671f3a109e93d diff --git a/ext/theora/gsttheoraenc.h b/ext/theora/gsttheoraenc.h index 009a56d8..6a04da72 100644 --- a/ext/theora/gsttheoraenc.h +++ b/ext/theora/gsttheoraenc.h @@ -72,6 +72,7 @@ struct _GstTheoraEnc theora_state state; theora_info info; theora_comment comment; + gboolean initialised; gboolean center; GstTheoraEncBorderMode border; diff --git a/ext/theora/theoraenc.c b/ext/theora/theoraenc.c index 75ebe156..d80838c2 100644 --- a/ext/theora/theoraenc.c +++ b/ext/theora/theoraenc.c @@ -396,6 +396,7 @@ theora_enc_sink_setcaps (GstPad * pad, GstCaps * caps) enc->info.keyframe_frequency_force, enc->granule_shift); theora_enc_reset (enc); + enc->initialised = TRUE; gst_object_unref (enc); @@ -550,14 +551,17 @@ theora_enc_sink_event (GstPad * pad, GstEvent * event) switch (GST_EVENT_TYPE (event)) { case GST_EVENT_EOS: - /* push last packet with eos flag */ - while (theora_encode_packetout (&enc->state, 1, &op)) { - /* See comment in the chain function */ - GstClockTime next_time = theora_granule_time (&enc->state, - granulepos_add (op.granulepos, 1, enc->granule_shift)) * GST_SECOND; - - theora_push_packet (enc, &op, enc->next_ts, next_time - enc->next_ts); - enc->next_ts = next_time; + if (enc->initialised) { + /* push last packet with eos flag */ + while (theora_encode_packetout (&enc->state, 1, &op)) { + /* See comment in the chain function */ + GstClockTime next_time = theora_granule_time (&enc->state, + granulepos_add (op.granulepos, 1, enc->granule_shift)) * + GST_SECOND; + + theora_push_packet (enc, &op, enc->next_ts, next_time - enc->next_ts); + enc->next_ts = next_time; + } } res = gst_pad_push_event (enc->srcpad, event); break; @@ -945,6 +949,7 @@ theora_enc_change_state (GstElement * element, GstStateChange transition) theora_info_clear (&enc->info); theora_enc_clear (enc); + enc->initialised = FALSE; break; case GST_STATE_CHANGE_READY_TO_NULL: break; |