aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-07 22:29:02 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-07 22:57:36 +0200
commitb8d017adba857715908ece3c28179549e40b48fa (patch)
tree3af515308dedb1b672a75ae6425190380ef3af53
parent8cda23f341bef315ace929d6bd5273a431f5c562 (diff)
downloadffmpeg-b8d017adba857715908ece3c28179549e40b48fa.tar.gz
avformat/segment: simplify localtime* use
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/segment.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libavformat/segment.c b/libavformat/segment.c
index a09d49d4bf..f5e25a29d5 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -669,13 +669,6 @@ fail:
return ret;
}
-#if !HAVE_LOCALTIME_R
-static void localtime_r(const time_t *t, struct tm *tm)
-{
- *tm = *localtime(t);
-}
-#endif
-
static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
{
SegmentContext *seg = s->priv_data;
@@ -697,7 +690,11 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
} else {
if (seg->use_clocktime) {
gettimeofday(&now, NULL);
+#if HAVE_LOCALTIME_R
localtime_r(&now.tv_sec, &ti);
+#else
+ ti = *localtime(&now.tv_sec);
+#endif
usecs = (int64_t)(ti.tm_hour*3600 + ti.tm_min*60 + ti.tm_sec) * 1000000 + now.tv_usec;
wrapped_val = usecs % seg->time;
if (seg->last_cut != usecs && wrapped_val < seg->last_val) {