Skip to content

Commit

Permalink
Merge branch 'release/2.33.33.331'
Browse files Browse the repository at this point in the history
  • Loading branch information
tautcony committed Aug 30, 2020
2 parents 5965774 + 6848aa0 commit 6430685
Show file tree
Hide file tree
Showing 21 changed files with 704 additions and 20 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,9 @@ FakesAssemblies/
# toaru database
*.VC.db
*.opendb

dist/windows/*.exe
dist/windows/*.config
dist/windows/*.dll
dist/windows/en-US/
dist/windows/LICENSE
6 changes: 6 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,3 +365,9 @@
## [2.33.33.33]
- 我始终致力于开发新功能、错误修正及效能改进。请即时更新至最新版本以取得最佳的验证体验
- 增加时间与帧数编辑功能

## [2.33.33.331]
- 修正某些时间编辑下抛异常的情况
- 增加安装包构建脚本
- 修正`Any CPU`编译条件,mp4文件在64位系统下无法正确加载的问题
- 修正四舍五入后为1000毫秒时时间未能进位的问题
2 changes: 0 additions & 2 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -619,5 +619,3 @@ Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.

END OF TERMS AND CONDITIONS

How to Apply These Terms to Your New Programs
17 changes: 15 additions & 2 deletions Time_Shift.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Time_Shift", "Time_Shift\Time_Shift.csproj", "{2E6AA275-D1E9-452C-B35E-E7CC6D197441}"
EndProject
Expand All @@ -10,29 +10,42 @@ EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Debug|x64.ActiveCfg = Debug|x64
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Debug|x64.Build.0 = Debug|x64
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Debug|x86.ActiveCfg = Debug|x86
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Debug|x86.Build.0 = Debug|x86
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Release|Any CPU.Build.0 = Release|Any CPU
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Release|x64.ActiveCfg = Release|x86
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Release|x64.Build.0 = Release|x86
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Release|x86.ActiveCfg = Release|x86
{2E6AA275-D1E9-452C-B35E-E7CC6D197441}.Release|x86.Build.0 = Release|x86
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Debug|x64.ActiveCfg = Debug|x64
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Debug|x64.Build.0 = Debug|x64
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Debug|x86.ActiveCfg = Debug|x86
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Debug|x86.Build.0 = Debug|x86
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Release|Any CPU.Build.0 = Release|Any CPU
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Release|x64.ActiveCfg = Release|x86
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Release|x64.Build.0 = Release|x86
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Release|x86.ActiveCfg = Release|x86
{E04D8960-17EB-4618-BE3F-E0BEFEBA956B}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {CCA0CA58-D6FC-428A-9087-0D3C08D67AF3}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Time_Shift/Forms/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions Time_Shift/Forms/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ private void LoadMp4()
{
Knuckleball.MP4File.OnLog += Log;
NativeMethods.CreateHardLinkCMD(linkedFile, FilePath);
_info = new Mp4Data(linkedFile).Chapter;
_info = File.Exists(linkedFile) ? new Mp4Data(linkedFile).Chapter : new Mp4Data(FilePath).Chapter;
}
catch (Exception exception)
{
Expand Down Expand Up @@ -1051,7 +1051,7 @@ private void UpdateGridView(int fpsIndex = 0, bool updateFrameInfo = true)
tsProgressBar1.Value = dataGridView1.RowCount > 1 ? 66 : 33;
}

private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var rowIndex = e.RowIndex;
if (rowIndex < 0)
Expand All @@ -1063,7 +1063,7 @@ private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEvent

var chapter = row.Tag as Chapter;
Debug.Assert(chapter != null, "Chapter should not be empty");
var newValue = row.Cells[columnIndex].Value.ToString();
var newValue = row.Cells[columnIndex].Value?.ToString() ?? string.Empty;

TimeSpan newTime;
var fpsIndex = comboBox1.SelectedIndex + 1;
Expand Down Expand Up @@ -1092,7 +1092,15 @@ private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEvent
default:
break;
}
UpdateGridView(fpsIndex);
try
{
UpdateGridView(fpsIndex);
}
catch (InvalidOperationException ex)
{
Log(ex.Message);
}

void UpdateTime(TimeSpan time)
{
if (time > TimeSpan.FromDays(1))
Expand Down
12 changes: 6 additions & 6 deletions Time_Shift/Knuckleball/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@ internal enum MP4ChapterType
Nero = 4
}

[DllImport("libMP4V2.dll", CharSet = CharSet.Ansi, ExactSpelling = true, BestFitMapping = false, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[DllImport("libMP4V2.dll", CharSet = CharSet.Auto, ExactSpelling = true, BestFitMapping = false, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr MP4Read([MarshalAs(UnmanagedType.LPStr)]string fileName);

[DllImport("libMP4V2.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[DllImport("libMP4V2.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
internal static extern void MP4Close(IntPtr file);

[DllImport("libMP4V2.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[DllImport("libMP4V2.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
internal static extern void MP4Free(IntPtr pointer);

[DllImport("libMP4V2.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[DllImport("libMP4V2.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[return: MarshalAs(UnmanagedType.I4)]
internal static extern MP4ChapterType MP4GetChapters(IntPtr hFile, ref IntPtr chapterList, ref int chapterCount, MP4ChapterType chapterType);

[DllImport("libMP4V2.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[DllImport("libMP4V2.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
internal static extern long MP4GetDuration(IntPtr hFile);

[DllImport("libMP4V2.dll", CharSet = CharSet.Ansi, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
[DllImport("libMP4V2.dll", CharSet = CharSet.Auto, ExactSpelling = true, SetLastError = true, CallingConvention = CallingConvention.Cdecl)]
internal static extern int MP4GetTimeScale(IntPtr hFile);

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Time_Shift/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.33.33.33")]
[assembly: AssemblyFileVersion("2.33.33.33")]
[assembly: AssemblyVersion("2.33.33.331")]
[assembly: AssemblyFileVersion("2.33.33.331")]
4 changes: 3 additions & 1 deletion Time_Shift/Time_Shift.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand All @@ -37,7 +39,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
<Prefer32Bit>true</Prefer32Bit>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<UseVSHostingProcess>true</UseVSHostingProcess>
<CodeAnalysisRuleSet>RuleSet.ruleset</CodeAnalysisRuleSet>
Expand Down
2 changes: 1 addition & 1 deletion Time_Shift/Util/ChapterData/IfoData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public override bool Equals(object obj)

public override string ToString()
{
return $"{Hours:D2}:{Minutes:D2}:{Second:D2}.{TotalFrames} [{(IsNTSC ? 'N' : 'P')}]";
return $"{Hours:D2}:{Minutes:D2}:{Second:D2}.{TotalFrames % RawFrameRate}f [{TotalFrames}{(IsNTSC ? 'N' : 'P')}]";
}
}
}
6 changes: 5 additions & 1 deletion Time_Shift/Util/ToolKits.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public static class ToolKits
public static string Time2String(this TimeSpan time)
{
var millisecond = (int)Math.Round((time.TotalSeconds - Math.Floor(time.TotalSeconds)) * 1000);
return $"{time.Hours:D2}:{time.Minutes:D2}:{time.Seconds:D2}.{millisecond:D3}";
return $"{time.Hours:D2}:{time.Minutes:D2}:" +
(millisecond == 1000 ?
$"{time.Seconds + 1:D2}.000" :
$"{time.Seconds:D2}.{millisecond:D3}"
);
}

/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions Time_Shift_Test/Util/ToolKitsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ChapterTool.Util.ChapterData;
using FluentAssertions;

namespace ChapterTool.Util.Tests
Expand Down Expand Up @@ -41,5 +42,16 @@ public void ConvertFr2IndexTest()
frameRate.Select(ToolKits.ConvertFr2Index).ToList().ForEach(Console.Write);
frameRate.Select(ToolKits.ConvertFr2Index).Should().Equal(expected);
}

[TestMethod]
public void MillisecondRoundUp()
{
const int frame = 30989; // DVD NTSC
var timespan = new IfoTimeSpan(true) {TotalFrames = frame};
var timespanString = ((TimeSpan) timespan).Time2String();
timespanString.Should().Be("00:17:14.000");


}
}
}
Loading

0 comments on commit 6430685

Please sign in to comment.