1 /*****************************************************************************
2 * text.c: text subtitles parser
3 *****************************************************************************
4 * Copyright (C) 2000-2001 VideoLAN
5 * $Id: text.c,v 1.2 2002/11/15 18:10:26 fenrir Exp $
7 * Authors: Gildas Bazin <gbazin@netcourrier.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
27 #include <stdlib.h> /* malloc(), free() */
28 #include <string.h> /* memcpy(), memset() */
32 #include <vlc/decoder.h>
36 /*****************************************************************************
38 *****************************************************************************/
40 /*****************************************************************************
41 * ParseText: parse an text subtitle packet and send it to the video output
42 *****************************************************************************/
43 void E_(ParseText)( spudec_thread_t *p_spudec, subtitler_font_t *p_font )
48 /* We cannot display a subpicture with no date */
49 i_pts = p_spudec->bit_stream.p_pes->i_pts;
50 i_dts = p_spudec->bit_stream.p_pes->i_dts;
54 NextDataPacket( p_spudec->p_fifo, &p_spudec->bit_stream );
55 msg_Warn( p_spudec->p_fifo, "subtitle without a date" );
60 /* Check validity of packet data */
61 if( (p_spudec->bit_stream.p_data->p_payload_end
62 - p_spudec->bit_stream.p_data->p_payload_start) <= 0
63 || (strlen(p_spudec->bit_stream.p_data->p_payload_start)
64 > p_spudec->bit_stream.p_data->p_payload_end
65 - p_spudec->bit_stream.p_data->p_payload_start) )
68 NextDataPacket( p_spudec->p_fifo, &p_spudec->bit_stream );
69 msg_Warn( p_spudec->p_fifo, "invalid subtitle" );
72 psz_subtitle = p_spudec->bit_stream.p_data->p_payload_start;
74 if( psz_subtitle[0] != '\0' )
76 subtitler_PlotSubtitle( p_spudec->p_vout,
82 /* Prepare for next time. No need to check that
83 * p_spudec->bit_stream->p_data is valid since we check later on
84 * for b_die and b_error */
85 NextDataPacket( p_spudec->p_fifo, &p_spudec->bit_stream );