@@ -94,7 +94,7 @@ def get_subsampling(clip: vs.VideoNode, /) -> Union[None, str]:
9494 raise ValueError ('Unknown subsampling.' )
9595
9696
97- def get_w (height : int , aspect_ratio : float = 16 / 9 , * , only_even : bool = True , mod4 : bool = False ) -> int :
97+ def get_w (height : int , aspect_ratio : float = 16 / 9 , * , only_even : Optional [ bool ] = None , mod : Optional [ int ] = None ) -> int :
9898 """Calculates the width for a clip with the given height and aspect ratio.
9999
100100 >>> get_w(720)
@@ -107,17 +107,22 @@ def get_w(height: int, aspect_ratio: float = 16 / 9, *, only_even: bool = True,
107107 :param only_even: Will return the nearest even integer.
108108 ``True`` by default because it imitates the math behind most standard resolutions
109109 (e.g. 854x480).
110- :param mod4: Ensure output is mod4, for when subsampling and/or interlacing require it.
111- Implies ``only_even`` as mod4 is always even as well.
110+ This parameter has been deprecated in favor of the ``mod`` param. For old behavior
111+ use ``mod=2`` for ``True`` and ``mod=1`` for ``False``
112+ :param mod: Ensure output is divisible by this number, for when subsampling or filter
113+ restrictions set specific requirements (e.g. 4 for interlaced content).
114+ Defaults to 2 to mimic the math behind most standard resolutions.
115+ Any values passed to this argument will override ``only_even`` behavior!
112116
113117 :return: Calculated width based on input `height`.
114118 """
115119 width = height * aspect_ratio
116- if mod4 :
117- return round (width / 4 ) * 4
118- if only_even :
119- return round (width / 2 ) * 2
120- return round (width )
120+ if only_even is not None :
121+ import warnings
122+ warnings .warn ("only_even is deprecated." , DeprecationWarning )
123+
124+ mod = func .fallback (mod , 2 if only_even in [None , True ] else 1 )
125+ return round (width / mod ) * mod
121126
122127
123128def is_image (filename : str , / ) -> bool :
0 commit comments