mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
ext/theora/theoraenc.c: Mark the last packet with an EOS flag which is not really needed in gstreamer.
Original commit message from CVS: * ext/theora/theoraenc.c: (gst_theora_enc_class_init), (theora_enc_sink_link), (theora_push_packet), (theora_enc_chain), (theora_enc_change_state), (theora_enc_set_property), (theora_enc_get_property): Mark the last packet with an EOS flag which is not really needed in gstreamer. Do some better video framerate initialisation. Update the buffer timestamp.
This commit is contained in:
parent
27dc0d1677
commit
299b599bd1
2 changed files with 45 additions and 36 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2004-05-10 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/theora/theoraenc.c: (gst_theora_enc_class_init),
|
||||||
|
(theora_enc_sink_link), (theora_push_packet), (theora_enc_chain),
|
||||||
|
(theora_enc_change_state), (theora_enc_set_property),
|
||||||
|
(theora_enc_get_property):
|
||||||
|
Mark the last packet with an EOS flag which is not really needed
|
||||||
|
in gstreamer.
|
||||||
|
Do some better video framerate initialisation.
|
||||||
|
Update the buffer timestamp.
|
||||||
|
|
||||||
2004-05-10 Jan Schmidt <thaytan@mad.scientist.com>
|
2004-05-10 Jan Schmidt <thaytan@mad.scientist.com>
|
||||||
|
|
||||||
* ext/dv/gstdvdec.c: (gst_dvdec_change_state):
|
* ext/dv/gstdvdec.c: (gst_dvdec_change_state):
|
||||||
|
|
|
@ -60,7 +60,6 @@ struct _GstTheoraEnc
|
||||||
gint width, height;
|
gint width, height;
|
||||||
|
|
||||||
guint packetno;
|
guint packetno;
|
||||||
guint64 granulepos;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstTheoraEncClass
|
struct _GstTheoraEncClass
|
||||||
|
@ -193,9 +192,9 @@ theora_enc_sink_link (GstPad * pad, const GstCaps * caps)
|
||||||
enc->info.offset_x = 0;
|
enc->info.offset_x = 0;
|
||||||
enc->info.offset_y = 0;
|
enc->info.offset_y = 0;
|
||||||
|
|
||||||
/* fixme, not done correctly */
|
/* do some scaling, we really need fractions in structures... */
|
||||||
enc->info.fps_numerator = fps;
|
enc->info.fps_numerator = fps * 10000000;
|
||||||
enc->info.fps_denominator = 1;
|
enc->info.fps_denominator = 10000000;
|
||||||
enc->info.aspect_numerator = 1;
|
enc->info.aspect_numerator = 1;
|
||||||
enc->info.aspect_denominator = 1;
|
enc->info.aspect_denominator = 1;
|
||||||
/* */
|
/* */
|
||||||
|
@ -219,17 +218,6 @@ theora_enc_sink_link (GstPad * pad, const GstCaps * caps)
|
||||||
return GST_PAD_LINK_OK;
|
return GST_PAD_LINK_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
theora_enc_event (GstTheoraEnc * enc, GstEvent * event)
|
|
||||||
{
|
|
||||||
GST_LOG_OBJECT (enc, "handling event");
|
|
||||||
switch (GST_EVENT_TYPE (event)) {
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
gst_pad_event_default (enc->sinkpad, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
theora_push_packet (GstTheoraEnc * enc, ogg_packet * packet)
|
theora_push_packet (GstTheoraEnc * enc, ogg_packet * packet)
|
||||||
{
|
{
|
||||||
|
@ -239,6 +227,8 @@ theora_push_packet (GstTheoraEnc * enc, ogg_packet * packet)
|
||||||
GST_BUFFER_OFFSET_NONE, packet->bytes);
|
GST_BUFFER_OFFSET_NONE, packet->bytes);
|
||||||
memcpy (GST_BUFFER_DATA (buf), packet->packet, packet->bytes);
|
memcpy (GST_BUFFER_DATA (buf), packet->packet, packet->bytes);
|
||||||
GST_BUFFER_OFFSET_END (buf) = packet->granulepos;
|
GST_BUFFER_OFFSET_END (buf) = packet->granulepos;
|
||||||
|
GST_BUFFER_TIMESTAMP (buf) =
|
||||||
|
theora_granule_time (&enc->state, packet->granulepos) * GST_SECOND;
|
||||||
if (GST_PAD_IS_USABLE (enc->srcpad))
|
if (GST_PAD_IS_USABLE (enc->srcpad))
|
||||||
gst_pad_push (enc->srcpad, GST_DATA (buf));
|
gst_pad_push (enc->srcpad, GST_DATA (buf));
|
||||||
|
|
||||||
|
@ -253,9 +243,16 @@ theora_enc_chain (GstPad * pad, GstData * data)
|
||||||
|
|
||||||
enc = GST_THEORA_ENC (gst_pad_get_parent (pad));
|
enc = GST_THEORA_ENC (gst_pad_get_parent (pad));
|
||||||
if (GST_IS_EVENT (data)) {
|
if (GST_IS_EVENT (data)) {
|
||||||
theora_enc_event (enc, GST_EVENT (data));
|
switch (GST_EVENT_TYPE (data)) {
|
||||||
|
case GST_EVENT_EOS:
|
||||||
|
/* push last packet with eos flag */
|
||||||
|
if (theora_encode_packetout (&enc->state, 1, &op))
|
||||||
|
theora_push_packet (enc, &op);
|
||||||
|
default:
|
||||||
|
gst_pad_event_default (pad, GST_EVENT (data));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* no packets written yet, setup headers */
|
/* no packets written yet, setup headers */
|
||||||
if (enc->packetno == 0) {
|
if (enc->packetno == 0) {
|
||||||
|
@ -277,6 +274,7 @@ theora_enc_chain (GstPad * pad, GstData * data)
|
||||||
theora_push_packet (enc, &op);
|
theora_push_packet (enc, &op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
yuv_buffer yuv;
|
yuv_buffer yuv;
|
||||||
gint y_size;
|
gint y_size;
|
||||||
guchar *pixels;
|
guchar *pixels;
|
||||||
|
@ -298,10 +296,11 @@ theora_enc_chain (GstPad * pad, GstData * data)
|
||||||
yuv.v = pixels + y_size * 5 / 4;
|
yuv.v = pixels + y_size * 5 / 4;
|
||||||
|
|
||||||
theora_encode_YUVin (&enc->state, &yuv);
|
theora_encode_YUVin (&enc->state, &yuv);
|
||||||
theora_encode_packetout (&enc->state, 0, &op);
|
if (theora_encode_packetout (&enc->state, 0, &op))
|
||||||
theora_push_packet (enc, &op);
|
theora_push_packet (enc, &op);
|
||||||
|
|
||||||
gst_data_unref (data);
|
gst_data_unref (data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstElementStateReturn
|
static GstElementStateReturn
|
||||||
|
@ -316,7 +315,6 @@ theora_enc_change_state (GstElement * element)
|
||||||
theora_info_init (&enc->info);
|
theora_info_init (&enc->info);
|
||||||
theora_comment_init (&enc->comment);
|
theora_comment_init (&enc->comment);
|
||||||
enc->packetno = 0;
|
enc->packetno = 0;
|
||||||
enc->granulepos = 0;
|
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue