Skip to content

Commit

Permalink
Fix bug with consecutive \t tags
Browse files Browse the repository at this point in the history
  • Loading branch information
www committed Apr 4, 2021
1 parent 0a30032 commit d180548
Show file tree
Hide file tree
Showing 4 changed files with 317 additions and 162 deletions.
21 changes: 12 additions & 9 deletions YTSubConverter.Tests/Files/Transform.ass
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ Last Style Storage: Default
Video File: ?dummy:23.976000:40000:640:480:150:150:150:
Video AR Value: 1.333333
Video Zoom Percent: 0.875000
Active Line: 28
Video Position: 239
Scroll Position: 15
Active Line: 25
Video Position: 220

[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Expand All @@ -35,7 +36,7 @@ Style: Outline+Hard shadow,Roboto,15,&H00FFFFFF,&H000000FF,&H00000000,&H00000000
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:00.00,0:00:04.98,Plain,,0,0,0,,{\t(\cFF)\pos(66,33.2)}\t(\cFF){\cFFFF}\cFFFF
Dialogue: 0,0:00:00.00,0:00:04.98,Plain,,0,0,0,,{\t(\c0)\pos(255.257,33.2)}\t(\c0)
Dialogue: 0,0:00:00.00,0:00:04.98,Plain,,0,0,0,,{\t(\c0)\pos(284.957,34)}\t(\c0)
Dialogue: 0,0:00:00.00,0:00:04.98,Plain,,0,0,0,,{\k224}{\pos(67.2,58.4)}{\pos(52.2,58.4)\t(\2cFF)}\t{\k83}(\2c{\k84}FF){\k109}{\2cFFFF}\2cFFFF
Dialogue: 0,0:00:00.00,0:00:04.98,Outline,,0,0,0,,{\t(\3cFF)\pos(73.2,99.2)}\t(\3cFF){\3cFFFF}\3cFFFF
Dialogue: 0,0:00:00.00,0:00:04.98,Glow shadow,,0,0,0,,{\t(\3cFF)\pos(190.8,95.6)}\t(\3cFF){\3cFFFF}\3cFFFF
Expand All @@ -45,9 +46,10 @@ Dialogue: 0,0:00:00.00,0:00:04.98,Outline,,0,0,0,,{\t(\4cFF)\pos(68.4,153.2)}\t(
Dialogue: 0,0:00:00.00,0:00:04.98,Glow shadow,,0,0,0,,{\t(\4cFF)\pos(190.2,152)}\t(\4cFF){\4cFFFF}\4cFFFF
Dialogue: 0,0:00:00.00,0:00:04.98,Outline+Soft shadow,,0,0,0,,{\t(\4cFF)\pos(69.6,175.4)}\t(\4cFF){\4cFFFF}\4cFFFF
Dialogue: 0,0:00:00.00,0:00:04.98,Outline box,,0,0,0,,{\t(\4cFF)\pos(190.8,176)}\t(\4cFF){\4cFFFF}\4cFFFF
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\k600\t(\1cFF0000\2cFF00\3cFF\4cFFFF)\pos(171,204.4)}\t{\k1}(\1cFF0000\2cFF00\3cFF\4cFFFF)
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\k600\t(0,5000,0.5,\1cFF0000\2cFF00\3cFF\4cFFFF)\pos(171,229.6)}\t{\k1}(0,5000,0.5,\1cFF0000\2cFF00\3cFF\4cFFFF)
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\t(0,1000,\cFF)\t(1000,2000,\cFF00)\pos(171.6,263.8)}\t(0,1000,\cFF)\t(1000,2000,\cFF00)\N{\cFFFFFF}\cFFFFFF{\t(\cFFFF)}\t(\cFFFF){\t(\cFFFF00)}\t(\cFFFF00)
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\k600\t(\1cFF0000\2cFF00\3cFF\4cFFFF)\pos(116.1,204.4)}\t{\k1}(\1cFF0000\2cFF00\3cFF\4cFFFF)
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\k600\t(0,5000,0.5,\1cFF0000\2cFF00\3cFF\4cFFFF)\pos(114.6,229.6)}\t{\k1}(0,5000,0.5,\1cFF0000\2cFF00\3cFF\4cFFFF)
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\t(0,1000,\cFF)\t(1000,2000,\cFF00)\pos(112.8,263.8)}\t(0,1000,\cFF)\t(1000,2000,\cFF00)\N{\cFFFFFF}\cFFFFFF{\t(\cFFFF)}\t(\cFFFF){\t(\cFFFF00)}\t(\cFFFF00)
Dialogue: 0,0:00:00.00,0:00:04.98,Soft shadow box,,0,0,0,,{\c0\t(0,2500,\cFF)\t(2500,5000,\c0)\pos(289.2,263.8)}\c0\t(0,2500,\cFF)\t(2500,5000,\c0)\N{\t(0,2500,\cFF0000)\t(2500,5000,\c0)}\t(0,2500,\cFF0000)\t(2500,5000,\c0)
Dialogue: 0,0:00:04.98,0:00:09.99,Plain,,0,0,0,,{\t(\1aFF)\pos(51.6,33.2)}\1aFF{\1a00}\1a00
Dialogue: 0,0:00:04.98,0:00:09.99,Plain,,0,0,0,,{\k295}{\pos(52.2,58.4)\t(\2aFF)}\t{\k72}(\2a{\k64}FF){\k72}{\2a00}\2a00
Dialogue: 0,0:00:04.98,0:00:09.99,Outline,,0,0,0,,{\t(\3aFF)\pos(54,97.4)}\t(\3aFF){\3a00}\3a00
Expand All @@ -58,9 +60,10 @@ Dialogue: 0,0:00:04.98,0:00:09.99,Outline,,0,0,0,,{\t(\4aFF)\pos(51.6,155)}\t(\4
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow,,0,0,0,,{\t(\4aFF)\pos(151.8,153.2)}\t(\4aFF){\4a00}\4a00
Dialogue: 0,0:00:04.98,0:00:09.99,Outline+Soft shadow,,0,0,0,,{\t(\4aFF)\pos(43.2,181.4)}\t(\4aFF){\4a00}\4a00
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow box,,0,0,0,,{\t(\4aFF)\pos(152.4,180.2)}\t(\4aFF){\4a00}\4a00
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow box,,0,0,0,,{\3c&HD90016&\t(\alphaFF)\pos(291.6,160.4)}\t(\alphaFF){\alpha00}\alpha00
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow box,,0,0,0,,{\3c&HD90016&\t(\3cFF\alphaFF)\pos(291.6,160.4)}\t(\3cFF\alphaFF){\alpha00}\alpha00
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow box,,0,0,0,,{\k600\t(\1a40\2a80\3aC0\4aFF)\pos(172.2,210.4)}\t{\k1}(\1a40\2a80\3aC0\4aFF)
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow box,,0,0,0,,{\k600\t(0,5000,0.5,\1a40\2a80\3aC0\4aFF)\pos(172.2,234)}\t{\k1}(0,5000,0.5,\1a40\2a80\3aC0\4aFF)
Dialogue: 0,0:00:04.98,0:00:09.99,Soft shadow box,,0,0,0,,{\t(0,1000,\1a80)\t(1000,2000,\1a00)\pos(172.2,263.4)}\t(0,1000,\1a80)\t(1000,2000,\1a00)\N{\1a00}\1a00{\t(\1a80)}\t(\1a80){\t(\1aFF)}\t(\1aFF)
Dialogue: 0,0:00:09.99,0:00:15.04,Hard shadow,,0,0,0,,{\fs15\t(1000,3000,\fs30.5)}\t(1000,3000,\fs30.5){\r}\r
Dialogue: 0,0:00:09.99,0:00:15.04,Hard shadow,,0,0,0,,{\fs15\t(1000,3000,0.5,\fs30.5)\pos(192,186)}\t(1000,3000,0.5,\fs30.5){\r}\r
Dialogue: 0,0:00:09.99,0:00:15.04,Hard shadow,,0,0,0,,{\fs15\t(1000,3000,\fs30.5)\pos(192,84)}\t(1000,3000,\fs30.5){\r}\r
Dialogue: 0,0:00:09.99,0:00:15.04,Hard shadow,,0,0,0,,{\fs15\t(0,2500,\fs30)\t(2500,5000,\fs15)\pos(192,193.6)}\t(0,2500,\fs30)\t(2500,5000,\fs15)\N{\t(0,2500,\fs7)\t(2500,5000,\fs15)}\t(0,2500,\fs7)\t(2500,5000,\fs15)
Dialogue: 0,0:00:09.99,0:00:15.04,Hard shadow,,0,0,0,,{\fs15\t(1000,3000,0.5,\fs30.5)\pos(192,114)}\t(1000,3000,0.5,\fs30.5){\r}\r
450 changes: 299 additions & 151 deletions YTSubConverter.Tests/Files/Transform.ytt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions YTSubConverter.UI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.1")]
[assembly: AssemblyFileVersion("1.5.1")]
[assembly: AssemblyVersion("1.5.2")]
[assembly: AssemblyFileVersion("1.5.2")]
[assembly: InternalsVisibleTo("YTSubConverter.Tests")]
4 changes: 4 additions & 0 deletions YTSubConverter/Formats/Ass/Tags/AssTransformTagHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ private static void HandleTransformFontSizeTag(AssTagContext context, DateTime s
return;

AssSection section = context.Section;
section.Animations.RemoveAll(a => a is ScaleAnimation && a.StartTime >= startTime);

ScaleAnimation prevAnim = section.Animations.OfType<ScaleAnimation>().LastOrDefault();
float startScale = prevAnim?.EndScale ?? context.Section.Scale;
float endScale = lineHeight / context.Document.DefaultStyle.LineHeight;
Expand Down Expand Up @@ -250,6 +252,8 @@ Func<DateTime, DateTime, Color, T> createAnim
)
where T : ColorAnimation
{
context.Section.Animations.RemoveAll(a => a is T && a.StartTime > startTime);

AssSection section = context.Section;
IEnumerable<T> existingAnims = section.Animations.OfType<T>().Where(a => a.StartTime == startTime && a.EndTime == endTime);
if (predicate != null)
Expand Down

0 comments on commit d180548

Please sign in to comment.