[FFmpeg-devel] [PATCH] movtextdec.c: Add support for highlight and hilightcolor box

Niklesh Lalwani niklesh.lalwani at iitb.ac.in
Tue Jul 7 17:03:12 CEST 2015


On Tue, Jul 7, 2015 at 3:12 AM, Clément Bœsch <u at pkh.me> wrote:

> On Mon, Jul 06, 2015 at 10:27:47PM +0530, Niklesh Lalwani wrote:
> > From: Niklesh <niklesh.lalwani at iitb.ac.in>
> >
> > Signed-off-by: Niklesh <niklesh.lalwani at iitb.ac.in>
> > ---
> >  libavcodec/movtextdec.c | 254
> +++++++++++++++++++++++++++++++++---------------
> >  1 file changed, 173 insertions(+), 81 deletions(-)
> >
> > diff --git a/libavcodec/movtextdec.c b/libavcodec/movtextdec.c
> > index a3afd91..7e9e4f5 100644
> > --- a/libavcodec/movtextdec.c
> > +++ b/libavcodec/movtextdec.c
> > @@ -31,37 +31,166 @@
> >  #define STYLE_FLAG_ITALIC       (1<<1)
> >  #define STYLE_FLAG_UNDERLINE    (1<<2)
> >
> > +#define STYL_BOX   (1<<0)
> > +#define HLIT_BOX   (1<<1)
> > +#define HCLR_BOX   (1<<2)
> > +
> >  typedef struct {
> >      uint16_t style_start;
> >      uint16_t style_end;
> >      uint8_t style_flag;
> >  } StyleBox;
> >
> > +typedef struct {
> > +    uint16_t hlit_start;
> > +    uint16_t hlit_end;
> > +} HighlightBox;
> > +
> > +typedef struct {
> > +   uint8_t hlit_color[4];
> > +} HilightcolorBox;
> > +
> > +typedef struct {
> > +    StyleBox **s;
> > +    StyleBox *s_temp;
> > +    HighlightBox h;
> > +    HilightcolorBox c;
> > +    uint8_t box_flags;
> > +    uint16_t style_entries;
> > +    uint64_t tracksize;
> > +    int size_var;
> > +    int count_s;
> > +} MovTextContext;
> > +
>
> > +struct Box
> > +{
>
> style
>

What about this?


> > +    uint32_t type;
> > +    size_t base_size;
> > +    int (*decode)(const uint8_t *tsmb, MovTextContext *m, AVPacket
> *avpkt);
> > +};
> > +
>



> >  {
> >      int i = 0;
> >      int text_pos = 0;
> >      while (text < text_end) {
> > -        for (i = 0; i < style_entries; i++) {
> > -            if (s[i]->style_flag && text_pos == s[i]->style_end) {
> > -                if (s[i]->style_flag & STYLE_FLAG_BOLD)
> > -                    av_bprintf(buf, "{\\b0}");
> > -                if (s[i]->style_flag & STYLE_FLAG_ITALIC)
> > -                    av_bprintf(buf, "{\\i0}");
> > -                if (s[i]->style_flag & STYLE_FLAG_UNDERLINE)
> > -                    av_bprintf(buf, "{\\u0}");
> > +        if (m->box_flags & STYL_BOX) {
>
> > +            for (i = 0; i < m->style_entries; i++) {
> > +                if (m->s[i]->style_flag && text_pos ==
> m->s[i]->style_end) {
> > +                    if (m->s[i]->style_flag & STYLE_FLAG_BOLD)
> > +                        av_bprintf(buf, "{\\b0}");
> > +                    if (m->s[i]->style_flag & STYLE_FLAG_ITALIC)
> > +                        av_bprintf(buf, "{\\i0}");
> > +                    if (m->s[i]->style_flag & STYLE_FLAG_UNDERLINE)
> > +                        av_bprintf(buf, "{\\u0}");
> > +                }
> > +            }
>
> keep this block not re-idented (and eventually add a /* TODO: reindent */
> above) to keep the diff small and ease review. You can re-indent in a
> later commit.
>
> ditto below if applicable.
>

Okay will do it.


>
> > +            for (i = 0; i < m->style_entries; i++) {
> > +                if (m->s[i]->style_flag && text_pos ==
> m->s[i]->style_start) {
> > +                    if (m->s[i]->style_flag & STYLE_FLAG_BOLD)
> > +                        av_bprintf(buf, "{\\b1}");
> > +                    if (m->s[i]->style_flag & STYLE_FLAG_ITALIC)
> > +                        av_bprintf(buf, "{\\i1}");
> > +                    if (m->s[i]->style_flag & STYLE_FLAG_UNDERLINE)
> > +                        av_bprintf(buf, "{\\u1}");
>

Rest all changes applied.

Thanks,

Niklesh


More information about the ffmpeg-devel mailing list