Changeset 6ef09b541a286e0ee1e2e3a313bc22dd6f60da2f

Show
Ignore:
Timestamp:
30/06/08 21:47:04 (5 months ago)
Author:
Antoine Cellerier <dionoea@videolan.org>
git-committer:
Antoine Cellerier <dionoea@videolan.org> 1214855224 +0200
git-parent:

[d2aa472ee162b6c81403b90a4eb0b3e44fc778a9]

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

Fix implicit filter chain module.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    rcba75ff r6ef09b5  
    12051205  VLC_ADD_PLUGIN([yuy2_i422]) 
    12061206  VLC_ADD_PLUGIN([yuy2_i420]) 
    1207   VLC_ADD_PLUGIN([chroma_chain]) 
     1207  VLC_ADD_PLUGIN([chain]) 
    12081208  VLC_ADD_PLUGIN([aout_file]) 
    12091209  VLC_ADD_PLUGIN([linear_resampler]) 
  • modules/video_filter/chain.c

    rc2c6729 r6ef09b5  
    3333#include <vlc_plugin.h> 
    3434#include <vlc_filter.h> 
    35 #include <vlc_vout.h> 
    3635 
    3736/***************************************************************************** 
     
    4140static void Destroy    ( vlc_object_t * ); 
    4241static picture_t *Chain( filter_t *, picture_t * ); 
     42static int AllocInit( filter_t *p_filter, void *p_data ); 
    4343 
    4444/***************************************************************************** 
     
    5555struct filter_sys_t 
    5656{ 
    57     filter_t       *p_filter1; /* conversion from fmt_in to fmr_mid */ 
    58     filter_t       *p_filter2; /* conversion from fmt_mid to fmt_out */ 
    59     picture_t      *p_tmp;     /* temporary picture buffer */ 
    60     video_format_t  fmt_mid; 
     57    filter_chain_t *p_chain; 
    6158}; 
    6259 
     
    6966}; 
    7067 
    71 static picture_t *get_pic( filter_t *p_filter
     68static int CreateChain( filter_chain_t *p_chain, es_format_t *p_fmt_mid
    7269{ 
    73     picture_t *p_pic = (picture_t *)p_filter->p_owner; 
    74     p_filter->p_owner = NULL; 
    75     return p_pic; 
     70    filter_t *p_filter1; 
     71    if( !( p_filter1 = 
     72           filter_chain_AppendFilter( p_chain, NULL, NULL, NULL, p_fmt_mid )) ) 
     73        return VLC_EGENERIC; 
     74    if( !filter_chain_AppendFilter( p_chain, NULL, NULL, p_fmt_mid, NULL ) ) 
     75    { 
     76        filter_chain_DeleteFilter( p_chain, p_filter1 ); 
     77        return VLC_EGENERIC; 
     78    } 
     79    return VLC_SUCCESS; 
    7680} 
    7781 
    78 /* FIXME: this is almost like DeleteFilter in src/misc/image.c */ 
    79 static void DeleteFilter( filter_t *p_filter ) 
     82static int AllocInit( filter_t *p_filter, void *p_data ) 
    8083{ 
    81     vlc_object_detach( p_filter ); 
    82     if( p_filter->p_module ) module_Unneed( p_filter, p_filter->p_module ); 
    83     vlc_object_release( p_filter ); 
    84 
    85  
    86 /* FIXME: this is almost like CreateFilter in src/misc/image.c */ 
    87 static filter_t *CreateFilter( vlc_object_t *p_this, video_format_t *fmt_in, 
    88                                video_format_t *fmt_out ) 
    89 
    90     filter_t *p_filter = vlc_object_create( p_this, sizeof(filter_t) ); 
    91     vlc_object_attach( p_filter, p_this ); 
    92  
    93     p_filter->pf_vout_buffer_new = get_pic; 
    94  
    95     p_filter->fmt_in = *fmt_in; 
    96     p_filter->fmt_out = *fmt_out; 
    97  
    98     p_filter->p_module = module_Need( p_filter, "video filter2", NULL, 0 ); 
    99  
    100     if( !p_filter->p_module ) 
    101     { 
    102         DeleteFilter( p_filter ); 
    103         return NULL; 
    104     } 
    105  
    106     return p_filter; 
    107 
    108  
    109 static int CreateChain( vlc_object_t *p_this, filter_sys_t *p_sys ) 
    110 
    111     p_sys->p_filter1 = CreateFilter( p_this, &p_filter->fmt_in.video, 
    112                                      &p_sys->fmt_mid ); 
    113     if( p_sys->p_filter1 ) 
    114     { 
    115         p_sys->p_filter2 = CreateFilter( p_this, &p_sys->fmt_mid, 
    116                                          &p_filter->fmt_out.video ); 
    117         if( p_sys->p_filter2 ) 
    118             return VLC_SUCCESS; 
    119         DeleteFilter( p_sys->p_filter1 ); 
    120     } 
    121     return VLC_EGENERIC; 
     84    /* Not sure about all of this ... it should work */ 
     85    p_filter->pf_vout_buffer_new = ((filter_t*)p_data)->pf_vout_buffer_new; 
     86    p_filter->pf_vout_buffer_del = ((filter_t*)p_data)->pf_vout_buffer_del; 
     87    p_filter->p_owner = ((filter_t*)p_data)->p_owner; 
     88    return VLC_SUCCESS; 
    12289} 
    12390 
     
    13198    filter_t *p_filter = (filter_t *)p_this; 
    13299    static int hack = 0; /* FIXME */ 
     100    es_format_t fmt_mid; 
    133101 
    134102    if( p_filter->fmt_in.video.i_chroma == p_filter->fmt_out.video.i_chroma ) 
     
    152120    p_filter->p_sys = p_sys; 
    153121 
    154     if( p_filter->fmt_in.i_width != p_filter->fmt_out.i_width || 
    155         p_filter->fmt_in.i_height != p_filter->fmt_out.i_height || 
    156         p_filter->fmt_in.i_visible_width != p_filter->fmt_out.i_visible_width || 
    157         p_filter->fmt_in.i_visible_height != p_filter->fmt_out.i_visible_height ) 
     122    p_sys->p_chain = filter_chain_New( p_filter, "video filter2", false, AllocInit, NULL, p_filter ); 
     123    if( !p_sys->p_chain ) 
     124    { 
     125        free( p_sys ); 
     126        return VLC_EGENERIC; 
     127    } 
     128    filter_chain_Reset( p_sys->p_chain, &p_filter->fmt_in, &p_filter->fmt_out ); 
     129 
     130    if( p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width || 
     131        p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height || 
     132        p_filter->fmt_in.video.i_visible_width != p_filter->fmt_out.video.i_visible_width || 
     133        p_filter->fmt_in.video.i_visible_height != p_filter->fmt_out.video.i_visible_height ) 
    158134    { 
    159135        /* Lets try resizing and then doing the chroma conversion */ 
    160         p_sys->fmt_mid = p_filter->fmt_out.video; 
    161         p_sys->fmt_mid.i_chroma = p_filter->fmt_in.video.i_chroma; 
    162         if( CreateChain( p_this, p_sys ) == VLC_SUCCESS ) 
     136        es_format_Copy( &fmt_mid, &p_filter->fmt_out ); 
     137        fmt_mid.video.i_chroma = p_filter->fmt_out.video.i_chroma; 
     138        if( CreateChain( p_sys->p_chain, &fmt_mid ) == VLC_SUCCESS ) 
     139        { 
     140            es_format_Clean( &fmt_mid ); 
     141            p_filter->pf_video_filter = Chain; 
    163142            return VLC_SUCCESS; 
     143        } 
    164144 
    165145        /* Lets try it the other way arround (chroma and then resize) */ 
    166         p_sys->fmt_mid = p_filter->fmt_in.video; 
    167         p_sys->fmt_mid.i_chroma = p_filter->fmt_out.video.i_chroma; 
    168         if( CreateChain( p_this, p_sys ) == VLC_SUCCESS ) 
     146        es_format_Clean( &fmt_mid ); 
     147        es_format_Copy( &fmt_mid, &p_filter->fmt_in ); 
     148        fmt_mid.video.i_chroma = p_filter->fmt_out.video.i_chroma; 
     149        if( CreateChain( p_sys->p_chain, &fmt_mid ) == VLC_SUCCESS ) 
     150        { 
     151            es_format_Clean( &fmt_mid ); 
     152            p_filter->pf_video_filter = Chain; 
    169153            return VLC_SUCCESS; 
     154        } 
    170155    } 
    171156    else 
     
    173158        /* Lets try doing a chroma chain */ 
    174159        int i; 
    175         p_sys->fmt_mid = p_filter->fmt_in.video
    176         for( i = 0; pi_allowed_chomas[i]; i++ ) 
     160        es_format_Copy( &fmt_mid, &p_filter->fmt_in )
     161        for( i = 0; pi_allowed_chromas[i]; i++ ) 
    177162        { 
    178             p_sys->fmt_mid.i_chroma = pi_allowed_chromas[i]; 
    179             if( CreateChain( p_this, p_sys ) == VLC_SUCCESS ) 
     163            fmt_mid.video.i_chroma = pi_allowed_chromas[i]; 
     164            if( CreateChain( p_sys->p_chain, &fmt_mid ) == VLC_SUCCESS ) 
     165            { 
     166                es_format_Clean( &fmt_mid ); 
     167                p_filter->pf_video_filter = Chain; 
    180168                return VLC_SUCCESS; 
     169            } 
    181170        } 
    182171    } 
    183172 
    184173    /* Hum ... looks like this really isn't going to work. Too bad. */ 
     174    es_format_Clean( &fmt_mid ); 
     175    filter_chain_Delete( p_sys->p_chain ); 
    185176    free( p_sys ); 
    186177    hack--; 
     
    191182{ 
    192183    filter_t *p_filter = (filter_t *)p_this; 
    193  
    194     DeleteFilter( p_filter->p_sys->filter1 ); 
    195     DeleteFilter( p_filter->p_sys->filter2 ); 
    196  
    197     if( p_filter->p_sys->p_tmp ) 
    198     { 
    199         free( p_filter->p_sys->p_tmp->p_data_orig ); 
    200         free( p_filter->p_sys->p_tmp ); 
    201     } 
    202  
     184    filter_chain_Delete( p_filter->p_sys->p_chain ); 
    203185    free( p_filter->p_sys ); 
    204186} 
     
    209191static picture_t *Chain( filter_t *p_filter, picture_t *p_pic ) 
    210192{ 
    211     picture_t *p_outpic = p_filter->pf_vout_buffer_new( p_filter ); 
    212     if( !p_outpic ) 
    213     { 
    214         msg_Warn( p_filter, "can't get output picture" ); 
    215         if( p_pic->pf_release ) 
    216             p_pic->pf_release( p_pic ); 
    217         return NULL; 
    218     } 
    219  
    220  
    221     if( !p_sys->p_tmp ) 
    222     { 
    223         picture_t *p_tmp = malloc( sizeof( picture_t ) ); 
    224         if( !p_tmp ) 
    225             return NULL; 
    226         vout_AllocatePicture( VLC_OBJECT( p_vout ), p_tmp, 
    227                               p_sys->fmt_mid.i_chroma, 
    228                               p_sys->fmt_mid.i_width, 
    229                               p_sys->fmt_mid.i_height, 
    230                               p_sys->fmt_mid.i_aspect ); 
    231         p_sys->p_tmp = p_tmp; 
    232         p_tmp->pf_release = NULL; 
    233         p_tmp->i_status = RESERVED_PICTURE; 
    234         p_tmp->p_sys = NULL; 
    235     } 
    236  
    237     p_sys->p_filter1->p_owner = (filter_owner_sys_t*)p_sys->p_tmp; 
    238     if( !p_sys->p_filter1->pf_video_filter( p_sys->p_filter1, p_pic ) ) 
    239     { 
    240         if( p_pic->pf_release ) 
    241             p_pic->pf_release( p_pic ); 
    242         return NULL; 
    243     } 
    244     if( p_pic->pf_release ) 
    245         p_pic->pf_release( p_pic ); 
    246     p_sys->p_filter2->p_owner = (filter_owner_sys_t*)p_outpic; 
    247     return p_sys->p_filter2->pf_video_filter( p_sys->p_filter2, p_sys->p_tmp ); 
     193    return filter_chain_VideoFilter( p_filter->p_sys->p_chain, p_pic ); 
    248194}