ext/dvdread/dvdreadsrc.c: Make check stronger.
authorTim-Philipp Müller <tim@centricular.net>
Thu, 29 Jun 2006 12:25:15 +0000 (12:25 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Thu, 29 Jun 2006 12:25:15 +0000 (12:25 +0000)
Original commit message from CVS:
* ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_is_nav_pack):
Make check stronger.

ChangeLog
ext/dvdread/dvdreadsrc.c

index aa89166..f60cad3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-06-29  Tim-Philipp Müller  <tim at centricular dot net>
+
+       * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_is_nav_pack):
+         Make check stronger.
+
 2006-06-28  Tim-Philipp Müller  <tim at centricular dot net>
 
        * gst/asfdemux/gstasfdemux.c: (gst_asf_demux_setup_pad),
index abfc10e..8e12435 100644 (file)
@@ -510,13 +510,32 @@ gst_dvd_read_src_get_next_cell_for (GstDvdReadSrc * src, gint cell)
   return cell + 1;              /* really +1? (tpm) */
 }
 
-/* Returns true if the pack is a NAV pack.  This check is clearly insufficient,
- * and sometimes we incorrectly think that valid other packs are NAV packs.  I
- * need to make this stronger. */
+/* Returns true if the pack is a NAV pack */
 static gboolean
-gst_dvd_read_src_is_nav_pack (const guint8 * buffer)
+gst_dvd_read_src_is_nav_pack (const guint8 * data)
 {
-  return (buffer[41] == 0xbf && buffer[1027] == 0xbf);
+  if (GST_READ_UINT32_BE (data + 0x26) != 0x000001BF)
+    return FALSE;
+
+  /* Check that this is substream 0 (PCI) */
+  if (data[0x2c] != 0)
+    return FALSE;
+
+  if (GST_READ_UINT32_BE (data + 0x400) != 0x000001BF)
+    return FALSE;
+
+  /* Check that this is substream 1 (DSI) */
+  if (data[0x406] != 1)
+    return FALSE;
+
+  /* Check sizes of PCI and DSI packets */
+  if (GST_READ_UINT16_BE (data + 0x2a) != 0x03d4)
+    return FALSE;
+
+  if (GST_READ_UINT16_BE (data + 0x404) != 0x03fa)
+    return FALSE;
+
+  return TRUE;
 }
 
 typedef enum