]> git.sesse.net Git - vlc/commitdiff
-Some functions to prepare ifo commands utilisation to move in the
authorStéphane Borel <stef@videolan.org>
Fri, 9 Feb 2001 03:51:42 +0000 (03:51 +0000)
committerStéphane Borel <stef@videolan.org>
Fri, 9 Feb 2001 03:51:42 +0000 (03:51 +0000)
structures of DVDs
-Change in configure to avoid compiling css functions on BSD.

configure
configure.in
include/defs.h.in
plugins/dvd/dvd_css.c
plugins/dvd/dvd_ifo.c
plugins/dvd/dvd_ifo.h
plugins/dvd/input_dvd.c

index bf95e10c8f233301a47da5e9ca407493e4bd6a45..a4cae0cde2ba646b58aedf498f76fbaafb7b5983 100755 (executable)
--- a/configure
+++ b/configure
@@ -3307,67 +3307,21 @@ if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   cat >> confdefs.h <<EOF
 #define $ac_tr_hdr 1
 EOF
-else
-  echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_hdr in sys/dvdio.h
-do
-ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
-echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3321: checking for $ac_hdr" >&5
-if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
-  echo $ac_n "(cached) $ac_c" 1>&6
-else
-  cat > conftest.$ac_ext <<EOF
-#line 3326 "configure"
-#include "confdefs.h"
-#include <$ac_hdr>
-EOF
-ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3331: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
-ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
-if test -z "$ac_err"; then
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=yes"
-else
-  echo "$ac_err" >&5
-  echo "configure: failed program was:" >&5
-  cat conftest.$ac_ext >&5
-  rm -rf conftest*
-  eval "ac_cv_header_$ac_safe=no"
-fi
-rm -f conftest*
-fi
-if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
-  echo "$ac_t""yes" 1>&6
-    ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
-  cat >> confdefs.h <<EOF
-#define $ac_tr_hdr 1
-EOF
-else
-  echo "$ac_t""no" 1>&6
-fi
-done
-
-for ac_hdr in linux/cdrom.h
+ for ac_hdr in linux/cdrom.h
 do
 ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:3361: checking for $ac_hdr" >&5
+echo "configure:3315: checking for $ac_hdr" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3366 "configure"
+#line 3320 "configure"
 #include "confdefs.h"
 #include <$ac_hdr>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3371: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3325: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3393,8 +3347,8 @@ else
 fi
 done
 
-cat > conftest.$ac_ext <<EOF
-#line 3398 "configure"
+   cat > conftest.$ac_ext <<EOF
+#line 3352 "configure"
 #include "confdefs.h"
 #include <linux/cdrom.h>
 EOF
@@ -3408,6 +3362,11 @@ EOF
 fi
 rm -f conftest*
 
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
 
 PLUGINS=${PLUGINS}"ps ts dvd yuv idct idctclassic motion ";
 
@@ -3544,17 +3503,17 @@ if test "${enable_alsa+set}" = set; then
   enableval="$enable_alsa"
   if test x$enable_alsa = xyes; then ac_safe=`echo "sys/asoundlib.h" | sed 'y%./+-%__p_%'`
 echo $ac_n "checking for sys/asoundlib.h""... $ac_c" 1>&6
-echo "configure:3548: checking for sys/asoundlib.h" >&5
+echo "configure:3507: checking for sys/asoundlib.h" >&5
 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
   cat > conftest.$ac_ext <<EOF
-#line 3553 "configure"
+#line 3512 "configure"
 #include "confdefs.h"
 #include <sys/asoundlib.h>
 EOF
 ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:3558: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:3517: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
 ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
 if test -z "$ac_err"; then
   rm -rf conftest*
@@ -3571,7 +3530,7 @@ fi
 if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
   echo "$ac_t""yes" 1>&6
   echo $ac_n "checking for main in -lasound""... $ac_c" 1>&6
-echo "configure:3575: checking for main in -lasound" >&5
+echo "configure:3534: checking for main in -lasound" >&5
 ac_lib_var=`echo asound'_'main | sed 'y%./+-%__p_%'`
 if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -3579,14 +3538,14 @@ else
   ac_save_LIBS="$LIBS"
 LIBS="-lasound  $LIBS"
 cat > conftest.$ac_ext <<EOF
-#line 3583 "configure"
+#line 3542 "configure"
 #include "confdefs.h"
 
 int main() {
 main()
 ; return 0; }
 EOF
-if { (eval echo configure:3590: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:3549: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
   rm -rf conftest*
   eval "ac_cv_lib_$ac_lib_var=yes"
 else
index 8a71adda6e38135712960fc7f09ea2bc0518d176..bee9b459a6cce414cac8ee3401b48c267b65678f 100644 (file)
@@ -101,10 +101,9 @@ AC_TYPE_SIZE_T
 AC_HEADER_TIME
 
 dnl Checks for DVD ioctls
-AC_CHECK_HEADERS(sys/ioctl.h)
-AC_CHECK_HEADERS(sys/dvdio.h)
-AC_CHECK_HEADERS(linux/cdrom.h)
-AC_EGREP_HEADER(dvd,linux/cdrom.h,AC_DEFINE(LINUX_DVD,1,DVD support for linux))
+AC_CHECK_HEADERS(sys/ioctl.h,
+  [AC_CHECK_HEADERS(linux/cdrom.h)
+   AC_EGREP_HEADER(dvd,linux/cdrom.h,AC_DEFINE(LINUX_DVD,1,DVD support for linux))])
 
 dnl default plugins 
 PLUGINS=${PLUGINS}"ps ts dvd yuv idct idctclassic motion ";
index f4933b547600e915e9164ebd5ffae13b63ea49ba..dba7934fd42c6cc3f52cf4658dbc719d85616dbf 100644 (file)
@@ -97,9 +97,6 @@
 /* Define if you have the <stddef.h> header file.  */
 #undef HAVE_STDDEF_H
 
-/* Define if you have the <sys/dvdio.h> header file.  */
-#undef HAVE_SYS_DVDIO_H
-
 /* Define if you have the <sys/ioctl.h> header file.  */
 #undef HAVE_SYS_IOCTL_H
 
index e76612fb0ea7bf17e8f4043e745f5ef1e3286e45..0164e75c29bae17daf07d7f7d9c4f234f6d5c44e 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_css.c: Functions for DVD authentification and unscrambling
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_css.c,v 1.3 2001/02/08 17:44:12 massiot Exp $
+ * $Id: dvd_css.c,v 1.4 2001/02/09 03:51:42 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -33,7 +33,9 @@
 #include <string.h>
 #include <fcntl.h>
 #include <netinet/in.h>
-#include <sys/ioctl.h>
+#ifdef HAVE_IOCTL_H
+# include <sys/ioctl.h>
+#endif
 #ifdef HAVE_SYS_DVDIO_H
 # include <sys/dvdio.h>
 #endif
index f11f0c4a53ef9278a9d313b158fd821343ff28d3..84b34a9a13747a83e354896bdeb82a34ae9dae4a 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_ifo.c: Functions for ifo parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_ifo.c,v 1.3 2001/02/08 17:44:12 massiot Exp $
+ * $Id: dvd_ifo.c,v 1.4 2001/02/09 03:51:42 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -35,6 +35,8 @@
 #include "dvd_ifo.h"
 #include "input_dvd.h"
 
+void CommandRead( ifo_command_t );
+
 /*
  * IFO Management.
  */
@@ -244,9 +246,10 @@ void IfoEnd( ifo_t* p_ifo )
                                 (int)((p_com)->i_dir_cmp),                  \
                                 (int)((p_com)->i_cmp),                      \
                                 (int)((p_com)->i_sub_cmd),                  \
-                                (int)((p_com)->i_v0),                       \
-                                (int)((p_com)->i_v2),                       \
-                                (int)((p_com)->i_v4) );           */          \
+                                (int)((p_com)->data.pi_16[0]),              \
+                                (int)((p_com)->data.pi_16[1]),              \
+                                (int)((p_com)->data.pi_16[2]));*/             \
+/*        CommandRead( *(p_com) );*/                                            \
         p_ifo->i_pos += 8;                                                  \
     }
 
@@ -1115,72 +1118,681 @@ void IfoRead( ifo_t* p_ifo )
 }
 
 /*
- * IFO virtual machine : a set of commands that give the behaviour of the dvd
+ * IFO virtual machine : a set of commands that give the
+ * interactive behaviour of the dvd
  */
-#if 0
-/*****************************************************************************
- * CommandRead : translates the command strings in ifo into command
- * structures.
- *****************************************************************************/
-void CommandRead( ifo_command_t com )
+#if 1
+
+#define OP_VAL_16(i) (ntoh16( com.data.pi_16[i]))
+#define OP_VAL_8(i) ((com.data.pi_8[i]))
+
+static char ifo_reg[][80]=
 {
-    u8*     pi_code = (u8*)(&com);
+    "Menu_Language_Code",
+    "Audio_Stream_#",
+    "SubPicture_Stream_#",
+    "Angle_#",
+    "VTS_#",
+    "VTS_Title_#",
+    "PGC_#",
+    "PTT_#",
+    "Highlighted_Button_#",
+    "Nav_Timer",
+    "TimedPGC",
+    "Karaoke_audio_mixing_mode",
+    "Parental_mgmt_country_code",
+    "Parental_Level",
+    "Player_Video_Cfg",
+    "Player_Audio_Cfg",
+    "Audio_language_code_setting",
+    "Audio_language_extension_code",
+    "SPU_language_code_setting",
+    "SPU_language_extension_code",
+    "?Player_Regional_Code",
+    "Reserved_21",
+    "Reserved_22",
+    "Reserved_23"
+};
+
+static char * IfoMath( char val )
+{
+    static char math_op[][10] =
+    {
+        "none",
+        "=", 
+        "<->",    // swap
+        "+=",
+        "-=",
+        "*=",
+        "/=",
+        "%=",
+        "rnd",    // rnd
+        "&=",
+        "|=",
+        "^=",
+        "??",    // invalid
+        "??",    // invalid
+        "??",    // invalid
+        "??"    // invalid
+    };
+
+    return (char *) math_op[val & 0x0f];
+}
 
-    switch( com.i_type )
+
+char ifo_cmp[][10] =
+{
+    "none",
+    "&&",
+    "==",
+    "!=",
+    ">=",
+    ">",
+    "<",
+    "<="
+};
+
+char ifo_parental[][10] =
+{
+    "0",
+    "G",
+    "2",
+    "PG",
+    "PG-13",
+    "5",
+    "R",
+    "NC-17"
+};
+
+char ifo_menu_id[][80] =
+{
+    "-0-",
+    "-1-",
+    "Title (VTS menu)",
+    "Root",
+    "Sub-Picture",
+    "Audio",
+    "Angle",
+    "Part of Title",
+};
+
+char * IfoMenuName( char index )
+{
+    return ifo_menu_id[index&0x07];
+}
+
+static void IfoRegister( u16 i_data, u8 i_direct)
+{
+    if( i_direct )
     {
-        case 0:                                     /* Goto */
-            if( !pi_code[1] )
+        if( 0/*isalpha( i_data >> 8 & 0xff )*/ )
+        {
+            printf("'%c%c'", i_data>>8&0xff, i_data&0xff);
+        }
+        else
+        {
+            printf("0x%02x", i_data);
+        }
+    }
+    else
+    {
+        if( i_data & 0x80 )
+        {
+            i_data &= 0x1f;
+
+            if( i_data > 0x17 )
             {
-                fprintf( stderr, "NOP\n" );
+                printf("s[ILL]");
             }
-            else if( cmd.i_cmp )
+            else
             {
-                
+                printf("s[%s]", ifo_reg[i_data]);
             }
+        }
+        else
+        {
+            i_data &= 0x1f;
+
+            if( i_data > 0xf )
+            {
+                printf("r[ILL]");
+            }
+            else
+            {
+                printf("r[0x%02x]", i_data);
+            }
+        }
+    }
+}
+
+static void IfoAdvanced( u8 *pi_code )
+{
+    u8      i_cmd = pi_code[0];
+
+    printf(" { ");
+
+    if( pi_code[1]>>2 )
+    {
+        printf( " Highlight button %d; ", pi_code[1]>>2 );
+    }
+
+    if( i_cmd == 0xff )
+    {
+        printf( " Illegal " );
+    }
+
+    if( i_cmd == 0x00 )
+    {
+        printf( "ReSuME %d", pi_code[7] );
+    }
+    else if( ( i_cmd & 0x06) == 0x02 )
+    {    // XX01Y
+        printf ("Link to %s cell ", ( i_cmd & 0x01 ) ? "prev" : "next");
+    }
+    else
+    {
+        printf( "advanced (0x%02x) ", i_cmd );
+    }
+    printf(" } ");
+}
+
+static void IfoJmp( ifo_command_t com )
+{
+
+    printf ("jmp ");
+
+    switch( com.i_sub_cmd )
+    {
+    case 0x01:
+        printf( "Exit" );
+        break;
+    case 0x02:
+        printf( "VTS 0x%02x", OP_VAL_8(3) );
+        break;
+    case 0x03:
+        printf( "This VTS Title 0x%02x", OP_VAL_8(3) );
+        break;
+    case 0x05:
+        printf( "This VTS Title 0x%02x Part 0x%04x",
+                            OP_VAL_8(3),
+                            OP_VAL_8(0)<<8|OP_VAL_8(1));
+        break;
+    case 0x06:
+#if 0
+            printf ("in SystemSpace ");
+            switch (OP_VAL_8(3)>>4) {
+                case 0x00:
+                    printf ("to play first PGC");
+                    break;
+                case 0x01: {
+                    printf ("to menu \"%s\"", decode_menuname (OP_VAL_8(3)));
+                }
+                    break;
+                case 0x02:
+                    printf ("to VTS 0x%02x and TTN 0x%02x", OP_VAL_8(1), OP_VAL_8(2));
+                    break;
+                case 0x03:
+                    printf ("to VMGM PGC number 0x%02x", OP_VAL_8(0)<<8 | OP_VAL_8(1));
+                    break;
+                case 0x08:
+                    printf ("vts 0x%02x lu 0x%02x menu \"%s\"", OP_VAL_8(2), OP_VAL_8(1), decode_menuname (OP_VAL_8(3)));
+                    break;
+#else
+        switch( OP_VAL_8(3)>>6 )
+        {
+        case 0x00:
+            printf( "to play first PGC" );
+            break;                
+        case 0x01:
+            printf( "to VMG title menu (?)" );
             break;
-        case 1:                                     /* Lnk */
-            break;
-        case 2:                                     /* SetSystem */
-            break;
-        case 3:                                     /* Set */
-            break;
-        case 4:                                     /* */
+        case 0x02:
+            printf( "vts 0x%02x lu 0x%02x menu \"%s\"",
+                            OP_VAL_8(2),
+                            OP_VAL_8(1),
+                            IfoMenuName( OP_VAL_8(3)&0xF ) );
+            break;                
+        case 0x03:
+            printf( "vmg pgc 0x%04x (?)", ( OP_VAL_8(0)<<8) | OP_VAL_8(1) );
             break;
-        case 5:                                     /* */
+#endif
+        }
+        break;
+    case 0x08:
+#if 0
+            switch(OP_VAL_8(3)>>4) {
+                case 0x00:
+                    printf ("system first pgc");
+                    break;
+                case 0x01:
+                    printf ("system title menu");
+                    break;
+                case 0x02:
+                    printf ("system menu \"%s\"", decode_menuname (OP_VAL_8(3)));
+                    break;
+                case 0x03:
+                    printf ("system vmg pgc %02x ????", OP_VAL_8(0)<<8|OP_VAL_8(1));
+                    break;
+                case 0x08:
+                    printf ("system lu 0x%02x menu \"%s\"", OP_VAL_8(2), decode_menuname (OP_VAL_8(3)));
+                    break;
+                case 0x0c:
+                    printf ("system vmg pgc 0x%02x", OP_VAL_8(0)<<8|OP_VAL_8(1));
+                    break;
+            }
+#else
+        // OP_VAL_8(2) is number of cell
+        // it is processed BEFORE switch
+        // under some conditions, it is ignored
+        // I don't understand exactly what it means
+        printf( " ( spec cell 0x%02X ) ", OP_VAL_8(2) ); 
+
+        switch( OP_VAL_8(3)>>6 )
+        {
+        case 0:
+            printf( "to FP PGC" );
             break;
-        case 6:                                     /* */
+        case 1:
+            printf( "to VMG root menu (?)" );
             break;
-        default:
-            fprintf( stderr, "Unknown Command\n" );
+        case 2:
+            printf( "to VTS menu \"%s\" (?)",
+                    IfoMenuName(OP_VAL_8(3)&0xF) );
+            break; 
+        case 3:
+            printf( "vmg pgc 0x%02x (?)", (OP_VAL_8(0)<<8)|OP_VAL_8(1) );
             break;
+        }    
+#endif
+        break;
     }
+}
 
-    return;
+static void IfoLnk( ifo_command_t com )
+{
+    u16     i_button=OP_VAL_8(4)>>2;
+
+    printf ("lnk to ");
+
+    switch( com.i_sub_cmd )
+    {
+    case 0x01:
+        IfoAdvanced( &OP_VAL_8(4) );
+        break;
+
+    case 0x04:
+        printf( "PGC 0x%02x", OP_VAL_16(2) );
+        break; 
+
+    case 0x05:
+        printf( "PTT 0x%02x", OP_VAL_16(2) );
+        break; 
+
+    case 0x06:
+        printf( "Program 0x%02x this PGC", OP_VAL_8(5) );
+        break;
+
+    case 0x07:
+        printf( "Cell 0x%02x this PGC", OP_VAL_8(5) );
+        break;
+    default:
+        return;
+    }
+
+    if( i_button )
+    {
+        printf( ", Highlight 0x%02x", OP_VAL_8(4)>>2 );
+    }
+            
 }
 
-/*****************************************************************************
- * IfoGoto
- *****************************************************************************/
-static void IfoGoto( ifo_command_t cmd )
+void IfoSetSystem( ifo_command_t com )
 {
-    
+    switch( com.i_cmd )
+    {
+    case 1: {
+        int i;
 
-    return;
+        for( i=1; i<=3; i++ )
+        {
+            if( OP_VAL_8(i)&0x80 )
+            {
+                if( com.i_direct )
+                {
+                    printf ("s[%s] = 0x%02x;", ifo_reg[i], OP_VAL_8(i)&0xf);
+                }
+                else
+                {
+                    printf ("s[%s] = r[0x%02x];", ifo_reg[i], OP_VAL_8(i)&0xf);
+                }
+            }
+        }
+#if 0
+                if(op->direct) {
+                        if(OP_VAL_8(1]&0x80)
+                                printf ("s[%s] = 0x%02x;", reg_name[1], OP_VAL_8(1]&0xf);
+                        if(OP_VAL_8(2)&0x80)
+//DENT: lwhat about 0x7f here ???
+                                printf ("s[%s] = 0x%02x;", reg_name[2], OP_VAL_8(2)&0x7f);
+                        if(OP_VAL_8(3)&0x80)
+                                printf ("s[%s] = 0x%02x;", reg_name[3], OP_VAL_8(3)&0xf);
+                } else {
+                        if(OP_VAL_8(1)&0x80)
+                                printf ("s[%s] = r[0x%02x];", reg_name[1], OP_VAL_8(1)&0xf);
+                        if(OP_VAL_8(2)&0x80)
+                                printf ("s[%s] = r[0x%02x];", reg_name[2], OP_VAL_8(2)&0xf);
+                        if(OP_VAL_8(3)&0x80)
+                                printf ("s[%s] = r[0x%02x];", reg_name[3], OP_VAL_8(3)&0xf);
+                }
+#endif
+        }
+        break;
+    case 2:
+        if( com.i_direct )
+        {
+            printf( "s[%s] = 0x%02x", ifo_reg[9], OP_VAL_16(0) );
+        }
+        else
+        {
+            printf( "s[%s] = r[0x%02x]", ifo_reg[9], OP_VAL_8(1)&0x0f );
+        }
+
+        printf( "s[%s] = (s[%s]&0x7FFF)|0x%02x", 
+                        ifo_reg[10], ifo_reg[10], OP_VAL_16(1)&0x8000);
+        break;
+    case 3:
+        if( com.i_direct )
+        {
+            printf( "r[0x%02x] = 0x%02x", OP_VAL_8(3)&0x0f, OP_VAL_16(0) );
+        }
+        else
+        {
+            printf ("r[r[0x%02x]] = r[0x%02x]",
+                                    OP_VAL_8(3)&0x0f, OP_VAL_8(1)&0x0f);
+        }
+        break;
+    case 4:
+        //actually only bits 00011100 00011100 are set
+        if( com.i_direct )
+        {
+            printf ("s[%s] = 0x%02x", ifo_reg[11], OP_VAL_16(1));
+        }
+        else
+        {
+            printf ("s[%s] = r[0x%02x]", ifo_reg[11], OP_VAL_8(3)&0x0f );
+        }
+        break;
+    case 6:
+        //actually,
+        //s[%s]=(r[%s]&0x3FF) | (0x%02x << 0xA);
+        //but it is way too ugly
+        if( com.i_direct )
+        {
+            printf( "s[%s] = 0x%02x", ifo_reg[8], OP_VAL_8(2)>>2 );
+        }
+        else
+        {
+            printf( "s[%s] = r[0x%02x]", ifo_reg[8], OP_VAL_8(3)&0x0f );
+        }
+        break;
+    default:
+        printf ("unknown");
+    }
+}
+
+static void IfoSet( ifo_command_t com )
+{
+    IfoRegister( OP_VAL_16(0), 0 );
+    printf( " %s ", IfoMath( com.i_cmd ) );
+    IfoRegister( OP_VAL_16(1), com.i_direct );
 }
 
 /*****************************************************************************
- * IfoLnk
+ * CommandRead : translates the command strings in ifo into command
+ * structures.
  *****************************************************************************/
-static void IfoLnk( ifo_t* p_ifo )
+void CommandRead( ifo_command_t com )
 {
+    u8*     pi_code = (u8*)(&com);
+
+    switch( com.i_type )
+    {
+    /* Goto */
+    case 0:
+        /* Main command */
+        if( !pi_code[1] )
+        {
+            printf( "NOP\n" );
+        }
+        else
+        {
+            if( com.i_cmp )
+            {
+                printf ("if (r[0x%02x] %s ", OP_VAL_8(1)&0x0f,
+                                             ifo_cmp[com.i_cmp]);
+                IfoRegister (OP_VAL_16(1), com.i_dir_cmp);
+                printf (") ");
+            }
+        
+            /* Sub command */
+            switch( com.i_sub_cmd )
+            {
+            case 1:
+                printf( "goto Line 0x%02x", OP_VAL_16(2) );
+                break;
+        
+            case 2:
+                printf( "stop VM" );
+                break;
+        
+            case 3:
+                printf( "Set Parental Level To %s and goto Line 0x%02x",
+                                     ifo_parental[OP_VAL_8(4)&0x7],
+                                     OP_VAL_8(5) );
+                break;
+        
+            default:
+                printf( "Illegal" );
+                break;
+            }
+        }
+        break;
+
+    /* Lnk */
+    case 1:
+        /* Main command */
+        if( !pi_code[1] )
+        {
+            printf( "NOP\n" );
+        }
+        else
+        {
+            if( com.i_direct )
+            {
+                if( com.i_cmp )
+                {
+                    printf( "if (r[0x%02x] %s ", OP_VAL_8(4)&0x0f,
+                                                 ifo_cmp[com.i_cmp] );
+                    IfoRegister( OP_VAL_8(5), 0 );
+                    printf( ") " );
+                }
+
+                /* Sub command */
+                IfoJmp( com );
+            }
+            else
+            {    
+                if( com.i_cmp )
+                {
+                    printf( "if (r[0x%02x] %s ", OP_VAL_8(1)&0x0f,
+                                                 ifo_cmp[com.i_cmp] );
+                    IfoRegister( OP_VAL_16(1), com.i_dir_cmp );
+                    printf( ") " );
+                }
+
+                /* Sub command */
+                IfoLnk( com );
+            }
+        }
+        break;
+
+    /* SetSystem */
+    case 2:
+        if( !pi_code[1] )
+        {
+            IfoSetSystem( com );
+        }
+        else if( com.i_cmp && !com.i_sub_cmd )
+        {
+            printf ("if (r[0x%02x] %s ", OP_VAL_8(4)&0x0f, ifo_cmp[com.i_cmp]);
+            IfoRegister( OP_VAL_8(5), 0 );
+            printf (") ");
+            IfoSetSystem( com );
+        }
+        else if( !com.i_cmp && com.i_sub_cmd )
+        {
+            printf( "if (" );
+            IfoSetSystem( com );
+            printf( ") " );
+            IfoLnk( com );
+        }
+        else
+        {
+            printf("nop");
+        }
+        break;
+
+    /* Set */
+    case 3:
+          if( ! pi_code[1] )
+        {
+            IfoSet( com );
+        }
+        else if( com.i_cmp && !com.i_sub_cmd )
+        {
+            printf ("if (r[0x%02x] %s ", OP_VAL_8(0)&0x0f, ifo_cmp[com.i_cmp]);
+            IfoRegister( OP_VAL_16(2), com.i_dir_cmp );
+            printf (") ");
+            IfoSet( com );
+        }
+        else if( !com.i_cmp && com.i_sub_cmd )
+        {
+            printf ("if (");
+            IfoSet( com );
+            printf (") ");
+            IfoLnk( com );
+        }
+        else
+        {
+            printf( "nop" );
+        }
+        break;
+
+    /* 
+     * math command on r[opcode[1]] and
+     * direct?be2me_16(OP_VAL_8(0)):reg[OP_VAL_8(1)] is executed
+     * ( unless command is swap; then r[opcode[1]] and r[OP_VAL_8(1)]
+     * are swapped )
+     * boolean operation cmp on r[opcode[1]] and
+     * dir_cmp?be2me_16(OP_VAL_8(1)[1]):reg[OP_VAL_8(3)] is executed
+     * on true result, buttons(c[6], c[7]) is called
+     * problem is 'what is buttons()'
+     */
+    case 4:
+        printf( "r[0x%X] ", pi_code[1] );
+        printf( " %s ", IfoMath( com.i_cmd ) );
+        if( com.i_cmd == 2 )
+        {
+            printf( "r[0x%X] ", OP_VAL_8(1) );
+        }
+        else
+        {
+            IfoRegister( OP_VAL_16(0), com.i_direct );
+        }
+        printf("; ");
+
+        printf( "if ( r[%d] %s ", pi_code[1], ifo_cmp[com.i_cmp] );
+        IfoRegister( OP_VAL_8(1), com.i_dir_cmp );
+        printf( " )  then {" );
+        IfoAdvanced( &OP_VAL_8(4) );
+        printf( "}" );
+        break;
+
+    /*
+     * opposite to case 4: boolean, math and buttons.
+     */
+    case 5:
+    case 6:
+        printf("if (");
+
+        if( !com.i_direct && com.i_dir_cmp )
+        {
+            printf( "0x%X", OP_VAL_16(1) );
+        }
+        else
+        {
+            IfoRegister( OP_VAL_8(3), 0 );
+            if( OP_VAL_8(3)&0x80 )
+            {
+                printf( "s[%s]", ifo_reg[OP_VAL_8(3)&0x1F] );
+            }
+            else
+            {
+                printf( "r[0x%X]", OP_VAL_8(3)&0x1F);
+                    // 0x1F is either not a mistake,
+                    // or Microsoft programmer's mistake!!!
+            }
+        }
+
+        printf( " %s r[0x%X] ", ifo_cmp[com.i_cmp],
+                                com.i_direct ? OP_VAL_8(2) : OP_VAL_8(1) );
+           printf( " )  then {" );
+        printf( "r[0x%X] ", pi_code[1] & 0xF );
+        printf( " %s ", IfoMath( com.i_cmd ) );
+
+        if( com.i_cmd == 0x02 )    // swap
+        {
+            printf("r[0x%X] ", OP_VAL_8(0)&0x1F);
+        }
+        else
+        {
+            if( com.i_direct )
+            {
+                printf( "0x%X", OP_VAL_16(0) );
+            }
+            else
+            {
+                if( OP_VAL_8(0) & 0x80 )
+                {
+                    printf("s[%s]", ifo_reg[OP_VAL_8(0) & 0x1F] );
+                }
+                else
+                {
+                    printf("r[0x%X]", OP_VAL_8(0) & 0x1F );
+                }
+            }
+        }
+
+        printf("; ");
+        IfoAdvanced( &OP_VAL_8(4) );
+        printf("}");
+
+        break;
+
+    default:
+        printf( "Unknown Command\n" );
+        break;
+    }
+
     return;
 }
 
 /*****************************************************************************
- * IfoJmp
+ * CommandPrint : print in clear text (I hope so !) what a command does
  *****************************************************************************/
-static void IfoJmp( ifo_t* p_ifo )
+void CommandPrint( ifo_t ifo )
 {
     return;
 }
+
 #endif
index 14f045cffcffbe4eaaf05f27fceeb856370c8015..3c6e2584ecc8f871a62cc2e775aba4d098675bf5 100644 (file)
@@ -2,7 +2,7 @@
  * dvd_ifo.h: Structures for ifo parsing
  *****************************************************************************
  * Copyright (C) 1999-2001 VideoLAN
- * $Id: dvd_ifo.h,v 1.2 2001/02/08 17:44:12 massiot Exp $
+ * $Id: dvd_ifo.h,v 1.3 2001/02/09 03:51:42 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -38,9 +38,11 @@ typedef struct ifo_command_s
     u8              i_dir_cmp   :1;
     u8              i_cmp       :3;
     u8              i_sub_cmd   :4;
-    u16             i_v0        :16;
-    u16             i_v2        :16;
-    u16             i_v4        :16;
+    union
+    {
+               u8          pi_8[6];
+               u16         pi_16[3];
+    } data;
 } ifo_command_t;
 
 /* Program Chain Command Table
index 6f4a0cfa40fd3a8fe72afb201ff6e9abcddb0eb9..5af36e5c8d5bb40cf47eafaaf776b1c9a3473eea 100644 (file)
@@ -10,7 +10,7 @@
  *  -dvd_udf to find files
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: input_dvd.c,v 1.5 2001/02/08 17:44:12 massiot Exp $
+ * $Id: input_dvd.c,v 1.6 2001/02/09 03:51:42 stef Exp $
  *
  * Author: Stéphane Borel <stef@via.ecp.fr>
  *
@@ -176,10 +176,10 @@ static void DVDInit( input_thread_t * p_input )
     IfoRead( &(p_method->ifo) );
     intf_Msg( "Ifo: Initialized" );
 
-#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
     /* CSS authentication and keys */
     if( ( p_method->b_encrypted = DVDCheckCSS( p_input ) ) )
     {
+#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
         int   i;
 
         p_method->css = CSSInit( p_input->i_handle );
@@ -199,8 +199,10 @@ static void DVDInit( input_thread_t * p_input )
         }
         CSSGetKeys( &(p_method->css) );
         intf_Msg( "CSS: Initialized" );
-    }
+#else
+        intf_ErrMsg( "Unscrambling not supported" );
 #endif
+    }
 
     /* FIXME: Kludge beginning of vts_01_1.vob */
     i_start = p_method->ifo.p_vts[0].i_pos +