ffmpeginteropx / FFmpegInteropX

FFmpeg decoding library for Windows 10 UWP and WinUI 3 Apps
Apache License 2.0
205 stars 52 forks source link

ASS Fixes 4: Properly handle Margins, adjust for Padding Bug and manage Margins for Abs Positioning #404

Closed softworkz closed 7 months ago

softworkz commented 8 months ago

SubtitleProviderSsaAss: Handle margins when absolute positioning
SubtitleProviderSsaAss: Reverse margins

softworkz commented 8 months ago

Explanations

WinUI Bug in Handling TimedTextPadding

I have seen that the margins from the defined styles (neither others) are not having the expected effect. Eventually I was able to trace this down to a WinUI bug for which I have submitted a fix PR now: https://github.com/microsoft/microsoft-ui-xaml/pull/9248

As long as this is not fixed, we need to workaround by switching Before/After and Start/End when using TimedTextPadding as done in this PR.

Style Margins and Dialogue Margins

The current code is ignoring margins from the style definition when only a single margin value is specified in a dialogue line. This is incorrect, as the override needs to done for each value independently (so does AegiSub).

MarginV Handling

MarginV is a top margin for top-aligned blocks and a bottom margin for bottom-aligned blocks even though the Word doc tells this for style defined margins and otherwise for dialog lines, where it talks about bottom only - which is incorrect (according to AegiSub behavior).

Handling Margins in Case of Absolute Positioning

MarginV is unused in case of absolute posiioned elements, but MarginL and MarginR still need to be applied. Unfortunately TimedTextRegions do not allow negative position values, so you already did the best of what is possible for region sizing and positioning. Only the horizontal margins were ignored. Those are now applied in a way that it resembles the behavior of AegiSub (see comments in code).