Fixes Ticket2470
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -3030,6 +3030,9 @@ It can accept an argument: a strftime() format string. |
3030 | 3030 |
@item n, frame_num |
3031 | 3031 |
The frame number, starting from 0. |
3032 | 3032 |
|
3033 |
+@item pict_type |
|
3034 |
+A 1 character description of the current picture type. |
|
3035 |
+ |
|
3033 | 3036 |
@item pts |
3034 | 3037 |
The timestamp of the current frame, in seconds, with microsecond accuracy. |
3035 | 3038 |
|
... | ... |
@@ -72,6 +72,7 @@ static const char *const var_names[] = { |
72 | 72 |
"text_w", "tw", ///< width of the rendered text |
73 | 73 |
"x", |
74 | 74 |
"y", |
75 |
+ "pict_type", |
|
75 | 76 |
NULL |
76 | 77 |
}; |
77 | 78 |
|
... | ... |
@@ -108,6 +109,7 @@ enum var_name { |
108 | 108 |
VAR_TEXT_W, VAR_TW, |
109 | 109 |
VAR_X, |
110 | 110 |
VAR_Y, |
111 |
+ VAR_PICT_TYPE, |
|
111 | 112 |
VAR_VARS_NB |
112 | 113 |
}; |
113 | 114 |
|
... | ... |
@@ -608,6 +610,15 @@ static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char |
608 | 608 |
return AVERROR(ENOSYS); |
609 | 609 |
} |
610 | 610 |
|
611 |
+static int func_pict_type(AVFilterContext *ctx, AVBPrint *bp, |
|
612 |
+ char *fct, unsigned argc, char **argv, int tag) |
|
613 |
+{ |
|
614 |
+ DrawTextContext *dtext = ctx->priv; |
|
615 |
+ |
|
616 |
+ av_bprintf(bp, "%c", av_get_picture_type_char(dtext->var_values[VAR_PICT_TYPE])); |
|
617 |
+ return 0; |
|
618 |
+} |
|
619 |
+ |
|
611 | 620 |
static int func_pts(AVFilterContext *ctx, AVBPrint *bp, |
612 | 621 |
char *fct, unsigned argc, char **argv, int tag) |
613 | 622 |
{ |
... | ... |
@@ -677,6 +688,7 @@ static const struct drawtext_function { |
677 | 677 |
} functions[] = { |
678 | 678 |
{ "expr", 1, 1, 0, func_eval_expr }, |
679 | 679 |
{ "e", 1, 1, 0, func_eval_expr }, |
680 |
+ { "pict_type", 0, 0, 0, func_pict_type }, |
|
680 | 681 |
{ "pts", 0, 0, 0, func_pts }, |
681 | 682 |
{ "gmtime", 0, 1, 'G', func_strftime }, |
682 | 683 |
{ "localtime", 0, 1, 'L', func_strftime }, |
... | ... |
@@ -987,6 +999,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) |
987 | 987 |
dtext->var_values[VAR_T] = frame->pts == AV_NOPTS_VALUE ? |
988 | 988 |
NAN : frame->pts * av_q2d(inlink->time_base); |
989 | 989 |
|
990 |
+ dtext->var_values[VAR_PICT_TYPE] = frame->pict_type; |
|
991 |
+ |
|
990 | 992 |
draw_text(ctx, frame, frame->width, frame->height); |
991 | 993 |
|
992 | 994 |
av_log(ctx, AV_LOG_DEBUG, "n:%d t:%f text_w:%d text_h:%d x:%d y:%d\n", |