2020-04-21 08:33:41 +00:00
|
|
|
#pragma warning disable CS1591
|
|
|
|
|
2019-01-06 20:50:43 +00:00
|
|
|
using System;
|
2016-10-26 19:29:56 +00:00
|
|
|
|
|
|
|
namespace DvdLib.Ifo
|
|
|
|
{
|
|
|
|
public class DvdTime
|
|
|
|
{
|
|
|
|
public readonly byte Hour, Minute, Second, Frames, FrameRate;
|
|
|
|
|
|
|
|
public DvdTime(byte[] data)
|
|
|
|
{
|
|
|
|
Hour = GetBCDValue(data[0]);
|
|
|
|
Minute = GetBCDValue(data[1]);
|
|
|
|
Second = GetBCDValue(data[2]);
|
|
|
|
Frames = GetBCDValue((byte)(data[3] & 0x3F));
|
|
|
|
|
2020-06-20 08:35:29 +00:00
|
|
|
if ((data[3] & 0x80) != 0)
|
|
|
|
{
|
|
|
|
FrameRate = 30;
|
|
|
|
}
|
|
|
|
else if ((data[3] & 0x40) != 0)
|
|
|
|
{
|
|
|
|
FrameRate = 25;
|
|
|
|
}
|
2016-10-26 19:29:56 +00:00
|
|
|
}
|
|
|
|
|
2019-01-06 20:50:43 +00:00
|
|
|
private static byte GetBCDValue(byte data)
|
2016-10-26 19:29:56 +00:00
|
|
|
{
|
|
|
|
return (byte)((((data & 0xF0) >> 4) * 10) + (data & 0x0F));
|
|
|
|
}
|
|
|
|
|
|
|
|
public static explicit operator TimeSpan(DvdTime time)
|
|
|
|
{
|
|
|
|
int ms = (int)(((1.0 / (double)time.FrameRate) * time.Frames) * 1000.0);
|
|
|
|
return new TimeSpan(0, time.Hour, time.Minute, time.Second, ms);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|