[vlc-devel] [PATCH 10/11] Add support for font height as a percentage of the video height

Rafaël Carré funman at videolan.org
Mon Dec 31 00:41:03 CET 2012


Le 27/12/2012 07:08, Devin Heitmueller a écrit :
> In order to get consistent EIA-608 caption positioning, we need to be able
> to size the fonts based on the size of the video.  Add support for
> specifying the font height as a percentage of the video.
> ---
>  modules/codec/cc.c       |    1 +
>  modules/codec/substext.h |   13 +++++++++++++
>  2 files changed, 14 insertions(+)
> 
> diff --git a/modules/codec/cc.c b/modules/codec/cc.c
> index 7e5bbca..4329c1c 100644
> --- a/modules/codec/cc.c
> +++ b/modules/codec/cc.c
> @@ -336,6 +336,7 @@ static subpicture_t *Subtitle( decoder_t *p_dec, char *psz_subtitle, char *psz_h
>      p_spu_sys->align = SUBPICTURE_ALIGN_TOP | SUBPICTURE_ALIGN_LEFT;
>      p_spu_sys->text  = psz_subtitle;
>      p_spu_sys->html  = psz_html;
> +    p_spu_sys->i_font_height_percent = 5;

I don't understand how this is not a constant

>  
>      return p_spu;
>  }
> diff --git a/modules/codec/substext.h b/modules/codec/substext.h
> index df9779c..68e6c61 100644
> --- a/modules/codec/substext.h
> +++ b/modules/codec/substext.h
> @@ -5,6 +5,7 @@ struct subpicture_updater_sys_t {
>      int  align;
>      int  x;
>      int  y;
> +    int  i_font_height_percent;

So we don't need to add this member to memory?

>  
>      bool is_fixed;
>      int  fixed_width;
> @@ -80,6 +81,18 @@ static void SubpictureTextUpdate(subpicture_t *subpic,
>          r->i_x = sys->x * fmt_dst->i_width  / sys->fixed_width;
>          r->i_y = sys->y * fmt_dst->i_height / sys->fixed_height;
>      }
> +
> +    if (sys->i_font_height_percent != 0)
> +    {
> +        r->p_style = text_style_New();
> +        if (r->p_style)
> +        {
> +	    r->p_style->i_font_size = sys->i_font_height_percent *
> +	      subpic->i_original_picture_height / 100;
> +            r->p_style->i_font_color = 0xffffff;
> +            r->p_style->i_font_alpha = 0xff;
> +	}
> +    }
>  }
>  static void SubpictureTextDestroy(subpicture_t *subpic)
>  {
> 




More information about the vlc-devel mailing list