summaryrefslogtreecommitdiff
path: root/gst/typefind
diff options
context:
space:
mode:
authorVincent Penquerc'h <vincent.penquerch@collabora.co.uk>2013-06-28 14:48:19 +0100
committerSebastian Dröge <slomo@circular-chaos.org>2013-07-01 11:08:24 +0200
commit5a064ca4234ecbc9451b59d36b4e4f13de203d4f (patch)
tree90f0824b6da3466478982e07740055c312c744c5 /gst/typefind
parent85eac2c31ce7f7ed2aa0dbd4a9dc2ad42b734788 (diff)
typefind: avoid too low mpeg/ts probability on small amount of data
With the current test, we get into problems when we try to typefind a MPEG stream from a small amount of data, which can happen when we get data pushed from a HTTP source. We thus make a second test to give higher probability if all the potential headers were either pack or pes headers (ie, no potential header was unrecognized). This fixes an issue with a MPEG1/MP2 stream being properly discovered as video/mpeg from a file, but as audio/mpeg from souphttpsrc. https://bugzilla.gnome.org/show_bug.cgi?id=703256
Diffstat (limited to 'gst/typefind')
-rw-r--r--gst/typefind/gsttypefindfunctions.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c
index 8feb6d55e..71b9234a4 100644
--- a/gst/typefind/gsttypefindfunctions.c
+++ b/gst/typefind/gsttypefindfunctions.c
@@ -2141,6 +2141,7 @@ mpeg_sys_type_find (GstTypeFind * tf, gpointer unused)
guint pack_size;
guint since_last_sync = 0;
guint32 sync_word = 0xffffffff;
+ guint potential_headers = 0;
G_STMT_START {
gint len;
@@ -2175,6 +2176,7 @@ mpeg_sys_type_find (GstTypeFind * tf, gpointer unused)
}
pack_size = 0;
+ potential_headers++;
if (IS_MPEG_PACK_CODE (data[0])) {
if ((data[1] & 0xC0) == 0x40) {
/* MPEG-2 */
@@ -2234,6 +2236,17 @@ suggest:
prob = GST_TYPE_FIND_POSSIBLE + (10 * (pack_headers + pes_headers));
prob = MIN (prob, GST_TYPE_FIND_MAXIMUM);
+ /* With the above test, we get into problems when we try to typefind
+ a MPEG stream from a small amount of data, which can happen when
+ we get data pushed from a HTTP source. We thus make a second test
+ to give higher probability if all the potential headers were either
+ pack or pes headers (ie, no potential header was unrecognized). */
+ if (potential_headers == pack_headers + pes_headers) {
+ GST_LOG ("Only %u headers, but all were recognized", potential_headers);
+ prob += 10;
+ prob = MIN (prob, GST_TYPE_FIND_MAXIMUM);
+ }
+
/* lower probability if the first packet wasn't right at the start */
if (data0 != first_sync && prob >= 10)
prob -= 10;