mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-11-24 03:39:45 +00:00
avfilter/drawtext: add pict_type support
Fixes Ticket2470 Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
15d2f26998
commit
a9a537b154
@ -3030,6 +3030,9 @@ It can accept an argument: a strftime() format string.
|
|||||||
@item n, frame_num
|
@item n, frame_num
|
||||||
The frame number, starting from 0.
|
The frame number, starting from 0.
|
||||||
|
|
||||||
|
@item pict_type
|
||||||
|
A 1 character description of the current picture type.
|
||||||
|
|
||||||
@item pts
|
@item pts
|
||||||
The timestamp of the current frame, in seconds, with microsecond accuracy.
|
The timestamp of the current frame, in seconds, with microsecond accuracy.
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ static const char *const var_names[] = {
|
|||||||
"text_w", "tw", ///< width of the rendered text
|
"text_w", "tw", ///< width of the rendered text
|
||||||
"x",
|
"x",
|
||||||
"y",
|
"y",
|
||||||
|
"pict_type",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -108,6 +109,7 @@ enum var_name {
|
|||||||
VAR_TEXT_W, VAR_TW,
|
VAR_TEXT_W, VAR_TW,
|
||||||
VAR_X,
|
VAR_X,
|
||||||
VAR_Y,
|
VAR_Y,
|
||||||
|
VAR_PICT_TYPE,
|
||||||
VAR_VARS_NB
|
VAR_VARS_NB
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -608,6 +610,15 @@ static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char
|
|||||||
return AVERROR(ENOSYS);
|
return AVERROR(ENOSYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int func_pict_type(AVFilterContext *ctx, AVBPrint *bp,
|
||||||
|
char *fct, unsigned argc, char **argv, int tag)
|
||||||
|
{
|
||||||
|
DrawTextContext *dtext = ctx->priv;
|
||||||
|
|
||||||
|
av_bprintf(bp, "%c", av_get_picture_type_char(dtext->var_values[VAR_PICT_TYPE]));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int func_pts(AVFilterContext *ctx, AVBPrint *bp,
|
static int func_pts(AVFilterContext *ctx, AVBPrint *bp,
|
||||||
char *fct, unsigned argc, char **argv, int tag)
|
char *fct, unsigned argc, char **argv, int tag)
|
||||||
{
|
{
|
||||||
@ -677,6 +688,7 @@ static const struct drawtext_function {
|
|||||||
} functions[] = {
|
} functions[] = {
|
||||||
{ "expr", 1, 1, 0, func_eval_expr },
|
{ "expr", 1, 1, 0, func_eval_expr },
|
||||||
{ "e", 1, 1, 0, func_eval_expr },
|
{ "e", 1, 1, 0, func_eval_expr },
|
||||||
|
{ "pict_type", 0, 0, 0, func_pict_type },
|
||||||
{ "pts", 0, 0, 0, func_pts },
|
{ "pts", 0, 0, 0, func_pts },
|
||||||
{ "gmtime", 0, 1, 'G', func_strftime },
|
{ "gmtime", 0, 1, 'G', func_strftime },
|
||||||
{ "localtime", 0, 1, 'L', func_strftime },
|
{ "localtime", 0, 1, 'L', func_strftime },
|
||||||
@ -987,6 +999,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
|
|||||||
dtext->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
|
dtext->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ?
|
||||||
NAN : frame->pts * av_q2d(inlink->time_base);
|
NAN : frame->pts * av_q2d(inlink->time_base);
|
||||||
|
|
||||||
|
dtext->var_values[VAR_PICT_TYPE] = frame->pict_type;
|
||||||
|
|
||||||
draw_text(ctx, frame, frame->width, frame->height);
|
draw_text(ctx, frame, frame->width, frame->height);
|
||||||
|
|
||||||
av_log(ctx, AV_LOG_DEBUG, "n:%d t:%f text_w:%d text_h:%d x:%d y:%d\n",
|
av_log(ctx, AV_LOG_DEBUG, "n:%d t:%f text_w:%d text_h:%d x:%d y:%d\n",
|
||||||
|
Loading…
Reference in New Issue
Block a user