Changeset e259db6fefa6941b1a9cc2c01de8536c53b3ec01

Show
Ignore:
Timestamp:
06/04/08 13:14:12 (3 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1212578052 +0200
git-parent:

[350148d32c57a849a34dd44df89058b41f28531c]

git-author:
Antoine Cellerier <dionoea@videolan.org> 1212539040 +0200
Message:

Use filter chain in subpicture core.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_osd.h

    r9d85c35 re259db6  
    7878 
    7979    /* Supciture filters */ 
    80     filter_t *pp_filter[10]; 
    81     int      i_filter; 
     80    filter_chain_t *p_chain; 
    8281}; 
    8382 
  • src/misc/filter_chain.c

    r57d88c8 re259db6  
    306306} 
    307307 
     308#include <vlc_osd.h> 
     309 
    308310void filter_chain_SubFilter( filter_chain_t *p_chain, 
    309311                             mtime_t display_date ) 
  • src/video_output/vout_subpictures.c

    rd666030 re259db6  
    5959                              vlc_value_t, vlc_value_t, void * ); 
    6060 
     61static int sub_filter_allocation_init( filter_t *, void * ); 
     62static void sub_filter_allocation_clear( filter_t * ); 
    6163struct filter_owner_sys_t 
    6264{ 
     
    7072    SCALE_SIZE 
    7173}; 
     74 
    7275/** 
    7376 * Creates the subpicture unit 
     
    8992    p_spu->p_text = NULL; 
    9093    p_spu->p_scale = NULL; 
    91     p_spu->i_filter = 0; 
    9294    p_spu->pf_control = spu_vaControlDefault; 
    9395 
     
    99101    vlc_object_attach( p_spu, p_this ); 
    100102 
     103    p_spu->p_chain = filter_chain_New( p_spu, "sub filter", false, 
     104                                       sub_filter_allocation_init, 
     105                                       sub_filter_allocation_clear, 
     106                                       p_spu ); 
    101107    return p_spu; 
    102108} 
     
    126132int spu_ParseChain( spu_t *p_spu ) 
    127133{ 
    128     char *psz_parser; 
    129     vlc_value_t val; 
    130     var_Get( p_spu, "sub-filter", &val ); 
    131     psz_parser = val.psz_string; 
    132  
    133     while( psz_parser && *psz_parser ) 
    134     { 
    135         config_chain_t *p_cfg; 
    136         char *psz_name; 
    137  
    138         psz_parser = config_ChainCreate( &psz_name, &p_cfg, psz_parser ); 
    139  
    140         msg_Dbg( p_spu, "adding sub-filter: %s", psz_name ); 
    141  
    142         p_spu->pp_filter[p_spu->i_filter] = 
    143             vlc_object_create( p_spu, VLC_OBJECT_FILTER ); 
    144         vlc_object_attach( p_spu->pp_filter[p_spu->i_filter], p_spu ); 
    145         p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_new = sub_new_buffer; 
    146         p_spu->pp_filter[p_spu->i_filter]->pf_sub_buffer_del = sub_del_buffer; 
    147         p_spu->pp_filter[p_spu->i_filter]->p_cfg = p_cfg; 
    148         p_spu->pp_filter[p_spu->i_filter]->p_module = 
    149             module_Need( p_spu->pp_filter[p_spu->i_filter], 
    150                          "sub filter", psz_name, true ); 
    151         free( psz_name ); 
    152  
    153         if( p_spu->pp_filter[p_spu->i_filter]->p_module ) 
    154         { 
    155             filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) ); 
    156             if( p_sys ) 
    157             { 
    158                 p_spu->pp_filter[p_spu->i_filter]->p_owner = p_sys; 
    159                 spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel ); 
    160                 p_sys->p_spu = p_spu; 
    161                 p_spu->i_filter++; 
    162             } 
    163         } 
    164         else 
    165         { 
    166             msg_Dbg( p_spu, "no sub filter found" ); 
    167             config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg ); 
    168             vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] ); 
    169             vlc_object_release( p_spu->pp_filter[p_spu->i_filter] ); 
    170         } 
    171  
    172         if( p_spu->i_filter >= 10 ) 
    173         { 
    174             msg_Dbg( p_spu, "can't add anymore filters" ); 
    175             break; 
    176         } 
    177  
    178     } 
    179     free( val.psz_string ); 
    180  
     134    char *psz_parser = var_GetString( p_spu, "sub-filter" ); 
     135    if( filter_chain_AppendFromString( p_spu->p_chain, psz_parser ) < 0 ) 
     136    { 
     137        free( psz_parser ); 
     138        return VLC_EGENERIC; 
     139    } 
     140 
     141    free( psz_parser ); 
    181142    return VLC_SUCCESS; 
    182143} 
     
    237198static void spu_DeleteChain( spu_t *p_spu ) 
    238199{ 
    239     if( p_spu->i_filter ) 
    240     while( p_spu->i_filter ) 
    241     { 
    242         p_spu->i_filter--; 
    243         module_Unneed( p_spu->pp_filter[p_spu->i_filter], 
    244                        p_spu->pp_filter[p_spu->i_filter]->p_module ); 
    245         free( p_spu->pp_filter[p_spu->i_filter]->p_owner ); 
    246         config_ChainDestroy( p_spu->pp_filter[p_spu->i_filter]->p_cfg ); 
    247         vlc_object_detach( p_spu->pp_filter[p_spu->i_filter] ); 
    248         vlc_object_release( p_spu->pp_filter[p_spu->i_filter] ); 
    249     } 
     200    filter_chain_Delete( p_spu->p_chain ); 
    250201} 
    251202 
     
    11171068 
    11181069    /* Run subpicture filters */ 
    1119     for( i_index = 0; i_index < p_spu->i_filter; i_index++ ) 
    1120     { 
    1121         subpicture_t *p_subpic_filter; 
    1122         p_subpic_filter = p_spu->pp_filter[i_index]-> 
    1123             pf_sub_filter( p_spu->pp_filter[i_index], display_date ); 
    1124         if( p_subpic_filter ) 
    1125         { 
    1126             spu_DisplaySubpicture( p_spu, p_subpic_filter ); 
    1127         } 
    1128     } 
     1070    filter_chain_SubFilter( p_spu->p_chain, display_date ); 
    11291071 
    11301072    /* We get an easily parsable chained list of subpictures which 
     
    14091351    return VLC_SUCCESS; 
    14101352} 
     1353 
     1354static int sub_filter_allocation_init( filter_t *p_filter, void *p_data ) 
     1355{ 
     1356    spu_t *p_spu = (spu_t *)p_data; 
     1357 
     1358    p_filter->pf_sub_buffer_new = sub_new_buffer; 
     1359    p_filter->pf_sub_buffer_del = sub_del_buffer; 
     1360 
     1361    filter_owner_sys_t *p_sys = malloc( sizeof(filter_owner_sys_t) ); 
     1362    if( !p_sys ) return VLC_EGENERIC; 
     1363 
     1364    p_filter->p_owner = p_sys; 
     1365    spu_Control( p_spu, SPU_CHANNEL_REGISTER, &p_sys->i_channel ); 
     1366    p_sys->p_spu = p_spu; 
     1367 
     1368    return VLC_SUCCESS; 
     1369} 
     1370 
     1371static void sub_filter_allocation_clear( filter_t *p_filter ) 
     1372{ 
     1373    free( p_filter->p_owner ); 
     1374}