Commit 8a1ec969 authored by Stéphane Borel's avatar Stéphane Borel

-Changes in the way stream size in DVD mode is calculated. It is no

longer such an ugly kludge and is much more accurate.

-Changes in DVDSeek so that the interface slider is in 0 when we are at
the beginning of the strem.

-Try to detect the beginning of the movie in the middle of the title. It
works for most of the DVDs but will begin in the middle of the movie
with some others.

-Calculate only the first title key in css mode because it might take a
long time with some title. The search stops now when we have a key once
whereas it did stop only when we had it twice before. It should not
cause problems.
parent 8d07abcd
......@@ -2,7 +2,7 @@
* dvd_css.c: Functions for DVD authentification and unscrambling
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_css.c,v 1.7 2001/02/13 10:08:51 stef Exp $
* $Id: dvd_css.c,v 1.8 2001/02/14 04:11:01 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -1000,7 +1000,7 @@ int CSSGetKeys( css_t * p_css )
int i_highest;
int i,j,k;
for( i_title = 0 ; i_title < p_css->i_title_nb ; i_title++ )
for( i_title = 0 ; i_title < 1/*p_css->i_title_nb*/ ; i_title++ )
{
/* Initialization for each title */
memset( p_title_key, 0, 10 );
......@@ -1072,8 +1072,10 @@ int CSSGetKeys( css_t * p_css )
(DVD_key_t*)&pi_buf[0x54], &key);
}
/* Stop search if we find two occurances of the key */
if( i_registered_keys == 1 && p_title_key[0].i >= 2 )
/* Stop search if we find one occurance of the key
* I have never found a DVD for which it is not enough
* but we should take care of that */
if( i_registered_keys == 1 && p_title_key[0].i >= 1 )
{
b_stop_scanning = 1;
}
......
......@@ -2,7 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.6 2001/02/13 10:08:51 stef Exp $
* $Id: dvd_ifo.c,v 1.7 2001/02/14 04:11:01 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -497,23 +497,24 @@ static pgci_ut_t ReadUnitTable( ifo_t* p_ifo )
static c_adt_t ReadCellInf( ifo_t* p_ifo )
{
c_adt_t c_adt;
int i, i_max;
off_t i_start = p_ifo->i_pos;
int i;
//fprintf( stderr, "CELL ADD\n" );
GETS( &c_adt.i_vob_nb );
FLUSH( 2 );
GETL( &c_adt.i_ebyte );
i_max = ( i_start + c_adt.i_ebyte + 1 - p_ifo->i_pos ) / sizeof(cell_inf_t);
c_adt.p_cell_inf = malloc( i_max *sizeof(cell_inf_t) );
c_adt.i_cell_nb =
( i_start + c_adt.i_ebyte + 1 - p_ifo->i_pos ) / sizeof(cell_inf_t);
c_adt.p_cell_inf = malloc( c_adt.i_cell_nb *sizeof(cell_inf_t) );
if( c_adt.p_cell_inf == NULL )
{
intf_ErrMsg( "Out of memory" );
p_ifo->b_error = 1;
return c_adt;
}
for( i=0 ; i<i_max ; i++ )
for( i = 0 ; i < c_adt.i_cell_nb ; i++ )
{
GETS( &c_adt.p_cell_inf[i].i_vob_id );
GETC( &c_adt.p_cell_inf[i].i_cell_id );
......
......@@ -2,7 +2,7 @@
* dvd_ifo.h: Structures for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.h,v 1.4 2001/02/13 10:08:51 stef Exp $
* $Id: dvd_ifo.h,v 1.5 2001/02/14 04:11:01 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -185,6 +185,8 @@ typedef struct c_adt_s
u16 i_vob_nb; // 2 bytes
// char[2] ???
u32 i_ebyte; // 4 bytes
u16 i_cell_nb; // not in ifo; computed
// with e_byte
cell_inf_t* p_cell_inf;
} c_adt_t;
......
......@@ -10,7 +10,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.9 2001/02/13 10:08:51 stef Exp $
* $Id: input_dvd.c,v 1.10 2001/02/14 04:11:01 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -146,6 +146,8 @@ static void DVDInit( input_thread_t * p_input )
{
thread_dvd_data_t * p_method;
off_t i_start;
off_t i_size;
int i_cell, i_cell_1, i_start_cell, i_end_cell;
if( (p_method = malloc( sizeof(thread_dvd_data_t) )) == NULL )
{
......@@ -229,12 +231,66 @@ static void DVDInit( input_thread_t * p_input )
#endif
}
/* FIXME: Kludge beginning of vts_01_1.vob */
i_start = p_method->ifo.p_vts[0].i_pos +
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector *DVD_LB_SIZE;
/* FIXME: Kludge beginning and end of the stream in vts_01_1.vob */
/* Determines which vob contains the movie */
i_cell = 0;
i_cell_1 = 0;
i_start_cell = 0;
i_end_cell = 0;
/* Loop on the number of vobs */
while( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell].i_vob_id <=
p_method->ifo.p_vts[0].c_adt.i_vob_nb )
{
i_cell_1 = i_cell;
/* Loop to find the number of cells in the vob */
do
{
i_cell++;
if( i_cell >= p_method->ifo.p_vts[0].c_adt.i_cell_nb )
{
break;
}
}
while( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell-1].i_cell_id <
p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell].i_cell_id );
if( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_cell-1].i_cell_id >
p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_end_cell].i_cell_id )
{
i_start_cell = i_cell_1;
i_end_cell = i_cell - 1;
}
}
/* The preceding does not work with all DVD, so we give the
* last cell of the title as end */
i_end_cell = p_method->ifo.p_vts[0].c_adt.i_cell_nb - 1;
intf_WarnMsg( 2, "DVD: Start cell: %d End Cell: %d",
i_start_cell, i_end_cell );
p_method->i_start_cell = i_start_cell;
p_method->i_end_cell = i_end_cell;
/* start is : beginning of vts + offset to vobs + offset to vob x */
i_start = p_method->ifo.p_vts[0].i_pos + DVD_LB_SIZE *
( p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector +
p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_start_cell].i_ssector );
p_method->i_start_byte = i_start;
i_start = lseek( p_input->i_handle, i_start, SEEK_SET );
intf_WarnMsg( 3, "DVD: VOB start at : %lld", i_start );
intf_WarnMsg( 3, "DVD: VOBstart at: %lld", i_start );
i_size = (off_t)
( p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_end_cell].i_esector -
p_method->ifo.p_vts[0].c_adt.p_cell_inf[i_start_cell].i_ssector + 1 )
*DVD_LB_SIZE;
intf_WarnMsg( 3, "DVD: stream size: %lld", i_size );
/* Initialize ES structures */
input_InitStream( p_input, sizeof( stream_ps_data_t ) );
......@@ -286,7 +342,11 @@ static void DVDInit( input_thread_t * p_input )
}
lseek( p_input->i_handle, i_start, SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.i_tell = i_start;
/* i_tell is an indicator from the beginning of the stream,
* not of the DVD */
p_input->stream.i_tell = 0;
if( p_demux_data->b_has_PSM )
{
/* (The PSM decoder will care about spawning the decoders) */
......@@ -359,12 +419,8 @@ static void DVDInit( input_thread_t * p_input )
input_DumpStream( p_input );
#endif
/* FIXME: kludge to implement file size */
p_input->stream.i_size =
(off_t)( p_method->ifo.vmg.ptt_srpt.p_tts[1].i_ssector -
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector ) *DVD_LB_SIZE;
intf_WarnMsg( 3, "DVD: stream size: %lld", p_input->stream.i_size );
/* FIXME : ugly kludge */
p_input->stream.i_size = i_size;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
......@@ -374,11 +430,8 @@ static void DVDInit( input_thread_t * p_input )
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.pp_programs[0]->b_is_ok = 0;
/* FIXME: kludge to implement file size */
p_input->stream.i_size =
( p_method->ifo.vmg.ptt_srpt.p_tts[1].i_ssector -
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector ) *DVD_LB_SIZE;
intf_WarnMsg( 3, "DVD: stream size: %lld", p_input->stream.i_size );
/* FIXME : ugly kludge */
p_input->stream.i_size = i_size;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
......@@ -531,15 +584,14 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
p_method = ( thread_dvd_data_t * )p_input->p_plugin_data;
/* We have to take care of offset of beginning of title */
i_pos = i_off - ( p_method->ifo.p_vts[0].i_pos +
p_method->ifo.p_vts[0].mat.i_tt_vobs_ssector *DVD_LB_SIZE );
i_pos = i_off + p_method->i_start_byte;
/* With DVD, we have to be on a sector boundary */
i_pos = i_pos & (~0x7ff);
i_pos = lseek( p_input->i_handle, i_pos, SEEK_SET );
p_input->stream.i_tell = i_pos;
p_input->stream.i_tell = i_pos - p_method->i_start_byte;
return;
}
......@@ -34,12 +34,20 @@ typedef struct thread_dvd_data_s
boolean_t b_encrypted; // CSS encryption
int i_read_once; // NB of bytes read by DVDRead
int i_title; // Current Title
/* FIXME: include these in a struct */
int i_start_byte;
int i_start_cell;
int i_end_cell;
/* Scrambling Information */
#if defined( HAVE_SYS_DVDIO_H ) || defined( LINUX_DVD )
struct css_s css;
#endif
/* Structure that contains all information of the DVD */
struct ifo_s ifo;
} thread_dvd_data_t;
/*****************************************************************************
......
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