From e863e4ed1b38bdd50cdad9efcdb217a9213ff9b3 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 13 Mar 2009 15:29:29 +0100 Subject: [PATCH] vorbisparse: be smarter when queueing headers Look at the first buffer byte to see if a buffer is a header instead of counting packets. --- ext/vorbis/vorbisparse.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/ext/vorbis/vorbisparse.c b/ext/vorbis/vorbisparse.c index 96a1a31c1d..5e3c12d9c0 100644 --- a/ext/vorbis/vorbisparse.c +++ b/ext/vorbis/vorbisparse.c @@ -247,8 +247,6 @@ vorbis_parse_push_headers (GstVorbisParse * parse) g_list_free (parse->streamheader); parse->streamheader = NULL; - - parse->streamheader_sent = TRUE; } static void @@ -393,18 +391,34 @@ static GstFlowReturn vorbis_parse_parse_packet (GstVorbisParse * parse, GstBuffer * buf) { GstFlowReturn ret; + guint8 *data; + guint size; + gboolean have_header; + + data = GST_BUFFER_DATA (buf); + size = GST_BUFFER_SIZE (buf); parse->packetno++; - if (parse->packetno <= 3) { - /* if 1 <= packetno <= 3, it's streamheader, - * so put it on the streamheader list and return */ - parse->streamheader = g_list_append (parse->streamheader, buf); + have_header = FALSE; + if (size >= 1) { + if (data[0] >= 0x01 && data[0] <= 0x05) + have_header = TRUE; + } + + if (have_header) { + if (!parse->streamheader_sent) { + /* we need to collect the headers still */ + /* so put it on the streamheader list and return */ + parse->streamheader = g_list_append (parse->streamheader, buf); + } ret = GST_FLOW_OK; } else { - if (!parse->streamheader_sent) + /* data packet, push the headers we collected before */ + if (!parse->streamheader_sent) { vorbis_parse_push_headers (parse); - + parse->streamheader_sent = TRUE; + } ret = vorbis_parse_queue_buffer (parse, buf); }