X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fcodec%2Fsubsusf.c;h=74a9cf765c9cf9a5425250a6a23c91c71dbf51a6;hb=b50c7652c71962d64df75ec60a901131e577fdc7;hp=ab480681f802e8053b22831eac99d69d2168ee12;hpb=0e17b717feed5b870b4fd1707399bf1e3688e7fe;p=vlc diff --git a/modules/codec/subsusf.c b/modules/codec/subsusf.c index ab480681f8..74a9cf765c 100644 --- a/modules/codec/subsusf.c +++ b/modules/codec/subsusf.c @@ -1,53 +1,46 @@ /***************************************************************************** * subsusf.c : USF subtitles decoder ***************************************************************************** - * Copyright (C) 2000-2006 the VideoLAN team + * Copyright (C) 2000-2006 VLC authors and VideoLAN * $Id$ * * Authors: Bernie Purcell * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#include -#include "subsdec.h" +#include #include #include -#include +#include +#include +#include +#include +#include +#include /***************************************************************************** - * Local prototypes + * Module descriptor. *****************************************************************************/ static int OpenDecoder ( vlc_object_t * ); static void CloseDecoder ( vlc_object_t * ); -static subpicture_t *DecodeBlock ( decoder_t *, block_t ** ); -static char *CreatePlainText( char * ); -static int ParseImageAttachments( decoder_t *p_dec ); - -static subpicture_t *ParseText ( decoder_t *, block_t * ); -static void ParseUSFHeader( decoder_t * ); -static subpicture_region_t *ParseUSFString( decoder_t *, char * ); -static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, const char *psz_filename, int i_transparent_color ); - -/***************************************************************************** - * Module descriptor. - *****************************************************************************/ - vlc_module_begin () set_capability( "decoder", 40 ) set_shortname( N_("USFSubs")) @@ -58,6 +51,58 @@ vlc_module_begin () /* We inherit subsdec-align and subsdec-formatted from subsdec.c */ vlc_module_end () + +/***************************************************************************** + * Local prototypes + *****************************************************************************/ +enum +{ + ATTRIBUTE_ALIGNMENT = (1 << 0), + ATTRIBUTE_X = (1 << 1), + ATTRIBUTE_X_PERCENT = (1 << 2), + ATTRIBUTE_Y = (1 << 3), + ATTRIBUTE_Y_PERCENT = (1 << 4), +}; + +typedef struct +{ + char *psz_filename; + picture_t *p_pic; +} image_attach_t; + +typedef struct +{ + char * psz_stylename; /* The name of the style, no comma's allowed */ + text_style_t font_style; + int i_align; + int i_margin_h; + int i_margin_v; + int i_margin_percent_h; + int i_margin_percent_v; +} ssa_style_t; + +struct decoder_sys_t +{ + int i_original_height; + int i_original_width; + int i_align; /* Subtitles alignment on the vout */ + + ssa_style_t **pp_ssa_styles; + int i_ssa_styles; + + image_attach_t **pp_images; + int i_images; +}; + +static subpicture_t *DecodeBlock ( decoder_t *, block_t ** ); +static char *CreatePlainText( char * ); +static int ParseImageAttachments( decoder_t *p_dec ); + +static subpicture_t *ParseText ( decoder_t *, block_t * ); +static void ParseUSFHeader( decoder_t * ); +static subpicture_region_t *ParseUSFString( decoder_t *, char * ); +static subpicture_region_t *LoadEmbeddedImage( decoder_t *p_dec, const char *psz_filename, int i_transparent_color ); + /***************************************************************************** * OpenDecoder: probe the decoder and return score ***************************************************************************** @@ -80,11 +125,6 @@ static int OpenDecoder( vlc_object_t *p_this ) p_dec->fmt_out.i_cat = SPU_ES; p_dec->fmt_out.i_codec = 0; - /* Unused fields of p_sys - not needed for USF decoding */ - p_sys->b_ass = false; - p_sys->iconv_handle = (vlc_iconv_t)-1; - p_sys->b_autodetect_utf8 = false; - /* init of p_sys */ p_sys->i_align = 0; p_sys->i_original_height = 0; @@ -474,7 +514,7 @@ static int ParseImageAttachments( decoder_t *p_dec ) { block_t *p_block; - p_block = block_New( p_image->p_parent, p_attach->i_data ); + p_block = block_Alloc( p_attach->i_data ); if( p_block != NULL ) {