summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libspudec/Makefile.am4
-rw-r--r--src/libspudec/bswap.h87
-rw-r--r--src/libspudec/nav_print.c279
-rw-r--r--src/libspudec/nav_print.h41
-rw-r--r--src/libspudec/nav_read.c207
-rw-r--r--src/libspudec/nav_read.h41
-rw-r--r--src/libspudec/nav_types.h404
-rw-r--r--src/libspudec/xine_decoder.c7
8 files changed, 1064 insertions, 6 deletions
diff --git a/src/libspudec/Makefile.am b/src/libspudec/Makefile.am
index 9e5d8ca4b..939609bf1 100644
--- a/src/libspudec/Makefile.am
+++ b/src/libspudec/Makefile.am
@@ -6,10 +6,10 @@ libdir = $(XINE_PLUGINDIR)
lib_LTLIBRARIES = xineplug_decode_spu.la
-xineplug_decode_spu_la_SOURCES = spu.c xine_decoder.c
+xineplug_decode_spu_la_SOURCES = spu.c xine_decoder.c nav_read.c
xineplug_decode_spu_la_LDFLAGS = -avoid-version -module
-noinst_HEADERS = spu.h
+noinst_HEADERS = spu.h nav_read.h bswap.h
include_HEADERS = spu_decoder_api.h
##
diff --git a/src/libspudec/bswap.h b/src/libspudec/bswap.h
new file mode 100644
index 000000000..23e2863b4
--- /dev/null
+++ b/src/libspudec/bswap.h
@@ -0,0 +1,87 @@
+/**
+ * Copyright (C) 2000, 2001 Billy Biggs <vektor@dumbterm.net>,
+ * Håkan Hjort <d95hjort@dtek.chalmers.se>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef BSWAP_H_INCLUDED
+#define BSWAP_H_INCLUDED
+
+#include <config.h>
+
+#if defined(WORDS_BIGENDIAN)
+/* All bigendian systems are fine, just ignore the swaps. */
+#define B2N_16(x) (void)(x)
+#define B2N_32(x) (void)(x)
+#define B2N_64(x) (void)(x)
+
+#else
+
+#if defined(__linux__)
+#include <byteswap.h>
+#define B2N_16(x) x = bswap_16(x)
+#define B2N_32(x) x = bswap_32(x)
+#define B2N_64(x) x = bswap_64(x)
+
+#elif defined(__NetBSD__)
+#include <sys/endian.h>
+#define B2N_16(x) BE16TOH(x)
+#define B2N_32(x) BE32TOH(x)
+#define B2N_64(x) BE64TOH(x)
+
+#elif defined(__OpenBSD__)
+#include <sys/endian.h>
+#define B2N_16(x) x = swap16(x)
+#define B2N_32(x) x = swap32(x)
+#define B2N_64(x) x = swap64(x)
+
+/* This is a slow but portable implementation, it has multiple evaluation
+ * problems so beware.
+ * FreeBSD and Solaris don't have <byteswap.h> or any other such
+ * functionality!
+ */
+
+#elif defined(__FreeBSD__) || defined(__sun) || defined(__bsdi__)
+#define B2N_16(x) \
+ x = ((((x) & 0xff00) >> 8) | \
+ (((x) & 0x00ff) << 8))
+#define B2N_32(x) \
+ x = ((((x) & 0xff000000) >> 24) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x000000ff) << 24))
+#define B2N_64(x) \
+ x = ((((x) & 0xff00000000000000) >> 56) | \
+ (((x) & 0x00ff000000000000) >> 40) | \
+ (((x) & 0x0000ff0000000000) >> 24) | \
+ (((x) & 0x000000ff00000000) >> 8) | \
+ (((x) & 0x00000000ff000000) << 8) | \
+ (((x) & 0x0000000000ff0000) << 24) | \
+ (((x) & 0x000000000000ff00) << 40) | \
+ (((x) & 0x00000000000000ff) << 56))
+
+#else
+
+/* If there isn't a header provided with your system with this functionality
+ * add the relevant || define( ) to the portable implementation above.
+ */
+#error "You need to add endian swap macros for you're system"
+
+#endif
+
+#endif /* WORDS_BIGENDIAN */
+
+#endif /* BSWAP_H_INCLUDED */
diff --git a/src/libspudec/nav_print.c b/src/libspudec/nav_print.c
new file mode 100644
index 000000000..f40d42cb7
--- /dev/null
+++ b/src/libspudec/nav_print.c
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2000 Håkan Hjort <d95hjort@dtek.chalmers.se>
+ *
+ * Much of the contents in this file is based on VOBDUMP.
+ *
+ * VOBDUMP: a program for examining DVD .VOB filse
+ *
+ * Copyright 1998, 1999 Eric Smith <eric@brouhaha.com>
+ *
+ * VOBDUMP is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. Note that I am not
+ * granting permission to redistribute or modify VOBDUMP under the
+ * terms of any later version of the General Public License.
+ *
+ * This program is distributed in the hope that it will be useful (or
+ * at least amusing), but WITHOUT ANY WARRANTY; without even the
+ * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include "config.h" // Needed for WORDS_BIGENDIAN
+#include "nav_types.h"
+#include "nav_print.h"
+
+
+static void print_time(dvd_time_t *dtime) {
+ const char *rate;
+ assert((dtime->hour>>4) < 0xa && (dtime->hour&0xf) < 0xa);
+ assert((dtime->minute>>4) < 0x7 && (dtime->minute&0xf) < 0xa);
+ assert((dtime->second>>4) < 0x7 && (dtime->second&0xf) < 0xa);
+ assert((dtime->frame_u&0xf) < 0xa);
+
+ printf("%02x:%02x:%02x.%02x",
+ dtime->hour,
+ dtime->minute,
+ dtime->second,
+ dtime->frame_u & 0x3f);
+ switch((dtime->frame_u & 0xc0) >> 6) {
+ case 1:
+ rate = "25.00";
+ break;
+ case 3:
+ rate = "29.97";
+ break;
+ default:
+ rate = "(please send a bug report)";
+ break;
+ }
+ printf(" @ %s fps", rate);
+}
+
+
+static void navPrint_PCI_GI(pci_gi_t *pci_gi) {
+ int i;
+
+ printf("pci_gi:\n");
+ printf("nv_pck_lbn 0x%08x\n", pci_gi->nv_pck_lbn);
+ printf("vobu_cat 0x%04x\n", pci_gi->vobu_cat);
+ printf("vobu_uop_ctl 0x%08x\n", *(uint32_t*)&pci_gi->vobu_uop_ctl);
+ printf("vobu_s_ptm 0x%08x\n", pci_gi->vobu_s_ptm);
+ printf("vobu_e_ptm 0x%08x\n", pci_gi->vobu_e_ptm);
+ printf("vobu_se_e_ptm 0x%08x\n", pci_gi->vobu_se_e_ptm);
+ printf("e_eltm ");
+ print_time(&pci_gi->e_eltm);
+ printf("\n");
+
+ printf("vobu_isrc \"");
+ for(i = 0; i < 32; i++) {
+ char c = pci_gi->vobu_isrc[i];
+ if((c >= ' ') && (c <= '~'))
+ printf("%c", c);
+ else
+ printf(".");
+ }
+ printf("\"\n");
+}
+
+static void navPrint_NSML_AGLI(nsml_agli_t *nsml_agli) {
+ int i, j = 0;
+
+ for(i = 0; i < 9; i++)
+ j |= nsml_agli->nsml_agl_dsta[i];
+ if(j == 0)
+ return;
+
+ printf("nsml_agli:\n");
+ for(i = 0; i < 9; i++)
+ if(nsml_agli->nsml_agl_dsta[i])
+ printf("nsml_agl_c%d_dsta 0x%08x\n", i + 1,
+ nsml_agli->nsml_agl_dsta[i]);
+}
+
+static void navPrint_HL_GI(hl_gi_t *hl_gi, int *btngr_ns, int *btn_ns) {
+
+ if((hl_gi->hli_ss & 0x03) == 0)
+ return;
+
+ printf("hl_gi:\n");
+ printf("hli_ss 0x%01x\n", hl_gi->hli_ss & 0x03);
+ printf("hli_s_ptm 0x%08x\n", hl_gi->hli_s_ptm);
+ printf("hli_e_ptm 0x%08x\n", hl_gi->hli_e_ptm);
+ printf("btn_se_e_ptm 0x%08x\n", hl_gi->btn_se_e_ptm);
+
+ *btngr_ns = hl_gi->btngr_ns;
+ printf("btngr_ns %d\n", hl_gi->btngr_ns);
+ printf("btngr%d_dsp_ty 0x%02x\n", 1, hl_gi->btngr1_dsp_ty);
+ printf("btngr%d_dsp_ty 0x%02x\n", 2, hl_gi->btngr2_dsp_ty);
+ printf("btngr%d_dsp_ty 0x%02x\n", 3, hl_gi->btngr3_dsp_ty);
+
+ printf("btn_ofn %d\n", hl_gi->btn_ofn);
+ *btn_ns = hl_gi->btn_ns;
+ printf("btn_ns %d\n", hl_gi->btn_ns);
+ printf("nsl_btn_ns %d\n", hl_gi->nsl_btn_ns);
+ printf("fosl_btnn %d\n", hl_gi->fosl_btnn);
+ printf("foac_btnn %d\n", hl_gi->foac_btnn);
+}
+
+static void navPrint_BTN_COLIT(btn_colit_t *btn_colit) {
+ int i, j;
+
+ j = 0;
+ for(i = 0; i < 6; i++)
+ j |= btn_colit->btn_coli[i/2][i&1];
+ if(j == 0)
+ return;
+
+ printf("btn_colit:\n");
+ for(i = 0; i < 3; i++)
+ for(j = 0; j < 2; j++)
+ printf("btn_cqoli %d %s_coli: %08x\n",
+ i, (j == 0) ? "sl" : "ac",
+ btn_colit->btn_coli[i][j]);
+}
+
+static void navPrint_BTNIT(btni_t *btni_table, int btngr_ns, int btn_ns) {
+ int i, j;
+
+ printf("btnit:\n");
+ printf("btngr_ns: %i\n", btngr_ns);
+ printf("btn_ns: %i\n", btn_ns);
+
+ if(btngr_ns == 0)
+ return;
+
+ for(i = 0; i < btngr_ns; i++) {
+ for(j = 0; j < (36 / btngr_ns); j++) {
+ if(j < btn_ns) {
+ btni_t *btni = &btni_table[(36 / btngr_ns) * i + j];
+
+ printf("group %d btni %d: ", i+1, j+1);
+ printf("btn_coln %d, auto_action_mode %d\n",
+ btni->btn_coln, btni->auto_action_mode);
+ printf("coords (%d, %d) .. (%d, %d)\n",
+ btni->x_start, btni->y_start, btni->x_end, btni->y_end);
+
+ printf("up %d, ", btni->up);
+ printf("down %d, ", btni->down);
+ printf("left %d, ", btni->left);
+ printf("right %d\n", btni->right);
+
+ // ifoPrint_COMMAND(&btni->cmd);
+ printf("\n");
+ }
+ }
+ }
+}
+
+static void navPrint_HLI(hli_t *hli) {
+ int btngr_ns = 0, btn_ns = 0;
+
+ printf("hli:\n");
+ navPrint_HL_GI(&hli->hl_gi, & btngr_ns, & btn_ns);
+ navPrint_BTN_COLIT(&hli->btn_colit);
+ navPrint_BTNIT(hli->btnit, btngr_ns, btn_ns);
+}
+
+void navPrint_PCI(pci_t *pci) {
+ printf("pci packet:\n");
+ navPrint_PCI_GI(&pci->pci_gi);
+ navPrint_NSML_AGLI(&pci->nsml_agli);
+ navPrint_HLI(&pci->hli);
+}
+
+static void navPrint_DSI_GI(dsi_gi_t *dsi_gi) {
+ printf("dsi_gi:\n");
+ printf("nv_pck_scr 0x%08x\n", dsi_gi->nv_pck_scr);
+ printf("nv_pck_lbn 0x%08x\n", dsi_gi->nv_pck_lbn );
+ printf("vobu_ea 0x%08x\n", dsi_gi->vobu_ea);
+ printf("vobu_1stref_ea 0x%08x\n", dsi_gi->vobu_1stref_ea);
+ printf("vobu_2ndref_ea 0x%08x\n", dsi_gi->vobu_2ndref_ea);
+ printf("vobu_3rdref_ea 0x%08x\n", dsi_gi->vobu_3rdref_ea);
+ printf("vobu_vob_idn 0x%04x\n", dsi_gi->vobu_vob_idn);
+ printf("vobu_c_idn 0x%02x\n", dsi_gi->vobu_c_idn);
+ printf("c_eltm ");
+ print_time(&dsi_gi->c_eltm);
+ printf("\n");
+}
+
+static void navPrint_SML_PBI(sml_pbi_t *sml_pbi) {
+ printf("sml_pbi:\n");
+ printf("category 0x%04x\n", sml_pbi->category);
+ if(sml_pbi->category & 0x8000)
+ printf("VOBU is in preunit\n");
+ if(sml_pbi->category & 0x4000)
+ printf("VOBU is in ILVU\n");
+ if(sml_pbi->category & 0x2000)
+ printf("VOBU at the beginning of ILVU\n");
+ if(sml_pbi->category & 0x1000)
+ printf("VOBU at end of PREU of ILVU\n");
+
+ printf("ilvu_ea 0x%08x\n", sml_pbi->ilvu_ea);
+ printf("nxt_ilvu_sa 0x%08x\n", sml_pbi->ilvu_sa);
+ printf("nxt_ilvu_size 0x%04x\n", sml_pbi->size);
+
+ printf("vob_v_s_s_ptm 0x%08x\n", sml_pbi->vob_v_s_s_ptm);
+ printf("vob_v_e_e_ptm 0x%08x\n", sml_pbi->vob_v_e_e_ptm);
+
+ /* $$$ more code needed here */
+}
+
+static void navPrint_SML_AGLI(sml_agli_t *sml_agli) {
+ int i;
+ printf("sml_agli:\n");
+ for(i = 0; i < 9; i++) {
+ printf("agl_c%d address: 0x%08x size 0x%04x\n", i,
+ sml_agli->data[i].address, sml_agli->data[i].size);
+ }
+}
+
+static void navPrint_VOBU_SRI(vobu_sri_t *vobu_sri) {
+ int i;
+ int stime[19] = { 240, 120, 60, 20, 15, 14, 13, 12, 11,
+ 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
+ printf("vobu_sri:\n");
+ printf("Next VOBU with Video %08x\n", vobu_sri->next_video);
+ for(i = 0; i < 19; i++) {
+ printf("%3.1f %08x ", stime[i]/2.0, vobu_sri->fwda[i]);
+ }
+ printf("\n");
+ printf("Next VOBU %08x\n", vobu_sri->next_vobu);
+ printf("--\n");
+ printf("Prev VOBU %08x\n", vobu_sri->prev_vobu);
+ for(i = 0; i < 19; i++) {
+ printf("%3.1f %08x ", stime[18 - i]/2.0, vobu_sri->bwda[i]);
+ }
+ printf("\n");
+ printf("Prev VOBU with Video %08x\n", vobu_sri->prev_video);
+}
+
+static void navPrint_SYNCI(synci_t *synci) {
+ int i;
+
+ printf("synci:\n");
+ /* $$$ more code needed here */
+ for(i = 0; i < 8; i++)
+ printf("%04x ", synci->a_synca[i]);
+ for(i = 0; i < 32; i++)
+ printf("%08x ", synci->sp_synca[i]);
+}
+
+void navPrint_DSI(dsi_t *dsi) {
+ printf("dsi packet:\n");
+ navPrint_DSI_GI(&dsi->dsi_gi);
+ navPrint_SML_PBI(&dsi->sml_pbi);
+ navPrint_SML_AGLI(&dsi->sml_agli);
+ navPrint_VOBU_SRI(&dsi->vobu_sri);
+ navPrint_SYNCI(&dsi->synci);
+}
+
+
diff --git a/src/libspudec/nav_print.h b/src/libspudec/nav_print.h
new file mode 100644
index 000000000..e70835631
--- /dev/null
+++ b/src/libspudec/nav_print.h
@@ -0,0 +1,41 @@
+/**
+ * Copyright (C) 2001 Billy Biggs <vektor@dumbterm.net>,
+ * Håkan Hjort <d95hjort@dtek.chalmers.se>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef NAV_PRINT_H_INCLUDED
+#define NAV_PRINT_H_INCLUDED
+
+#include <stdio.h>
+#include "nav_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * This file provides example functions for printing information about the NAV
+ * packet to stdout.
+ */
+
+void navPrint_PCI(pci_t *pci);
+void navPrint_DSI(dsi_t *dsi);
+
+#ifdef __cplusplus
+};
+#endif
+#endif /* NAV_PRINT_H_INCLUDED */
diff --git a/src/libspudec/nav_read.c b/src/libspudec/nav_read.c
new file mode 100644
index 000000000..0a8ac3813
--- /dev/null
+++ b/src/libspudec/nav_read.c
@@ -0,0 +1,207 @@
+/**
+ * Copyright (C) 2000 Håkan Hjort <d95hjort@dtek.chalmers.se>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <inttypes.h>
+#include <assert.h>
+
+#include "config.h" // Needed for WORDS_BIGENDIAN
+#include "bswap.h"
+#include "nav_types.h"
+#include "nav_read.h"
+
+void nav_read_pci(pci_t *pci, unsigned char *buffer) {
+ int i, j;
+
+ assert(sizeof(pci_t) == PCI_BYTES - 1); // -1 for substream id
+
+ memcpy(pci, buffer, sizeof(pci_t));
+
+ /* Endian conversions */
+
+ /* pci pci_gi */
+ B2N_32(pci->pci_gi.nv_pck_lbn);
+ B2N_16(pci->pci_gi.vobu_cat);
+ B2N_32(pci->pci_gi.vobu_s_ptm);
+ B2N_32(pci->pci_gi.vobu_e_ptm);
+ B2N_32(pci->pci_gi.vobu_se_e_ptm);
+
+ /* pci nsml_agli */
+ for(i = 0; i < 9; i++)
+ B2N_32(pci->nsml_agli.nsml_agl_dsta[i]);
+
+ /* pci hli hli_gi */
+ B2N_16(pci->hli.hl_gi.hli_ss);
+ B2N_32(pci->hli.hl_gi.hli_s_ptm);
+ B2N_32(pci->hli.hl_gi.hli_e_ptm);
+ B2N_32(pci->hli.hl_gi.btn_se_e_ptm);
+
+ /* pci hli btn_colit */
+ for(i = 0; i < 3; i++)
+ for(j = 0; j < 2; j++)
+ B2N_32(pci->hli.btn_colit.btn_coli[i][j]);
+
+
+ /* pci hli btni */
+ /* There are some issues with this bitfiled with some compilers
+ because they stradle word boundaries. */
+
+#if !defined(WORDS_BIGENDIAN)
+ for(i = 0; i < 36; i++) {
+#if 0 /* Wierd Sun CC code that does not work */
+ unsigned char m[6];
+ memcpy(m, &pci->hli.btnit[i], 6);
+ pci->hli.btnit[i].zero1 = (m[1] >> 2);
+ pci->hli.btnit[i].x_start = (m[0] << 4) | (m[1] >> 4);
+ pci->hli.btnit[i].x_end = (m[1] << 8) | m[2];
+ pci->hli.btnit[i].y_start = (m[3] << 4) | (m[4] >> 4);
+ pci->hli.btnit[i].y_end = (m[4] << 8) | m[5];
+ pci->hli.btnit[i].zero2 = (m[4] >> 2);
+ pci->hli.btnit[i].btn_coln = (m[0] >> 6);
+ pci->hli.btnit[i].auto_action_mode = (m[3] >> 6);
+#else
+ char tmp[6], swap;
+ memcpy(tmp, &(pci->hli.btnit[i]), 6);
+ /* This is a B2N_24() */
+ swap = tmp[0]; tmp[0] = tmp[2]; tmp[2] = swap;
+ /* This is a B2N_24() */
+ swap = tmp[3]; tmp[3] = tmp[5]; tmp[5] = swap;
+ memcpy(&(pci->hli.btnit[i]), tmp, 6);
+#endif
+ }
+#endif
+
+
+ /* Asserts */
+
+ /* pci pci gi */
+ assert(pci->pci_gi.zero1 == 0);
+
+ /* pci hli hli_gi */
+ assert(pci->hli.hl_gi.zero1 == 0);
+ assert(pci->hli.hl_gi.zero2 == 0);
+ assert(pci->hli.hl_gi.zero3 == 0);
+ assert(pci->hli.hl_gi.zero4 == 0);
+ assert(pci->hli.hl_gi.zero5 == 0);
+
+ /* Are there buttons defined here? */
+ if((pci->hli.hl_gi.hli_ss & 0x03) != 0) {
+ assert(pci->hli.hl_gi.btn_ns != 0);
+ assert(pci->hli.hl_gi.btngr_ns != 0);
+ } else {
+ assert((pci->hli.hl_gi.btn_ns != 0 && pci->hli.hl_gi.btngr_ns != 0)
+ || (pci->hli.hl_gi.btn_ns == 0 && pci->hli.hl_gi.btngr_ns == 0));
+ }
+
+ /* pci hli btnit */
+
+#if NDEBUG
+ for(i = 0; i < pci->hli.hl_gi.btngr_ns; i++) {
+ for(j = 0; j < (36 / pci->hli.hl_gi.btngr_ns); j++) {
+ int n = (36 / pci->hli.hl_gi.btngr_ns) * i + j;
+ assert(pci->hli.btnit[n].zero1 == 0);
+ assert(pci->hli.btnit[n].zero2 == 0);
+ assert(pci->hli.btnit[n].zero3 == 0);
+ assert(pci->hli.btnit[n].zero4 == 0);
+ assert(pci->hli.btnit[n].zero5 == 0);
+ assert(pci->hli.btnit[n].zero6 == 0);
+
+ if (j < pci->hli.hl_gi.btn_ns) {
+ assert(pci->hli.btnit[n].x_start <= pci->hli.btnit[n].x_end);
+ assert(pci->hli.btnit[n].y_start <= pci->hli.btnit[n].y_end);
+ assert(pci->hli.btnit[n].up <= pci->hli.hl_gi.btn_ns);
+ assert(pci->hli.btnit[n].down <= pci->hli.hl_gi.btn_ns);
+ assert(pci->hli.btnit[n].left <= pci->hli.hl_gi.btn_ns);
+ assert(pci->hli.btnit[n].right <= pci->hli.hl_gi.btn_ns);
+ //vmcmd_verify(pci->hli.btnit[n].cmd);
+ } else {
+ int k;
+ assert(pci->hli.btnit[n].btn_coln == 0);
+ assert(pci->hli.btnit[n].auto_action_mode == 0);
+ assert(pci->hli.btnit[n].x_start == 0);
+ assert(pci->hli.btnit[n].y_start == 0);
+ assert(pci->hli.btnit[n].x_end == 0);
+ assert(pci->hli.btnit[n].y_end == 0);
+ assert(pci->hli.btnit[n].up == 0);
+ assert(pci->hli.btnit[n].down == 0);
+ assert(pci->hli.btnit[n].left == 0);
+ assert(pci->hli.btnit[n].right == 0);
+ for (k = 0; k < 8; k++)
+ assert(pci->hli.btnit[n].cmd.bytes[k] == 0); //CHECK_ZERO?
+ }
+ }
+ }
+#endif
+}
+
+void nav_read_dsi(dsi_t *dsi, unsigned char *buffer) {
+ int i;
+
+ assert(sizeof(dsi_t) == DSI_BYTES - 1); // -1 for substream id
+
+ memcpy(dsi, buffer, sizeof(dsi_t));
+
+ /* Endian conversions */
+
+ /* dsi dsi gi */
+ B2N_32(dsi->dsi_gi.nv_pck_scr);
+ B2N_32(dsi->dsi_gi.nv_pck_lbn);
+ B2N_32(dsi->dsi_gi.vobu_ea);
+ B2N_32(dsi->dsi_gi.vobu_1stref_ea);
+ B2N_32(dsi->dsi_gi.vobu_2ndref_ea);
+ B2N_32(dsi->dsi_gi.vobu_3rdref_ea);
+ B2N_16(dsi->dsi_gi.vobu_vob_idn);
+
+ /* dsi sml pbi */
+ B2N_16(dsi->sml_pbi.category);
+ B2N_32(dsi->sml_pbi.ilvu_ea);
+ B2N_32(dsi->sml_pbi.ilvu_sa);
+ B2N_16(dsi->sml_pbi.size);
+ B2N_32(dsi->sml_pbi.vob_v_s_s_ptm);
+ B2N_32(dsi->sml_pbi.vob_v_e_e_ptm);
+
+ /* dsi sml agli */
+ for(i = 0; i < 9; i++) {
+ B2N_32(dsi->sml_agli.data[ i ].address);
+ B2N_16(dsi->sml_agli.data[ i ].size);
+ }
+
+ /* dsi vobu sri */
+ B2N_32(dsi->vobu_sri.next_video);
+ for(i = 0; i < 19; i++)
+ B2N_32(dsi->vobu_sri.fwda[i]);
+ B2N_32(dsi->vobu_sri.next_vobu);
+ B2N_32(dsi->vobu_sri.prev_vobu);
+ for(i = 0; i < 19; i++)
+ B2N_32(dsi->vobu_sri.bwda[i]);
+ B2N_32(dsi->vobu_sri.prev_video);
+
+ /* dsi synci */
+ for(i = 0; i < 8; i++)
+ B2N_16(dsi->synci.a_synca[i]);
+ for(i = 0; i < 32; i++)
+ B2N_32(dsi->synci.sp_synca[i]);
+
+
+ /* Asserts */
+
+ /* dsi dsi gi */
+ assert(dsi->dsi_gi.zero1 == 0);
+}
+
diff --git a/src/libspudec/nav_read.h b/src/libspudec/nav_read.h
new file mode 100644
index 000000000..ba4dc4dca
--- /dev/null
+++ b/src/libspudec/nav_read.h
@@ -0,0 +1,41 @@
+/**
+ * Copyright (C) 2000, 2001 Håkan Hjort <d95hjort@dtek.chalmers.se>.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef NAV_READ_H_INCLUDED
+#define NAV_READ_H_INCLUDED
+
+#include "nav_types.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * Reads the PCI packet which begins at buffer into pci.
+ */
+void nav_read_pci(pci_t *pci, unsigned char *buffer);
+
+/**
+ * Reads the DSI packet which begins at buffer into dsi.
+ */
+void nav_read_dsi(dsi_t *dsi, unsigned char *buffer);
+
+#ifdef __cplusplus
+};
+#endif
+#endif /* NAV_READ_H_INCLUDED */
diff --git a/src/libspudec/nav_types.h b/src/libspudec/nav_types.h
new file mode 100644
index 000000000..6b8bbfa0b
--- /dev/null
+++ b/src/libspudec/nav_types.h
@@ -0,0 +1,404 @@
+/**
+ * Copyright (C) 2000 Håkan Hjort <d95hjort@dtek.chalmers.se>
+ *
+ * The data structures in this file should represent the layout of the
+ * pci and dsi packets as they are stored in the stream. Information
+ * found by reading the source to VOBDUMP is the base for the structure
+ * and names of these data types.
+ *
+ * VOBDUMP: a program for examining DVD .VOB files.
+ * Copyright 1998, 1999 Eric Smith <eric@brouhaha.com>
+ *
+ * VOBDUMP is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation. Note that I am not
+ * granting permission to redistribute or modify VOBDUMP under the terms
+ * of any later version of the General Public License.
+ *
+ * This program is distributed in the hope that it will be useful (or at
+ * least amusing), but WITHOUT ANY WARRANTY; without even the implied
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
+ * the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef NAV_TYPES_H_INCLUDED
+#define NAV_TYPES_H_INCLUDED
+
+#include <inttypes.h>
+
+#undef ATTRIBUTE_PACKED
+#undef PRAGMA_PACK_BEGIN
+#undef PRAGMA_PACK_END
+
+#if defined(__GNUC__)
+#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+#define ATTRIBUTE_PACKED __attribute__ ((packed))
+#define PRAGMA_PACK 0
+#endif
+#endif
+
+#if !defined(ATTRIBUTE_PACKED)
+#define ATTRIBUTE_PACKED
+#define PRAGMA_PACK 1
+#endif
+
+
+/* The length including the substream id byte. */
+#define PCI_BYTES 0x3d4
+#define DSI_BYTES 0x3fa
+
+#define PS2_PCI_SUBSTREAM_ID 0x00
+#define PS2_DSI_SUBSTREAM_ID 0x01
+
+/* Remove this */
+#define DSI_START_BYTE 1031
+
+
+#if PRAGMA_PACK
+#pragma pack(1)
+#endif
+
+/**
+ * DVD Time Information.
+ */
+typedef struct {
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ uint8_t frame_u; // The two high bits are the frame rate.
+} ATTRIBUTE_PACKED dvd_time_t;
+
+/**
+ * Type to store per-command data.
+ */
+typedef struct {
+ uint8_t bytes[8];
+} ATTRIBUTE_PACKED vm_cmd_t;
+
+/**
+ * User Operations.
+ */
+typedef struct {
+#ifdef WORDS_BIGENDIAN
+ unsigned int zero : 7; // 25-31
+ unsigned int video_pres_mode_change : 1; // 24
+
+ unsigned int karaoke_audio_pres_mode_change : 1; // 23
+ unsigned int angle_change : 1; // 22
+ unsigned int subpic_stream_change : 1; // 21
+ unsigned int audio_stream_change : 1; // 20
+ unsigned int pause_on : 1; // 19
+ unsigned int still_off : 1; // 18
+ unsigned int button_select_or_activate : 1; // 17
+ unsigned int resume : 1; // 16
+
+ unsigned int chapter_menu_call : 1; // 15
+ unsigned int angle_menu_call : 1; // 14
+ unsigned int audio_menu_call : 1; // 13
+ unsigned int subpic_menu_call : 1; // 12
+ unsigned int root_menu_call : 1; // 11
+ unsigned int title_menu_call : 1; // 10
+ unsigned int backward_scan : 1; // 9
+ unsigned int forward_scan : 1; // 8
+
+ unsigned int next_pg_search : 1; // 7
+ unsigned int prev_or_top_pg_search : 1; // 6
+ unsigned int time_or_chapter_search : 1; // 5
+ unsigned int go_up : 1; // 4
+ unsigned int stop : 1; // 3
+ unsigned int title_play : 1; // 2
+ unsigned int chapter_search_or_play : 1; // 1
+ unsigned int title_or_time_play : 1; // 0
+#else
+ unsigned int video_pres_mode_change : 1; // 24
+ unsigned int zero : 7; // 25-31
+
+ unsigned int resume : 1; // 16
+ unsigned int button_select_or_activate : 1; // 17
+ unsigned int still_off : 1; // 18
+ unsigned int pause_on : 1; // 19
+ unsigned int audio_stream_change : 1; // 20
+ unsigned int subpic_stream_change : 1; // 21
+ unsigned int angle_change : 1; // 22
+ unsigned int karaoke_audio_pres_mode_change : 1; // 23
+
+ unsigned int forward_scan : 1; // 8
+ unsigned int backward_scan : 1; // 9
+ unsigned int title_menu_call : 1; // 10
+ unsigned int root_menu_call : 1; // 11
+ unsigned int subpic_menu_call : 1; // 12
+ unsigned int audio_menu_call : 1; // 13
+ unsigned int angle_menu_call : 1; // 14
+ unsigned int chapter_menu_call : 1; // 15
+
+ unsigned int title_or_time_play : 1; // 0
+ unsigned int chapter_search_or_play : 1; // 1
+ unsigned int title_play : 1; // 2
+ unsigned int stop : 1; // 3
+ unsigned int go_up : 1; // 4
+ unsigned int time_or_chapter_search : 1; // 5
+ unsigned int prev_or_top_pg_search : 1; // 6
+ unsigned int next_pg_search : 1; // 7
+#endif
+} ATTRIBUTE_PACKED user_ops_t;
+
+
+
+/**
+ * PCI General Information
+ */
+typedef struct {
+ uint32_t nv_pck_lbn;
+ uint16_t vobu_cat;
+ uint16_t zero1;
+ user_ops_t vobu_uop_ctl;
+ uint32_t vobu_s_ptm;
+ uint32_t vobu_e_ptm;
+ uint32_t vobu_se_e_ptm;
+ dvd_time_t e_eltm;
+ char vobu_isrc[32];
+} ATTRIBUTE_PACKED pci_gi_t;
+
+/**
+ * Non Seamless Angle Information
+ */
+typedef struct {
+ uint32_t nsml_agl_dsta[9];
+} ATTRIBUTE_PACKED nsml_agli_t;
+
+/**
+ * Highlight General Information
+ */
+typedef struct {
+ uint16_t hli_ss; // only low 2 bits
+ uint32_t hli_s_ptm;
+ uint32_t hli_e_ptm;
+ uint32_t btn_se_e_ptm;
+#ifdef WORDS_BIGENDIAN
+ unsigned int zero1 : 2;
+ unsigned int btngr_ns : 2;
+ unsigned int zero2 : 1;
+ unsigned int btngr1_dsp_ty : 3;
+ unsigned int zero3 : 1;
+ unsigned int btngr2_dsp_ty : 3;
+ unsigned int zero4 : 1;
+ unsigned int btngr3_dsp_ty : 3;
+#else
+ unsigned int btngr1_dsp_ty : 3;
+ unsigned int zero2 : 1;
+ unsigned int btngr_ns : 2;
+ unsigned int zero1 : 2;
+ unsigned int btngr3_dsp_ty : 3;
+ unsigned int zero4 : 1;
+ unsigned int btngr2_dsp_ty : 3;
+ unsigned int zero3 : 1;
+#endif
+ uint8_t btn_ofn;
+ uint8_t btn_ns; // only low 6 bits
+ uint8_t nsl_btn_ns; // only low 6 bits
+ uint8_t zero5;
+ uint8_t fosl_btnn; // only low 6 bits
+ uint8_t foac_btnn; // only low 6 bits
+} ATTRIBUTE_PACKED hl_gi_t;
+
+
+/**
+ * Button Color Information Table
+ */
+typedef struct {
+ uint32_t btn_coli[3][2];
+} ATTRIBUTE_PACKED btn_colit_t;
+
+
+/*
+ btn_coln 11000000 00000000 00000000 00000000 00000000 00000000
+ x_start 00111111 11110000 00000000 00000000 00000000 00000000
+ zero1 00000000 00001100 00000000 00000000 00000000 00000000
+ x_end 00000000 00000011 11111111 00000000 00000000 00000000
+ auto_action_mode 00000000 00000000 00000000 11000000 00000000 00000000
+ y_start 00000000 00000000 00000000 00111111 11110000 00000000
+ zero2 00000000 00000000 00000000 00000000 00001100 00000000
+ y_end 00000000 00000000 00000000 00000000 00000011 11111111
+
+ unsigned int btn_coln : 2; // 0 - m[0]>>6
+ unsigned int x_start : 10; // 2 - m[0]<<4 | m[1]>>4
+ unsigned int zero1 : 2; // 12 - m[1]>>2
+ unsigned int x_end : 10; // 14 - m[1]<<8 | m[2]
+
+ unsigned int auto_action_mode : 2; // 24 - m[3]>>6
+ unsigned int y_start : 10; // 26 - m[3]<<4 | m[4]>>4
+ unsigned int zero2 : 2; // 36 - m[4]>>2
+ unsigned int y_end : 10; // 38 - m[4]<<8 | m[5]
+ */
+
+/**
+ * Button Information
+ */
+typedef struct {
+#if 0 /* Wierd Sun CC code that does not work */
+ unsigned int zero1 : 2;
+ unsigned int x_start : 10;
+ unsigned int x_end : 10;
+ unsigned int y_start : 10;
+
+ unsigned int zero2 : 2;
+ unsigned int btn_coln : 2;
+ unsigned int auto_action_mode : 2;
+ unsigned int y_end : 10;
+#endif
+#ifdef WORDS_BIGENDIAN
+ unsigned int btn_coln : 2;
+ unsigned int x_start : 10;
+ unsigned int zero1 : 2;
+ unsigned int x_end : 10;
+ unsigned int auto_action_mode : 2;
+ unsigned int y_start : 10;
+ unsigned int zero2 : 2;
+ unsigned int y_end : 10;
+
+ unsigned int zero3 : 2;
+ unsigned int up : 6;
+ unsigned int zero4 : 2;
+ unsigned int down : 6;
+ unsigned int zero5 : 2;
+ unsigned int left : 6;
+ unsigned int zero6 : 2;
+ unsigned int right : 6;
+#else
+ unsigned int x_end : 10;
+ unsigned int zero1 : 2;
+ unsigned int x_start : 10;
+ unsigned int btn_coln : 2;
+ unsigned int y_end : 10;
+ unsigned int zero2 : 2;
+ unsigned int y_start : 10;
+ unsigned int auto_action_mode : 2;
+
+ unsigned int up : 6;
+ unsigned int zero3 : 2;
+ unsigned int down : 6;
+ unsigned int zero4 : 2;
+ unsigned int left : 6;
+ unsigned int zero5 : 2;
+ unsigned int right : 6;
+ unsigned int zero6 : 2;
+#endif
+ vm_cmd_t cmd;
+} ATTRIBUTE_PACKED btni_t;
+
+/**
+ * Highlight Information
+ */
+typedef struct {
+ hl_gi_t hl_gi;
+ btn_colit_t btn_colit;
+ btni_t btnit[36];
+} ATTRIBUTE_PACKED hli_t;
+
+/**
+ * PCI packet
+ */
+typedef struct {
+ pci_gi_t pci_gi;
+ nsml_agli_t nsml_agli;
+ hli_t hli;
+ uint8_t zero1[189];
+} ATTRIBUTE_PACKED pci_t;
+
+
+
+
+/**
+ * DSI General Information
+ */
+typedef struct {
+ uint32_t nv_pck_scr;
+ uint32_t nv_pck_lbn;
+ uint32_t vobu_ea;
+ uint32_t vobu_1stref_ea;
+ uint32_t vobu_2ndref_ea;
+ uint32_t vobu_3rdref_ea;
+ uint16_t vobu_vob_idn;
+ uint8_t zero1;
+ uint8_t vobu_c_idn;
+ dvd_time_t c_eltm;
+} ATTRIBUTE_PACKED dsi_gi_t;
+
+/**
+ * Seamless Playback Information
+ */
+typedef struct {
+ uint16_t category; // category of seamless VOBU
+ uint32_t ilvu_ea; // end address of interleaved Unit (sectors)
+ uint32_t ilvu_sa; // start address of next interleaved unit (sectors)
+ uint16_t size; // size of next interleaved unit (sectors)
+ uint32_t vob_v_s_s_ptm; /* video start ptm in vob */
+ uint32_t vob_v_e_e_ptm; /* video end ptm in vob */
+ struct {
+ uint32_t stp_ptm1;
+ uint32_t stp_ptm2;
+ uint32_t gap_len1;
+ uint32_t gap_len2;
+ } vob_a[8];
+} ATTRIBUTE_PACKED sml_pbi_t;
+
+/**
+ * Seamless Angle Infromation for one angle
+ */
+typedef struct {
+ uint32_t address; // Sector offset to next ILVU, high bit is before/after
+ uint16_t size; // Byte size of the ILVU poited to by address.
+} ATTRIBUTE_PACKED sml_agl_data_t;
+
+/**
+ * Seamless Angle Infromation
+ */
+typedef struct {
+ sml_agl_data_t data[9];
+} ATTRIBUTE_PACKED sml_agli_t;
+
+/**
+ * VOBU Search Information
+ */
+typedef struct {
+ uint32_t next_video; // Next vobu that contains video
+ uint32_t fwda[19]; // Forwards, time
+ uint32_t next_vobu;
+ uint32_t prev_vobu;
+ uint32_t bwda[19]; // Backwards, time
+ uint32_t prev_video;
+} ATTRIBUTE_PACKED vobu_sri_t;
+
+#define SRI_END_OF_CELL 0x3fffffff
+
+/**
+ * Synchronous Information
+ */
+typedef struct {
+ uint16_t a_synca[8]; // Sector offset to first audio packet for this VOBU
+ uint32_t sp_synca[32]; // Sector offset to first subpicture packet
+} ATTRIBUTE_PACKED synci_t;
+
+/**
+ * DSI packet
+ */
+typedef struct {
+ dsi_gi_t dsi_gi;
+ sml_pbi_t sml_pbi;
+ sml_agli_t sml_agli;
+ vobu_sri_t vobu_sri;
+ synci_t synci;
+ uint8_t zero1[471];
+} ATTRIBUTE_PACKED dsi_t;
+
+
+#if PRAGMA_PACK
+#pragma pack()
+#endif
+
+#endif /* NAV_TYPES_H_INCLUDED */
diff --git a/src/libspudec/xine_decoder.c b/src/libspudec/xine_decoder.c
index 8a8763207..a75c6b7d5 100644
--- a/src/libspudec/xine_decoder.c
+++ b/src/libspudec/xine_decoder.c
@@ -19,7 +19,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: xine_decoder.c,v 1.45 2001/12/12 15:05:37 jcdutton Exp $
+ * $Id: xine_decoder.c,v 1.46 2002/01/03 23:56:44 jcdutton Exp $
*
* stuff needed to turn libspu into a xine decoder plugin
*/
@@ -141,9 +141,8 @@ static void spu_process (spudec_decoder_t *this, uint32_t stream_id) {
* For subtitles, open event.
* For menus, store it for later.
*/
-
- if ((this->xine->spu_channel != stream_id) &&
- (this->state.menu == 0) ) {
+/* spu_channel is now set based on whether we are in the menu or not. */
+ if (this->xine->spu_channel != stream_id) {
#ifdef LOG_DEBUG
printf ("spu: Dropping SPU channel %d\n", stream_id);
#endif