[vlc-devel] commit: Add new canvas option to crop instead of padd to fit in canvas. ( Antoine Cellerier )

Laurent Aimar fenrir at via.ecp.fr
Thu Sep 11 09:20:47 CEST 2008


On Thu, Sep 11, 2008, git version control wrote:
> +        /* Padd */
> +        if( fmt.video.i_height > i_height )
> +        {
> +            fmt.video.i_height = i_height;
> +            fmt.video.i_width = ( p_filter->fmt_in.video.i_width * i_height )
> +                                / p_filter->fmt_in.video.i_height;
> +            fmt.video.i_width = ( fmt.video.i_width * p_filter->fmt_in.video.i_aspect )
> +                                / i_aspect;
> +            if( fmt.video.i_width & 1 ) fmt.video.i_width -= 1;
> +
> +            i_padd = (i_width - fmt.video.i_width) / 2;
> +            i_offset = (i_padd & 1);
> +            /* Gruik */
> +            snprintf( psz_croppadd, 100, "croppadd{paddleft=%d,paddright=%d}",
> +                      i_padd - i_offset, i_padd + i_offset );
> +        }
> +        else
> +        {
> +            if( fmt.video.i_height & 1 ) fmt.video.i_height -= 1;
> +            i_padd = (i_height - fmt.video.i_height ) / 2;
> +            i_offset = (i_padd & 1);
> +            /* Gruik */
> +            snprintf( psz_croppadd, 100, "croppadd{paddtop=%d,paddbottom=%d}",
> +                      i_padd - i_offset, i_padd + i_offset );
> +        }
and
> +        /* Crop */
> +        if( fmt.video.i_height < i_height )
> +        {
> +            fmt.video.i_height = i_height;
> +            fmt.video.i_width = ( p_filter->fmt_in.video.i_width * i_height )
> +                                / p_filter->fmt_in.video.i_height;
> +            fmt.video.i_width = ( fmt.video.i_width * p_filter->fmt_in.video.i_aspect )
> +                                / i_aspect;
> +            if( fmt.video.i_width & 1 ) fmt.video.i_width -= 1;
> +
> +            i_padd = (fmt.video.i_width - i_width) / 2;
> +            i_offset =  (i_padd & 1);
> +            /* Gruik */
> +            snprintf( psz_croppadd, 100, "croppadd{cropleft=%d,cropright=%d}",
> +                      i_padd - i_offset, i_padd + i_offset );
> +        }
> +        else
> +        {
> +            if( fmt.video.i_height & 1 ) fmt.video.i_height -= 1;
> +            i_padd = (fmt.video.i_height - i_height) / 2;
> +            i_offset = (i_padd & 1);
> +            /* Gruik */
> +            snprintf( psz_croppadd, 100, "croppadd{croptop=%d,cropbottom=%d}",
> +                      i_padd - i_offset, i_padd + i_offset );
> +        }
>      }
seems to contain a lot of duplicated code (and so a lot of potential
 duplicated bugs)...

-- 
fenrir




More information about the vlc-devel mailing list