Commit 83b13fcb authored by Stéphane Borel's avatar Stéphane Borel

Rewrite most functions in DVD plugin. Some old bugs might have been
solved in the operation. The plugin some be more readable now, and
should produce fewaer segfaults (I hope so :p)
parent 97d95892
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dvd.h: thread structure of the DVD plugin * dvd.h: thread structure of the DVD plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: dvd.h,v 1.1 2002/03/06 01:20:56 stef Exp $ * $Id: dvd.h,v 1.2 2002/03/08 22:58:12 stef Exp $
* *
* Author: Stéphane Borel <stef@via.ecp.fr> * Author: Stéphane Borel <stef@via.ecp.fr>
* *
...@@ -45,19 +45,19 @@ typedef struct thread_dvd_data_s ...@@ -45,19 +45,19 @@ typedef struct thread_dvd_data_s
int i_chapter_nb; int i_chapter_nb;
int i_chapter; int i_chapter;
boolean_t b_new_chapter;
int i_angle_nb; int i_angle_nb;
int i_angle; int i_angle;
int i_angle_cell; /* cell index in the current angle */
int i_cell; /* cell index in adress map */ int i_map_cell; /* cell index in adress map */
int i_prg_cell; /* cell index in program map */ int i_prg_cell; /* cell index in program map */
int i_angle_cell; /* cell index in the current angle */
int i_sector; int i_vts_start; /* offset to beginning of vts */
int i_end_sector; /* last sector of current cell */ int i_vts_lb; /* sector in vts */
int i_end_lb; /* last sector of current cell */
int i_title_start;
int i_start;
int i_size; int i_size;
/* Structure that contains all information of the DVD */ /* Structure that contains all information of the DVD */
......
This diff is collapsed.
/* dvd_es.c: functions to find and select ES /* dvd_es.c: functions to find and select ES
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_es.c,v 1.1 2002/03/06 01:20:56 stef Exp $ * $Id: dvd_es.c,v 1.2 2002/03/08 22:58:12 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -70,27 +70,37 @@ void DVDLaunchDecoders( input_thread_t * p_input ); ...@@ -70,27 +70,37 @@ void DVDLaunchDecoders( input_thread_t * p_input );
#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
#define ADDES( stream_id, private_id, type, cat, lang ) \
i_id = ( (private_id) << 8 ) | (stream_id); \
p_es = input_AddES( p_input, NULL, i_id, 0 ); \
p_es->i_stream_id = (stream_id); \
p_es->i_type = (type); \
p_es->i_cat = (cat); \
if( lang ) \
{ \
strcpy( p_es->psz_desc, DecodeLanguage( hton16( lang ) ) ); \
}
/***************************************************************************** /*****************************************************************************
* DVDReadVideo * DVDReadVideo: read video ES
*****************************************************************************/ *****************************************************************************/
void DVDReadVideo( input_thread_t * p_input ) void DVDReadVideo( input_thread_t * p_input )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
es_descriptor_t * p_es; es_descriptor_t * p_es;
int i_id;
p_dvd = (thread_dvd_data_t*)(p_input->p_access_data); p_dvd = (thread_dvd_data_t*)(p_input->p_access_data);
/* ES 0 -> video MPEG2 */ /* ES 0 -> video MPEG2 */
IfoPrintVideo( p_dvd ); IfoPrintVideo( p_dvd );
p_es = input_AddES( p_input, NULL, 0xe0, 0 ); ADDES( 0xe0, 0, MPEG2_VIDEO_ES, VIDEO_ES, 0 );
p_es->i_stream_id = 0xe0;
p_es->i_type = MPEG2_VIDEO_ES;
p_es->i_cat = VIDEO_ES;
} }
/***************************************************************************** /*****************************************************************************
* DVDReadAudio * DVDReadAudio: read audio ES
*****************************************************************************/ *****************************************************************************/
#define audio_status \ #define audio_status \
vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_audio_status[i-1] vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_audio_status[i-1]
...@@ -99,10 +109,12 @@ void DVDReadAudio( input_thread_t * p_input ) ...@@ -99,10 +109,12 @@ void DVDReadAudio( input_thread_t * p_input )
{ {
thread_dvd_data_t * p_dvd; thread_dvd_data_t * p_dvd;
es_descriptor_t * p_es; es_descriptor_t * p_es;
int i_lang;
int i_id; int i_id;
int i; int i;
p_dvd = (thread_dvd_data_t*)(p_input->p_access_data); p_dvd = (thread_dvd_data_t*)(p_input->p_access_data);
p_dvd->i_audio_nb = 0;
/* Audio ES, in the order they appear in .ifo */ /* Audio ES, in the order they appear in .ifo */
for( i = 1 ; i <= vts.manager_inf.i_audio_nb ; i++ ) for( i = 1 ; i <= vts.manager_inf.i_audio_nb ; i++ )
...@@ -113,44 +125,30 @@ void DVDReadAudio( input_thread_t * p_input ) ...@@ -113,44 +125,30 @@ void DVDReadAudio( input_thread_t * p_input )
if( audio_status.i_available ) if( audio_status.i_available )
{ {
p_dvd->i_audio_nb++; p_dvd->i_audio_nb++;
i_lang = vts.manager_inf.p_audio_attr[i-1].i_lang_code;
i_id = audio_status.i_position;
switch( vts.manager_inf.p_audio_attr[i-1].i_coding_mode ) switch( vts.manager_inf.p_audio_attr[i-1].i_coding_mode )
{ {
case 0x00: /* AC3 */ case 0x00: /* AC3 */
i_id = ( ( 0x80 + audio_status.i_position ) << 8 ) | 0xbd; ADDES( 0xbd, 0x80 + audio_status.i_position,
p_es = input_AddES( p_input, NULL, i_id, 0 ); AC3_AUDIO_ES, AUDIO_ES, i_lang );
p_es->i_stream_id = 0xbd;
p_es->i_type = AC3_AUDIO_ES;
p_es->b_audio = 1; p_es->b_audio = 1;
p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage( hton16(
vts.manager_inf.p_audio_attr[i-1].i_lang_code ) ) );
strcat( p_es->psz_desc, " (ac3)" ); strcat( p_es->psz_desc, " (ac3)" );
break; break;
case 0x02: case 0x02:
case 0x03: /* MPEG audio */ case 0x03: /* MPEG audio */
i_id = 0xc0 + audio_status.i_position; ADDES( 0xc0 + audio_status.i_position, 0,
p_es = input_AddES( p_input, NULL, i_id, 0 ); MPEG2_AUDIO_ES, AUDIO_ES, i_lang );
p_es->i_stream_id = i_id;
p_es->i_type = MPEG2_AUDIO_ES;
p_es->b_audio = 1; p_es->b_audio = 1;
p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage( hton16(
vts.manager_inf.p_audio_attr[i-1].i_lang_code ) ) );
strcat( p_es->psz_desc, " (mpeg)" ); strcat( p_es->psz_desc, " (mpeg)" );
break; break;
case 0x04: /* LPCM */ case 0x04: /* LPCM */
ADDES( 0xbd, 0xa0 + audio_status.i_position,
i_id = ( ( 0xa0 + audio_status.i_position ) << 8 ) | 0xbd; LPCM_AUDIO_ES, AUDIO_ES, i_lang );
p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = 0xbd;
p_es->i_type = LPCM_AUDIO_ES;
p_es->b_audio = 1; p_es->b_audio = 1;
p_es->i_cat = AUDIO_ES;
strcpy( p_es->psz_desc, DecodeLanguage( hton16(
vts.manager_inf.p_audio_attr[i-1].i_lang_code ) ) );
strcat( p_es->psz_desc, " (lpcm)" ); strcat( p_es->psz_desc, " (lpcm)" );
break; break;
...@@ -170,7 +168,7 @@ void DVDReadAudio( input_thread_t * p_input ) ...@@ -170,7 +168,7 @@ void DVDReadAudio( input_thread_t * p_input )
#undef audio_status #undef audio_status
/***************************************************************************** /*****************************************************************************
* DVDReadSPU: Read subpictures ES * DVDReadSPU: read subpictures ES
*****************************************************************************/ *****************************************************************************/
#define spu_status \ #define spu_status \
vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_spu_status[i-1] vts.title_unit.p_title[p_dvd->i_title_id-1].title.pi_spu_status[i-1]
...@@ -183,6 +181,7 @@ void DVDReadSPU( input_thread_t * p_input ) ...@@ -183,6 +181,7 @@ void DVDReadSPU( input_thread_t * p_input )
int i; int i;
p_dvd = (thread_dvd_data_t*)(p_input->p_access_data); p_dvd = (thread_dvd_data_t*)(p_input->p_access_data);
p_dvd->i_spu_nb = 0;
for( i = 1 ; i <= vts.manager_inf.i_spu_nb; i++ ) for( i = 1 ; i <= vts.manager_inf.i_spu_nb; i++ )
{ {
...@@ -199,31 +198,24 @@ void DVDReadSPU( input_thread_t * p_input ) ...@@ -199,31 +198,24 @@ void DVDReadSPU( input_thread_t * p_input )
switch( vts.manager_inf.video_attr.i_perm_displ ) switch( vts.manager_inf.video_attr.i_perm_displ )
{ {
case 1: case 1:
i_id = ( ( 0x20 + spu_status.i_position_pan ) << 8 ) i_id = spu_status.i_position_pan;
| 0xbd;
break; break;
case 2: case 2:
i_id = ( ( 0x20 + spu_status.i_position_letter ) << 8 ) i_id = spu_status.i_position_letter;
| 0xbd;
break; break;
default: default:
i_id = ( ( 0x20 + spu_status.i_position_wide ) << 8 ) i_id = spu_status.i_position_wide;
| 0xbd;
break; break;
} }
} }
else else
{ {
/* 4:3 */ /* 4:3 */
i_id = ( ( 0x20 + spu_status.i_position_43 ) << 8 ) i_id = spu_status.i_position_43;
| 0xbd;
} }
p_es = input_AddES( p_input, NULL, i_id, 0 );
p_es->i_stream_id = 0xbd; ADDES( 0xbd, 0x20 + i_id, DVD_SPU_ES, SPU_ES,
p_es->i_type = DVD_SPU_ES; vts.manager_inf.p_spu_attr[i-1].i_lang_code );
p_es->i_cat = SPU_ES;
strcpy( p_es->psz_desc, DecodeLanguage( hton16(
vts.manager_inf.p_spu_attr[i-1].i_lang_code ) ) );
} }
} }
} }
...@@ -233,7 +225,7 @@ void DVDReadSPU( input_thread_t * p_input ) ...@@ -233,7 +225,7 @@ void DVDReadSPU( input_thread_t * p_input )
#undef vmg #undef vmg
/***************************************************************************** /*****************************************************************************
* DVDLaunchDecoders * DVDLaunchDecoders: select ES for video, audio and spu
*****************************************************************************/ *****************************************************************************/
void DVDLaunchDecoders( input_thread_t * p_input ) void DVDLaunchDecoders( input_thread_t * p_input )
{ {
...@@ -250,17 +242,16 @@ void DVDLaunchDecoders( input_thread_t * p_input ) ...@@ -250,17 +242,16 @@ void DVDLaunchDecoders( input_thread_t * p_input )
} }
/* Select audio stream */ /* Select audio stream */
if( p_main->b_audio ) if( p_main->b_audio && p_dvd->i_audio_nb > 0 )
{ {
/* For audio: first one if none or a not existing one specified */ /* For audio: first one if none or a not existing one specified */
i_audio = config_GetIntVariable( INPUT_CHANNEL_VAR ); i_audio = config_GetIntVariable( INPUT_CHANNEL_VAR );
if( i_audio < 0 || i_audio > p_dvd->i_audio_nb ) if( i_audio <= 0 || i_audio > p_dvd->i_audio_nb )
{ {
config_PutIntVariable( INPUT_CHANNEL_VAR, 1 ); config_PutIntVariable( INPUT_CHANNEL_VAR, 1 );
i_audio = 1; i_audio = 1;
} }
if( i_audio > 0 && p_dvd->i_audio_nb > 0 )
{
if( config_GetIntVariable( AOUT_SPDIF_VAR ) || if( config_GetIntVariable( AOUT_SPDIF_VAR ) ||
( config_GetIntVariable( INPUT_AUDIO_VAR ) == ( config_GetIntVariable( INPUT_AUDIO_VAR ) ==
REQUESTED_AC3 ) ) REQUESTED_AC3 ) )
...@@ -284,10 +275,9 @@ void DVDLaunchDecoders( input_thread_t * p_input ) ...@@ -284,10 +275,9 @@ void DVDLaunchDecoders( input_thread_t * p_input )
p_input->stream.pp_es[i_audio] ); p_input->stream.pp_es[i_audio] );
} }
} }
}
/* Select subtitle */ /* Select subtitle */
if( p_main->b_video ) if( p_main->b_video && p_dvd->i_spu_nb > 0 )
{ {
/* for spu, default is none */ /* for spu, default is none */
i_spu = config_GetIntVariable( INPUT_SUBTITLE_VAR ); i_spu = config_GetIntVariable( INPUT_SUBTITLE_VAR );
...@@ -296,7 +286,7 @@ void DVDLaunchDecoders( input_thread_t * p_input ) ...@@ -296,7 +286,7 @@ void DVDLaunchDecoders( input_thread_t * p_input )
config_PutIntVariable( INPUT_SUBTITLE_VAR, 0 ); config_PutIntVariable( INPUT_SUBTITLE_VAR, 0 );
i_spu = 0; i_spu = 0;
} }
if( i_spu > 0 && p_dvd->i_spu_nb > 0 ) if( i_spu > 0 )
{ {
i_spu += p_dvd->p_ifo->vts.manager_inf.i_audio_nb; i_spu += p_dvd->p_ifo->vts.manager_inf.i_audio_nb;
input_SelectES( p_input, p_input->stream.pp_es[i_spu] ); input_SelectES( p_input, p_input->stream.pp_es[i_spu] );
......
...@@ -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.44 2002/03/06 01:20:56 stef Exp $ * $Id: dvd_ifo.c,v 1.45 2002/03/08 22:58:12 stef Exp $
* *
* Authors: Stphane Borel <stef@via.ecp.fr> * Authors: Stphane Borel <stef@via.ecp.fr>
* German Tischler <tanis@gaspode.franken.de> * German Tischler <tanis@gaspode.franken.de>
...@@ -438,7 +438,7 @@ int IfoInit( ifo_t * p_ifo ) ...@@ -438,7 +438,7 @@ int IfoInit( ifo_t * p_ifo )
/***************************************************************************** /*****************************************************************************
* IfoTitleSet: Parse vts*.ifo files to fill the Video Title Set structure. * IfoTitleSet: Parse vts*.ifo files to fill the Video Title Set structure.
*****************************************************************************/ *****************************************************************************/
int IfoTitleSet( ifo_t * p_ifo ) int IfoTitleSet( ifo_t * p_ifo, int i_title )
{ {
u8 p_buf[DVD_LB_SIZE]; u8 p_buf[DVD_LB_SIZE];
u8 * p_tmp; u8 * p_tmp;
...@@ -453,7 +453,7 @@ int IfoTitleSet( ifo_t * p_ifo ) ...@@ -453,7 +453,7 @@ int IfoTitleSet( ifo_t * p_ifo )
FreeTitleSet( &p_ifo->vts ); FreeTitleSet( &p_ifo->vts );
} }
i_off = p_ifo->vmg.title_inf.p_attr[p_ifo->i_title-1].i_start_sector i_off = p_ifo->vmg.title_inf.p_attr[i_title-1].i_start_sector
+ p_ifo->i_start; + p_ifo->i_start;
//fprintf(stderr, "offset: %d\n" , i_off ); //fprintf(stderr, "offset: %d\n" , i_off );
...@@ -748,8 +748,8 @@ int IfoTitleSet( ifo_t * p_ifo ) ...@@ -748,8 +748,8 @@ int IfoTitleSet( ifo_t * p_ifo )
} }
#undef MGINF #undef MGINF
intf_WarnMsg( 2, "ifo info: vts %d initialized", intf_WarnMsg( 4, "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[i_title-1].i_title_set_num );
p_ifo->vts.b_initialized = 1; p_ifo->vts.b_initialized = 1;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* dvd_ifo.h: Structures for ifo parsing * dvd_ifo.h: Structures for ifo parsing
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.h,v 1.17 2001/06/12 22:14:44 sam Exp $ * $Id: dvd_ifo.h,v 1.18 2002/03/08 22:58:12 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -543,7 +543,6 @@ typedef struct ifo_s ...@@ -543,7 +543,6 @@ typedef struct ifo_s
int i_pos; /* Position of stream pointer */ int i_pos; /* Position of stream pointer */
boolean_t b_error; /* Error Management */ boolean_t b_error; /* Error Management */
vmg_t vmg; /* Structure described in video_ts */ vmg_t vmg; /* Structure described in video_ts */
int i_title; /* Current title number */
vts_t vts; /* Vts ifo for current title set */ vts_t vts; /* Vts ifo for current title set */
/* Remap buffer for unaligned reads */ /* Remap buffer for unaligned reads */
...@@ -559,6 +558,6 @@ struct thread_dvd_data_s; ...@@ -559,6 +558,6 @@ struct thread_dvd_data_s;
int IfoCreate ( struct thread_dvd_data_s * ); int IfoCreate ( struct thread_dvd_data_s * );
int IfoInit ( struct ifo_s * ); int IfoInit ( struct ifo_s * );
int IfoTitleSet ( struct ifo_s * ); int IfoTitleSet ( struct ifo_s *, int );
void IfoDestroy ( struct ifo_s * ); void IfoDestroy ( struct ifo_s * );
This diff is collapsed.
/* dvd_seek.h: DVD access plugin. /* dvd_seek.h: DVD access plugin.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_seek.h,v 1.1 2002/03/06 01:20:56 stef Exp $ * $Id: dvd_seek.h,v 1.2 2002/03/08 22:58:12 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -20,7 +20,18 @@ ...@@ -20,7 +20,18 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
int DVDChooseAngle( thread_dvd_data_t * ); int CellIsInterleaved( thread_dvd_data_t * );
int DVDFindCell( thread_dvd_data_t * ); u32 CellAngleOffset ( thread_dvd_data_t *, u32 );
int DVDFindSector( thread_dvd_data_t * ); u32 CellPrg2Map ( thread_dvd_data_t * );
int DVDChapterSelect( thread_dvd_data_t *, int ); u32 CellStartSector ( thread_dvd_data_t * );
u32 CellEndSector ( thread_dvd_data_t * );
u32 NextCellPrg ( thread_dvd_data_t * );
u32 Lb2CellPrg ( thread_dvd_data_t * );
u32 Lb2CellMap ( thread_dvd_data_t * );
u32 LbMaxOnce ( thread_dvd_data_t * );
int CellPrg2Chapter ( thread_dvd_data_t * );
int NextChapter ( thread_dvd_data_t * );
int DVDSetChapter ( thread_dvd_data_t *, int );
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* found in .ifo. * found in .ifo.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2001 VideoLAN * Copyright (C) 1998-2001 VideoLAN
* $Id: dvd_summary.c,v 1.14 2002/03/06 01:20:56 stef Exp $ * $Id: dvd_summary.c,v 1.15 2002/03/08 22:58:12 stef Exp $
* *
* Author: Stphane Borel <stef@via.ecp.fr> * Author: Stphane Borel <stef@via.ecp.fr>
* *
...@@ -68,13 +68,11 @@ ...@@ -68,13 +68,11 @@
****************************************************************************/ ****************************************************************************/
void IfoPrintTitle( thread_dvd_data_t * p_dvd ) void IfoPrintTitle( thread_dvd_data_t * p_dvd )
{ {
intf_WarnMsg( 5, "dvd info: title %d, %d chapter%s, %d angle%s, " intf_WarnMsg( 5, "dvd info: title %d, %d chapter%s, %d angle%s",
"vobstart at %d blocks, stream size %d blocks",
p_dvd->i_title, p_dvd->i_chapter_nb, p_dvd->i_title, p_dvd->i_chapter_nb,
(p_dvd->i_chapter_nb == 1) ? "" : "s", (p_dvd->i_chapter_nb == 1) ? "" : "s",
p_dvd->i_angle_nb, p_dvd->i_angle_nb,
(p_dvd->i_angle_nb == 1) ? "" : "s", (p_dvd->i_angle_nb == 1) ? "" : "s" );
p_dvd->i_start, p_dvd->i_size );
} }
/**************************************************************************** /****************************************************************************
......
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