[FFmpeg-devel] [PATCH] movtextdec: Use default style information from movtext header

Michael Niedermayer michael at niedermayer.cc
Mon Aug 10 02:15:51 CEST 2015


On Mon, Aug 10, 2015 at 01:18:58AM +0530, Niklesh Lalwani wrote:
> >
> > > +
> > > +typedef struct {
> > > +    char *font;
> > > +    int fontsize;
> > > +    int color;
> > > +    int back_color;
> > > +    int bold;
> > > +    int italic;
> > > +    int underline;
> > > +    int alignment;
> > > +} Movtext_default;
> > > +
> >
> > This name is inconsistent. Use MovTextDefault.
> >
> 
> Yes, makes sense. Updated patch attached.
> 
> Thanks,
> Niklesh

>  movtextdec.c |   82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 4 deletions(-)
> 20d03c931668fcce77acae70d9234c5bd6761a05  0001-movtextdec-Use-default-style-information-from-movtex.patch
> From d74d032eb8047c301eb03aa4b022d3146c83f4f2 Mon Sep 17 00:00:00 2001
> From: Niklesh <niklesh.lalwani at iitb.ac.in>
> Date: Mon, 10 Aug 2015 01:13:43 +0530
> Subject: [PATCH] movtextdec: Use default style information from movtext header
> 
> Signed-off-by: Niklesh <niklesh.lalwani at iitb.ac.in>
> ---
>  libavcodec/movtextdec.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 78 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> index fc6993e..e92b04b 100644
> --- a/libavcodec/movtextdec.c
> +++ b/libavcodec/movtextdec.c
> @@ -37,6 +37,27 @@
>  #define HLIT_BOX   (1<<1)
>  #define HCLR_BOX   (1<<2)
>  
> +#define BOTTOM_LEFT     1
> +#define BOTTOM_CENTER   2
> +#define BOTTOM_RIGHT    3
> +#define MIDDLE_LEFT     4
> +#define MIDDLE_CENTER   5
> +#define MIDDLE_RIGHT    6
> +#define TOP_LEFT        7
> +#define TOP_CENTER      8
> +#define TOP_RIGHT       9
> +
> +typedef struct {
> +    char *font;
> +    int fontsize;
> +    int color;
> +    int back_color;
> +    int bold;
> +    int italic;
> +    int underline;
> +    int alignment;
> +} MovTextDefault;
> +
>  typedef struct {
>      uint16_t fontID;
>      char *font;
> @@ -66,6 +87,7 @@ typedef struct {
>      HilightcolorBox c;
>      FontRecord **ftab;
>      FontRecord *ftab_temp;
> +    MovTextDefault d;
>      uint8_t box_flags;
>      uint16_t style_entries, ftab_entries;
>      uint64_t tracksize;
> @@ -106,6 +128,9 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
>  {
>      char *tx3g_ptr = avctx->extradata;
>      int i, box_size, font_length;
> +    int8_t v_align, h_align;
> +    int style_fontID;
> +    StyleBox s_default;
>  
>      m->count_f = 0;
>      m->ftab_entries = 0;
> @@ -116,13 +141,52 @@ static int mov_text_tx3g(AVCodecContext *avctx, MovTextContext *m)
>      // Display Flags
>      tx3g_ptr += 4;
>      // Alignment
> -    tx3g_ptr += 2;
> +    h_align = *tx3g_ptr++;
> +    v_align = *tx3g_ptr++;
> +    if (h_align == 0) {
> +        if (v_align == 0)
> +            m->d.alignment = TOP_LEFT;
> +        if (v_align == 1)
> +            m->d.alignment = MIDDLE_LEFT;
> +        if (v_align == -1)
> +            m->d.alignment = BOTTOM_LEFT;
> +    }
> +    if (h_align == 1) {
> +        if (v_align == 0)
> +            m->d.alignment = TOP_CENTER;
> +        if (v_align == 1)
> +            m->d.alignment = MIDDLE_CENTER;
> +        if (v_align == -1)
> +            m->d.alignment = BOTTOM_CENTER;
> +    }
> +    if (h_align == -1) {
> +        if (v_align == 0)
> +            m->d.alignment = TOP_RIGHT;
> +        if (v_align == 1)
> +            m->d.alignment = MIDDLE_RIGHT;
> +        if (v_align == -1)
> +            m->d.alignment = BOTTOM_RIGHT;
> +    }
>      // Background Color

> +    memcpy(&m->d.back_color, tx3g_ptr, 3);

what is this ?
back_color is a int, copying 3 bytes into a int makes no sense


>      tx3g_ptr += 4;
>      // BoxRecord
>      tx3g_ptr += 8;
>      // StyleRecord
> -    tx3g_ptr += 12;
> +    tx3g_ptr += 4;
> +    // fontID
> +    style_fontID = AV_RB16(tx3g_ptr);
> +    tx3g_ptr += 2;
> +    // face-style-flags
> +    s_default.style_flag = *tx3g_ptr++;
> +    m->d.bold = s_default.style_flag & STYLE_FLAG_BOLD;
> +    m->d.italic = s_default.style_flag & STYLE_FLAG_ITALIC;
> +    m->d.underline = s_default.style_flag & STYLE_FLAG_UNDERLINE;
> +    // fontsize
> +    m->d.fontsize = *tx3g_ptr++;

> +    // Primary color
> +    memcpy(&m->d.color, tx3g_ptr, 3);

same issue

also patch breaks fate sub-movtext and sub-subripenc
ill revert in a moment unless someone is quicker or fixed it by then

[...]


-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150810/cd898439/attachment.sig>


More information about the ffmpeg-devel mailing list