From 9f91ef55790ee74fed1ec7ad650b326e1556c0d3 Mon Sep 17 00:00:00 2001 From: LightArrowsEXE Date: Thu, 10 Oct 2024 19:26:03 +0200 Subject: [PATCH] ChromaLocation.from_res: Always return LEFT The decision to always return LEFT is simple: Every regular format expects LEFT. The only exception is UHD, but only if that has HDR. SDR streams are explicitly tagged as being LEFT in rips we've checked. As we've decided with Matrix.from_res, the onus should be on the user to ensure their UHD sources are properly tagged. --- vstools/enums/generic.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/vstools/enums/generic.py b/vstools/enums/generic.py index 7530b51..bed638f 100644 --- a/vstools/enums/generic.py +++ b/vstools/enums/generic.py @@ -28,7 +28,8 @@ def _missing_(cls: type[ChromaLocation], value: Any) -> ChromaLocation | None: return cls.LEFT if value > cls.BOTTOM: - raise UnsupportedChromaLocationError(f'ChromaLocation({value}) is unsupported.', cls) + raise UnsupportedChromaLocationError( + f'ChromaLocation({value}) is unsupported.', cls) return None @@ -48,16 +49,6 @@ def from_res(cls, frame: vs.VideoNode | vs.VideoFrame) -> ChromaLocation: :return: ChromaLocation object. """ - from .color import Matrix, Primaries, Transfer - - matrix, transfer, primaries = Matrix(frame), Transfer(frame), Primaries(frame) - - if ( - primaries == Primaries.BT2020 - or matrix in (Matrix.BT2020CL, Matrix.BT2020NCL) - or transfer in (Transfer.BT2020_10, Transfer.BT2020_12) - ): - return ChromaLocation.TOP_LEFT return ChromaLocation.LEFT @@ -92,7 +83,8 @@ def get_offsets( if isinstance(chroma_loc, vs.VideoNode): assert chroma_loc.format - subsampling = (chroma_loc.format.subsampling_w, chroma_loc.format.subsampling_h) + subsampling = (chroma_loc.format.subsampling_w, + chroma_loc.format.subsampling_h) if subsampling in [(1, 0), (1, 1)]: offsets = (0.5, 0) @@ -131,7 +123,8 @@ def _missing_(cls: type[FieldBased], value: Any) -> FieldBased | None: return cls.PROGRESSIVE if value > cls.TFF: - raise UnsupportedFieldBasedError(f'FieldBased({value}) is unsupported.', cls) + raise UnsupportedFieldBasedError( + f'FieldBased({value}) is unsupported.', cls) return None