[vlc-devel] [PATCH 19/19] ttml codec: add Bidirectionnal support

Francois Cartegnie fcvlcdev at free.fr
Tue Aug 30 13:35:58 CEST 2016


Le 29/08/2016 à 23:01, Stanislas Plessia a écrit :
> ---
>  modules/codec/substtml.c | 79 ++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 79 insertions(+)
> 
> diff --git a/modules/codec/substtml.c b/modules/codec/substtml.c
> index 62fb5ac..9b8470b 100644
> --- a/modules/codec/substtml.c
> +++ b/modules/codec/substtml.c
> @@ -71,6 +71,8 @@ typedef struct
>      int             i_margin_v;
>      int             i_margin_percent_h;
>      int             i_margin_percent_v;
> +    int             i_direction;
> +    bool            b_direction_set;
>  }  ttml_style_t;
>
>  struct decoder_sys_t
> @@ -80,6 +82,14 @@ struct decoder_sys_t
>      size_t                  i_styles;
>  };
>  
> +enum
> +{
> +    UNICODE_BIDI_LTR = 0,
> +    UNICODE_BIDI_RTL = 1,
> +    UNICODE_BIDI_EMBEDDED = 2,
> +    UNICODE_BIDI_OVERRIDE = 4,
> +};
> +

boolean is useless.
Just needs a shift to use 0 as undefined.

>  
>  static ttml_style_t* DuplicateStyle( ttml_style_t* p_style_src )
> @@ -443,6 +459,41 @@ static ttml_style_t* ParseTTMLStyle( decoder_t *p_dec, xml_reader_t* p_reader, c
>              }
>              free( value );
>          }
> +        else if( !strcasecmp( "tts:direction", attr ) )
> +        {
> +            if( !strcasecmp( "rtl", val ) )
> +            {
> +                p_ttml_style->i_direction |= UNICODE_BIDI_RTL;
> +                p_ttml_style->b_direction_set = true;
> +            }
> +            else if( !strcasecmp( "ltr", val ) )
> +            {
> +                p_ttml_style->i_direction |= UNICODE_BIDI_LTR;
> +                p_ttml_style->b_direction_set = true;
> +            }

Need to clear prev value as below.

> +        }
> +        else if( !strcasecmp( "tts:unicodeBidi", attr ) )
> +        {
> +                if( !strcasecmp( "bidiOverride", val ) )
> +                    p_ttml_style->i_direction |= UNICODE_BIDI_OVERRIDE & ~UNICODE_BIDI_EMBEDDED;
> +                else if( !strcasecmp( "embed", val ) )
> +                    p_ttml_style->i_direction |= UNICODE_BIDI_EMBEDDED & ~UNICODE_BIDI_OVERRIDE;
> +        }


Francois


More information about the vlc-devel mailing list