Commit 5427a369 authored by Stéphane Borel's avatar Stéphane Borel

-I hope I have fixed the ifo bug lastly !

parent c01112ad
......@@ -2,7 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.21 2001/04/15 15:32:48 stef Exp $
* $Id: dvd_ifo.c,v 1.22 2001/04/15 21:17:50 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -78,9 +78,9 @@ static __inline__ u8 ReadByte( ifo_t * p_ifo, u8* pi_buffer, u8** pp_current )
{
u8 i_ret;
if( *pp_current >= pi_buffer + DVD_LB_SIZE )
if( *pp_current > pi_buffer + DVD_LB_SIZE )
{
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos );
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos + DVD_LB_SIZE );
}
i_ret = *(*pp_current)++;
......@@ -92,9 +92,9 @@ static __inline__ u16 ReadWord( ifo_t* p_ifo, u8* pi_buffer, u8** pp_current )
{
u16 i_ret;
if( *pp_current >= pi_buffer + DVD_LB_SIZE - 2 )
if( *pp_current > pi_buffer + DVD_LB_SIZE - 2 )
{
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos );
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos + DVD_LB_SIZE );
}
i_ret = U16_AT(*pp_current);
......@@ -108,9 +108,10 @@ static __inline__ u32 ReadDouble( ifo_t * p_ifo, u8* pi_buffer,
{
u32 i_ret;
if( *pp_current >= pi_buffer + DVD_LB_SIZE - 4 )
if( *pp_current > pi_buffer + DVD_LB_SIZE - 4 )
{
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos );
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos + DVD_LB_SIZE);
// intf_WarnMsg( 1, "new buffer in double @ %lld", p_ifo->i_pos );
}
i_ret = U32_AT(*pp_current);
......@@ -123,9 +124,9 @@ static __inline__ u64 ReadQuad( ifo_t* p_ifo, u8* pi_buffer, u8** pp_current )
{
u64 i_ret;
if( *pp_current >= pi_buffer + DVD_LB_SIZE - 8 )
if( *pp_current > pi_buffer + DVD_LB_SIZE - 8 )
{
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos );
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos + DVD_LB_SIZE );
}
i_ret = U64_AT(*pp_current);
......@@ -137,9 +138,9 @@ static __inline__ u64 ReadQuad( ifo_t* p_ifo, u8* pi_buffer, u8** pp_current )
static __inline__ void ReadBits( ifo_t* p_ifo, u8* pi_buffer, u8** pp_current,
u8* pi_dest, int i_nb )
{
if( *pp_current >= pi_buffer + DVD_LB_SIZE - i_nb )
if( *pp_current > pi_buffer + DVD_LB_SIZE - i_nb )
{
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos );
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos + DVD_LB_SIZE );
}
memcpy( pi_dest, *pp_current, i_nb );
......@@ -151,9 +152,9 @@ static __inline__ void ReadBits( ifo_t* p_ifo, u8* pi_buffer, u8** pp_current,
static __inline__ void DumpBits( ifo_t* p_ifo, u8* pi_buffer,
u8** pp_current, int i_nb )
{
if( *pp_current >= pi_buffer + DVD_LB_SIZE - i_nb )
if( *pp_current > pi_buffer + DVD_LB_SIZE - i_nb )
{
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos );
*pp_current = FillBuffer( p_ifo, pi_buffer, p_ifo->i_pos + DVD_LB_SIZE );
}
*pp_current += i_nb;
......@@ -1320,7 +1321,7 @@ static int ReadCellInf( ifo_t * p_ifo, cell_inf_t * p_cell_inf, off_t i_pos )
DumpBits( p_ifo, pi_buffer, &p_current, 2 );
p_cell_inf->i_end_byte = ReadDouble( p_ifo, pi_buffer, &p_current );
p_cell_inf->i_cell_nb = (p_cell_inf->i_end_byte - 8) / sizeof(cell_map_t);
p_cell_inf->i_cell_nb = (p_cell_inf->i_end_byte/* - 7*/) / 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 );
......@@ -1338,6 +1339,7 @@ static int ReadCellInf( ifo_t * p_ifo, cell_inf_t * p_cell_inf, off_t i_pos )
p_cell_inf->p_cell_map[i].i_cell_id = ReadByte( p_ifo, pi_buffer, &p_current );
DumpBits( p_ifo, pi_buffer, &p_current, 1 );
p_cell_inf->p_cell_map[i].i_start_sector = ReadDouble( p_ifo, pi_buffer, &p_current );
// fprintf(stderr, "sector[%d] %d (%lld)\n", i,ntohl(*(u32*)(p_current)), p_ifo->i_pos);
p_cell_inf->p_cell_map[i].i_end_sector = ReadDouble( p_ifo, pi_buffer, &p_current );
}
......
......@@ -10,7 +10,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.46 2001/04/15 04:19:57 sam Exp $
* $Id: input_dvd.c,v 1.47 2001/04/15 21:17:50 stef Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -354,31 +354,30 @@ static int DVDFindCell( thread_dvd_data_t * p_dvd )
i_cell = p_dvd->i_cell;
i_index = p_dvd->i_prg_cell;
if( i_cell >= cell.i_cell_nb )
{
return -1;
}
while( ( ( title.p_cell_pos[i_index].i_vob_id !=
cell.p_cell_map[i_cell].i_vob_id ) ||
( title.p_cell_pos[i_index].i_cell_id !=
cell.p_cell_map[i_cell].i_cell_id ) ) &&
( i_cell < cell.i_cell_nb ) )
( i_cell < cell.i_cell_nb - 1 ) )
{
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 )
{
intf_ErrMsg( "dvd error: can't find cell" );
return -1;
}
else
{
p_dvd->i_cell = i_cell;
return 0;
}
#undef title
#undef cell
}
......@@ -411,7 +410,7 @@ 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,
title.p_cell_play[p_dvd->i_prg_cell].i_end_sector );
/* intf_WarnMsg( 1, "cell: %d sector1: 0x%x end1: 0x%x\n"
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,
......@@ -419,7 +418,7 @@ static int DVDFindSector( thread_dvd_data_t * p_dvd )
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
return 0;
......@@ -427,7 +426,6 @@ static int DVDFindSector( thread_dvd_data_t * p_dvd )
/*****************************************************************************
* DVDChapterSelect: find the cell corresponding to requested chapter
* When called to find chapter 1, also sets title size and end.
*****************************************************************************/
static int DVDChapterSelect( thread_dvd_data_t * p_dvd, int i_chapter )
{
......@@ -575,9 +573,11 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_dvd->i_cell = vts.cell_inf.i_cell_nb - 1;
}
p_dvd->i_sector = 0;
p_dvd->i_size = DVD_LB_SIZE *
(off_t)( vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector );
intf_WarnMsg( 2, "dvd info: stream size 1: %lld @ %d", p_dvd->i_size,vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector );
if( DVDChapterSelect( p_dvd, 1 ) < 0 )
{
......@@ -1217,6 +1217,7 @@ static void DVDSeek( input_thread_t * p_input, off_t i_off )
/* Find first title cell which is inside program cell */
if( DVDFindCell( p_dvd ) < 0 )
{
/* no following cell : we're at eof */
intf_ErrMsg( "dvd error: cell seeking failed" );
p_input->b_error = 1;
return;
......
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