static int draw_text(AVFilterContext *ctx, AVFrame *frame,

                     int width, int height)

{

    DrawTextContext *s = ctx->priv;

    AVFilterLink *inlink = ctx->inputs[0];



    uint32_t code = 0, prev_code = 0;

    int x = 0, y = 0, i = 0, ret;

    int max_text_line_w = 0, len;

    int box_w, box_h;

    char *text;

    uint8_t *p;

    int y_min = 32000, y_max = -32000;

    int x_min = 32000, x_max = -32000;

    FT_Vector delta;

    Glyph *glyph = NULL, *prev_glyph = NULL;

    Glyph dummy = { 0 };



    time_t now = time(0);

    struct tm ltime;

    AVBPrint *bp = &s->expanded_text;



    FFDrawColor fontcolor;

    FFDrawColor shadowcolor;

    FFDrawColor bordercolor;

    FFDrawColor boxcolor;



    av_bprint_clear(bp);



    if(s->basetime != AV_NOPTS_VALUE)

        now= frame->pts*av_q2d(ctx->inputs[0]->time_base) + s->basetime/1000000;



    switch (s->exp_mode) {

    case EXP_NONE:

        av_bprintf(bp, "%s", s->text);

        break;

    case EXP_NORMAL:

        if ((ret = expand_text(ctx, s->text, &s->expanded_text)) < 0)

            return ret;

        break;

    case EXP_STRFTIME:

        localtime_r(&now, &ltime);

        av_bprint_strftime(bp, s->text, &ltime);

        break;

    }



    if (s->tc_opt_string) {

        char tcbuf[AV_TIMECODE_STR_SIZE];

        av_timecode_make_string(&s->tc, tcbuf, inlink->frame_count);

        av_bprint_clear(bp);

        av_bprintf(bp, "%s%s", s->text, tcbuf);

    }



    if (!av_bprint_is_complete(bp))

        return AVERROR(ENOMEM);

    text = s->expanded_text.str;

    if ((len = s->expanded_text.len) > s->nb_positions) {

        if (!(s->positions =

              av_realloc(s->positions, len*sizeof(*s->positions))))

            return AVERROR(ENOMEM);

        s->nb_positions = len;

    }



    if (s->fontcolor_expr[0]) {

        /* If expression is set, evaluate and replace the static value */

        av_bprint_clear(&s->expanded_fontcolor);

        if ((ret = expand_text(ctx, s->fontcolor_expr, &s->expanded_fontcolor)) < 0)

            return ret;

        if (!av_bprint_is_complete(&s->expanded_fontcolor))

            return AVERROR(ENOMEM);

        av_log(s, AV_LOG_DEBUG, "Evaluated fontcolor is '%s'\n", s->expanded_fontcolor.str);

        ret = av_parse_color(s->fontcolor.rgba, s->expanded_fontcolor.str, -1, s);

        if (ret)

            return ret;

        ff_draw_color(&s->dc, &s->fontcolor, s->fontcolor.rgba);

    }



    x = 0;

    y = 0;



    /* load and cache glyphs */

    for (i = 0, p = text; *p; i++) {

        GET_UTF8(code, *p++, continue;);



        /* get glyph */

        dummy.code = code;

        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);

        if (!glyph) {

            load_glyph(ctx, &glyph, code);

        }



        y_min = FFMIN(glyph->bbox.yMin, y_min);

        y_max = FFMAX(glyph->bbox.yMax, y_max);

        x_min = FFMIN(glyph->bbox.xMin, x_min);

        x_max = FFMAX(glyph->bbox.xMax, x_max);

    }

    s->max_glyph_h = y_max - y_min;

    s->max_glyph_w = x_max - x_min;



    /* compute and save position for each glyph */

    glyph = NULL;

    for (i = 0, p = text; *p; i++) {

        GET_UTF8(code, *p++, continue;);



        /* skip the \n in the sequence \r\n */

        if (prev_code == '\r' && code == '\n')

            continue;



        prev_code = code;

        if (is_newline(code)) {



            max_text_line_w = FFMAX(max_text_line_w, x);

            y += s->max_glyph_h;

            x = 0;

            continue;

        }



        /* get glyph */

        prev_glyph = glyph;

        dummy.code = code;

        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);



        /* kerning */

        if (s->use_kerning && prev_glyph && glyph->code) {

            FT_Get_Kerning(s->face, prev_glyph->code, glyph->code,

                           ft_kerning_default, &delta);

            x += delta.x >> 6;

        }



        /* save position */

        s->positions[i].x = x + glyph->bitmap_left;

        s->positions[i].y = y - glyph->bitmap_top + y_max;

        if (code == '\t') x  = (x / s->tabsize + 1)*s->tabsize;

        else              x += glyph->advance;

    }



    max_text_line_w = FFMAX(x, max_text_line_w);



    s->var_values[VAR_TW] = s->var_values[VAR_TEXT_W] = max_text_line_w;

    s->var_values[VAR_TH] = s->var_values[VAR_TEXT_H] = y + s->max_glyph_h;



    s->var_values[VAR_MAX_GLYPH_W] = s->max_glyph_w;

    s->var_values[VAR_MAX_GLYPH_H] = s->max_glyph_h;

    s->var_values[VAR_MAX_GLYPH_A] = s->var_values[VAR_ASCENT ] = y_max;

    s->var_values[VAR_MAX_GLYPH_D] = s->var_values[VAR_DESCENT] = y_min;



    s->var_values[VAR_LINE_H] = s->var_values[VAR_LH] = s->max_glyph_h;



    s->x = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);

    s->y = s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, &s->prng);

    s->x = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);



    update_alpha(s);

    update_color_with_alpha(s, &fontcolor  , s->fontcolor  );

    update_color_with_alpha(s, &shadowcolor, s->shadowcolor);

    update_color_with_alpha(s, &bordercolor, s->bordercolor);

    update_color_with_alpha(s, &boxcolor   , s->boxcolor   );



    box_w = FFMIN(width - 1 , max_text_line_w);

    box_h = FFMIN(height - 1, y + s->max_glyph_h);



    /* draw box */

    if (s->draw_box)

        ff_blend_rectangle(&s->dc, &boxcolor,

                           frame->data, frame->linesize, width, height,

                           s->x - s->boxborderw, s->y - s->boxborderw,

                           box_w + s->boxborderw * 2, box_h + s->boxborderw * 2);



    if (s->shadowx || s->shadowy) {

        if ((ret = draw_glyphs(s, frame, width, height,

                               &shadowcolor, s->shadowx, s->shadowy, 0)) < 0)

            return ret;

    }



    if (s->borderw) {

        if ((ret = draw_glyphs(s, frame, width, height,

                               &bordercolor, 0, 0, s->borderw)) < 0)

            return ret;

    }

    if ((ret = draw_glyphs(s, frame, width, height,

                           &fontcolor, 0, 0, 0)) < 0)

        return ret;



    return 0;

}

static int draw_text(AVFilterContext *ctx, AVFrame *frame,

                     int width, int height)

{

    DrawTextContext *s = ctx->priv;

    AVFilterLink *inlink = ctx->inputs[0];



    uint32_t code = 0, prev_code = 0;

    int x = 0, y = 0, i = 0, ret;

    int max_text_line_w = 0, len;

    int box_w, box_h;

    char *text;

    uint8_t *p;

    int y_min = 32000, y_max = -32000;

    int x_min = 32000, x_max = -32000;

    FT_Vector delta;

    Glyph *glyph = NULL, *prev_glyph = NULL;

    Glyph dummy = { 0 };



    time_t now = time(0);

    struct tm ltime;

    AVBPrint *bp = &s->expanded_text;



    FFDrawColor fontcolor;

    FFDrawColor shadowcolor;

    FFDrawColor bordercolor;

    FFDrawColor boxcolor;



    av_bprint_clear(bp);



    if(s->basetime != AV_NOPTS_VALUE)

        now= frame->pts*av_q2d(ctx->inputs[0]->time_base) + s->basetime/1000000;



    switch (s->exp_mode) {

    case EXP_NONE:

        av_bprintf(bp, "%s", s->text);

        break;

    case EXP_NORMAL:

        if ((ret = expand_text(ctx, s->text, &s->expanded_text)) < 0)

            return ret;

        break;

    case EXP_STRFTIME:

        localtime_r(&now, &ltime);

        av_bprint_strftime(bp, s->text, &ltime);

        break;

    }



    if (s->tc_opt_string) {

        char tcbuf[AV_TIMECODE_STR_SIZE];

        av_timecode_make_string(&s->tc, tcbuf, inlink->frame_count);

        av_bprint_clear(bp);

        av_bprintf(bp, "%s%s", s->text, tcbuf);

    }



    if (!av_bprint_is_complete(bp))

        return AVERROR(ENOMEM);

    text = s->expanded_text.str;

    if ((len = s->expanded_text.len) > s->nb_positions) {

        if (!(s->positions =

              av_realloc(s->positions, len*sizeof(*s->positions))))

            return AVERROR(ENOMEM);

        s->nb_positions = len;

    }



    if (s->fontcolor_expr[0]) {

        

        av_bprint_clear(&s->expanded_fontcolor);

        if ((ret = expand_text(ctx, s->fontcolor_expr, &s->expanded_fontcolor)) < 0)

            return ret;

        if (!av_bprint_is_complete(&s->expanded_fontcolor))

            return AVERROR(ENOMEM);

        av_log(s, AV_LOG_DEBUG, "Evaluated fontcolor is '%s'\n", s->expanded_fontcolor.str);

        ret = av_parse_color(s->fontcolor.rgba, s->expanded_fontcolor.str, -1, s);

        if (ret)

            return ret;

        ff_draw_color(&s->dc, &s->fontcolor, s->fontcolor.rgba);

    }



    x = 0;

    y = 0;



    

    for (i = 0, p = text; *p; i++) {

        GET_UTF8(code, *p++, continue;);



        

        dummy.code = code;

        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);

        if (!glyph) {

            load_glyph(ctx, &glyph, code);

        }



        y_min = FFMIN(glyph->bbox.yMin, y_min);

        y_max = FFMAX(glyph->bbox.yMax, y_max);

        x_min = FFMIN(glyph->bbox.xMin, x_min);

        x_max = FFMAX(glyph->bbox.xMax, x_max);

    }

    s->max_glyph_h = y_max - y_min;

    s->max_glyph_w = x_max - x_min;



    

    glyph = NULL;

    for (i = 0, p = text; *p; i++) {

        GET_UTF8(code, *p++, continue;);



        

        if (prev_code == '\r' && code == '\n')

            continue;



        prev_code = code;

        if (is_newline(code)) {



            max_text_line_w = FFMAX(max_text_line_w, x);

            y += s->max_glyph_h;

            x = 0;

            continue;

        }



        

        prev_glyph = glyph;

        dummy.code = code;

        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);



        

        if (s->use_kerning && prev_glyph && glyph->code) {

            FT_Get_Kerning(s->face, prev_glyph->code, glyph->code,

                           ft_kerning_default, &delta);

            x += delta.x >> 6;

        }



        

        s->positions[i].x = x + glyph->bitmap_left;

        s->positions[i].y = y - glyph->bitmap_top + y_max;

        if (code == '\t') x  = (x / s->tabsize + 1)*s->tabsize;

        else              x += glyph->advance;

    }



    max_text_line_w = FFMAX(x, max_text_line_w);



    s->var_values[VAR_TW] = s->var_values[VAR_TEXT_W] = max_text_line_w;

    s->var_values[VAR_TH] = s->var_values[VAR_TEXT_H] = y + s->max_glyph_h;



    s->var_values[VAR_MAX_GLYPH_W] = s->max_glyph_w;

    s->var_values[VAR_MAX_GLYPH_H] = s->max_glyph_h;

    s->var_values[VAR_MAX_GLYPH_A] = s->var_values[VAR_ASCENT ] = y_max;

    s->var_values[VAR_MAX_GLYPH_D] = s->var_values[VAR_DESCENT] = y_min;



    s->var_values[VAR_LINE_H] = s->var_values[VAR_LH] = s->max_glyph_h;



    s->x = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);

    s->y = s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, &s->prng);

    s->x = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);



    update_alpha(s);

    update_color_with_alpha(s, &fontcolor  , s->fontcolor  );

    update_color_with_alpha(s, &shadowcolor, s->shadowcolor);

    update_color_with_alpha(s, &bordercolor, s->bordercolor);

    update_color_with_alpha(s, &boxcolor   , s->boxcolor   );



    box_w = FFMIN(width - 1 , max_text_line_w);

    box_h = FFMIN(height - 1, y + s->max_glyph_h);



    

    if (s->draw_box)

        ff_blend_rectangle(&s->dc, &boxcolor,

                           frame->data, frame->linesize, width, height,

                           s->x - s->boxborderw, s->y - s->boxborderw,

                           box_w + s->boxborderw * 2, box_h + s->boxborderw * 2);



    if (s->shadowx || s->shadowy) {

        if ((ret = draw_glyphs(s, frame, width, height,

                               &shadowcolor, s->shadowx, s->shadowy, 0)) < 0)

            return ret;

    }



    if (s->borderw) {

        if ((ret = draw_glyphs(s, frame, width, height,

                               &bordercolor, 0, 0, s->borderw)) < 0)

            return ret;

    }

    if ((ret = draw_glyphs(s, frame, width, height,

                           &fontcolor, 0, 0, 0)) < 0)

        return ret;



    return 0;

}

static int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1,

                     int VAR_2, int VAR_3)

{

    DrawTextContext *s = VAR_0->priv;

    AVFilterLink *inlink = VAR_0->inputs[0];



    uint32_t code = 0, prev_code = 0;

    int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7;

    int VAR_8 = 0, VAR_9;

    int VAR_10, VAR_11;

    char *VAR_12;

    uint8_t *p;

    int VAR_13 = 32000, VAR_14 = -32000;

    int VAR_15 = 32000, VAR_16 = -32000;

    FT_Vector delta;

    Glyph *glyph = NULL, *prev_glyph = NULL;

    Glyph dummy = { 0 };



    time_t now = time(0);

    struct tm VAR_17;

    AVBPrint *bp = &s->expanded_text;



    FFDrawColor fontcolor;

    FFDrawColor shadowcolor;

    FFDrawColor bordercolor;

    FFDrawColor boxcolor;



    av_bprint_clear(bp);



    if(s->basetime != AV_NOPTS_VALUE)

        now= VAR_1->pts*av_q2d(VAR_0->inputs[0]->time_base) + s->basetime/1000000;



    switch (s->exp_mode) {

    case EXP_NONE:

        av_bprintf(bp, "%s", s->VAR_12);

        break;

    case EXP_NORMAL:

        if ((VAR_7 = expand_text(VAR_0, s->VAR_12, &s->expanded_text)) < 0)

            return VAR_7;

        break;

    case EXP_STRFTIME:

        localtime_r(&now, &VAR_17);

        av_bprint_strftime(bp, s->VAR_12, &VAR_17);

        break;

    }



    if (s->tc_opt_string) {

        char VAR_18[AV_TIMECODE_STR_SIZE];

        av_timecode_make_string(&s->tc, VAR_18, inlink->frame_count);

        av_bprint_clear(bp);

        av_bprintf(bp, "%s%s", s->VAR_12, VAR_18);

    }



    if (!av_bprint_is_complete(bp))

        return AVERROR(ENOMEM);

    VAR_12 = s->expanded_text.str;

    if ((VAR_9 = s->expanded_text.VAR_9) > s->nb_positions) {

        if (!(s->positions =

              av_realloc(s->positions, VAR_9*sizeof(*s->positions))))

            return AVERROR(ENOMEM);

        s->nb_positions = VAR_9;

    }



    if (s->fontcolor_expr[0]) {

        

        av_bprint_clear(&s->expanded_fontcolor);

        if ((VAR_7 = expand_text(VAR_0, s->fontcolor_expr, &s->expanded_fontcolor)) < 0)

            return VAR_7;

        if (!av_bprint_is_complete(&s->expanded_fontcolor))

            return AVERROR(ENOMEM);

        av_log(s, AV_LOG_DEBUG, "Evaluated fontcolor is '%s'\n", s->expanded_fontcolor.str);

        VAR_7 = av_parse_color(s->fontcolor.rgba, s->expanded_fontcolor.str, -1, s);

        if (VAR_7)

            return VAR_7;

        ff_draw_color(&s->dc, &s->fontcolor, s->fontcolor.rgba);

    }



    VAR_4 = 0;

    VAR_5 = 0;



    

    for (VAR_6 = 0, p = VAR_12; *p; VAR_6++) {

        GET_UTF8(code, *p++, continue;);



        

        dummy.code = code;

        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);

        if (!glyph) {

            load_glyph(VAR_0, &glyph, code);

        }



        VAR_13 = FFMIN(glyph->bbox.yMin, VAR_13);

        VAR_14 = FFMAX(glyph->bbox.yMax, VAR_14);

        VAR_15 = FFMIN(glyph->bbox.xMin, VAR_15);

        VAR_16 = FFMAX(glyph->bbox.xMax, VAR_16);

    }

    s->max_glyph_h = VAR_14 - VAR_13;

    s->max_glyph_w = VAR_16 - VAR_15;



    

    glyph = NULL;

    for (VAR_6 = 0, p = VAR_12; *p; VAR_6++) {

        GET_UTF8(code, *p++, continue;);



        

        if (prev_code == '\r' && code == '\n')

            continue;



        prev_code = code;

        if (is_newline(code)) {



            VAR_8 = FFMAX(VAR_8, VAR_4);

            VAR_5 += s->max_glyph_h;

            VAR_4 = 0;

            continue;

        }



        

        prev_glyph = glyph;

        dummy.code = code;

        glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL);



        

        if (s->use_kerning && prev_glyph && glyph->code) {

            FT_Get_Kerning(s->face, prev_glyph->code, glyph->code,

                           ft_kerning_default, &delta);

            VAR_4 += delta.VAR_4 >> 6;

        }



        

        s->positions[VAR_6].VAR_4 = VAR_4 + glyph->bitmap_left;

        s->positions[VAR_6].VAR_5 = VAR_5 - glyph->bitmap_top + VAR_14;

        if (code == '\t') VAR_4  = (VAR_4 / s->tabsize + 1)*s->tabsize;

        else              VAR_4 += glyph->advance;

    }



    VAR_8 = FFMAX(VAR_4, VAR_8);



    s->var_values[VAR_TW] = s->var_values[VAR_TEXT_W] = VAR_8;

    s->var_values[VAR_TH] = s->var_values[VAR_TEXT_H] = VAR_5 + s->max_glyph_h;



    s->var_values[VAR_MAX_GLYPH_W] = s->max_glyph_w;

    s->var_values[VAR_MAX_GLYPH_H] = s->max_glyph_h;

    s->var_values[VAR_MAX_GLYPH_A] = s->var_values[VAR_ASCENT ] = VAR_14;

    s->var_values[VAR_MAX_GLYPH_D] = s->var_values[VAR_DESCENT] = VAR_13;



    s->var_values[VAR_LINE_H] = s->var_values[VAR_LH] = s->max_glyph_h;



    s->VAR_4 = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);

    s->VAR_5 = s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, &s->prng);

    s->VAR_4 = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng);



    update_alpha(s);

    update_color_with_alpha(s, &fontcolor  , s->fontcolor  );

    update_color_with_alpha(s, &shadowcolor, s->shadowcolor);

    update_color_with_alpha(s, &bordercolor, s->bordercolor);

    update_color_with_alpha(s, &boxcolor   , s->boxcolor   );



    VAR_10 = FFMIN(VAR_2 - 1 , VAR_8);

    VAR_11 = FFMIN(VAR_3 - 1, VAR_5 + s->max_glyph_h);



    

    if (s->draw_box)

        ff_blend_rectangle(&s->dc, &boxcolor,

                           VAR_1->data, VAR_1->linesize, VAR_2, VAR_3,

                           s->VAR_4 - s->boxborderw, s->VAR_5 - s->boxborderw,

                           VAR_10 + s->boxborderw * 2, VAR_11 + s->boxborderw * 2);



    if (s->shadowx || s->shadowy) {

        if ((VAR_7 = draw_glyphs(s, VAR_1, VAR_2, VAR_3,

                               &shadowcolor, s->shadowx, s->shadowy, 0)) < 0)

            return VAR_7;

    }



    if (s->borderw) {

        if ((VAR_7 = draw_glyphs(s, VAR_1, VAR_2, VAR_3,

                               &bordercolor, 0, 0, s->borderw)) < 0)

            return VAR_7;

    }

    if ((VAR_7 = draw_glyphs(s, VAR_1, VAR_2, VAR_3,

                           &fontcolor, 0, 0, 0)) < 0)

        return VAR_7;



    return 0;

}

static int FUNC_0(AVFilterContext *VAR_0, AVFrame *VAR_1,
int VAR_2, int VAR_3)
{ DrawTextContext *s = VAR_0->priv; AVFilterLink *inlink = VAR_0->inputs[0]; uint32_t code = 0, prev_code = 0; int VAR_4 = 0, VAR_5 = 0, VAR_6 = 0, VAR_7; int VAR_8 = 0, VAR_9; int VAR_10, VAR_11; char *VAR_12; uint8_t *p; int VAR_13 = 32000, VAR_14 = -32000; int VAR_15 = 32000, VAR_16 = -32000; FT_Vector delta; Glyph *glyph = NULL, *prev_glyph = NULL; Glyph dummy = { 0 }; time_t now = time(0); struct tm VAR_17; AVBPrint *bp = &s->expanded_text; FFDrawColor fontcolor; FFDrawColor shadowcolor; FFDrawColor bordercolor; FFDrawColor boxcolor; av_bprint_clear(bp); if(s->basetime != AV_NOPTS_VALUE)
now= VAR_1->pts*av_q2d(VAR_0->inputs[0]->time_base) + s->basetime/1000000; switch (s->exp_mode) { case EXP_NONE:
av_bprintf(bp, "%s", s->VAR_12); break; case EXP_NORMAL:
if ((VAR_7 = expand_text(VAR_0, s->VAR_12, &s->expanded_text)) < 0)
return VAR_7; break; case EXP_STRFTIME:
localtime_r(&now, &VAR_17); av_bprint_strftime(bp, s->VAR_12, &VAR_17); break; } if (s->tc_opt_string) { char VAR_18[AV_TIMECODE_STR_SIZE]; av_timecode_make_string(&s->tc, VAR_18, inlink->frame_count); av_bprint_clear(bp); av_bprintf(bp, "%s%s", s->VAR_12, VAR_18); } if (!av_bprint_is_complete(bp))
return AVERROR(ENOMEM); VAR_12 = s->expanded_text.str; if ((VAR_9 = s->expanded_text.VAR_9) > s->nb_positions) { if (!(s->positions =
av_realloc(s->positions, VAR_9*sizeof(*s->positions))))
return AVERROR(ENOMEM); s->nb_positions = VAR_9; } if (s->fontcolor_expr[0]) { av_bprint_clear(&s->expanded_fontcolor); if ((VAR_7 = expand_text(VAR_0, s->fontcolor_expr, &s->expanded_fontcolor)) < 0)
return VAR_7; if (!av_bprint_is_complete(&s->expanded_fontcolor))
return AVERROR(ENOMEM); av_log(s, AV_LOG_DEBUG, "Evaluated fontcolor is '%s'\n", s->expanded_fontcolor.str); VAR_7 = av_parse_color(s->fontcolor.rgba, s->expanded_fontcolor.str, -1, s); if (VAR_7)
return VAR_7; ff_draw_color(&s->dc, &s->fontcolor, s->fontcolor.rgba); } VAR_4 = 0; VAR_5 = 0; for (VAR_6 = 0, p = VAR_12; *p; VAR_6++) { GET_UTF8(code, *p++, continue;); dummy.code = code; glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL); if (!glyph) { load_glyph(VAR_0, &glyph, code); } VAR_13 = FFMIN(glyph->bbox.yMin, VAR_13); VAR_14 = FFMAX(glyph->bbox.yMax, VAR_14); VAR_15 = FFMIN(glyph->bbox.xMin, VAR_15); VAR_16 = FFMAX(glyph->bbox.xMax, VAR_16); } s->max_glyph_h = VAR_14 - VAR_13; s->max_glyph_w = VAR_16 - VAR_15; glyph = NULL; for (VAR_6 = 0, p = VAR_12; *p; VAR_6++) { GET_UTF8(code, *p++, continue;); if (prev_code == '\r' && code == '\n')
continue; prev_code = code; if (is_newline(code)) { VAR_8 = FFMAX(VAR_8, VAR_4); VAR_5 += s->max_glyph_h; VAR_4 = 0; continue; } prev_glyph = glyph; dummy.code = code; glyph = av_tree_find(s->glyphs, &dummy, glyph_cmp, NULL); if (s->use_kerning && prev_glyph && glyph->code) { FT_Get_Kerning(s->face, prev_glyph->code, glyph->code,
ft_kerning_default, &delta); VAR_4 += delta.VAR_4 >> 6; } s->positions[VAR_6].VAR_4 = VAR_4 + glyph->bitmap_left; s->positions[VAR_6].VAR_5 = VAR_5 - glyph->bitmap_top + VAR_14; if (code == '\t') VAR_4  = (VAR_4 / s->tabsize + 1)*s->tabsize; else              VAR_4 += glyph->advance; } VAR_8 = FFMAX(VAR_4, VAR_8); s->var_values[VAR_TW] = s->var_values[VAR_TEXT_W] = VAR_8; s->var_values[VAR_TH] = s->var_values[VAR_TEXT_H] = VAR_5 + s->max_glyph_h; s->var_values[VAR_MAX_GLYPH_W] = s->max_glyph_w; s->var_values[VAR_MAX_GLYPH_H] = s->max_glyph_h; s->var_values[VAR_MAX_GLYPH_A] = s->var_values[VAR_ASCENT ] = VAR_14; s->var_values[VAR_MAX_GLYPH_D] = s->var_values[VAR_DESCENT] = VAR_13; s->var_values[VAR_LINE_H] = s->var_values[VAR_LH] = s->max_glyph_h; s->VAR_4 = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng); s->VAR_5 = s->var_values[VAR_Y] = av_expr_eval(s->y_pexpr, s->var_values, &s->prng); s->VAR_4 = s->var_values[VAR_X] = av_expr_eval(s->x_pexpr, s->var_values, &s->prng); update_alpha(s); update_color_with_alpha(s, &fontcolor  , s->fontcolor  ); update_color_with_alpha(s, &shadowcolor, s->shadowcolor); update_color_with_alpha(s, &bordercolor, s->bordercolor); update_color_with_alpha(s, &boxcolor   , s->boxcolor   ); VAR_10 = FFMIN(VAR_2 - 1 , VAR_8); VAR_11 = FFMIN(VAR_3 - 1, VAR_5 + s->max_glyph_h); if (s->draw_box)
ff_blend_rectangle(&s->dc, &boxcolor,
VAR_1->data, VAR_1->linesize, VAR_2, VAR_3,
s->VAR_4 - s->boxborderw, s->VAR_5 - s->boxborderw,
VAR_10 + s->boxborderw * 2, VAR_11 + s->boxborderw * 2); if (s->shadowx || s->shadowy) { if ((VAR_7 = draw_glyphs(s, VAR_1, VAR_2, VAR_3,
&shadowcolor, s->shadowx, s->shadowy, 0)) < 0)
return VAR_7; } if (s->borderw) { if ((VAR_7 = draw_glyphs(s, VAR_1, VAR_2, VAR_3,
&bordercolor, 0, 0, s->borderw)) < 0)
return VAR_7; } if ((VAR_7 = draw_glyphs(s, VAR_1, VAR_2, VAR_3,
&fontcolor, 0, 0, 0)) < 0)
return VAR_7; return 0; }