⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subsusf.c

📁 VLC Player Source Code
💻 C
📖 第 1 页 / 共 4 页
字号:
        else if( !strcasecmp( "MiddleLeft", psz_align ) )            *i_align = SUBPICTURE_ALIGN_LEFT;        else if( !strcasecmp( "MiddleCenter", psz_align ) )            *i_align = 0;        else if( !strcasecmp( "MiddleRight", psz_align ) )            *i_align = SUBPICTURE_ALIGN_RIGHT;        else if( !strcasecmp( "BottomLeft", psz_align ) )            *i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_LEFT;        else if( !strcasecmp( "BottomCenter", psz_align ) )            *i_align = SUBPICTURE_ALIGN_BOTTOM;        else if( !strcasecmp( "BottomRight", psz_align ) )            *i_align = SUBPICTURE_ALIGN_BOTTOM | SUBPICTURE_ALIGN_RIGHT;        i_mask |= ATTRIBUTE_ALIGNMENT;        free( psz_align );    }    if( psz_margin_x )    {        *i_x = atoi( psz_margin_x );        if( strchr( psz_margin_x, '%' ) )            i_mask |= ATTRIBUTE_X_PERCENT;        else            i_mask |= ATTRIBUTE_X;        free( psz_margin_x );    }    if( psz_margin_y )    {        *i_y = atoi( psz_margin_y );        if( strchr( psz_margin_y, '%' ) )            i_mask |= ATTRIBUTE_Y_PERCENT;        else            i_mask |= ATTRIBUTE_Y;        free( psz_margin_y );    }    return i_mask;}static void SetupPositions( subpicture_region_t *p_region, char *psz_subtitle ){    int           i_mask = 0;    int           i_align;    int           i_x, i_y;    i_mask = ParsePositionAttributeList( psz_subtitle, &i_align, &i_x, &i_y );    if( i_mask & ATTRIBUTE_ALIGNMENT )        p_region->i_align = i_align;    /* TODO: Setup % based offsets properly, without adversely affecting     *       everything else in vlc. Will address with separate patch, to     *       prevent this one being any more complicated.     */    if( i_mask & ATTRIBUTE_X )        p_region->i_x = i_x;    else if( i_mask & ATTRIBUTE_X_PERCENT )        p_region->i_x = 0;    if( i_mask & ATTRIBUTE_Y )        p_region->i_y = i_y;    else if( i_mask & ATTRIBUTE_Y_PERCENT )        p_region->i_y = 0;}static subpicture_region_t *CreateTextRegion( decoder_t *p_dec,                                              subpicture_t *p_spu,                                              char *psz_subtitle,                                              int i_len,                                              int i_sys_align ){    decoder_sys_t        *p_sys = p_dec->p_sys;    subpicture_region_t  *p_text_region;    video_format_t        fmt;    /* Create a new subpicture region */    memset( &fmt, 0, sizeof(video_format_t) );    fmt.i_chroma = VLC_FOURCC('T','E','X','T');    fmt.i_aspect = 0;    fmt.i_width = fmt.i_height = 0;    fmt.i_x_offset = fmt.i_y_offset = 0;    p_text_region = p_spu->pf_create_region( VLC_OBJECT(p_dec), &fmt );    if( p_text_region != NULL )    {        ssa_style_t  *p_style = NULL;        p_text_region->psz_text = NULL;        p_text_region->psz_html = strndup( psz_subtitle, i_len );        if( ! p_text_region->psz_html )        {            p_spu->pf_destroy_region( VLC_OBJECT(p_dec), p_text_region );            return NULL;        }        p_style = ParseStyle( p_sys, p_text_region->psz_html );        if( !p_style )        {            int i;            for( i = 0; i < p_sys->i_ssa_styles; i++ )            {                if( !strcasecmp( p_sys->pp_ssa_styles[i]->psz_stylename, "Default" ) )                    p_style = p_sys->pp_ssa_styles[i];            }        }        if( p_style )        {            msg_Dbg( p_dec, "style is: %s", p_style->psz_stylename );            p_text_region->p_style = &p_style->font_style;            p_text_region->i_align = p_style->i_align;            /* TODO: Setup % based offsets properly, without adversely affecting             *       everything else in vlc. Will address with separate patch,             *       to prevent this one being any more complicated.                     * p_style->i_margin_percent_h;                     * p_style->i_margin_percent_v;             */            p_text_region->i_x         = p_style->i_margin_h;            p_text_region->i_y         = p_style->i_margin_v;        }        else        {            p_text_region->i_align = SUBPICTURE_ALIGN_BOTTOM | i_sys_align;            p_text_region->i_x = i_sys_align ? 20 : 0;            p_text_region->i_y = 10;        }        /* Look for position arguments which may override the style-based         * defaults.         */        SetupPositions( p_text_region, psz_subtitle );        p_text_region->p_next = NULL;    }    return p_text_region;}static int ParseImageAttachments( decoder_t *p_dec ){    decoder_sys_t        *p_sys = p_dec->p_sys;    input_attachment_t  **pp_attachments;    int                   i_attachments_cnt;    int                   k = 0;    if( VLC_SUCCESS != decoder_GetInputAttachments( p_dec, &pp_attachments, &i_attachments_cnt ))        return VLC_EGENERIC;    for( k = 0; k < i_attachments_cnt; k++ )    {        input_attachment_t *p_attach = pp_attachments[k];        vlc_fourcc_t  type  = 0;        if( ( !strcmp( p_attach->psz_mime, "image/bmp" ) )      || /* BMP */            ( !strcmp( p_attach->psz_mime, "image/x-bmp" ) )    ||            ( !strcmp( p_attach->psz_mime, "image/x-bitmap" ) ) ||            ( !strcmp( p_attach->psz_mime, "image/x-ms-bmp" ) ) )        {             type = VLC_FOURCC('b','m','p',' ');        }        else if( ( !strcmp( p_attach->psz_mime, "image/x-portable-anymap" ) )  || /* PNM */                 ( !strcmp( p_attach->psz_mime, "image/x-portable-bitmap" ) )  || /* PBM */                 ( !strcmp( p_attach->psz_mime, "image/x-portable-graymap" ) ) || /* PGM */                 ( !strcmp( p_attach->psz_mime, "image/x-portable-pixmap" ) ) )   /* PPM */        {            type = VLC_FOURCC('p','n','m',' ');        }        else if ( !strcmp( p_attach->psz_mime, "image/gif" ) )         /* GIF */            type = VLC_FOURCC('g','i','f',' ');        else if ( !strcmp( p_attach->psz_mime, "image/jpeg" ) )        /* JPG, JPEG */            type = VLC_FOURCC('j','p','e','g');        else if ( !strcmp( p_attach->psz_mime, "image/pcx" ) )         /* PCX */            type = VLC_FOURCC('p','c','x',' ');        else if ( !strcmp( p_attach->psz_mime, "image/png" ) )         /* PNG */            type = VLC_FOURCC('p','n','g',' ');        else if ( !strcmp( p_attach->psz_mime, "image/tiff" ) )        /* TIF, TIFF */            type = VLC_FOURCC('t','i','f','f');        else if ( !strcmp( p_attach->psz_mime, "image/x-tga" ) )       /* TGA */            type = VLC_FOURCC('t','g','a',' ');        else if ( !strcmp( p_attach->psz_mime, "image/x-xpixmap") )    /* XPM */            type = VLC_FOURCC('x','p','m',' ');        if( ( type != 0 ) &&            ( p_attach->i_data > 0 ) &&            ( p_attach->p_data != NULL ) )        {            picture_t         *p_pic = NULL;            image_handler_t   *p_image;            p_image = image_HandlerCreate( p_dec );            if( p_image != NULL )            {                block_t   *p_block;                p_block = block_New( p_image->p_parent, p_attach->i_data );                if( p_block != NULL )                {                    video_format_t     fmt_in;                    video_format_t     fmt_out;                    memcpy( p_block->p_buffer, p_attach->p_data, p_attach->i_data );                    memset( &fmt_in,  0, sizeof( video_format_t));                    memset( &fmt_out, 0, sizeof( video_format_t));                    fmt_in.i_chroma  = type;                    fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');                    /* Find a suitable decoder module */                    if( module_Exists( p_dec, "sdl_image" ) )                    {                        /* ffmpeg thinks it can handle bmp properly but it can't (at least                         * not all of them), so use sdl_image if it is available */                        vlc_value_t val;                        var_Create( p_dec, "codec", VLC_VAR_MODULE | VLC_VAR_DOINHERIT );                        val.psz_string = (char*) "sdl_image";                        var_Set( p_dec, "codec", val );                    }                    p_pic = image_Read( p_image, p_block, &fmt_in, &fmt_out );                    var_Destroy( p_dec, "codec" );                }                image_HandlerDelete( p_image );            }            if( p_pic )            {                image_attach_t *p_picture = malloc( sizeof(image_attach_t) );                if( p_picture )                {                    p_picture->psz_filename = strdup( p_attach->psz_name );                    p_picture->p_pic = p_pic;                    TAB_APPEND( p_sys->i_images, p_sys->pp_images, p_picture );                }            }        }        vlc_input_attachment_Delete( pp_attachments[ k ] );    }    free( pp_attachments );    return VLC_SUCCESS;}static void ParseUSFHeaderTags( decoder_t *p_dec, xml_reader_t *p_xml_reader ){    decoder_sys_t *p_sys = p_dec->p_sys;    char *psz_node;    ssa_style_t *p_style = NULL;    int i_style_level = 0;    int i_metadata_level = 0;    while ( xml_ReaderRead( p_xml_reader ) == 1 )    {        switch ( xml_ReaderNodeType( p_xml_reader ) )        {            case XML_READER_TEXT:            case XML_READER_NONE:                break;            case XML_READER_ENDELEM:                psz_node = xml_ReaderName( p_xml_reader );                if( !psz_node )                    break;                switch (i_style_level)                {                    case 0:                        if( !strcasecmp( "metadata", psz_node ) && (i_metadata_level == 1) )                        {                            i_metadata_level--;                        }                        break;                    case 1:                        if( !strcasecmp( "styles", psz_node ) )                        {                            i_style_level--;                        }                        break;                    case 2:                        if( !strcasecmp( "style", psz_node ) )                        {                            TAB_APPEND( p_sys->i_ssa_styles, p_sys->pp_ssa_styles, p_style );                            p_style = NULL;                            i_style_level--;                        }                        break;                }                free( psz_node );                break;            case XML_READER_STARTELEM:                psz_node = xml_ReaderName( p_xml_reader );                if( !psz_node )                    break;                if( !strcasecmp( "metadata", psz_node ) && (i_style_level == 0) )                {                    i_metadata_level++;                }                else if( !strcasecmp( "resolution", psz_node ) &&                         ( i_metadata_level == 1) )                {                    while ( xml_ReaderNextAttr( p_xml_reader ) == VLC_SUCCESS )                    {                        char *psz_name = xml_ReaderName ( p_xml_reader );                        char *psz_value = xml_ReaderValue ( p_xml_reader );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -