]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/wtv.c
libfdk-aacdec: Bump the max number of channels to 8
[ffmpeg] / libavformat / wtv.c
index fa864e840afa37a5ff6feca56822d88f0f2fba52..bab61f3422036f6c4a04c70924576974e30d4c2c 100644 (file)
@@ -31,6 +31,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/dict.h"
+#include "libavutil/time_internal.h"
 #include "avformat.h"
 #include "internal.h"
 #include "riff.h"
@@ -56,7 +57,7 @@
 
 #define SHIFT_SECTOR_BITS(a) ((int64_t)(a) << WTV_SECTOR_BITS)
 
-typedef struct {
+typedef struct WtvFile {
     AVIOContext *pb_filesystem;  /** file system (AVFormatContext->pb) */
 
     int sector_bits;     /** sector shift bits; used to convert sector number into pb_filesystem offset */
@@ -323,11 +324,11 @@ static void wtvfile_close(AVIOContext *pb)
  *
  */
 
-typedef struct {
+typedef struct WtvStream {
     int seen_data;
 } WtvStream;
 
-typedef struct {
+typedef struct WtvContext {
     AVIOContext *pb;       /** timeline file */
     int64_t epoch;
     int64_t pts;             /** pts for next data chunk */
@@ -428,10 +429,12 @@ static int read_probe(AVProbeData *p)
 static void filetime_to_iso8601(char *buf, int buf_size, int64_t value)
 {
     time_t t = (value / 10000000LL) - 11644473600LL;
-    struct tm *tm = gmtime(&t);
-    if (tm)
-        strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm);
-    else
+    struct tm tmbuf;
+    struct tm *tm = gmtime_r(&t, &tmbuf);
+    if (tm) {
+        if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+            buf[0] = '\0';
+    } else
         buf[0] = '\0';
 }
 
@@ -441,10 +444,12 @@ static void filetime_to_iso8601(char *buf, int buf_size, int64_t value)
 static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
 {
     time_t t = (value / 10000000LL) - 719162LL*86400LL;
-    struct tm *tm = gmtime(&t);
-    if (tm)
-        strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm);
-    else
+    struct tm tmbuf;
+    struct tm *tm = gmtime_r(&t, &tmbuf);
+    if (tm) {
+        if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+            buf[0] = '\0';
+    } else
         buf[0] = '\0';
 }
 
@@ -454,10 +459,12 @@ static void crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
 static void oledate_to_iso8601(char *buf, int buf_size, int64_t value)
 {
     time_t t = 631112400LL + 86400*av_int2double(value);
-    struct tm *tm = gmtime(&t);
-    if (tm)
-        strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm);
-    else
+    struct tm tmbuf;
+    struct tm *tm = gmtime_r(&t, &tmbuf);
+    if (tm) {
+        if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
+            buf[0] = '\0';
+    } else
         buf[0] = '\0';
 }
 
@@ -684,7 +691,7 @@ static AVStream * parse_media_type(AVFormatContext *s, AVStream *st, int sid,
         if (!st)
             return NULL;
         if (!ff_guidcmp(formattype, format_waveformatex)) {
-            int ret = ff_get_wav_header(pb, st->codec, size);
+            int ret = ff_get_wav_header(s, pb, st->codec, size);
             if (ret < 0)
                 return NULL;
         } else {