* 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: Stéphane Borel <stef@via.ecp.fr>
*
{
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)++;
{
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);
{
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);
{
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);
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 );
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;
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 );
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 );
}
* -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: Stéphane Borel <stef@via.ecp.fr>
*
#define title \
p_dvd->p_ifo->vts.title_unit.p_title[p_dvd->i_program_chain-1].title
#define cell p_dvd->p_ifo->vts.cell_inf
-
+
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;
- }
+
+ p_dvd->i_cell = i_cell;
+ return 0;
+
#undef title
#undef cell
}
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"
- "index: %d sector2: 0x%x end2: 0x%x",
+ 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
return 0;
/*****************************************************************************
* 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 )
{
/* start is : beginning of vts vobs + offset to vob x */
p_dvd->i_start = p_dvd->i_title_start +
- DVD_LB_SIZE * (off_t)( p_dvd->i_sector );
+ DVD_LB_SIZE * (off_t)( p_dvd->i_sector );
/* Position the fd pointer on the right address */
p_dvd->i_start = lseek( p_dvd->i_fd, p_dvd->i_start, SEEK_SET );
{
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 )
{
intf_ErrMsg( "dvd error: can't find first chapter" );
/* 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;