mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Improve rounding slightly
This commit is contained in:
parent
5429996c0c
commit
b331f7e20f
@ -457,7 +457,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public static int MillisecondsToFramesMaxFrameRate(double milliseconds)
|
||||
{
|
||||
int frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate)), MidpointRounding.AwayFromZero);
|
||||
var frames = (int)Math.Round(milliseconds / (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate)), MidpointRounding.AwayFromZero);
|
||||
if (frames >= Configuration.Settings.General.CurrentFrameRate)
|
||||
{
|
||||
frames = (int)(Configuration.Settings.General.CurrentFrameRate - 0.01);
|
||||
@ -468,12 +468,12 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public static int FramesToMilliseconds(double frames)
|
||||
{
|
||||
return (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate)));
|
||||
return (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate)), MidpointRounding.AwayFromZero);
|
||||
}
|
||||
|
||||
public static int FramesToMillisecondsMax999(double frames)
|
||||
{
|
||||
int ms = (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate)));
|
||||
var ms = (int)Math.Round(frames * (TimeCode.BaseUnit / GetFrameForCalculation(Configuration.Settings.General.CurrentFrameRate)), MidpointRounding.AwayFromZero);
|
||||
return Math.Min(ms, 999);
|
||||
}
|
||||
|
||||
@ -669,7 +669,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
|
||||
public static SubtitleFormat FromName(string formatName, SubtitleFormat defaultFormat)
|
||||
{
|
||||
string trimmedFormatName = formatName.Trim();
|
||||
var trimmedFormatName = formatName.Trim();
|
||||
foreach (var format in AllSubtitleFormats)
|
||||
{
|
||||
if (format.Name.Trim().Equals(trimmedFormatName, StringComparison.OrdinalIgnoreCase) ||
|
||||
@ -682,7 +682,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
return defaultFormat;
|
||||
}
|
||||
|
||||
private static IList<SubtitleFormat> GetOrderedFormatsList(IList<SubtitleFormat> unorderedFormatsList)
|
||||
private static IList<SubtitleFormat> GetOrderedFormatsList(IEnumerable<SubtitleFormat> unorderedFormatsList)
|
||||
{
|
||||
IEnumerable<SubtitleFormat> newSelectedFormats = new[] { Utilities.GetSubtitleFormatByFriendlyName(Configuration.Settings.General.DefaultSubtitleFormat) };
|
||||
if (!string.IsNullOrEmpty(Configuration.Settings.General.FavoriteSubtitleFormats))
|
||||
|
Loading…
Reference in New Issue
Block a user