mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
vf_drawtext: make strftime work without localtime_r()
modern OS should have localtime_r() or return thread locals on localtime() hopefully Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
6f8b1fcd4b
commit
038a465efc
@ -318,10 +318,6 @@ static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque)
|
|||||||
}
|
}
|
||||||
dtext->tabsize *= glyph->advance;
|
dtext->tabsize *= glyph->advance;
|
||||||
|
|
||||||
#if !HAVE_LOCALTIME_R
|
|
||||||
av_log(ctx, AV_LOG_WARNING, "strftime() expansion unavailable!\n");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,7 +570,6 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
|
|||||||
Glyph *glyph = NULL, *prev_glyph = NULL;
|
Glyph *glyph = NULL, *prev_glyph = NULL;
|
||||||
Glyph dummy = { 0 };
|
Glyph dummy = { 0 };
|
||||||
|
|
||||||
#if HAVE_LOCALTIME_R
|
|
||||||
time_t now = time(0);
|
time_t now = time(0);
|
||||||
struct tm ltime;
|
struct tm ltime;
|
||||||
uint8_t *buf = dtext->expanded_text;
|
uint8_t *buf = dtext->expanded_text;
|
||||||
@ -588,7 +583,12 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
|
|||||||
buf = av_malloc(buf_size);
|
buf = av_malloc(buf_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if HAVE_LOCALTIME_R
|
||||||
localtime_r(&now, <ime);
|
localtime_r(&now, <ime);
|
||||||
|
#else
|
||||||
|
if(strchr(dtext->text, '%'))
|
||||||
|
ltime= *localtime(&now);
|
||||||
|
#endif
|
||||||
|
|
||||||
do {
|
do {
|
||||||
*buf = 1;
|
*buf = 1;
|
||||||
@ -601,7 +601,6 @@ static int draw_text(AVFilterContext *ctx, AVFilterBufferRef *picref,
|
|||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
text = dtext->expanded_text = buf;
|
text = dtext->expanded_text = buf;
|
||||||
dtext->expanded_text_size = buf_size;
|
dtext->expanded_text_size = buf_size;
|
||||||
#endif
|
|
||||||
if ((len = strlen(text)) > dtext->nb_positions) {
|
if ((len = strlen(text)) > dtext->nb_positions) {
|
||||||
if (!(dtext->positions =
|
if (!(dtext->positions =
|
||||||
av_realloc(dtext->positions, len*sizeof(*dtext->positions))))
|
av_realloc(dtext->positions, len*sizeof(*dtext->positions))))
|
||||||
|
Loading…
Reference in New Issue
Block a user