]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/wtvdec.c
avformat/mpegts: Continue parsing PMTs during duration estimation
[ffmpeg] / libavformat / wtvdec.c
index ee1ae1ab19c774f8315ffbd48cdb5c95af70684e..4009964824cdff07102f2f48fe1ef31820a5f191 100644 (file)
@@ -30,6 +30,7 @@
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
+#include "libavutil/time_internal.h"
 #include "avformat.h"
 #include "internal.h"
 #include "wtv.h"
@@ -386,10 +387,12 @@ static int read_probe(AVProbeData *p)
 static int filetime_to_iso8601(char *buf, int buf_size, int64_t value)
 {
     time_t t = (value / 10000000LL) - 11644473600LL;
-    struct tm *tm = gmtime(&t);
+    struct tm tmbuf;
+    struct tm *tm = gmtime_r(&t, &tmbuf);
     if (!tm)
         return -1;
-    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+        return -1;
     return 0;
 }
 
@@ -400,10 +403,12 @@ static int filetime_to_iso8601(char *buf, int buf_size, int64_t value)
 static int crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
 {
     time_t t = (value / 10000000LL) - 719162LL*86400LL;
-    struct tm *tm = gmtime(&t);
+    struct tm tmbuf;
+    struct tm *tm = gmtime_r(&t, &tmbuf);
     if (!tm)
         return -1;
-    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", gmtime(&t));
+    if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+        return -1;
     return 0;
 }
 
@@ -414,10 +419,12 @@ static int crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
 static int oledate_to_iso8601(char *buf, int buf_size, int64_t value)
 {
     time_t t = (av_int2double(value) - 25569.0) * 86400;
-    struct tm *result= gmtime(&t);
-    if (!result)
+    struct tm tmbuf;
+    struct tm *tm= gmtime_r(&t, &tmbuf);
+    if (!tm)
+        return -1;
+    if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
         return -1;
-    strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", result);
     return 0;
 }