fix: Improve width matching tolerance for cinema/ultrawide aspect ratios in MediaInfoExtractor; add test for 2160p scope resolution

This commit is contained in:
sha
2026-04-13 14:56:38 +03:00
parent b3c8580789
commit 4b90abb457
5 changed files with 17 additions and 7 deletions
+5 -2
View File
@@ -249,11 +249,14 @@ class MediaInfoExtractor:
effective_height = height
# First, try to match width to typical widths
# Use a larger tolerance (10 pixels) to handle cinema/ultrawide aspect ratios
# Use proportional tolerance (2% of typical width, min 10px) to handle
# cinema/ultrawide aspect ratios where encoded width may differ slightly
# (e.g. 3820×1592 scope 4K → 2160p, not a non-standard 1592p)
width_matches = []
for frame_class, info in FRAME_CLASSES.items():
for tw in info["typical_widths"]:
if abs(width - tw) <= 10 and frame_class.endswith(scan_type):
width_tolerance = max(10, int(tw * 0.02))
if abs(width - tw) <= width_tolerance and frame_class.endswith(scan_type):
diff = abs(height - info["nominal_height"])
width_matches.append((frame_class, diff))
@@ -154,5 +154,12 @@
"interlaced": false,
"expected_frame_class": "1080p",
"testname": "test-mistakenly-high-height-2"
},
{
"testname": "test-2160p-scope-240",
"resolution": [3820, 1592],
"interlaced": false,
"expected_frame_class": "2160p",
"description": "4K cinema scope 2.40:1 - width slightly under 3840, height non-standard 1592"
}
]