Commit 4a39d4c6 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit '82ee7d0d'

* commit '82ee7d0d':
  Use gmtime_r instead of gmtime and localtime_r instead of localtime

Conflicts:
	libavformat/mov.c
	libavformat/mxfenc.c
	libavformat/wtvdec.c
	libavutil/parseutils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents edb069e5 82ee7d0d
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h" #include "libavutil/intfloat.h"
#include "libavutil/mathematics.h" #include "libavutil/mathematics.h"
#include "libavutil/time_internal.h"
#include "libavutil/avstring.h" #include "libavutil/avstring.h"
#include "libavutil/dict.h" #include "libavutil/dict.h"
#include "libavutil/opt.h" #include "libavutil/opt.h"
...@@ -809,12 +810,12 @@ static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time) ...@@ -809,12 +810,12 @@ static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time)
{ {
char buffer[32]; char buffer[32];
if (time) { if (time) {
struct tm *ptm; struct tm *ptm, tmbuf;
time_t timet; time_t timet;
if(time >= 2082844800) if(time >= 2082844800)
time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ time -= 2082844800; /* seconds between 1904-01-01 and Epoch */
timet = time; timet = time;
ptm = gmtime(&timet); ptm = gmtime_r(&timet, &tmbuf);
if (!ptm) return; if (!ptm) return;
if (strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm)) if (strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", ptm))
av_dict_set(metadata, "creation_time", buffer, 0); av_dict_set(metadata, "creation_time", buffer, 0);
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "libavutil/random_seed.h" #include "libavutil/random_seed.h"
#include "libavutil/timecode.h" #include "libavutil/timecode.h"
#include "libavutil/avassert.h" #include "libavutil/avassert.h"
#include "libavutil/time_internal.h"
#include "libavcodec/bytestream.h" #include "libavcodec/bytestream.h"
#include "libavcodec/dnxhddata.h" #include "libavcodec/dnxhddata.h"
#include "audiointerleave.h" #include "audiointerleave.h"
...@@ -1664,7 +1665,8 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st, ...@@ -1664,7 +1665,8 @@ static int mxf_parse_mpeg2_frame(AVFormatContext *s, AVStream *st,
static uint64_t mxf_parse_timestamp(time_t timestamp) static uint64_t mxf_parse_timestamp(time_t timestamp)
{ {
struct tm *time = gmtime(&timestamp); struct tm tmbuf;
struct tm *time = gmtime_r(&timestamp, &tmbuf);
if (!time) if (!time)
return 0; return 0;
return (uint64_t)(time->tm_year+1900) << 48 | return (uint64_t)(time->tm_year+1900) << 48 |
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "libavutil/channel_layout.h" #include "libavutil/channel_layout.h"
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "libavutil/intfloat.h" #include "libavutil/intfloat.h"
#include "libavutil/time_internal.h"
#include "avformat.h" #include "avformat.h"
#include "internal.h" #include "internal.h"
#include "wtv.h" #include "wtv.h"
...@@ -386,7 +387,8 @@ static int read_probe(AVProbeData *p) ...@@ -386,7 +387,8 @@ static int read_probe(AVProbeData *p)
static int filetime_to_iso8601(char *buf, int buf_size, int64_t value) static int filetime_to_iso8601(char *buf, int buf_size, int64_t value)
{ {
time_t t = (value / 10000000LL) - 11644473600LL; time_t t = (value / 10000000LL) - 11644473600LL;
struct tm *tm = gmtime(&t); struct tm tmbuf;
struct tm *tm = gmtime_r(&t, &tmbuf);
if (!tm) if (!tm)
return -1; return -1;
if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
...@@ -401,7 +403,8 @@ static int filetime_to_iso8601(char *buf, int buf_size, int64_t value) ...@@ -401,7 +403,8 @@ 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) static int crazytime_to_iso8601(char *buf, int buf_size, int64_t value)
{ {
time_t t = (value / 10000000LL) - 719162LL*86400LL; time_t t = (value / 10000000LL) - 719162LL*86400LL;
struct tm *tm = gmtime(&t); struct tm tmbuf;
struct tm *tm = gmtime_r(&t, &tmbuf);
if (!tm) if (!tm)
return -1; return -1;
if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
...@@ -416,7 +419,8 @@ static int crazytime_to_iso8601(char *buf, int buf_size, int64_t value) ...@@ -416,7 +419,8 @@ 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) static int oledate_to_iso8601(char *buf, int buf_size, int64_t value)
{ {
time_t t = (av_int2double(value) - 25569.0) * 86400; time_t t = (av_int2double(value) - 25569.0) * 86400;
struct tm *tm= gmtime(&t); struct tm tmbuf;
struct tm *tm= gmtime_r(&t, &tmbuf);
if (!tm) if (!tm)
return -1; return -1;
if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm)) if (!strftime(buf, buf_size, "%Y-%m-%d %H:%M:%S", tm))
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "eval.h" #include "eval.h"
#include "log.h" #include "log.h"
#include "random_seed.h" #include "random_seed.h"
#include "time_internal.h"
#include "parseutils.h" #include "parseutils.h"
#ifdef TEST #ifdef TEST
...@@ -552,7 +553,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) ...@@ -552,7 +553,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
const char *p, *q; const char *p, *q;
int64_t t; int64_t t;
time_t now; time_t now;
struct tm dt = { 0 }; struct tm dt = { 0 }, tmbuf;
int today = 0, negative = 0, microseconds = 0; int today = 0, negative = 0, microseconds = 0;
int i; int i;
static const char * const date_fmt[] = { static const char * const date_fmt[] = {
...@@ -647,7 +648,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration) ...@@ -647,7 +648,7 @@ int av_parse_time(int64_t *timeval, const char *timestr, int duration)
int is_utc = *q == 'Z' || *q == 'z'; int is_utc = *q == 'Z' || *q == 'z';
q += is_utc; q += is_utc;
if (today) { /* fill in today's date */ if (today) { /* fill in today's date */
struct tm dt2 = is_utc ? *gmtime(&now) : *localtime(&now); struct tm dt2 = is_utc ? *gmtime_r(&now, &tmbuf) : *localtime_r(&now, &tmbuf);
dt2.tm_hour = dt.tm_hour; dt2.tm_hour = dt.tm_hour;
dt2.tm_min = dt.tm_min; dt2.tm_min = dt.tm_min;
dt2.tm_sec = dt.tm_sec; dt2.tm_sec = dt.tm_sec;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment