1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-28 23:09:59 +02:00

dvbsub.c: DVB subtitles decoder (ETSI EN 300 743). There is still a lot of

things to write to implement competely the standard but this decoder
          will work in most of the pictures subtitles cases. Text subtitles
          decoding is not implemented at all.
          This decoder has been validated with CAVENA encoders after few
          remarks of their developpers.

include/*: addded a p_spuinfo field in the decider_fifo_t and the
           es_descriptor_t

codecs.h: added a dvb_spuinfo_t structure to identify the id of the selected
          track.

modules/demux/mpeg: added the support of the dvb subtitles track. Need last
                    libdvbpsi (0x59 descriptor) to compile. The demuxer
                    creates n fake ES as each ES carries up to 256 subtitles
                    tracks.


This work is part of the work done by Anevia for the "Gran Theatro del
Barcelona".
This commit is contained in:
Damien Lucas 2003-11-06 16:36:41 +00:00
parent 56a43112a1
commit 1ddb23b6e8
11 changed files with 148 additions and 18 deletions

View File

@ -1,5 +1,5 @@
dnl Autoconf settings for vlc
dnl $Id: configure.ac,v 1.104 2003/11/04 11:11:29 titer Exp $
dnl $Id: configure.ac,v 1.105 2003/11/06 16:36:40 nitrox Exp $
AC_INIT(vlc,0.6.3-cvs)
@ -847,7 +847,7 @@ dnl default modules
dnl
AX_ADD_PLUGINS([dummy rc logger gestures memcpy hotkeys])
AX_ADD_PLUGINS([es mpga m4v mpeg_system ps ts avi asf aac mp4 rawdv])
AX_ADD_PLUGINS([spudec mpeg_audio lpcm a52 dts cinepak])
AX_ADD_PLUGINS([spudec mpeg_audio lpcm a52 dts cinepak dvbsub])
AX_ADD_PLUGINS([deinterlace invert adjust wall transform distort clone crop motionblur])
AX_ADD_PLUGINS([float32tos16 float32tos8 float32tou16 float32tou8 a52tospdif dtstospdif fixed32tofloat32 fixed32tos16 s16tofixed32 s16tofloat32 s16tofloat32swab s8tofloat32 u8tofixed32 u8tofloat32])
AX_ADD_PLUGINS([trivial_resampler ugly_resampler linear_resampler bandlimited_resampler])

View File

@ -2,7 +2,7 @@
* codecs.h: codec related structures needed by the demuxers and decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: codecs.h,v 1.7 2003/11/05 00:17:50 hartman Exp $
* $Id: codecs.h,v 1.8 2003/11/06 16:36:40 nitrox Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
@ -68,6 +68,12 @@ typedef struct {
} BITMAPINFO, *LPBITMAPINFO;
#endif
/* dvb_spuinfo_t exports the id of the selected track to the decoder */
typedef struct
{
unsigned int i_id;
} dvb_spuinfo_t;
/* WAVE form wFormatTag IDs */
#define WAVE_FORMAT_UNKNOWN 0x0000 /* Microsoft Corporation */

View File

@ -2,7 +2,7 @@
* input_ext-dec.h: structures exported to the VideoLAN decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_ext-dec.h,v 1.81 2003/10/08 21:01:07 gbazin Exp $
* $Id: input_ext-dec.h,v 1.82 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Kaempf <maxx@via.ecp.fr>
@ -109,6 +109,7 @@ struct decoder_fifo_t
sout_instance_t * p_sout;
void * p_waveformatex;
void * p_bitmapinfoheader;
void * p_spuinfo;
decoder_t * p_dec;
};

View File

@ -4,7 +4,7 @@
* control the pace of reading.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: input_ext-intf.h,v 1.96 2003/09/13 17:42:15 fenrir Exp $
* $Id: input_ext-intf.h,v 1.97 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
@ -68,6 +68,7 @@ struct es_descriptor_t
decoder_fifo_t * p_decoder_fifo;
void * p_waveformatex;
void * p_bitmapinfoheader;
void * p_spuinfo;
count_t c_packets; /* total packets read */
count_t c_invalid_packets; /* invalid packets read */

View File

@ -18,3 +18,4 @@ SOURCES_rawvideo = rawvideo.c
SOURCES_quicktime = quicktime.c
SOURCES_subsdec = subsdec.c
SOURCES_faad = faad.c
SOURCES_dvbsub = dvbsub.c

View File

@ -2,7 +2,7 @@
* spudec.c : SPU decoder thread
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: spudec.c,v 1.25 2003/09/02 20:19:26 gbazin Exp $
* $Id: spudec.c,v 1.26 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
@ -63,10 +63,10 @@ static int OpenDecoder( vlc_object_t *p_this )
if( p_dec->p_fifo->i_fourcc != VLC_FOURCC('s','p','u',' ')
&& p_dec->p_fifo->i_fourcc != VLC_FOURCC('s','p','u','b') )
{
{
return VLC_EGENERIC;
}
p_dec->pf_run = RunDecoder;
return VLC_SUCCESS;
@ -88,13 +88,13 @@ static int RunDecoder( decoder_fifo_t * p_fifo )
DecoderError( p_fifo );
return( -1 );
}
/*
* Initialize the thread properties
*/
p_spudec->p_vout = NULL;
p_spudec->p_fifo = p_fifo;
/*
* Initialize thread and free configuration
*/

View File

@ -2,7 +2,7 @@
* system.c: helper module for TS, PS and PES management
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: system.c,v 1.18 2003/10/25 00:49:14 sam Exp $
* $Id: system.c,v 1.19 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Michel Lespinasse <walken@via.ecp.fr>
@ -418,6 +418,29 @@ static void ParsePES( input_thread_t * p_input, es_descriptor_t * p_es )
{
input_DecodePES( p_es->p_decoder_fifo, p_pes );
}
else if ( p_es->p_decoder_fifo == NULL &&
((es_ts_data_t*)p_es->p_demux_data)->b_dvbsub)
{
es_descriptor_t* p_dvbsub;
uint8_t i_count;
uint8_t i;
i_count = ((es_ts_data_t*)p_es->p_demux_data)->i_dvbsub_es_count;
// If a language is selected, we send the packet to the decoder
for(i = 0; i < i_count; i++)
{
p_dvbsub = ((es_ts_data_t*)p_es->p_demux_data)->p_dvbsub_es[i];
if(p_dvbsub->p_decoder_fifo!=NULL)
{
input_DecodePES ( p_dvbsub->p_decoder_fifo, p_pes );
break;
}
}
if(i == i_count)
{
input_DeletePES( p_input->p_method_data, p_pes );
}
}
else
{
msg_Err( p_input, "no fifo to receive PES %p "
@ -444,7 +467,7 @@ static void GatherPES( input_thread_t * p_input, data_packet_t * p_data,
/* If we lost data, insert a NULL data packet (philosophy : 0 is quite
* often an escape sequence in decoders, so that should make them wait
* for the next start code). */
if( b_packet_lost )
if( b_packet_lost && !((es_ts_data_t*)p_es->p_demux_data)->b_dvbsub)
{
input_NullPacket( p_input, p_es );
}
@ -1187,6 +1210,7 @@ static void DemuxTS( input_thread_t * p_input, data_packet_t * p_data,
vlc_bool_t b_trash = 0; /* Is the packet unuseful ? */
vlc_bool_t b_lost = 0; /* Was there a packet loss ? */
vlc_bool_t b_psi = 0; /* Is this a PSI ? */
vlc_bool_t b_dvbsub = 0; /* Is this a dvb subtitle ? */
vlc_bool_t b_pcr = 0; /* Does it have a PCR ? */
es_descriptor_t * p_es = NULL;
es_ts_data_t * p_es_demux = NULL;
@ -1230,6 +1254,10 @@ static void DemuxTS( input_thread_t * p_input, data_packet_t * p_data,
{
b_psi = 1;
}
else if ( p_es_demux->b_dvbsub )
{
b_dvbsub = 1;
}
else
{
p_pgrm_demux = (pgrm_ts_data_t *)p_es->p_pgrm->p_demux_data;
@ -1243,7 +1271,7 @@ static void DemuxTS( input_thread_t * p_input, data_packet_t * p_data,
/* Not selected. Just read the adaptation field for a PCR. */
b_trash = 1;
}
else if( p_es->p_decoder_fifo == NULL && !b_psi )
else if( p_es->p_decoder_fifo == NULL && !b_psi && !b_dvbsub )
{
b_trash = 1;
}
@ -1256,7 +1284,7 @@ static void DemuxTS( input_thread_t * p_input, data_packet_t * p_data,
* may still be null. Who said it was ugly ?
* I have written worse. --Meuuh */
if( ( p_es ) &&
((p_es->p_decoder_fifo != NULL) || b_psi || b_pcr ) )
((p_es->p_decoder_fifo != NULL) || b_psi || b_pcr || b_dvbsub) )
{
p_es->c_packets++;

View File

@ -2,7 +2,7 @@
* system.h: MPEG demultiplexing.
*****************************************************************************
* Copyright (C) 1999-2002 VideoLAN
* $Id: system.h,v 1.11 2003/11/03 14:02:54 gbazin Exp $
* $Id: system.h,v 1.12 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
@ -246,6 +246,11 @@ typedef struct es_ts_data_t
int b_mpeg4;
uint16_t i_es_id;
/* dvb subtitles in TS data specific */
vlc_bool_t b_dvbsub;
uint8_t i_dvbsub_es_count;
es_descriptor_t* p_dvbsub_es[256];
es_mpeg4_descriptor_t *p_es_descr; /* es_descr of IOD */
} es_ts_data_t;

View File

@ -2,7 +2,7 @@
* mpeg_ts.c : Transport Stream input module for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: ts.c,v 1.39 2003/11/03 14:02:54 gbazin Exp $
* $Id: ts.c,v 1.40 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Henri Fallon <henri@via.ecp.fr>
* Johan Bilien <jobi@via.ecp.fr>
@ -64,6 +64,36 @@ struct demux_sys_t
mpeg_demux_t mpeg;
};
#define local_iso639_getlang(p1, p2) \
{ \
const iso639_lang_t * p_iso; \
p_iso = GetLang_2T((char*)(p1)); \
if( p_iso && strcmp(p_iso->psz_native_name,"Unknown")) \
{ \
if( p_iso->psz_native_name[0] ) \
strncpy( (p2), p_iso->psz_native_name, 20 ); \
else \
strncpy( (p2), p_iso->psz_eng_name, 20 ); \
} \
else \
{ \
p_iso = GetLang_2B((char*)(p1)); \
if ( p_iso ) \
{ \
if( p_iso->psz_native_name[0] ) \
strncpy( (p2), p_iso->psz_native_name, 20 ); \
else \
strncpy( (p2), p_iso->psz_eng_name, 20 ); \
} \
else \
{ \
strncpy( (p2), p1, 3 ); \
} \
} \
}
/*****************************************************************************
* Local prototypes
*****************************************************************************/
@ -1608,9 +1638,58 @@ static void TS_DVBPSI_HandlePMT( input_thread_t * p_input,
}
else if( p_dr->i_tag == 0x59 )
{
uint16_t n;
es_descriptor_t * p_dvbsub_es;
es_ts_data_t dvbsub_demux_data;
dvb_spuinfo_t* p_info;
dvbpsi_subtitling_dr_t* sub;
demux_data.b_dvbsub = 1;
demux_data.i_dvbsub_es_count = 0;
/* DVB subtitle */
i_fourcc = VLC_FOURCC( 'd', 'v', 'b', 's' );
i_cat = SPU_ES;
sub = dvbpsi_DecodeSubtitlingDr( p_dr );
for( n = 0; n < sub->i_subtitles_number; n++)
{
/* As each subtitle ES contains n languages,
* We are going to create n fake ES for the n
* tracks */
local_iso639_getlang(
sub->p_subtitle[n].i_iso6392_language_code,
psz_desc);
p_dvbsub_es = input_AddES( p_input,
p_pgrm,
0xfe12+n,
SPU_ES,
psz_desc,
sizeof(es_ts_data_t) );
if( p_dvbsub_es == NULL )
{
msg_Err( p_input, "could not add ES %d",
p_es->i_pid );
p_input->b_error = 1;
return;
}
p_dvbsub_es->i_fourcc = i_fourcc;
p_dvbsub_es->i_stream_id = i_stream_id;
p_info = malloc(sizeof(dvb_spuinfo_t));
p_info->i_id =
sub->p_subtitle[n].i_composition_page_id;
p_dvbsub_es->p_spuinfo = (void*) p_info;
memcpy( p_dvbsub_es->p_demux_data,
&dvbsub_demux_data,
sizeof(es_ts_data_t) );
((es_ts_data_t *)p_dvbsub_es->p_demux_data)
->i_continuity_counter = 0xFF;
// Finaly we add this stream to the index
demux_data.p_dvbsub_es[
demux_data.i_dvbsub_es_count++] = p_dvbsub_es;
i_cat = UNKNOWN_ES;
}
}
}
if( i_fourcc == VLC_FOURCC(0,0,0,0) )
@ -1629,6 +1708,8 @@ static void TS_DVBPSI_HandlePMT( input_thread_t * p_input,
{
dvbpsi_iso639_dr_t *p_decoded =
dvbpsi_DecodeISO639Dr( p_dr );
local_iso639_getlang(p_decoded->i_iso_639_code, psz_desc);
#if 0
if( p_decoded->i_code_count > 0 )
{
const iso639_lang_t * p_iso;
@ -1662,6 +1743,7 @@ static void TS_DVBPSI_HandlePMT( input_thread_t * p_input,
}
}
}
#endif
}
switch( p_es->i_type )
{

View File

@ -2,7 +2,7 @@
* input_dec.c: Functions for the management of decoders
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: input_dec.c,v 1.65 2003/10/10 17:09:42 gbazin Exp $
* $Id: input_dec.c,v 1.66 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
@ -329,6 +329,7 @@ static decoder_t * CreateDecoder( input_thread_t * p_input,
p_dec->p_fifo->p_demux_data = p_es->p_demux_data;
p_dec->p_fifo->p_waveformatex = p_es->p_waveformatex;
p_dec->p_fifo->p_bitmapinfoheader = p_es->p_bitmapinfoheader;
p_dec->p_fifo->p_spuinfo = p_es->p_spuinfo;
p_dec->p_fifo->p_stream_ctrl = &p_input->stream.control;
p_dec->p_fifo->p_sout = p_input->stream.p_sout;

View File

@ -2,7 +2,7 @@
* input_programs.c: es_descriptor_t, pgrm_descriptor_t management
*****************************************************************************
* Copyright (C) 1999-2002 VideoLAN
* $Id: input_programs.c,v 1.119 2003/09/20 17:35:38 gbazin Exp $
* $Id: input_programs.c,v 1.120 2003/11/06 16:36:41 nitrox Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
@ -635,6 +635,7 @@ es_descriptor_t * input_AddES( input_thread_t * p_input,
}
p_es->p_waveformatex = NULL;
p_es->p_bitmapinfoheader = NULL;
p_es->p_spuinfo = NULL;
/* Add this ES to the program definition if one is given */
if( p_pgrm )
@ -787,6 +788,10 @@ void input_DelES( input_thread_t * p_input, es_descriptor_t * p_es )
{
free( p_es->p_bitmapinfoheader );
}
if( p_es->p_spuinfo )
{
free( p_es->p_spuinfo );
}
/* Free the description string */
if( p_es->psz_desc != NULL )