From 94cf5f13eaf565ea230ca3628119029caf07d2c5 Mon Sep 17 00:00:00 2001
From: SiyuanHuang <saber.huang@samsung.com>
Date: Thu, 28 May 2020 13:42:01 +0800
Subject: [PATCH] libavfilter/vf_drawtext.c:add support to generte ms level
 timestamp

for test latency , need sub-seconds level timestamp watermark

Signed-off-by: SiyuanHuang <saber.huang@samsung.com>
---
 libavfilter/vf_drawtext.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
 mode change 100644 => 100755 libavfilter/vf_drawtext.c

diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c
old mode 100644
new mode 100755
index abe1ca6c35..734556eef3
--- a/libavfilter/vf_drawtext.c
+++ b/libavfilter/vf_drawtext.c
@@ -61,6 +61,8 @@
 #include "internal.h"
 #include "video.h"
 
+#include <sys/timeb.h>
+#include <time.h>
 #if CONFIG_LIBFRIBIDI
 #include <fribidi.h>
 #endif
@@ -1322,8 +1324,21 @@ static int draw_text(AVFilterContext *ctx, AVFrame *frame,
             return ret;
         break;
     case EXP_STRFTIME:
-        localtime_r(&now, &ltime);
-        av_bprint_strftime(bp, s->text, &ltime);
+        if (!= av_stristr(s->text, "mspts")) {
+            struct tm *ptm;
+            struct timeb stTimeb;
+            static char szTime[24];
+            ftime(&stTimeb);
+            ptm = localtime(&stTimeb.time);
+            sprintf(szTime, "%04d-%02d-%02d %02d:%02d:%02d.%03d",
+                    ptm->tm_year + 1900, ptm->tm_mon + 1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec, stTimeb.millitm);
+            szTime[23] = 0;
+            av_bprintf(bp, "%s", szTime);
+        } else {
+            localtime_r(&now, &ltime);
+            av_bprint_strftime(bp, s->text, &ltime);
+        }
+
         break;
     }
 
-- 
2.17.1

