summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2004-06-11 17:34:32 +0000
committerWim Taymans <wim.taymans@gmail.com>2004-06-11 17:34:32 +0000
commit01c78dfc8012628a8172b10f5a5c25fc65711e04 (patch)
treeba4e5fc33c8e9557850007235fa3718945d3706d
parent0bf06aa33b1ac3d6468d4986602b6c2d068a9431 (diff)
ext/theora/theoradec.c: Don't try to decode frames before we received a keyframe
Original commit message from CVS: * ext/theora/theoradec.c: (theora_dec_chain), (theora_dec_change_state): Don't try to decode frames before we received a keyframe
-rw-r--r--ChangeLog6
-rw-r--r--ext/theora/theoradec.c19
2 files changed, 23 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 8a3464c1d..764a2d840 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2004-06-11 Wim Taymans <wim@fluendo.com>
+ * ext/theora/theoradec.c: (theora_dec_chain),
+ (theora_dec_change_state):
+ Don't try to decode frames before we received a keyframe.
+
+2004-06-11 Wim Taymans <wim@fluendo.com>
+
* ext/ogg/gstoggmux.c: (gst_ogg_mux_class_init),
(gst_ogg_mux_init), (gst_ogg_mux_next_buffer),
(gst_ogg_mux_get_headers), (gst_ogg_mux_set_header_on_caps),
diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c
index bd2292832..df59681f5 100644
--- a/ext/theora/theoradec.c
+++ b/ext/theora/theoradec.c
@@ -54,6 +54,8 @@ struct _GstTheoraDec
guint packetno;
guint64 granulepos;
+
+ gboolean need_keyframe;
};
struct _GstTheoraDecClass
@@ -334,6 +336,7 @@ theora_dec_chain (GstPad * pad, GstData * data)
packet.packetno = dec->packetno++;
packet.b_o_s = (packet.packetno == 0) ? 1 : 0;
packet.e_o_s = 0;
+
/* switch depending on packet type */
if (packet.packet[0] & 0x80) {
/* header packet */
@@ -376,12 +379,23 @@ theora_dec_chain (GstPad * pad, GstData * data)
gst_caps_free (caps);
}
} else {
+ /* normal data packet */
yuv_buffer yuv;
GstBuffer *out;
guint8 *y, *v, *u;
guint i;
-
- /* normal data packet */
+ gboolean keyframe;
+
+ /* the second most significant bit of the first data byte is cleared
+ * for keyframes */
+ keyframe = (packet.packet[0] & 0x40) == 0;
+ if (keyframe) {
+ dec->need_keyframe = FALSE;
+ } else if (dec->need_keyframe) {
+ /* drop frames if we're looking for a keyframe */
+ gst_data_unref (data);
+ return;
+ }
#if 0
{
GTimeVal tv;
@@ -446,6 +460,7 @@ theora_dec_change_state (GstElement * element)
case GST_STATE_READY_TO_PAUSED:
theora_info_init (&dec->info);
theora_comment_init (&dec->comment);
+ dec->need_keyframe = TRUE;
break;
case GST_STATE_PAUSED_TO_PLAYING:
break;