Changeset 794eece829a9840339be996a8cd44a9153916877

Show
Ignore:
Timestamp:
21/10/07 01:37:56 (1 year ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1192923476 +0000
git-parent:

[e7d9e5601fe3603405749091d0eef49630ac7ee8]

git-author:
Laurent Aimar <fenrir@videolan.org> 1192923476 +0000
Message:

Fixed subtitle blend module loading.
The blend module will be loaded only if needed and reloaded on chroma change.
(As a side effect it should allow displaying TEXT even when no blending module
exist)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/video_output/vout_subpictures.c

    r8db5db8 r794eece  
    548548            p_spu->p_blend->fmt_out.video.i_aspect = p_fmt->i_aspect; 
    549549            p_spu->p_blend->fmt_out.video.i_chroma = p_fmt->i_chroma; 
    550             p_spu->p_blend->fmt_in.video.i_chroma = p_region->fmt.i_chroma; 
    551  
    552             p_spu->p_blend->p_module = 
    553                 module_Need( p_spu->p_blend, "video blending", 0, 0 )
     550 
     551            /* The blend module will be loaded when needed with the real input format */ 
     552            memset( &p_spu->p_blend->fmt_in, 0, sizeof(p_spu->p_blend->fmt_in) ); 
     553            p_spu->p_blend->p_module = NULL
    554554        } 
    555555 
     
    722722        } 
    723723 
    724         while( p_region && p_spu->p_blend && p_spu->p_blend->pf_video_blend
     724        while( p_region
    725725        { 
    726726            video_format_t orig_fmt = p_region->fmt; 
     
    935935            } 
    936936 
    937             p_spu->p_blend->fmt_in.video = p_region->fmt; 
    938  
    939             /* Force cropping if requested */ 
    940             if( p_spu->b_force_crop ) 
    941             { 
    942                 video_format_t *p_fmt = &p_spu->p_blend->fmt_in.video; 
    943                 int i_crop_x = p_spu->i_crop_x * pi_scale_width[ i_scale_idx ] / 1000 
    944                                     * i_inv_scale_x / 1000; 
    945                 int i_crop_y = p_spu->i_crop_y * pi_scale_height[ i_scale_idx ] / 1000 
    946                                     * i_inv_scale_y / 1000; 
    947                 int i_crop_width = p_spu->i_crop_width * pi_scale_width[ i_scale_idx ] / 1000 
    948                                     * i_inv_scale_x / 1000; 
    949                 int i_crop_height = p_spu->i_crop_height * pi_scale_height[ i_scale_idx ] / 1000 
    950                                     * i_inv_scale_y / 1000; 
    951  
    952                 /* Find the intersection */ 
    953                 if( i_crop_x + i_crop_width <= i_x_offset || 
    954                     i_x_offset + (int)p_fmt->i_visible_width < i_crop_x || 
    955                     i_crop_y + i_crop_height <= i_y_offset || 
    956                     i_y_offset + (int)p_fmt->i_visible_height < i_crop_y ) 
    957                 { 
    958                     /* No intersection */ 
    959                     p_fmt->i_visible_width = p_fmt->i_visible_height = 0; 
    960                 } 
    961                 else 
    962                 { 
    963                     int i_x, i_y, i_x_end, i_y_end; 
    964                     i_x = __MAX( i_crop_x, i_x_offset ); 
    965                     i_y = __MAX( i_crop_y, i_y_offset ); 
    966                     i_x_end = __MIN( i_crop_x + i_crop_width, 
    967                                    i_x_offset + (int)p_fmt->i_visible_width ); 
    968                     i_y_end = __MIN( i_crop_y + i_crop_height, 
    969                                    i_y_offset + (int)p_fmt->i_visible_height ); 
    970  
    971                     p_fmt->i_x_offset = i_x - i_x_offset; 
    972                     p_fmt->i_y_offset = i_y - i_y_offset; 
    973                     p_fmt->i_visible_width = i_x_end - i_x; 
    974                     p_fmt->i_visible_height = i_y_end - i_y; 
    975  
    976                     i_x_offset = i_x; 
    977                     i_y_offset = i_y; 
    978                 } 
    979             } 
    980  
    981937            if( p_subpic->b_fade ) 
    982938            { 
     
    991947            } 
    992948 
    993             i_x_offset = __MAX( i_x_offset, 0 ); 
    994             i_y_offset = __MAX( i_y_offset, 0 ); 
    995  
    996949            if( p_region->fmt.i_chroma != VLC_FOURCC('T','E','X','T') ) 
    997950            { 
     951                if( p_spu->p_blend->fmt_in.video.i_chroma != p_region->fmt.i_chroma ) 
     952                { 
     953                    /* The chroma is not the same, we need to reload the blend module 
     954                     * XXX to match the old behaviour just test !p_spu->p_blend->fmt_in.video.i_chroma */ 
     955                    if( p_spu->p_blend->p_module ) 
     956                        module_Unneed( p_spu->p_blend, p_spu->p_blend->p_module ); 
     957 
     958                    p_spu->p_blend->fmt_in.video = p_region->fmt; 
     959                    p_spu->p_blend->p_module = module_Need( p_spu->p_blend, "video blending", 0, 0 ); 
     960                } 
     961                else 
     962                { 
     963                    p_spu->p_blend->fmt_in.video = p_region->fmt; 
     964                } 
     965 
     966                /* Force cropping if requested */ 
     967                if( p_spu->b_force_crop ) 
     968                { 
     969                    video_format_t *p_fmt = &p_spu->p_blend->fmt_in.video; 
     970                    int i_crop_x = p_spu->i_crop_x * pi_scale_width[ i_scale_idx ] / 1000 
     971                                        * i_inv_scale_x / 1000; 
     972                    int i_crop_y = p_spu->i_crop_y * pi_scale_height[ i_scale_idx ] / 1000 
     973                                        * i_inv_scale_y / 1000; 
     974                    int i_crop_width = p_spu->i_crop_width * pi_scale_width[ i_scale_idx ] / 1000 
     975                                        * i_inv_scale_x / 1000; 
     976                    int i_crop_height = p_spu->i_crop_height * pi_scale_height[ i_scale_idx ] / 1000 
     977                                        * i_inv_scale_y / 1000; 
     978 
     979                    /* Find the intersection */ 
     980                    if( i_crop_x + i_crop_width <= i_x_offset || 
     981                        i_x_offset + (int)p_fmt->i_visible_width < i_crop_x || 
     982                        i_crop_y + i_crop_height <= i_y_offset || 
     983                        i_y_offset + (int)p_fmt->i_visible_height < i_crop_y ) 
     984                    { 
     985                        /* No intersection */ 
     986                        p_fmt->i_visible_width = p_fmt->i_visible_height = 0; 
     987                    } 
     988                    else 
     989                    { 
     990                        int i_x, i_y, i_x_end, i_y_end; 
     991                        i_x = __MAX( i_crop_x, i_x_offset ); 
     992                        i_y = __MAX( i_crop_y, i_y_offset ); 
     993                        i_x_end = __MIN( i_crop_x + i_crop_width, 
     994                                       i_x_offset + (int)p_fmt->i_visible_width ); 
     995                        i_y_end = __MIN( i_crop_y + i_crop_height, 
     996                                       i_y_offset + (int)p_fmt->i_visible_height ); 
     997 
     998                        p_fmt->i_x_offset = i_x - i_x_offset; 
     999                        p_fmt->i_y_offset = i_y - i_y_offset; 
     1000                        p_fmt->i_visible_width = i_x_end - i_x; 
     1001                        p_fmt->i_visible_height = i_y_end - i_y; 
     1002 
     1003                        i_x_offset = i_x; 
     1004                        i_y_offset = i_y; 
     1005                    } 
     1006                } 
     1007 
     1008 
     1009                i_x_offset = __MAX( i_x_offset, 0 ); 
     1010                i_y_offset = __MAX( i_y_offset, 0 ); 
     1011 
    9981012                /* Update the output picture size */ 
    9991013                p_spu->p_blend->fmt_out.video.i_width = 
     
    10041018                        p_fmt->i_height; 
    10051019 
    1006                 p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst, 
    1007                     p_pic_src, &p_region->picture, i_x_offset, i_y_offset, 
    1008                     i_fade_alpha * p_subpic->i_alpha / 255 ); 
     1020                if( p_spu->p_blend->p_module ) 
     1021                { 
     1022                    p_spu->p_blend->pf_video_blend( p_spu->p_blend, p_pic_dst, 
     1023                        p_pic_src, &p_region->picture, i_x_offset, i_y_offset, 
     1024                        i_fade_alpha * p_subpic->i_alpha / 255 ); 
     1025                } 
     1026                else 
     1027                { 
     1028                    msg_Err( p_spu, "blending %4.4s to %4.4s failed", 
     1029                             (char *)&p_spu->p_blend->fmt_out.video.i_chroma, 
     1030                             (char *)&p_spu->p_blend->fmt_out.video.i_chroma ); 
     1031                } 
    10091032            } 
    10101033