Commit b3d7d241 authored by Stéphane Borel's avatar Stéphane Borel

-Fixed the lock segfault bug with some compilers

-Quick kludge in ifo to avoid a bug with optims. The real fix is coming.
parent b8539d07
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* control the pace of reading. * control the pace of reading.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.30 2001/04/08 07:24:47 stef Exp $ * $Id: input_ext-intf.h,v 1.31 2001/04/10 17:47:05 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -97,7 +97,7 @@ typedef struct es_descriptor_s ...@@ -97,7 +97,7 @@ typedef struct es_descriptor_s
#define LPCM_AUDIO_ES 0x83 #define LPCM_AUDIO_ES 0x83
#define UNKNOWN_ES 0xFF #define UNKNOWN_ES 0xFF
/* ES Categories */ /* ES Categories to be used by interface plugins */
#define VIDEO_ES 0x00 #define VIDEO_ES 0x00
#define AUDIO_ES 0x01 #define AUDIO_ES 0x01
#define SPU_ES 0x02 #define SPU_ES 0x02
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dvd_css.c: Functions for DVD authentification and unscrambling * dvd_css.c: Functions for DVD authentification and unscrambling
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.c,v 1.22 2001/04/08 16:57:47 sam Exp $ * $Id: dvd_css.c,v 1.23 2001/04/10 17:47:05 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -275,7 +275,8 @@ int CSSInit( css_t * p_css ) ...@@ -275,7 +275,8 @@ int CSSInit( css_t * p_css )
return 0; return 0;
case 0: case 0:
intf_WarnMsg( 3, "css info: no way to authenticate" ); intf_ErrMsg( "css error: no way to authenticate" );
return -1;
} }
#else /* HAVE_CSS */ #else /* HAVE_CSS */
...@@ -406,13 +407,13 @@ int CSSGetKey( css_t * p_css ) ...@@ -406,13 +407,13 @@ int CSSGetKey( css_t * p_css )
if( !b_encrypted ) if( !b_encrypted )
{ {
intf_WarnMsg( 3, "css warning: this file was _NOT_ encrypted!" ); intf_WarnMsg( 3, "css warning: this file was _NOT_ encrypted!" );
return(0); return 0;
} }
if( b_encrypted && i_registered_keys == 0 ) if( b_encrypted && i_registered_keys == 0 )
{ {
intf_ErrMsg( "css error: unable to determine keys from file" ); intf_ErrMsg( "css error: unable to determine keys from file" );
return(1); return -1;
} }
for( i = 0 ; i < i_registered_keys - 1 ; i++ ) for( i = 0 ; i < i_registered_keys - 1 ; i++ )
...@@ -469,10 +470,12 @@ int CSSGetKey( css_t * p_css ) ...@@ -469,10 +470,12 @@ int CSSGetKey( css_t * p_css )
memcpy( p_css->pi_title_key, memcpy( p_css->pi_title_key,
p_title_key[i_highest].pi_key, KEY_SIZE ); p_title_key[i_highest].pi_key, KEY_SIZE );
intf_WarnMsg( 2, "css info: vts key initialized" );
return 0; return 0;
#else /* HAVE_CSS */ #else /* HAVE_CSS */
return 1; intf_ErrMsg( "css error: css decryption unavailable" );
return -1;
#endif /* HAVE_CSS */ #endif /* HAVE_CSS */
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing * dvd_ifo.c: Functions for ifo parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.17 2001/04/08 07:24:47 stef Exp $ * $Id: dvd_ifo.c,v 1.18 2001/04/10 17:47:05 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -69,9 +69,9 @@ static int FreeTitleSet ( vts_t * ); ...@@ -69,9 +69,9 @@ static int FreeTitleSet ( vts_t * );
#define GET( p_field , i_len ) \ #define GET( p_field , i_len ) \
{ \ { \
read( p_ifo->i_fd , (p_field) , (i_len) ); \ read( p_ifo->i_fd , (p_field) , (i_len) ); \
/*fprintf(stderr, "Pos : %lld Val : %llx\n", \ /* fprintf(stderr, "Pos : %lld Val : %llx\n", \
(long long)(p_ifo->i_pos - i_start), \ (long long)(p_ifo->i_pos - i_start), \
(long long)*(p_field) ); */ \ (long long)*(p_field) ); */ \
p_ifo->i_pos += i_len; \ p_ifo->i_pos += i_len; \
} }
...@@ -80,7 +80,7 @@ static int FreeTitleSet ( vts_t * ); ...@@ -80,7 +80,7 @@ static int FreeTitleSet ( vts_t * );
read( p_ifo->i_fd , (p_field) , 1 ); \ read( p_ifo->i_fd , (p_field) , 1 ); \
/*fprintf(stderr, "Pos : %lld Value : %d\n", \ /*fprintf(stderr, "Pos : %lld Value : %d\n", \
(long long)(p_ifo->i_pos - i_start), \ (long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \ *(p_field) ); */ \
p_ifo->i_pos += 1; \ p_ifo->i_pos += 1; \
} }
...@@ -90,7 +90,7 @@ static int FreeTitleSet ( vts_t * ); ...@@ -90,7 +90,7 @@ static int FreeTitleSet ( vts_t * );
*(p_field) = ntohs( *(p_field) ); \ *(p_field) = ntohs( *(p_field) ); \
/*fprintf(stderr, "Pos : %lld Value : %d\n", \ /*fprintf(stderr, "Pos : %lld Value : %d\n", \
(long long)(p_ifo->i_pos - i_start), \ (long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \ *(p_field) ); */ \
p_ifo->i_pos += 2; \ p_ifo->i_pos += 2; \
} }
...@@ -100,7 +100,7 @@ static int FreeTitleSet ( vts_t * ); ...@@ -100,7 +100,7 @@ static int FreeTitleSet ( vts_t * );
*(p_field) = ntohl( *(p_field) ); \ *(p_field) = ntohl( *(p_field) ); \
/*fprintf(stderr, "Pos : %lld Value : %d\n", \ /*fprintf(stderr, "Pos : %lld Value : %d\n", \
(long long)(p_ifo->i_pos - i_start), \ (long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \ *(p_field) ); */ \
p_ifo->i_pos += 4; \ p_ifo->i_pos += 4; \
} }
...@@ -110,7 +110,7 @@ static int FreeTitleSet ( vts_t * ); ...@@ -110,7 +110,7 @@ static int FreeTitleSet ( vts_t * );
*(p_field) = ntoh64( *(p_field) ); \ *(p_field) = ntoh64( *(p_field) ); \
/*fprintf(stderr, "Pos : %lld Value : %lld\n", \ /*fprintf(stderr, "Pos : %lld Value : %lld\n", \
(long long)(p_ifo->i_pos - i_start), \ (long long)(p_ifo->i_pos - i_start), \
*(p_field) );*/ \ *(p_field) ); */ \
p_ifo->i_pos += 8; \ p_ifo->i_pos += 8; \
} }
...@@ -126,38 +126,42 @@ static int FreeTitleSet ( vts_t * ); ...@@ -126,38 +126,42 @@ static int FreeTitleSet ( vts_t * );
/* /*
* IFO Management. * IFO Management.
*/ */
/***************************************************************************** /*****************************************************************************
* IfoInit : Creates an ifo structure and prepares for parsing directly * IfoCreate : Creates an ifo structure and prepares for parsing directly
* on DVD device. Then reads information from the management table. * on DVD device
*****************************************************************************/ *****************************************************************************/
int IfoInit( ifo_t ** pp_ifo, int i_fd ) int IfoCreate( thread_dvd_data_t * p_dvd )
{ {
ifo_t * p_ifo; p_dvd->p_ifo = malloc( sizeof(ifo_t) );
u64 i_temp; if( p_dvd->p_ifo == NULL )
u32 i_lba;
int i, j, k;
off_t i_start;
p_ifo = malloc( sizeof(ifo_t) );
if( p_ifo == NULL )
{ {
intf_ErrMsg( "ifo error: unable to allocate memory. aborting" ); intf_ErrMsg( "ifo error: unable to allocate memory. aborting" );
return -1; return -1;
} }
*pp_ifo = p_ifo;
/* if we are here the dvd device has already been opened */ /* if we are here the dvd device has already been opened */
p_ifo->i_fd = i_fd; p_dvd->p_ifo->i_fd = p_dvd->i_fd;
return 0;
}
/*****************************************************************************
* IfoInit : Reads information from the management table.
*****************************************************************************/
int IfoInit( ifo_t * p_ifo )
{
u64 i_temp;
u32 i_lba;
int i, j, k;
off_t i_start;
/* find the start sector of video information on the dvd */ /* find the start sector of video information on the dvd */
i_lba = UDFFindFile( i_fd, "/VIDEO_TS/VIDEO_TS.IFO"); i_lba = UDFFindFile( p_ifo->i_fd, "/VIDEO_TS/VIDEO_TS.IFO");
p_ifo->i_off = (off_t)(i_lba) * DVD_LB_SIZE; p_ifo->i_off = (off_t)(i_lba) * DVD_LB_SIZE;
p_ifo->i_pos = lseek( p_ifo->i_fd, p_ifo->i_off, SEEK_SET ); p_ifo->i_pos = lseek( p_ifo->i_fd, p_ifo->i_off, SEEK_SET );
//i_start = p_ifo->i_pos;
/* /*
* read the video manager information table * read the video manager information table
*/ */
...@@ -203,7 +207,7 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd ) ...@@ -203,7 +207,7 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
} }
FLUSH( 17 ); FLUSH( 17 );
GETC( &manager_inf.i_spu_nb ); GETC( &manager_inf.i_spu_nb );
//fprintf( stderr, "vmgi subpic nb : %d\n", manager_inf.i_subpic_nb ); //fprintf( stderr, "vmgi subpic nb : %d\n", manager_inf.i_spu_nb );
for( i=0 ; i < manager_inf.i_spu_nb ; i++ ) for( i=0 ; i < manager_inf.i_spu_nb ; i++ )
{ {
GET( &i_temp, 6 ); GET( &i_temp, 6 );
...@@ -254,7 +258,7 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd ) ...@@ -254,7 +258,7 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
GETC( &title_inf.p_attr[i].i_title_set_num ); GETC( &title_inf.p_attr[i].i_title_set_num );
GETC( &title_inf.p_attr[i].i_title_num ); GETC( &title_inf.p_attr[i].i_title_num );
GETL( &title_inf.p_attr[i].i_start_sector ); GETL( &title_inf.p_attr[i].i_start_sector );
//fprintf( stderr, "title_inf: %d %d %d\n", ptr.p_tts[i].i_ptt_nb, ptr.p_tts[i].i_tts_nb,ptr.p_tts[i].i_vts_ttn ); //fprintf( stderr, "title_inf: %d %d %d\n",title_inf.p_attr[i].i_chapter_nb ,title_inf.p_attr[i].i_title_set_num,title_inf.p_attr[i].i_title_num );
} }
} }
else else
...@@ -391,14 +395,14 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd ) ...@@ -391,14 +395,14 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
FLUSH(2); FLUSH(2);
FLUSH( 1 ); FLUSH( 1 );
GETC( &vts_inf.p_vts_attr[i].i_vts_menu_audio_nb ); GETC( &vts_inf.p_vts_attr[i].i_vts_menu_audio_nb );
//fprintf( stderr, "m audio nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtsm_audio_nb ); //fprintf( stderr, "m audio nb : %d\n", vts_inf.p_vts_attr[i].i_vts_menu_audio_nb );
for( j = 0 ; j < 8 ; j++ ) for( j = 0 ; j < 8 ; j++ )
{ {
GETLL( &i_temp ); GETLL( &i_temp );
} }
FLUSH( 17 ); FLUSH( 17 );
GETC( &vts_inf.p_vts_attr[i].i_vts_menu_spu_nb ); GETC( &vts_inf.p_vts_attr[i].i_vts_menu_spu_nb );
//fprintf( stderr, "m subp nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtsm_subpic_nb ); //fprintf( stderr, "m subp nb : %d\n", vts_inf.p_vts_attr[i].i_vts_menu_spu_nb );
for( j = 0 ; j < 28 ; j++ ) for( j = 0 ; j < 28 ; j++ )
{ {
GET( &i_temp, 6 ); GET( &i_temp, 6 );
...@@ -409,14 +413,14 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd ) ...@@ -409,14 +413,14 @@ int IfoInit( ifo_t ** pp_ifo, int i_fd )
FLUSH(2); FLUSH(2);
FLUSH( 1 ); FLUSH( 1 );
GETL( &vts_inf.p_vts_attr[i].i_vts_title_audio_nb ); GETL( &vts_inf.p_vts_attr[i].i_vts_title_audio_nb );
//fprintf( stderr, "tt audio nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtstt_audio_nb ); //fprintf( stderr, "tt audio nb : %d\n", vts_inf.p_vts_attr[i].i_vts_title_audio_nb );
for( j = 0 ; j < 8 ; j++ ) for( j = 0 ; j < 8 ; j++ )
{ {
GETLL( &i_temp ); GETLL( &i_temp );
} }
FLUSH( 17 ); FLUSH( 17 );
GETC( &vts_inf.p_vts_attr[i].i_vts_title_spu_nb ); GETC( &vts_inf.p_vts_attr[i].i_vts_title_spu_nb );
//fprintf( stderr, "tt subp nb : %d\n", vts_inf.p_vts_vts_inf[i].i_vtstt_subpic_nb ); //fprintf( stderr, "tt subp nb : %d\n", vts_inf.p_vts_attr[i].i_vts_title_spu_nb );
for( j=0 ; j<28/*vts_inf.p_vts_vts_inf[i].i_vtstt_subpic_nb*/ ; j++ ) for( j=0 ; j<28/*vts_inf.p_vts_vts_inf[i].i_vtstt_subpic_nb*/ ; j++ )
{ {
GET( &i_temp, 6 ); GET( &i_temp, 6 );
...@@ -482,8 +486,10 @@ int IfoTitleSet( ifo_t * p_ifo ) ...@@ -482,8 +486,10 @@ int IfoTitleSet( ifo_t * p_ifo )
* DVD_LB_SIZE * DVD_LB_SIZE
+ p_ifo->i_off; + p_ifo->i_off;
p_ifo->i_pos = lseek( p_ifo->i_fd, i_off, SEEK_SET ); //fprintf(stderr, "offset: %lld\n" , i_off );
p_ifo->i_pos = lseek( p_ifo->i_fd, i_off, SEEK_SET );
//i_start = p_ifo->i_pos;
p_ifo->vts.i_pos = p_ifo->i_pos; p_ifo->vts.i_pos = p_ifo->i_pos;
#define manager_inf p_ifo->vts.manager_inf #define manager_inf p_ifo->vts.manager_inf
...@@ -566,7 +572,7 @@ FLUSH(2); ...@@ -566,7 +572,7 @@ FLUSH(2);
} }
FLUSH( 17 ); FLUSH( 17 );
GETC( &manager_inf.i_spu_nb ); GETC( &manager_inf.i_spu_nb );
//fprintf( stderr, "vtsi subpic nb : %d\n", manager_inf.i_subpic_nb ); //fprintf( stderr, "vtsi subpic nb : %d\n", manager_inf.i_spu_nb );
for( i=0 ; i<manager_inf.i_spu_nb ; i++ ) for( i=0 ; i<manager_inf.i_spu_nb ; i++ )
{ {
GET( &i_temp, 6 ); GET( &i_temp, 6 );
...@@ -759,12 +765,11 @@ FLUSH(2); ...@@ -759,12 +765,11 @@ FLUSH(2);
return -1; return -1;
} }
} }
#undef manager_inf
intf_WarnMsg( 2, "ifo info: VTS %d initialized", intf_WarnMsg( 2, "ifo info: vts %d initialized",
p_ifo->vmg.title_inf.p_attr[p_ifo->i_title-1].i_title_set_num ); p_ifo->vmg.title_inf.p_attr[p_ifo->i_title-1].i_title_set_num );
#undef manager_inf
p_ifo->vts.b_initialized = 1; p_ifo->vts.b_initialized = 1;
return 0; return 0;
...@@ -918,15 +923,26 @@ static int ReadTitle( ifo_t * p_ifo, title_t * p_title ) ...@@ -918,15 +923,26 @@ static int ReadTitle( ifo_t * p_ifo, title_t * p_title )
{ {
off_t i_start; off_t i_start;
int i; int i;
u16 i_temp;
i_start = p_ifo->i_pos; i_start = p_ifo->i_pos;
//fprintf( stderr, "PGC\n" ); p_ifo->i_pos = lseek( p_ifo->i_fd, p_ifo->i_pos, SEEK_SET );
//fprintf( stderr, "PGC @ %lld\n",p_ifo->i_pos );
FLUSH(2); FLUSH(2);
#if 0
GETC( &p_title->i_chapter_nb ); GETC( &p_title->i_chapter_nb );
fprintf( stderr, "title: prg %d\n", p_title->i_chapter_nb );
FLUSH(0);
GETC( &p_title->i_cell_nb ); GETC( &p_title->i_cell_nb );
//fprintf( stderr, "title: Prg: %d Cell: %d\n", pgc.i_prg_nb, pgc.i_cell_nb ); fprintf( stderr, "title: cell %d\n", p_title->i_cell_nb );
#endif
GETS( &i_temp );
//fprintf(stderr, "title : temp = %x\n", i_temp );
p_title->i_chapter_nb = (i_temp & 0xFF );
p_title->i_cell_nb = (i_temp & 0xFF00 ) >> 8;
//fprintf( stderr, "title: Prg: %d Cell: %d\n",p_title->i_chapter_nb,p_title->i_cell_nb );
GETL( &p_title->i_play_time ); GETL( &p_title->i_play_time );
GETL( &p_title->i_prohibited_user_op ); GETL( &p_title->i_prohibited_user_op );
for( i=0 ; i<8 ; i++ ) for( i=0 ; i<8 ; i++ )
...@@ -1192,7 +1208,7 @@ static int ReadUnitInf( ifo_t * p_ifo, unit_inf_t * p_unit_inf ) ...@@ -1192,7 +1208,7 @@ static int ReadUnitInf( ifo_t * p_ifo, unit_inf_t * p_unit_inf )
p_ifo->i_pos = lseek( p_ifo->i_fd, i_start + p_ifo->i_pos = lseek( p_ifo->i_fd, i_start +
p_unit_inf->p_title[i].i_title_start_byte, p_unit_inf->p_title[i].i_title_start_byte,
SEEK_SET ); SEEK_SET );
//fprintf( stderr, "Unit: PGC %d\n", i ); //fprintf( stderr, "Unit: PGC %d @ %lld\n", i, p_ifo->i_pos );
ReadTitle( p_ifo, &p_unit_inf->p_title[i].title ); ReadTitle( p_ifo, &p_unit_inf->p_title[i].title );
} }
...@@ -1227,6 +1243,8 @@ static int ReadTitleUnit( ifo_t * p_ifo, title_unit_t * p_title_unit ) ...@@ -1227,6 +1243,8 @@ static int ReadTitleUnit( ifo_t * p_ifo, title_unit_t * p_title_unit )
FLUSH( 2 ); FLUSH( 2 );
GETL( &p_title_unit->i_end_byte ); GETL( &p_title_unit->i_end_byte );
//fprintf(stderr, "Unit: nb %d end %d\n", p_title_unit->i_unit_nb, p_title_unit->i_end_byte );
p_title_unit->p_unit = malloc( p_title_unit->i_unit_nb *sizeof(unit_t) ); p_title_unit->p_unit = malloc( p_title_unit->i_unit_nb *sizeof(unit_t) );
if( p_title_unit->p_unit == NULL ) if( p_title_unit->p_unit == NULL )
{ {
...@@ -1300,6 +1318,8 @@ static int ReadCellInf( ifo_t * p_ifo, cell_inf_t * p_cell_inf ) ...@@ -1300,6 +1318,8 @@ static int ReadCellInf( ifo_t * p_ifo, cell_inf_t * p_cell_inf )
( i_start + p_cell_inf->i_end_byte + 1 - p_ifo->i_pos ) ( i_start + p_cell_inf->i_end_byte + 1 - p_ifo->i_pos )
/ sizeof(cell_map_t); / sizeof(cell_map_t);
//fprintf( stderr, "Cell inf: vob %d end %d cell %d\n", p_cell_inf->i_vob_nb, p_cell_inf->i_end_byte, p_cell_inf->i_cell_nb );
p_cell_inf->p_cell_map = p_cell_inf->p_cell_map =
malloc( p_cell_inf->i_cell_nb *sizeof(cell_map_t) ); malloc( p_cell_inf->i_cell_nb *sizeof(cell_map_t) );
if( p_cell_inf->p_cell_map == NULL ) if( p_cell_inf->p_cell_map == NULL )
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* -dvd_udf to find files * -dvd_udf to find files
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.40 2001/04/08 16:57:47 sam Exp $ * $Id: input_dvd.c,v 1.41 2001/04/10 17:47:05 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -363,6 +363,12 @@ static int DVDFindCell( thread_dvd_data_t * p_dvd ) ...@@ -363,6 +363,12 @@ static int DVDFindCell( thread_dvd_data_t * p_dvd )
i_cell++; i_cell++;
} }
intf_WarnMsg( 1, "FindCell: i_cell %d i_index %d found %d nb %d",
p_dvd->i_cell,
p_dvd->i_prg_cell,
i_cell,
cell.i_cell_nb );
if( i_cell == cell.i_cell_nb ) if( i_cell == cell.i_cell_nb )
{ {
intf_ErrMsg( "dvd error: can't find cell" ); intf_ErrMsg( "dvd error: can't find cell" );
...@@ -405,7 +411,14 @@ static int DVDFindSector( thread_dvd_data_t * p_dvd ) ...@@ -405,7 +411,14 @@ static int DVDFindSector( thread_dvd_data_t * p_dvd )
p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector, p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector,
title.p_cell_play[p_dvd->i_prg_cell].i_end_sector ); title.p_cell_play[p_dvd->i_prg_cell].i_end_sector );
//intf_WarnMsg( 3, "cell: %d sector1: 0x%x end1: 0x%x\nindex: %d sector2: 0x%x end2: 0x%x", p_dvd->i_cell, p_dvd->p_ifo->p_vts->c_adt.p_cell_inf[p_dvd->i_cell].i_ssector, p_dvd->p_ifo->p_vts->c_adt.p_cell_inf[p_dvd->i_cell].i_esector, p_dvd->i_prg_cell, p_pgc->p_cell_play_inf[p_dvd->i_prg_cell].i_entry_sector, p_pgc->p_cell_play_inf[p_dvd->i_prg_cell].i_lsector ); intf_WarnMsg( 1, "cell: %d sector1: 0x%x end1: 0x%x\n"
"index: %d sector2: 0x%x end2: 0x%x",
p_dvd->i_cell,
p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_start_sector,
p_dvd->p_ifo->vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector,
p_dvd->i_prg_cell,
title.p_cell_play[p_dvd->i_prg_cell].i_start_sector,
title.p_cell_play[p_dvd->i_prg_cell].i_end_sector );
#undef title #undef title
return 0; return 0;
...@@ -460,6 +473,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -460,6 +473,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
u8 i_mpeg; u8 i_mpeg;
u8 i_sub_pic; u8 i_sub_pic;
u8 i; u8 i;
int j;
boolean_t b_last; boolean_t b_last;
p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data; p_dvd = (thread_dvd_data_t*)p_input->p_plugin_data;
...@@ -476,14 +490,21 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -476,14 +490,21 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_input->stream.p_selected_area = p_input->stream.p_selected_area =
p_input->stream.pp_areas[p_area->i_id]; p_input->stream.pp_areas[p_area->i_id];
/* title number: it is not vts nb! */ /* title number: it is not vts nb!,
* it is what appears in the interface list */
p_dvd->i_title = p_area->i_id; p_dvd->i_title = p_area->i_id;
p_dvd->p_ifo->i_title = p_dvd->i_title; p_dvd->p_ifo->i_title = p_dvd->i_title;
/* ifo vts */ /* ifo vts */
IfoTitleSet( p_dvd->p_ifo ); if( IfoTitleSet( p_dvd->p_ifo ) < 0 )
intf_WarnMsg( 2, "ifo info: vts initialized" ); {
intf_ErrMsg( "dvd error: fatal error in vts ifo" );
free( p_dvd );
p_input->b_error = 1;
return -1;
}
//intf_WarnMsg( 3, "cell nb %d", p_dvd->p_ifo->vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb );
#define vmg p_dvd->p_ifo->vmg #define vmg p_dvd->p_ifo->vmg
#define vts p_dvd->p_ifo->vts #define vts p_dvd->p_ifo->vts
/* title position inside the selected vts */ /* title position inside the selected vts */
...@@ -492,16 +513,36 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -492,16 +513,36 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_dvd->i_program_chain = p_dvd->i_program_chain =
vts.title_inf.p_title_start[p_dvd->i_vts_title-1].i_program_chain_num; vts.title_inf.p_title_start[p_dvd->i_vts_title-1].i_program_chain_num;
intf_WarnMsg( 1, "dvd: title %d vts_title %d pgc %d",
p_dvd->i_title,
p_dvd->i_vts_title,
p_dvd->i_program_chain );
/* css title key for current vts */ /* css title key for current vts */
if( p_dvd->b_encrypted ) if( p_dvd->b_encrypted )
{ {
/* this one is vts number */
p_dvd->p_css->i_title = p_dvd->p_css->i_title =
vmg.title_inf.p_attr[p_dvd->i_title-1].i_title_set_num; vmg.title_inf.p_attr[p_dvd->i_title-1].i_title_set_num;
p_dvd->p_css->i_title_pos = p_dvd->p_css->i_title_pos =
vts.i_pos + vts.i_pos +
vts.manager_inf.i_title_vob_start_sector * DVD_LB_SIZE; vts.manager_inf.i_title_vob_start_sector * DVD_LB_SIZE;
CSSGetKey( p_dvd->p_css );
intf_WarnMsg( 2, "css info: vts key initialized" ); j = CSSGetKey( p_dvd->p_css );
if( j < 0 )
{
intf_ErrMsg( "dvd error: fatal error in vts css key" );
free( p_dvd );
p_input->b_error = 1;
return -1;
}
else if( j > 0 )
{
intf_ErrMsg( "dvd error: css decryption unavailable" );
free( p_dvd );
p_input->b_error = 1;
return -1;
}
} }
/* /*
...@@ -516,6 +557,9 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -516,6 +557,9 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_dvd->i_cell = 0; p_dvd->i_cell = 0;
p_dvd->i_prg_cell = -1 + p_dvd->i_prg_cell = -1 +
vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb; vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb;
intf_WarnMsg( 3, "cell nb %d", vts.title_unit.p_title[p_dvd->i_program_chain-1].title.i_cell_nb );
DVDFindCell( p_dvd ); DVDFindCell( p_dvd );
/* temporary hack to fix size in some dvds */ /* temporary hack to fix size in some dvds */
...@@ -575,8 +619,11 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -575,8 +619,11 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_es->i_stream_id = 0xe0; p_es->i_stream_id = 0xe0;
p_es->i_type = MPEG2_VIDEO_ES; p_es->i_type = MPEG2_VIDEO_ES;
p_es->i_cat = VIDEO_ES; p_es->i_cat = VIDEO_ES;
input_SelectES( p_input, p_es ); intf_WarnMsg( 1, "dvd info: video mpeg2 stream" );
intf_WarnMsg( 1, "dvd info: video MPEG2 stream" ); if( p_main->b_video )
{
input_SelectES( p_input, p_es );
}
/* Audio ES, in the order they appear in .ifo */ /* Audio ES, in the order they appear in .ifo */
...@@ -679,29 +726,35 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -679,29 +726,35 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
} }
} }
/* For audio: first one if none or a not existing one specified */ if( p_main->b_audio )
i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 );
if( i_audio < 0 || i_audio > vts.manager_inf.i_audio_nb )
{ {
main_PutIntVariable( INPUT_CHANNEL_VAR, 1 ); /* For audio: first one if none or a not existing one specified */
i_audio = 1; i_audio = main_GetIntVariable( INPUT_CHANNEL_VAR, 1 );
} if( i_audio < 0 || i_audio > vts.manager_inf.i_audio_nb )
if( i_audio > 0 && vts.manager_inf.i_audio_nb > 0 ) {
{ main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
input_SelectES( p_input, p_input->stream.pp_es[i_audio] ); i_audio = 1;
} }
if( i_audio > 0 && vts.manager_inf.i_audio_nb > 0 )
/* for spu, default is none */ {
i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 ); input_SelectES( p_input, p_input->stream.pp_es[i_audio] );
if( i_spu < 0 || i_spu > vts.manager_inf.i_spu_nb ) }
{
main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
i_spu = 0;
} }
if( i_spu > 0 && vts.manager_inf.i_spu_nb > 0 )
if( p_main->b_video )
{ {
i_spu += vts.manager_inf.i_audio_nb; /* for spu, default is none */
input_SelectES( p_input, p_input->stream.pp_es[i_spu] ); i_spu = main_GetIntVariable( INPUT_SUBTITLE_VAR, 0 );
if( i_spu < 0 || i_spu > vts.manager_inf.i_spu_nb )
{
main_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
i_spu = 0;
}
if( i_spu > 0 && vts.manager_inf.i_spu_nb > 0 )
{
i_spu += vts.manager_inf.i_audio_nb;
input_SelectES( p_input, p_input->stream.pp_es[i_spu] );
}
} }
} /* i_title >= 0 */ } /* i_title >= 0 */
else else
...@@ -729,6 +782,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -729,6 +782,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
#undef vts #undef vts
#undef vmg #undef vmg
return 0; return 0;
} }
...@@ -738,6 +792,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area ) ...@@ -738,6 +792,7 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
static void DVDInit( input_thread_t * p_input ) static void DVDInit( input_thread_t * p_input )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
input_area_t * p_area;
int i_title; int i_title;
int i_chapter; int i_chapter;
int i; int i;
...@@ -762,13 +817,12 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -762,13 +817,12 @@ static void DVDInit( input_thread_t * p_input )
* when using input_ToggleES * when using input_ToggleES
* who wrote thez damn buggy piece of shit ??? --stef */ * who wrote thez damn buggy piece of shit ??? --stef */
p_dvd->i_block_once = 1;//32; p_dvd->i_block_once = 1;//32;
p_input->i_read_once = 4;//128; p_input->i_read_once = 8;//128;
i = CSSTest( p_input->i_handle ); i = CSSTest( p_input->i_handle );
if( i < 0 ) if( i < 0 )
{ {
intf_ErrMsg( "css error: could not get copyright bit" );
free( p_dvd ); free( p_dvd );
p_input->b_error = 1; p_input->b_error = 1;
return; return;
...@@ -783,8 +837,15 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -783,8 +837,15 @@ static void DVDInit( input_thread_t * p_input )
DVDNetlistInit( 2048, 8192, 2048, DVD_LB_SIZE, p_dvd->i_block_once ); DVDNetlistInit( 2048, 8192, 2048, DVD_LB_SIZE, p_dvd->i_block_once );
intf_WarnMsg( 2, "dvd info: netlist initialized" ); intf_WarnMsg( 2, "dvd info: netlist initialized" );
/* Ifo initialisation */ /* Ifo allocation & initialisation */
if( IfoInit( &p_dvd->p_ifo, p_input->i_handle ) < 0 ) if( IfoCreate( p_dvd ) < 0 )
{
intf_ErrMsg( "dvd error: allcation error in IFO" );
p_input->b_error = 1;
return;
}
if( IfoInit( p_dvd->p_ifo ) < 0 )
{ {
intf_ErrMsg( "dvd error: fatal failure in IFO" ); intf_ErrMsg( "dvd error: fatal failure in IFO" );
free( p_dvd ); free( p_dvd );
...@@ -807,7 +868,7 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -807,7 +868,7 @@ static void DVDInit( input_thread_t * p_input )
p_dvd->p_css->i_fd = p_input->i_handle; p_dvd->p_css->i_fd = p_input->i_handle;
p_dvd->p_css->i_agid = 0; p_dvd->p_css->i_agid = 0;
if( CSSInit( p_dvd->p_css ) ) if( CSSInit( p_dvd->p_css ) < 0 )
{ {
intf_ErrMsg( "dvd error: fatal failure in CSS" ); intf_ErrMsg( "dvd error: fatal failure in CSS" );
free( p_dvd->p_css ); free( p_dvd->p_css );
...@@ -819,12 +880,12 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -819,12 +880,12 @@ static void DVDInit( input_thread_t * p_input )
intf_WarnMsg( 2, "dvd info: CSS initialized" ); intf_WarnMsg( 2, "dvd info: CSS initialized" );
} }
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
/* Set stream and area data */ /* Set stream and area data */
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
#define title_inf p_dvd->p_ifo->vmg.title_inf #define title_inf p_dvd->p_ifo->vmg.title_inf
intf_WarnMsg( 2, "dvd info: number of titles: %d", title_inf.i_title_nb ); intf_WarnMsg( 2, "dvd info: number of titles: %d", title_inf.i_title_nb );
...@@ -853,8 +914,6 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -853,8 +914,6 @@ static void DVDInit( input_thread_t * p_input )
} }
#undef area #undef area
vlc_mutex_unlock( &p_input->stream.stream_lock );
/* Get requested title - if none try the first title */ /* Get requested title - if none try the first title */
i_title = main_GetIntVariable( INPUT_TITLE_VAR, 1 ); i_title = main_GetIntVariable( INPUT_TITLE_VAR, 1 );
if( i_title <= 0 || i_title > title_inf.i_title_nb ) if( i_title <= 0 || i_title > title_inf.i_title_nb )
...@@ -871,8 +930,12 @@ static void DVDInit( input_thread_t * p_input ) ...@@ -871,8 +930,12 @@ static void DVDInit( input_thread_t * p_input )
p_input->stream.pp_areas[i_title]->i_part = i_chapter; p_input->stream.pp_areas[i_title]->i_part = i_chapter;
p_area = p_input->stream.pp_areas[i_title];
vlc_mutex_unlock( &p_input->stream.stream_lock );
/* set title, chapter, audio and subpic */ /* set title, chapter, audio and subpic */
DVDSetArea( p_input, p_input->stream.pp_areas[i_title] ); DVDSetArea( p_input, p_area );
return; return;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_dvd.h: thread structure of the DVD plugin * input_dvd.h: thread structure of the DVD plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: input_dvd.h,v 1.16 2001/04/08 16:57:47 sam Exp $ * $Id: input_dvd.h,v 1.17 2001/04/10 17:47:05 stef Exp $
* *
* Author: Stéphane Borel <stef@via.ecp.fr> * Author: Stéphane Borel <stef@via.ecp.fr>
* *
...@@ -64,13 +64,6 @@ typedef struct thread_dvd_data_s ...@@ -64,13 +64,6 @@ typedef struct thread_dvd_data_s
} thread_dvd_data_t; } thread_dvd_data_t;
/*****************************************************************************
* Prototypes in dvd_ifo.c
*****************************************************************************/
int IfoInit ( struct ifo_s **, int );
int IfoTitleSet ( struct ifo_s * );
void IfoEnd ( struct ifo_s * );
/***************************************************************************** /*****************************************************************************
* Prototypes in dvd_css.c * Prototypes in dvd_css.c
*****************************************************************************/ *****************************************************************************/
...@@ -79,3 +72,12 @@ int CSSInit ( struct css_s * ); ...@@ -79,3 +72,12 @@ int CSSInit ( struct css_s * );
int CSSGetKey ( struct css_s * ); int CSSGetKey ( struct css_s * );
int CSSDescrambleSector ( u8 * , u8 * ); int CSSDescrambleSector ( u8 * , u8 * );
/*****************************************************************************
* Prototypes in dvd_ifo.c
*****************************************************************************/
int IfoCreate ( struct thread_dvd_data_s * );
int IfoInit ( struct ifo_s * );
int IfoTitleSet ( struct ifo_s * );
void IfoEnd ( struct ifo_s * );
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN * Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.95 2001/04/08 09:04:33 stef Exp $ * $Id: input.c,v 1.96 2001/04/10 17:47:05 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -233,6 +233,7 @@ static void RunThread( input_thread_t *p_input ) ...@@ -233,6 +233,7 @@ static void RunThread( input_thread_t *p_input )
#endif #endif
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
if( p_input->stream.p_selected_area->i_seek != NO_SEEK ) if( p_input->stream.p_selected_area->i_seek != NO_SEEK )
{ {
if( p_input->stream.b_seekable && p_input->pf_seek != NULL ) if( p_input->stream.b_seekable && p_input->pf_seek != NULL )
...@@ -254,6 +255,7 @@ static void RunThread( input_thread_t *p_input ) ...@@ -254,6 +255,7 @@ static void RunThread( input_thread_t *p_input )
} }
p_input->stream.p_selected_area->i_seek = NO_SEEK; p_input->stream.p_selected_area->i_seek = NO_SEEK;
} }
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
i_error = p_input->pf_read( p_input, pp_packets ); i_error = p_input->pf_read( p_input, pp_packets );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management * input_programs.c: es_descriptor_t, pgrm_descriptor_t management
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: input_programs.c,v 1.45 2001/04/08 07:24:47 stef Exp $ * $Id: input_programs.c,v 1.46 2001/04/10 17:47:05 stef Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -58,6 +58,8 @@ int input_InitStream( input_thread_t * p_input, size_t i_data_len ) ...@@ -58,6 +58,8 @@ int input_InitStream( input_thread_t * p_input, size_t i_data_len )
p_input->stream.pp_es = NULL; p_input->stream.pp_es = NULL;
p_input->stream.pp_selected_es = NULL; p_input->stream.pp_selected_es = NULL;
p_input->stream.pp_programs = NULL; p_input->stream.pp_programs = NULL;
p_input->stream.pp_areas = NULL;
p_input->stream.p_selected_area = NULL;
if( i_data_len ) if( i_data_len )
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment