From b756660a3cdc4d1a1f66ee797185b5100df0e763 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 29 Jun 2006 12:25:15 +0000 Subject: [PATCH] ext/dvdread/dvdreadsrc.c: Make check stronger. Original commit message from CVS: * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_is_nav_pack): Make check stronger. --- ChangeLog | 5 +++++ ext/dvdread/dvdreadsrc.c | 29 ++++++++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index aa89166d89..f60cad37bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-06-29 Tim-Philipp Müller + + * ext/dvdread/dvdreadsrc.c: (gst_dvd_read_src_is_nav_pack): + Make check stronger. + 2006-06-28 Tim-Philipp Müller * gst/asfdemux/gstasfdemux.c: (gst_asf_demux_setup_pad), diff --git a/ext/dvdread/dvdreadsrc.c b/ext/dvdread/dvdreadsrc.c index abfc10e3a9..8e12435e68 100644 --- a/ext/dvdread/dvdreadsrc.c +++ b/ext/dvdread/dvdreadsrc.c @@ -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