📄 subsusf.c
字号:
if( psz_name && psz_value ) { if( !strcasecmp( "x", psz_name ) ) p_sys->i_original_width = atoi( psz_value ); else if( !strcasecmp( "y", psz_name ) ) p_sys->i_original_height = atoi( psz_value ); } free( psz_name ); free( psz_value ); } } else if( !strcasecmp( "styles", psz_node ) && (i_style_level == 0) ) { i_style_level++; } else if( !strcasecmp( "style", psz_node ) && (i_style_level == 1) ) { i_style_level++; p_style = calloc( 1, sizeof(ssa_style_t) ); if( ! p_style ) { free( psz_node ); break; } /* All styles are supposed to default to Default, and then * one or more settings are over-ridden. * At the moment this only effects styles defined AFTER * Default in the XML */ int i; for( i = 0; i < p_sys->i_ssa_styles; i++ ) { if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) ) { ssa_style_t *p_default_style = p_sys->pp_ssa_styles[i]; memcpy( p_style, p_default_style, sizeof( ssa_style_t ) ); p_style->font_style.psz_fontname = strdup( p_style->font_style.psz_fontname ); p_style->psz_stylename = NULL; } } while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) { char *psz_name = xml_ReaderName ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader ); if( psz_name && psz_value ) { if( !strcasecmp( "name", psz_name ) ) p_style->psz_stylename = strdup( psz_value); } free( psz_name ); free( psz_value ); } } else if( !strcasecmp( "fontstyle", psz_node ) && (i_style_level == 2) ) { while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) { char *psz_name = xml_ReaderName ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader ); if( psz_name && psz_value ) { if( !strcasecmp( "face", psz_name ) ) { free( p_style->font_style.psz_fontname ); p_style->font_style.psz_fontname = strdup( psz_value ); } else if( !strcasecmp( "size", psz_name ) ) { if( ( *psz_value == '+' ) || ( *psz_value == '-' ) ) { int i_value = atoi( psz_value ); if( ( i_value >= -5 ) && ( i_value <= 5 ) ) p_style->font_style.i_font_size += ( i_value * p_style->font_style.i_font_size ) / 10; else if( i_value < -5 ) p_style->font_style.i_font_size = - i_value; else if( i_value > 5 ) p_style->font_style.i_font_size = i_value; } else p_style->font_style.i_font_size = atoi( psz_value ); } else if( !strcasecmp( "italic", psz_name ) ) { if( !strcasecmp( "yes", psz_value )) p_style->font_style.i_style_flags |= STYLE_ITALIC; else p_style->font_style.i_style_flags &= ~STYLE_ITALIC; } else if( !strcasecmp( "weight", psz_name ) ) { if( !strcasecmp( "bold", psz_value )) p_style->font_style.i_style_flags |= STYLE_BOLD; else p_style->font_style.i_style_flags &= ~STYLE_BOLD; } else if( !strcasecmp( "underline", psz_name ) ) { if( !strcasecmp( "yes", psz_value )) p_style->font_style.i_style_flags |= STYLE_UNDERLINE; else p_style->font_style.i_style_flags &= ~STYLE_UNDERLINE; } else if( !strcasecmp( "color", psz_name ) ) { if( *psz_value == '#' ) { unsigned long col = strtol(psz_value+1, NULL, 16); p_style->font_style.i_font_color = (col & 0x00ffffff); p_style->font_style.i_font_alpha = (col >> 24) & 0xff; } } else if( !strcasecmp( "outline-color", psz_name ) ) { if( *psz_value == '#' ) { unsigned long col = strtol(psz_value+1, NULL, 16); p_style->font_style.i_outline_color = (col & 0x00ffffff); p_style->font_style.i_outline_alpha = (col >> 24) & 0xff; } } else if( !strcasecmp( "outline-level", psz_name ) ) { p_style->font_style.i_outline_width = atoi( psz_value ); } else if( !strcasecmp( "shadow-color", psz_name ) ) { if( *psz_value == '#' ) { unsigned long col = strtol(psz_value+1, NULL, 16); p_style->font_style.i_shadow_color = (col & 0x00ffffff); p_style->font_style.i_shadow_alpha = (col >> 24) & 0xff; } } else if( !strcasecmp( "shadow-level", psz_name ) ) { p_style->font_style.i_shadow_width = atoi( psz_value ); } else if( !strcasecmp( "back-color", psz_name ) ) { if( *psz_value == '#' ) { unsigned long col = strtol(psz_value+1, NULL, 16); p_style->font_style.i_karaoke_background_color = (col & 0x00ffffff); p_style->font_style.i_karaoke_background_alpha = (col >> 24) & 0xff; } } else if( !strcasecmp( "spacing", psz_name ) ) { p_style->font_style.i_spacing = atoi( psz_value ); } } free( psz_name ); free( psz_value ); } } else if( !strcasecmp( "position", psz_node ) && (i_style_level == 2) ) { while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS ) { char *psz_name = xml_ReaderName ( p_xml_reader ); char *psz_value = xml_ReaderValue ( p_xml_reader ); if( psz_name && psz_value ) { if( !strcasecmp( "alignment", psz_name ) ) { if( !strcasecmp( "TopLeft", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT; else if( !strcasecmp( "TopCenter", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_TOP; else if( !strcasecmp( "TopRight", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_RIGHT; else if( !strcasecmp( "MiddleLeft", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_LEFT; else if( !strcasecmp( "MiddleCenter", psz_value ) ) p_style->i_align = 0; else if( !strcasecmp( "MiddleRight", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_RIGHT; else if( !strcasecmp( "BottomLeft", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT; else if( !strcasecmp( "BottomCenter", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_BOTTOM; else if( !strcasecmp( "BottomRight", psz_value ) ) p_style->i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT; } else if( !strcasecmp( "horizontal-margin", psz_name ) ) { if( strchr( psz_value, '%' ) ) { p_style->i_margin_h = 0; p_style->i_margin_percent_h = atoi( psz_value ); } else { p_style->i_margin_h = atoi( psz_value ); p_style->i_margin_percent_h = 0; } } else if( !strcasecmp( "vertical-margin", psz_name ) ) { if( strchr( psz_value, '%' ) ) { p_style->i_margin_v = 0; p_style->i_margin_percent_v = atoi( psz_value ); } else { p_style->i_margin_v = atoi( psz_value ); p_style->i_margin_percent_v = 0; } } } free( psz_name ); free( psz_value ); } } free( psz_node ); break; } } free( p_style );}static subpicture_region_t *ParseUSFString( decoder_t *p_dec, char *psz_subtitle, subpicture_t *p_spu_in ){ decoder_sys_t *p_sys = p_dec->p_sys; subpicture_t *p_spu = p_spu_in; subpicture_region_t *p_region_first = NULL; subpicture_region_t *p_region_upto = p_region_first; while( *psz_subtitle ) { if( *psz_subtitle == '<' ) { char *psz_end = NULL; if(( !strncasecmp( psz_subtitle, "<text ", 6 )) || ( !strncasecmp( psz_subtitle, "<text>", 6 ))) { psz_end = strcasestr( psz_subtitle, "</text>" ); if( psz_end ) { subpicture_region_t *p_text_region; psz_end += strcspn( psz_end, ">" ) + 1; p_text_region = CreateTextRegion( p_dec, p_spu, psz_subtitle, psz_end - psz_subtitle, p_sys->i_align ); if( p_text_region ) { p_text_region->psz_text = CreatePlainText( p_text_region->psz_html ); if( ! var_CreateGetBool( p_dec, "subsdec-formatted" ) ) { free( p_text_region->psz_html ); p_text_region->psz_html = NULL; } } if( !p_region_first ) { p_region_first = p_region_upto = p_text_region; } else if( p_text_region ) { p_region_upto->p_next = p_text_region; p_region_upto = p_region_upto->p_next; } } } else if(( !strncasecmp( psz_subtitle, "<karaoke ", 9 )) || ( !strncasecmp( psz_subtitle, "<karaoke>", 9 ))) { psz_end = strcasestr( psz_subtitle, "</karaoke>" ); if( psz_end ) { subpicture_region_t *p_text_region; psz_end += strcspn( psz_end, ">" ) + 1; p_text_region = CreateTextRegion( p_dec, p_spu, psz_subtitle, psz_end - psz_subtitle, p_sys->i_align ); if( p_text_region ) { if( ! var_CreateGetBool( p_dec, "subsdec-formatted" ) ) { free( p_text_region->psz_html ); p_text_region->psz_html = NULL; } } if( !p_region_first ) { p_region_first = p_region_upto = p_text_region;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -