diff options
| author | NoFear0411 <9083405+NoFear0411@users.noreply.github.com> | 2026-03-01 00:00:05 +0400 |
|---|---|---|
| committer | NoFear0411 <9083405+NoFear0411@users.noreply.github.com> | 2026-03-01 00:00:05 +0400 |
| commit | bc316b3dc855e93d4d11e2c0d73d70326c38b889 (patch) | |
| tree | 02a37bcafd0465cced81f2fca26aa651098133de /tests | |
| parent | e6d73ae367e9179779114c4e292dee1f5431a1d9 (diff) | |
Fix near-1:1 SAR values falsely flagged as anamorphic
Encoders sometimes produce sample aspect ratios like 3201:3200
(0.03% off square) for content that has effectively square pixels.
The exact string comparison against "1:1" marks these as anamorphic,
which triggers unnecessary transcoding on clients that require
non-anamorphic video.
Parse the SAR ratio numerically and treat values within 1% of 1:1
as square pixels. This threshold is well clear of the nearest real
anamorphic SAR (PAL 4:3 at 16:15 = 6.67% off).
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs b/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs index 8a2f84734..40f853699 100644 --- a/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs +++ b/tests/Jellyfin.MediaEncoding.Tests/Probing/ProbeResultNormalizerTests.cs @@ -39,6 +39,23 @@ namespace Jellyfin.MediaEncoding.Tests.Probing public void GetFrameRate_Success(string value, float? expected) => Assert.Equal(expected, ProbeResultNormalizer.GetFrameRate(value)); + [Theory] + [InlineData("1:1", true)] // exact square pixels + [InlineData("3201:3200", true)] // 0.03% off — encoder rounding artifact (4K HEVC) + [InlineData("1215:1216", true)] // 0.08% off — encoder rounding artifact + [InlineData("1001:1000", true)] // 0.1% off — encoder rounding artifact + [InlineData("16:15", false)] // 6.67% off — PAL DVD 4:3, genuinely anamorphic + [InlineData("8:9", false)] // 11.1% off — NTSC DVD 4:3 + [InlineData("32:27", false)] // 18.5% off — NTSC DVD 16:9 + [InlineData("10:11", false)] // 9.1% off — DV NTSC + [InlineData("64:45", false)] // 42.2% off — PAL DVD 16:9 + [InlineData("4:3", false)] // 33.3% off — classic anamorphic + [InlineData("0:1", false)] // invalid/unknown SAR + [InlineData("", false)] // empty + [InlineData(null, false)] // null + public void IsNearSquarePixelSar_DetectsCorrectly(string sar, bool expected) + => Assert.Equal(expected, ProbeResultNormalizer.IsNearSquarePixelSar(sar)); + [Fact] public void GetMediaInfo_MetaData_Success() { @@ -123,6 +140,7 @@ namespace Jellyfin.MediaEncoding.Tests.Probing Assert.Equal(358, res.VideoStream.Height); Assert.Equal(720, res.VideoStream.Width); Assert.Equal("2.40:1", res.VideoStream.AspectRatio); + Assert.True(res.VideoStream.IsAnamorphic); // SAR 32:27 — genuinely anamorphic NTSC DVD 16:9 Assert.Equal("yuv420p", res.VideoStream.PixelFormat); Assert.Equal(31d, res.VideoStream.Level); Assert.Equal(1, res.VideoStream.RefFrames); |
