From: Vincent Penquerc'h Date: Tue, 22 Nov 2011 13:15:33 +0000 (+0000) Subject: oggstream: recognize opus headers from data, not packet count X-Git-Tag: 1.19.3~511^2~6555^2~317 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bf73491077d31db9032e13a0640a5c4552f5aee9;p=platform%2Fupstream%2Fgstreamer.git oggstream: recognize opus headers from data, not packet count Opus streams outside of Ogg may not have headers, and oggstream may be used by oggmux to mux an Opus stream which does not come from Ogg - thus without headers. Determining headerness by packet count would strip the first two packets from such an Opus stream, leading to a very small amount of audio being clipped at the beginning of the stream. --- diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index e0dde03..79b67b2 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -1872,6 +1872,12 @@ setup_opus_mapper (GstOggStream * pad, ogg_packet * packet) return TRUE; } +static gboolean +is_header_opus (GstOggStream * pad, ogg_packet * packet) +{ + return packet->bytes >= 8 && !memcmp (packet->packet, "Opus", 4); +} + static gint64 packet_duration_opus (GstOggStream * pad, ogg_packet * packet) { @@ -1896,7 +1902,7 @@ packet_duration_opus (GstOggStream * pad, ogg_packet * packet) return 0; /* headers */ - if (packet->bytes >= 8 && !memcmp (packet->packet, "Opus", 4)) + if (is_header_opus (pad, packet)) return 0; toc = packet->packet[0]; @@ -2109,7 +2115,7 @@ const GstOggMap mappers[] = { granulepos_to_granule_default, granule_to_granulepos_default, NULL, - is_header_count, + is_header_opus, packet_duration_opus, NULL, extract_tags_count