From 21f2437d9beea8b2a5e6234d278c92c7be397d9c Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 3 Oct 2005 14:29:01 +0000 Subject: Fix DVD audio and subtitle stream mapping, esp. for DVD with both 4:3 and 16:9 subtitles. Patch by Lehel Bernadt (lehel at pmc-services hu) with minor modifications. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@16650 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdvdkit2/ifo_print.c | 4 ++-- libmpdvdkit2/ifo_read.c | 8 ++------ libmpdvdkit2/ifo_types.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 10 deletions(-) (limited to 'libmpdvdkit2') diff --git a/libmpdvdkit2/ifo_print.c b/libmpdvdkit2/ifo_print.c index 6d5b54acfa..0ce1c0011e 100644 --- a/libmpdvdkit2/ifo_print.c +++ b/libmpdvdkit2/ifo_print.c @@ -761,14 +761,14 @@ void ifoPrint_PGC(pgc_t *pgc) { ifoPrint_USER_OPS(&pgc->prohibited_ops); for(i = 0; i < 8; i++) { - if(pgc->audio_control[i] & 0x8000) { /* The 'is present' bit */ + if(pgc->audio_control[i].present) { printf("Audio stream %i control: %04x\n", i, pgc->audio_control[i]); } } for(i = 0; i < 32; i++) { - if(pgc->subp_control[i] & 0x80000000) { /* The 'is present' bit */ + if(pgc->subp_control[i].present) { printf("Subpicture stream %2i control: %08x\n", i, pgc->subp_control[i]); } diff --git a/libmpdvdkit2/ifo_read.c b/libmpdvdkit2/ifo_read.c index 60ce748199..ef308b52e0 100644 --- a/libmpdvdkit2/ifo_read.c +++ b/libmpdvdkit2/ifo_read.c @@ -638,10 +638,6 @@ static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t *pgc, unsigned int offset) { B2N_16(pgc->cell_playback_offset); B2N_16(pgc->cell_position_offset); - for(i = 0; i < 8; i++) - B2N_16(pgc->audio_control[i]); - for(i = 0; i < 32; i++) - B2N_32(pgc->subp_control[i]); for(i = 0; i < 16; i++) B2N_32(pgc->palette[i]); @@ -650,10 +646,10 @@ static int ifoRead_PGC(ifo_handle_t *ifofile, pgc_t *pgc, unsigned int offset) { /* verify time (look at print_time) */ for(i = 0; i < 8; i++) - if(!pgc->audio_control[i] & 0x8000) /* The 'is present' bit */ + if(!pgc->audio_control[i].present) CHECK_ZERO(pgc->audio_control[i]); for(i = 0; i < 32; i++) - if(!pgc->subp_control[i] & 0x80000000) /* The 'is present' bit */ + if(!pgc->subp_control[i].present) CHECK_ZERO(pgc->subp_control[i]); /* Check that time is 0:0:0:0 also if nr_of_programs == 0 */ diff --git a/libmpdvdkit2/ifo_types.h b/libmpdvdkit2/ifo_types.h index 94b115007c..d128144d51 100644 --- a/libmpdvdkit2/ifo_types.h +++ b/libmpdvdkit2/ifo_types.h @@ -397,6 +397,55 @@ typedef struct { #endif } ATTRIBUTE_PACKED user_ops_t; +/** + * Subpicture stream mapping for a subtitle + */ +typedef struct { +#ifdef WORDS_BIGENDIAN + unsigned int present : 1; + unsigned int zero1 : 2; + unsigned int s_4p3 : 5; /* stream for 4:3 on any display */ + + unsigned int zero2 : 3; + unsigned int s_wide : 5; /* stream for 16:9 on widescreen display */ + + unsigned int zero3 : 3; + unsigned int s_lbox : 5; /* stream for 16:9 on letterboxed 4:3 display */ + + unsigned int zero4 : 3; + unsigned int s_panscan : 5; /* stream for 16:9 with pan&scan data on 4:3 display */ +#else + unsigned int s_4p3 : 5; /* stream for 4:3 on any display */ + unsigned int zero1 : 2; + unsigned int present : 1; + + unsigned int s_wide : 5; /* stream for 16:9 on widescreen display */ + unsigned int zero2 : 3; + + unsigned int s_lbox : 5; /* stream for 16:9 on letterboxed 4:3 display */ + unsigned int zero3 : 3; + + unsigned int s_panscan : 5; /* stream for 16:9 with pan&scan data on 4:3 display */ + unsigned int zero4 : 3; +#endif +} ATTRIBUTE_PACKED subp_mapping_t; + +/** + * Audio stream mapping for a soundtrack + */ +typedef struct { +#ifdef WORDS_BIGENDIAN + unsigned int present : 1; + unsigned int zero1 : 4; + unsigned int s_audio : 3; +#else + unsigned int s_audio : 3; + unsigned int zero1 : 4; + unsigned int present : 1; +#endif + uint8_t zero2; +} ATTRIBUTE_PACKED audio_mapping_t; + /** * Program Chain Information. */ @@ -406,8 +455,8 @@ typedef struct { uint8_t nr_of_cells; dvd_time_t playback_time; user_ops_t prohibited_ops; - uint16_t audio_control[8]; /* New type? */ - uint32_t subp_control[32]; /* New type? */ + audio_mapping_t audio_control[8]; + subp_mapping_t subp_control[32]; uint16_t next_pgc_nr; uint16_t prev_pgc_nr; uint16_t goup_pgc_nr; -- cgit v1.2.3