Message ID | 20181223001256.31893-2-cus@passwd.hu |
---|---|
State | Accepted |
Commit | 02935c2c93e8e1691c1d903ef96b00b3facb454a |
Headers | show |
sön 2018-12-23 klockan 01:12 +0100 skrev Marton Balint: > > Signed-off-by: Marton Balint <cus@passwd.hu> > --- > libavformat/mxfdec.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c > index d78f8ad2e4..0553adcb06 100644 > --- a/libavformat/mxfdec.c > +++ b/libavformat/mxfdec.c > @@ -2556,12 +2556,14 @@ fail_and_free: > static int64_t mxf_timestamp_to_int64(uint64_t timestamp) > { > struct tm time = { 0 }; > + int msecs; > time.tm_year = (timestamp >> 48) - 1900; > time.tm_mon = (timestamp >> 40 & 0xFF) - 1; > time.tm_mday = (timestamp >> 32 & 0xFF); > time.tm_hour = (timestamp >> 24 & 0xFF); > time.tm_min = (timestamp >> 16 & 0xFF); > time.tm_sec = (timestamp >> 8 & 0xFF); > + msecs = (timestamp & 0xFF) * 4; > > /* Clip values for legacy reasons. Maybe we should return error instead? */ > time.tm_mon = av_clip(time.tm_mon, 0, 11); > @@ -2569,8 +2571,9 @@ static int64_t mxf_timestamp_to_int64(uint64_t timestamp) > time.tm_hour = av_clip(time.tm_hour, 0, 23); > time.tm_min = av_clip(time.tm_min, 0, 59); > time.tm_sec = av_clip(time.tm_sec, 0, 59); > + msecs = av_clip(msecs, 0, 999); > > - return (int64_t)av_timegm(&time) * 1000000; > + return (int64_t)av_timegm(&time) * 1000000 + msecs * 1000; Looks OK I kinda wonder how this and the muxer code could have ignored the milliseconds. Did the old creation time metadata use seconds only? /Tomas
On Tue, 25 Dec 2018, Tomas Härdin wrote: > sön 2018-12-23 klockan 01:12 +0100 skrev Marton Balint: >> > Signed-off-by: Marton Balint <cus@passwd.hu> >> --- >> libavformat/mxfdec.c | 5 ++++- >> 1 file changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c >> index d78f8ad2e4..0553adcb06 100644 >> --- a/libavformat/mxfdec.c >> +++ b/libavformat/mxfdec.c >> @@ -2556,12 +2556,14 @@ fail_and_free: >> static int64_t mxf_timestamp_to_int64(uint64_t timestamp) >> { >> struct tm time = { 0 }; >> + int msecs; >> time.tm_year = (timestamp >> 48) - 1900; >> time.tm_mon = (timestamp >> 40 & 0xFF) - 1; >> time.tm_mday = (timestamp >> 32 & 0xFF); >> time.tm_hour = (timestamp >> 24 & 0xFF); >> time.tm_min = (timestamp >> 16 & 0xFF); >> time.tm_sec = (timestamp >> 8 & 0xFF); >> + msecs = (timestamp & 0xFF) * 4; >> >> /* Clip values for legacy reasons. Maybe we should return error instead? */ >> time.tm_mon = av_clip(time.tm_mon, 0, 11); >> @@ -2569,8 +2571,9 @@ static int64_t mxf_timestamp_to_int64(uint64_t timestamp) >> time.tm_hour = av_clip(time.tm_hour, 0, 23); >> time.tm_min = av_clip(time.tm_min, 0, 59); >> time.tm_sec = av_clip(time.tm_sec, 0, 59); >> + msecs = av_clip(msecs, 0, 999); >> >> - return (int64_t)av_timegm(&time) * 1000000; >> + return (int64_t)av_timegm(&time) * 1000000 + msecs * 1000; > > Looks OK Thanks, pushed this and the other patch. > > I kinda wonder how this and the muxer code could have ignored the > milliseconds. Did the old creation time metadata use seconds only? Yes, it used to be in this format: "%Y-%m-%d %H:%M:%S". Regards, Marton
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c index d78f8ad2e4..0553adcb06 100644 --- a/libavformat/mxfdec.c +++ b/libavformat/mxfdec.c @@ -2556,12 +2556,14 @@ fail_and_free: static int64_t mxf_timestamp_to_int64(uint64_t timestamp) { struct tm time = { 0 }; + int msecs; time.tm_year = (timestamp >> 48) - 1900; time.tm_mon = (timestamp >> 40 & 0xFF) - 1; time.tm_mday = (timestamp >> 32 & 0xFF); time.tm_hour = (timestamp >> 24 & 0xFF); time.tm_min = (timestamp >> 16 & 0xFF); time.tm_sec = (timestamp >> 8 & 0xFF); + msecs = (timestamp & 0xFF) * 4; /* Clip values for legacy reasons. Maybe we should return error instead? */ time.tm_mon = av_clip(time.tm_mon, 0, 11); @@ -2569,8 +2571,9 @@ static int64_t mxf_timestamp_to_int64(uint64_t timestamp) time.tm_hour = av_clip(time.tm_hour, 0, 23); time.tm_min = av_clip(time.tm_min, 0, 59); time.tm_sec = av_clip(time.tm_sec, 0, 59); + msecs = av_clip(msecs, 0, 999); - return (int64_t)av_timegm(&time) * 1000000; + return (int64_t)av_timegm(&time) * 1000000 + msecs * 1000; } #define SET_STR_METADATA(pb, name, str) do { \
Signed-off-by: Marton Balint <cus@passwd.hu> --- libavformat/mxfdec.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)