#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"
#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 */
*
*/
-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 */
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", gmtime(&t));
- 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';
}
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", gmtime(&t));
- 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';
}
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", gmtime(&t));
- 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';
}
if (!wst)
return NULL;
st = avformat_new_stream(s, NULL);
- if (!st)
+ if (!st) {
+ av_free(wst);
return NULL;
+ }
st->id = sid;
st->priv_data = wst;
}
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 {
avio_skip(s->pb, 4);
root_sector = avio_rl32(s->pb);
- seek_by_sector(s->pb, root_sector, 0);
+ ret = seek_by_sector(s->pb, root_sector, 0);
+ if (ret < 0)
+ return ret;
root_size = avio_read(s->pb, root, root_size);
if (root_size < 0)
return AVERROR_INVALIDDATA;