Skip to content

Commit

Permalink
part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
emotion3459 committed Oct 23, 2024
1 parent 9c6c24f commit 9946660
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions vsexprtools/exprop.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,37 @@ class ExprTokenBase(str):

class ExprToken(ExprTokenBase, CustomEnum):
LumaMin = 'ymin'
ChromaMin = 'cmin'
LumaMax = 'ymax'
ChromaMin = 'cmin'
ChromaMax = 'cmax'
FormatMin = 'fmin'
FormatMax = 'fmax'
Neutral = 'neutral'
RangeSize = 'range_size'

@property
def is_chroma(self) -> bool:
return 'chroma' in self._name_.lower()

def get_value(self, clip: vs.VideoNode, chroma: bool = False, range_in: ColorRange = ColorRange.LIMITED) -> float:
def get_value(self, clip: vs.VideoNode) -> float:
if self is ExprToken.LumaMin:
return get_lowest_value(clip, False)
return get_lowest_value(clip)

if self is ExprToken.LumaMax:
return get_peak_value(clip)

if self is ExprToken.ChromaMin:
return get_lowest_value(clip, True)

if self is ExprToken.LumaMax:
return get_peak_value(clip, False)

if self is ExprToken.ChromaMax:
return get_peak_value(clip, True)

if self is ExprToken.FormatMin:
return get_lowest_value(clip, range_in=ColorRange.FULL)

if self is ExprToken.FormatMax:
return get_peak_value(clip, range_in=ColorRange.FULL)

if self is ExprToken.Neutral:
return get_neutral_value(clip)

Expand Down

0 comments on commit 9946660

Please sign in to comment.