Dcinema smpte sometimes generated illegal frame numbers - thx knut :)

This commit is contained in:
niksedk 2014-03-17 20:14:28 +01:00
parent a5b60e8b2a
commit 26f335bb2b
3 changed files with 23 additions and 17 deletions

View File

@ -776,8 +776,7 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
private string ConvertToTimeString(TimeCode time)
{
int frames = (int)System.Math.Round(time.Milliseconds / (1000.0 / frameRate));
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, frames);
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, DCinemaSmpte2010.MsToFramesMaxFrameRate(time.Milliseconds, frameRate));
}
}

View File

@ -774,10 +774,17 @@ namespace Nikse.SubtitleEdit.Logic.SubtitleFormats
return new TimeCode(ts);
}
public static int MsToFramesMaxFrameRate(double milliseconds, double frameRate)
{
int frames = (int)System.Math.Round(milliseconds / (1000.0 / frameRate));
if (frames >= Configuration.Settings.General.CurrentFrameRate)
frames = (int)(frameRate - 0.01);
return frames;
}
private string ConvertToTimeString(TimeCode time)
{
int frames = (int)System.Math.Round(time.Milliseconds / (1000.0 / frameRate));
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, frames);
return string.Format("{0:00}:{1:00}:{2:00}:{3:00}", time.Hours, time.Minutes, time.Seconds, MsToFramesMaxFrameRate(time.Milliseconds, frameRate));
}
}

View File

@ -18,7 +18,7 @@ namespace Nikse.SubtitleEdit.Logic.TransportStream
public long TotalNumberOfPrivateStream1Continuation0 { get; private set; }
public List<int> SubtitlePacketIds { get; private set; }
public List<Packet> SubtitlePackets { get; private set; }
public List<Packet> ProgramAssociationTables { get; private set; }
// public List<Packet> ProgramAssociationTables { get; private set; }
private Dictionary<int, List<DvbSubPes>> SubtitlesLookup { get; set; }
private Dictionary<int, List<TransportStreamSubtitle>> DvbSubtitlesLookup { get; set; }
public bool IsM2TransportStream { get; private set; }
@ -45,7 +45,7 @@ namespace Nikse.SubtitleEdit.Logic.TransportStream
TotalNumberOfPrivateStream1Continuation0 = 0;
SubtitlePacketIds = new List<int>();
SubtitlePackets = new List<Packet>();
ProgramAssociationTables = new List<Packet>();
// ProgramAssociationTables = new List<Packet>();
ms.Position = 0;
int packetLength = 188;
DetectFormat(ms);
@ -147,20 +147,20 @@ namespace Nikse.SubtitleEdit.Logic.TransportStream
{
TotalNumberOfPrivateStream1Continuation0++;
int pesExtensionlength = 0;
if (12 + packet.AdaptionFieldLength < packetBuffer.Length)
pesExtensionlength = 0xFF & packetBuffer[12 + packet.AdaptionFieldLength];
int pesOffset = 13 + packet.AdaptionFieldLength + pesExtensionlength;
bool isTeletext = (pesExtensionlength == 0x24 && (0xFF & packetBuffer[pesOffset]) >> 4 == 1);
//int pesExtensionlength = 0;
//if (12 + packet.AdaptionFieldLength < packetBuffer.Length)
// pesExtensionlength = 0xFF & packetBuffer[12 + packet.AdaptionFieldLength];
//int pesOffset = 13 + packet.AdaptionFieldLength + pesExtensionlength;
//bool isTeletext = (pesExtensionlength == 0x24 && (0xFF & packetBuffer[pesOffset]) >> 4 == 1);
// workaround uk freesat teletext
if (!isTeletext)
isTeletext = (pesExtensionlength == 0x24 && (0xFF & packetBuffer[pesOffset]) == 0x99);
//// workaround uk freesat teletext
//if (!isTeletext)
// isTeletext = (pesExtensionlength == 0x24 && (0xFF & packetBuffer[pesOffset]) == 0x99);
if (!isTeletext)
{
//if (!isTeletext)
//{
}
//}
}
}
TotalNumberOfPackets++;