Skip to content

Commit

Permalink
ChromaLocation.from_res: Always return LEFT
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LightArrowsEXE committed Oct 10, 2024
1 parent 086af43 commit 9f91ef5
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions vstools/enums/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 9f91ef5

Please sign in to comment.