From 0847cf8b66d4fdf136f16f64f143a9c115311fc3 Mon Sep 17 00:00:00 2001
From: SiyuanHuang <saber.huang@samsung.com>
Date: Fri, 29 May 2020 10:34: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 | 20 ++++++++++++++++++--
 1 file changed, 18 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..cfd08b4092
--- 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,22 @@ 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(NULL!=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

