Changeset 28c10c83b4dc8f1de74a1180d68b44a04a6458d4

Show
Ignore:
Timestamp:
08/03/05 14:16:38 (4 years ago)
Author:
Gildas Bazin <gbazin@videolan.org>
git-committer:
Gildas Bazin <gbazin@videolan.org> 1110287798 +0000
git-parent:

[739d192acea9e963c567f006b477ec278070d3d5]

git-author:
Gildas Bazin <gbazin@videolan.org> 1110287798 +0000
Message:

* modules/codec/ffmpeg/video_filter.c: a few fixes and cleanup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/codec/ffmpeg/video_filter.c

    rae42e9e r28c10c8  
    5151    vlc_bool_t b_resize; 
    5252    vlc_bool_t b_convert; 
     53    vlc_bool_t b_resize_first; 
    5354 
    5455    es_format_t fmt_in; 
     
    99100    /* Misc init */ 
    100101    p_sys->p_rsc = NULL; 
    101     p_sys->b_convert = b_convert; 
    102102    p_sys->i_src_ffmpeg_chroma = 
    103103        E_(GetFfmpegChroma)( p_filter->fmt_in.video.i_chroma ); 
     
    108108    es_format_Init( &p_sys->fmt_out, 0, 0 ); 
    109109 
     110    /* Dummy alloc, will be reallocated in CheckInit */ 
     111    avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma, 
     112                     p_filter->fmt_out.video.i_width, 
     113                     p_filter->fmt_out.video.i_height ); 
     114 
    110115    if( CheckInit( p_filter ) != VLC_SUCCESS ) 
    111116    { 
    112117        free( p_sys ); 
    113118        return VLC_EGENERIC; 
    114     } 
    115  
    116     if( p_sys->b_resize && p_sys->b_convert ) 
    117     { 
    118         if ( p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > 
    119              p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height ) 
    120         { 
    121             /* Resizing then conversion */ 
    122             avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma, 
    123                              p_filter->fmt_out.video.i_width, 
    124                              p_filter->fmt_out.video.i_height ); 
    125         } 
    126         else 
    127         { 
    128             /* Conversion then resizing */ 
    129             avpicture_alloc( &p_sys->tmp_pic, p_sys->i_dst_ffmpeg_chroma, 
    130                              p_filter->fmt_in.video.i_width, 
    131                              p_filter->fmt_in.video.i_height ); 
    132         } 
    133119    } 
    134120 
     
    175161        p_sys->p_rsc = 0; 
    176162 
     163        p_sys->b_convert = 
     164          p_filter->fmt_in.video.i_chroma != p_filter->fmt_out.video.i_chroma; 
     165 
    177166        p_sys->b_resize = 
    178167          p_filter->fmt_in.video.i_width != p_filter->fmt_out.video.i_width || 
    179168          p_filter->fmt_in.video.i_height != p_filter->fmt_out.video.i_height; 
     169 
     170        p_sys->b_resize_first = 
     171          p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > 
     172          p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height; 
     173 
     174        if( E_(GetFfmpegChroma)( p_filter->fmt_in.video.i_chroma ) != 
     175            VLC_FOURCC('I','4','2','0') ) 
     176            p_sys->b_resize_first = VLC_FALSE; 
    180177 
    181178        if( p_sys->b_resize ) 
     
    193190        } 
    194191 
     192        avpicture_free( &p_sys->tmp_pic ); 
     193 
     194        if( p_sys->b_resize_first ) 
     195        { 
     196            /* Resizing then conversion */ 
     197            avpicture_alloc( &p_sys->tmp_pic, p_sys->i_src_ffmpeg_chroma, 
     198                             p_filter->fmt_out.video.i_width, 
     199                             p_filter->fmt_out.video.i_height ); 
     200        } 
     201        else 
     202        { 
     203            /* Conversion then resizing */ 
     204            avpicture_alloc( &p_sys->tmp_pic, p_sys->i_dst_ffmpeg_chroma, 
     205                             p_filter->fmt_in.video.i_width, 
     206                             p_filter->fmt_in.video.i_height ); 
     207        } 
     208 
    195209        p_sys->fmt_in = p_filter->fmt_in; 
    196210        p_sys->fmt_out = p_filter->fmt_out; 
     
    209223    AVPicture *p_src, *p_dst; 
    210224    picture_t *p_pic_dst; 
    211     vlc_bool_t b_resize = p_sys->b_resize; 
    212225    int i; 
    213226 
     
    257270    p_src = &src_pic; 
    258271 
    259     if( b_resize && p_sys->p_rsc ) 
     272    if( p_sys->b_resize && p_sys->p_rsc ) 
    260273    { 
    261274        p_dst = &dest_pic; 
    262         if ( p_filter->fmt_in.video.i_width * p_filter->fmt_in.video.i_height > 
    263              p_filter->fmt_out.video.i_width * p_filter->fmt_out.video.i_height ) 
    264         { 
    265             if ( p_sys->b_convert ) p_dst = &p_sys->tmp_pic; 
     275        if( p_sys->b_resize_first ) 
     276        { 
     277            if( p_sys->b_convert ) p_dst = &p_sys->tmp_pic; 
    266278            img_resample( p_sys->p_rsc, p_dst, p_src ); 
    267             b_resize = VLC_FALSE; 
    268279            p_src = p_dst; 
    269280        } 
     
    274285        video_format_t *p_fmt = &p_filter->fmt_out.video; 
    275286        p_dst = &dest_pic; 
    276         if( b_resize
     287        if( p_sys->b_resize && !p_sys->b_resize_first
    277288        { 
    278289            p_dst = &p_sys->tmp_pic; 
     
    287298    } 
    288299 
    289     if( b_resize && p_sys->p_rsc ) 
     300    if( p_sys->b_resize && !p_sys->b_resize_first && p_sys->p_rsc ) 
    290301    { 
    291302        p_dst = &dest_pic;