Commit 29c0bd55 authored by Gildas Bazin's avatar Gildas Bazin

* access/dvdread.c: misc improvements/fixes.

* modules/access/dvdnav.c: chapters start from 1.
* modules/gui/wxwindows/menus.cpp: removed debug message.
parent 926aa46c
...@@ -116,14 +116,6 @@ static int Control( demux_t *, int, va_list ); ...@@ -116,14 +116,6 @@ static int Control( demux_t *, int, va_list );
static int Demux ( demux_t * ); static int Demux ( demux_t * );
static int DemuxBlock ( demux_t *, uint8_t *pkt, int i_pkt ); static int DemuxBlock ( demux_t *, uint8_t *pkt, int i_pkt );
enum
{
AR_SQUARE_PICTURE = 1, /* square pixels */
AR_3_4_PICTURE = 2, /* 3:4 picture (TV) */
AR_16_9_PICTURE = 3, /* 16:9 picture (wide screen) */
AR_221_1_PICTURE = 4, /* 2.21:1 picture (movie) */
};
static void DemuxTitles( demux_t *p_demux ); static void DemuxTitles( demux_t *p_demux );
static void ESSubtitleUpdate( demux_t * ); static void ESSubtitleUpdate( demux_t * );
static void ButtonUpdate( demux_t * ); static void ButtonUpdate( demux_t * );
...@@ -229,13 +221,13 @@ static int Open( vlc_object_t *p_this ) ...@@ -229,13 +221,13 @@ static int Open( vlc_object_t *p_this )
} }
} }
if( i_chapter != 0 && i_title != 0 ) if( i_chapter != 1 && i_title != 0 )
{ {
if( dvdnav_part_play( p_sys->dvdnav, i_title, i_chapter ) != if( dvdnav_part_play( p_sys->dvdnav, i_title, i_chapter ) !=
DVDNAV_STATUS_OK ) DVDNAV_STATUS_OK )
{ {
msg_Warn( p_demux, "cannot set chapter" ); msg_Warn( p_demux, "cannot set chapter" );
i_chapter = 0; i_chapter = 1;
} }
else else
{ {
...@@ -395,7 +387,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) ...@@ -395,7 +387,8 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
msg_Warn( p_demux, "cannot set title/chapter" ); msg_Warn( p_demux, "cannot set title/chapter" );
return VLC_EGENERIC; return VLC_EGENERIC;
} }
p_demux->info.i_update |= INPUT_UPDATE_TITLE|INPUT_UPDATE_SEEKPOINT; p_demux->info.i_update |=
INPUT_UPDATE_TITLE | INPUT_UPDATE_SEEKPOINT;
p_demux->info.i_title = i; p_demux->info.i_title = i;
p_demux->info.i_seekpoint = 0; p_demux->info.i_seekpoint = 0;
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -702,7 +695,8 @@ static int Demux( demux_t *p_demux ) ...@@ -702,7 +695,8 @@ static int Demux( demux_t *p_demux )
} }
/***************************************************************************** /*****************************************************************************
* ParseCL: parse command line * ParseCL: parse command line.
* Titles start from 0 (menu), chapters and angles start from 1.
*****************************************************************************/ *****************************************************************************/
static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
int *i_title, int *i_chapter, int *i_angle ) int *i_title, int *i_chapter, int *i_angle )
...@@ -713,7 +707,7 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, ...@@ -713,7 +707,7 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
if( psz_source == NULL ) return NULL; if( psz_source == NULL ) return NULL;
*i_title = 0; *i_title = 0;
*i_chapter = 0; *i_chapter = 1;
*i_angle = 1; *i_angle = 1;
/* Start with the end, because you could have : /* Start with the end, because you could have :
...@@ -742,8 +736,8 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, ...@@ -742,8 +736,8 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
} }
*i_title = *i_title >= 0 ? *i_title : 0; *i_title = *i_title >= 0 ? *i_title : 0;
*i_chapter = *i_chapter ? *i_chapter : 0; *i_chapter = *i_chapter > 0 ? *i_chapter : 1;
*i_angle = *i_angle ? *i_angle : 1; *i_angle = *i_angle > 0 ? *i_angle : 1;
if( !*psz_source ) if( !*psz_source )
{ {
...@@ -826,6 +820,8 @@ static void DemuxTitles( demux_t *p_demux ) ...@@ -826,6 +820,8 @@ static void DemuxTitles( demux_t *p_demux )
for( j = 0; j < __MAX( i_chapters, 1 ); j++ ) for( j = 0; j < __MAX( i_chapters, 1 ); j++ )
{ {
s = vlc_seekpoint_New(); s = vlc_seekpoint_New();
s->psz_name = malloc( strlen( _("Chapter %i") ) + 20 );
sprintf( s->psz_name, _("Chapter %i"), j + 1 );
TAB_APPEND( t->i_seekpoint, t->seekpoint, s ); TAB_APPEND( t->i_seekpoint, t->seekpoint, s );
} }
......
...@@ -134,6 +134,7 @@ struct demux_sys_t ...@@ -134,6 +134,7 @@ struct demux_sys_t
unsigned int i_title_offset; unsigned int i_title_offset;
unsigned int i_title_start_cell; unsigned int i_title_start_cell;
unsigned int i_title_end_cell;
unsigned int i_cur_cell; unsigned int i_cur_cell;
unsigned int i_next_cell; unsigned int i_next_cell;
...@@ -254,7 +255,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -254,7 +255,7 @@ static int Open( vlc_object_t *p_this )
DemuxTitles( p_demux, &i_title, &i_chapter, &i_angle ); DemuxTitles( p_demux, &i_title, &i_chapter, &i_angle );
DvdReadSetArea( p_demux, i_title - 1, i_chapter, i_angle ); DvdReadSetArea( p_demux, i_title, i_chapter, i_angle );
/* Update default_pts to a suitable value for dvdread access */ /* Update default_pts to a suitable value for dvdread access */
var_Create( p_demux, "dvdread-caching", var_Create( p_demux, "dvdread-caching",
...@@ -428,9 +429,9 @@ static int Demux( demux_t *p_demux ) ...@@ -428,9 +429,9 @@ static int Demux( demux_t *p_demux )
DvdReadSetArea( p_demux, p_sys->i_title + 1, 0, -1 ); DvdReadSetArea( p_demux, p_sys->i_title + 1, 0, -1 );
} }
if( p_sys->i_pack_len <= 0 ) if( p_sys->i_pack_len >= 1024 )
{ {
msg_Err( p_demux, "i_pack_len <= 0. This shouldn't happen!" ); msg_Err( p_demux, "i_pack_len >= 1024. This shouldn't happen!" );
return 0; /* EOF */ return 0; /* EOF */
} }
...@@ -695,6 +696,7 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter, ...@@ -695,6 +696,7 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
p_sys->i_title_start_block = p_sys->i_title_start_block =
p_pgc->cell_playback[i_start_cell].first_sector; p_pgc->cell_playback[i_start_cell].first_sector;
p_sys->i_title_end_cell =
i_end_cell = p_pgc->nr_of_cells - 1; i_end_cell = p_pgc->nr_of_cells - 1;
p_sys->i_title_end_block = p_sys->i_title_end_block =
p_pgc->cell_playback[i_end_cell].last_sector; p_pgc->cell_playback[i_end_cell].last_sector;
...@@ -784,6 +786,7 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter, ...@@ -784,6 +786,7 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
ESNew( p_demux, 0xe0, 0 ); /* Video, FIXME ? */ ESNew( p_demux, 0xe0, 0 ); /* Video, FIXME ? */
p_sys->i_aspect = p_vts->vtsi_mat->vts_video_attr.display_aspect_ratio;
#define audio_control \ #define audio_control \
p_sys->p_vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc->audio_control[i-1] p_sys->p_vts_file->vts_pgcit->pgci_srp[pgc_id-1].pgc->audio_control[i-1]
...@@ -849,13 +852,13 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter, ...@@ -849,13 +852,13 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
/* 16:9 */ /* 16:9 */
switch( p_vts->vtsi_mat->vts_video_attr.permitted_df ) switch( p_vts->vtsi_mat->vts_video_attr.permitted_df )
{ {
case 1: case 1: /* letterbox */
i_position = spu_control & 0xff; i_position = spu_control & 0xff;
break; break;
case 2: case 2: /* pan&scan */
i_position = ( spu_control >> 8 ) & 0xff; i_position = ( spu_control >> 8 ) & 0xff;
break; break;
default: default: /* widescreen */
i_position = ( spu_control >> 16 ) & 0xff; i_position = ( spu_control >> 16 ) & 0xff;
break; break;
} }
...@@ -875,17 +878,17 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter, ...@@ -875,17 +878,17 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
#undef spu_control #undef spu_control
} }
else else if( i_title != -1 && i_title != p_sys->i_title )
{ {
/* TODO: update input ? */ return VLC_EGENERIC; /* Couldn't set title */
} }
/* /*
* Chapter selection * Chapter selection
*/ */
if( i_chapter >= 0 && i_chapter <= p_sys->i_chapters && if( i_chapter >= 0 && i_chapter <= p_sys->i_chapters )
i_chapter != p_sys->i_chapter )
{ {
pgc_id = p_vts->vts_ptt_srpt->title[ pgc_id = p_vts->vts_ptt_srpt->title[
p_sys->i_ttn - 1].ptt[i_chapter].pgcn; p_sys->i_ttn - 1].ptt[i_chapter].pgcn;
...@@ -915,6 +918,11 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter, ...@@ -915,6 +918,11 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
p_demux->info.i_seekpoint = i_chapter; p_demux->info.i_seekpoint = i_chapter;
} }
} }
else if( i_chapter != -1 )
{
return VLC_EGENERIC; /* Couldn't set chapter */
}
#undef p_pgc #undef p_pgc
#undef p_vts #undef p_vts
...@@ -932,36 +940,39 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter, ...@@ -932,36 +940,39 @@ static int DvdReadSetArea( demux_t *p_demux, int i_title, int i_chapter,
static void DvdReadSeek( demux_t *p_demux, int i_block_offset ) static void DvdReadSeek( demux_t *p_demux, int i_block_offset )
{ {
demux_sys_t *p_sys = p_demux->p_sys; demux_sys_t *p_sys = p_demux->p_sys;
unsigned int i_tmp; unsigned int i_chapter = 0;
unsigned int i_chapter = -1;
unsigned int i_cell = 0; unsigned int i_cell = 0;
unsigned int i_vobu = 0; unsigned int i_vobu = 0;
unsigned int i_sub_cell = 0; unsigned int i_sub_cell = 0;
int i_block; int i_block;
msg_Err( p_demux, "seek offset: %i", i_block_offset );
#define p_pgc p_sys->p_cur_pgc #define p_pgc p_sys->p_cur_pgc
#define p_vts p_sys->p_vts_file #define p_vts p_sys->p_vts_file
/* Find cell */ /* Find cell */
p_sys->i_title_offset = i_block = i_block_offset; i_block = i_block_offset;
while( i_block >= (int)p_pgc->cell_playback[i_cell].last_sector - for( i_cell = p_sys->i_title_start_cell;
(int)p_pgc->cell_playback[i_cell].first_sector + 1 ) i_cell <= p_sys->i_title_end_cell; i_cell++ )
{ {
i_cell++; if( i_block < (int)p_pgc->cell_playback[i_cell].last_sector -
(int)p_pgc->cell_playback[i_cell].first_sector + 1 ) break;
i_block -= p_pgc->cell_playback[i_cell].last_sector - i_block -= (p_pgc->cell_playback[i_cell].last_sector -
p_pgc->cell_playback[i_cell].first_sector + 1; p_pgc->cell_playback[i_cell].first_sector + 1);
}
if( i_cell > p_sys->i_title_end_cell )
{
msg_Err( p_demux, "couldn't find cell for block %i", i_block_offset );
return;
} }
i_block += p_pgc->cell_playback[i_cell].first_sector; i_block += p_pgc->cell_playback[i_cell].first_sector;
p_sys->i_title_offset = i_block_offset;
/* Find chapter */ /* Find chapter */
do for( i_chapter = 0; i_chapter < p_sys->i_chapters; i_chapter++ )
{ {
int pgc_id, pgn; int pgc_id, pgn, i_tmp;
i_chapter++;
pgc_id = p_vts->vts_ptt_srpt->title[ pgc_id = p_vts->vts_ptt_srpt->title[
p_sys->i_ttn - 1].ptt[i_chapter].pgcn; p_sys->i_ttn - 1].ptt[i_chapter].pgcn;
pgn = p_vts->vts_ptt_srpt->title[ pgn = p_vts->vts_ptt_srpt->title[
...@@ -969,7 +980,8 @@ static void DvdReadSeek( demux_t *p_demux, int i_block_offset ) ...@@ -969,7 +980,8 @@ static void DvdReadSeek( demux_t *p_demux, int i_block_offset )
i_tmp = p_vts->vts_pgcit->pgci_srp[pgc_id - 1].pgc->program_map[pgn-1]; i_tmp = p_vts->vts_pgcit->pgci_srp[pgc_id - 1].pgc->program_map[pgn-1];
} while( i_tmp <= i_cell ); if( i_tmp > (int)i_cell ) break;
}
if( i_chapter < p_sys->i_chapters && if( i_chapter < p_sys->i_chapters &&
p_demux->info.i_seekpoint != i_chapter ) p_demux->info.i_seekpoint != i_chapter )
...@@ -1206,7 +1218,7 @@ static void DemuxTitles( demux_t *p_demux, ...@@ -1206,7 +1218,7 @@ static void DemuxTitles( demux_t *p_demux,
} }
/* Set forced title/chapter/angle */ /* Set forced title/chapter/angle */
*pi_title = (*pi_title >= 1 && *pi_title <= i_titles) ? *pi_title : 1; *pi_title = (*pi_title >= 0 && *pi_title < i_titles) ? *pi_title : 0;
*pi_chapter = (*pi_chapter >= 0 && *pi_chapter < *pi_chapter = (*pi_chapter >= 0 && *pi_chapter <
tt_srpt->title[*pi_title].nr_of_ptts) ? *pi_chapter : 0; tt_srpt->title[*pi_title].nr_of_ptts) ? *pi_chapter : 0;
...@@ -1214,7 +1226,7 @@ static void DemuxTitles( demux_t *p_demux, ...@@ -1214,7 +1226,7 @@ static void DemuxTitles( demux_t *p_demux,
} }
/***************************************************************************** /*****************************************************************************
* ParseCL: parse command line * ParseCL: parse command line. Titles, chapters and angles start from 1.
*****************************************************************************/ *****************************************************************************/
static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
int *i_title, int *i_chapter, int *i_angle ) int *i_title, int *i_chapter, int *i_angle )
...@@ -1224,8 +1236,8 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, ...@@ -1224,8 +1236,8 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
psz_source = strdup( psz_name ); psz_source = strdup( psz_name );
if( psz_source == NULL ) return NULL; if( psz_source == NULL ) return NULL;
*i_title = 0; *i_title = 1;
*i_chapter = 0; *i_chapter = 1;
*i_angle = 1; *i_angle = 1;
/* Start with the end, because you could have : /* Start with the end, because you could have :
...@@ -1253,9 +1265,9 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, ...@@ -1253,9 +1265,9 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
} }
} }
*i_title = *i_title >= 0 ? *i_title : 0; *i_title = *i_title > 0 ? *i_title : 1;
*i_chapter = *i_chapter ? *i_chapter : 0; *i_chapter = *i_chapter > 0 ? *i_chapter : 1;
*i_angle = *i_angle ? *i_angle : 1; *i_angle = *i_angle > 0 ? *i_angle : 1;
if( !*psz_source ) if( !*psz_source )
{ {
...@@ -1279,5 +1291,9 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force, ...@@ -1279,5 +1291,9 @@ static char *ParseCL( vlc_object_t *p_this, char *psz_name, vlc_bool_t b_force,
msg_Dbg( p_this, "dvdroot=%s title=%d chapter=%d angle=%d", msg_Dbg( p_this, "dvdroot=%s title=%d chapter=%d angle=%d",
psz_source, *i_title, *i_chapter, *i_angle ); psz_source, *i_title, *i_chapter, *i_angle );
/* Get back to a 0-based offset */
(*i_title)--;
(*i_chapter)--;
return psz_source; return psz_source;
} }
...@@ -862,8 +862,6 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event ) ...@@ -862,8 +862,6 @@ void MenuEvtHandler::OnMenuEvent( wxCommandEvent& event )
return; return;
} }
msg_Err( p_intf, "received event: %i", event.GetId() );
/* Check if this is an hotkey event */ /* Check if this is an hotkey event */
if( event.GetId() >= i_hotkey_event && if( event.GetId() >= i_hotkey_event &&
event.GetId() < i_hotkey_event + i_hotkeys ) event.GetId() < i_hotkey_event + i_hotkeys )
......
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