funcs ¶
Classes:
-
FunctionUtil–Function util to normalize common actions and boilerplate often used in functions.
FunctionUtil ¶
FunctionUtil(
clip: VideoNode,
func: FuncExcept,
planes: Planes = None,
color_family: VideoFormatLike
| HoldsVideoFormat
| HoldsNumpyFormat
| ColorFamily
| Iterable[
VideoFormatLike | HoldsVideoFormat | HoldsNumpyFormat | ColorFamily
]
| None = None,
bitdepth: int | range | tuple[int, int] | set[int] | None = None,
*,
matrix: MatrixLike | None = None,
transfer: TransferLike | None = None,
primaries: PrimariesLike | None = None,
range_in: RangeLike | None = None,
chromaloc: ChromaLocationLike | None = None,
order: FieldBasedLike | None = None,
)
Function util to normalize common actions and boilerplate often used in functions.
Main use is:
- Automatically dither up and down as required.
- Automatically check if the input clip has variable formats, resolutions, etc.
- Fully type safe and removes the need for asserts or typeguards in function code.
- Handy properties for common code paths, improving code readability and writability.
Examples:
func = FunctionUtil(clip, planes=0, color_family=(vs.YUV, vs.GRAY), bitdepth=16)
wclip = func.work_clip
txt = wclip.text.Text("This clip has been processed!")
return func.return_clip(txt)
For further examples, see: https://github.com/search?q=org%3AJaded-Encoding-Thaumaturgy+FunctionUtil
Initializes the class.
Parameters:
-
(clip¶VideoNode) –Clip to process.
-
(func¶FuncExcept) –Function returned for custom error handling. This should only be set by VS package developers.
-
(planes¶Planes, default:None) –Planes that get processed in the function. Default: All planes.
-
(color_family¶VideoFormatLike | HoldsVideoFormat | HoldsNumpyFormat | ColorFamily | Iterable[VideoFormatLike | HoldsVideoFormat | HoldsNumpyFormat | ColorFamily] | None, default:None) –Accepted color families. If the input does not adhere to these, an exception will be raised. Default: All families.
-
(bitdepth¶int | range | tuple[int, int] | set[int] | None, default:None) –The bitdepth or range of bitdepths to work with. Can be an int, range, tuple, or set. Range or tuple indicates a range of allowed bitdepths, set indicates specific allowed bitdepths. If an int is provided, set the clip's bitdepth to that value.
If a range or set is provided and the work clip's bitdepth is not allowed, the work clip's bitdepth will be converted to the lowest bitdepth that is greater than or equal to the work clip's current bitdepth.
return_clip automatically restores the clip to the original bitdepth.
If None, use the input clip's bitdepth. Default: None.
-
(matrix¶MatrixLike | None, default:None) –Color Matrix to work in. Used for YUV <-> RGB conversions. Default: Get matrix from the input clip.
-
(transfer¶TransferLike | None, default:None) –Transfer to work in. Default: Get transfer from the input clip.
-
(primaries¶PrimariesLike | None, default:None) –Color primaries to work in. Default: Get primaries from the input clip.
-
(range_in¶RangeLike | None, default:None) –Color Range to work in. Default: Get the color range from the input clip.
-
(chromaloc¶ChromaLocationLike | None, default:None) –Chroma location to work in. Default: Get the chroma location from the input clip.
-
(order¶FieldBasedLike | None, default:None) –Field order to work in. Default: Get the field order from the input clip.
Methods:
-
chroma_planes–Get a list of all chroma planes in the normalised clip.
-
chromaloc–Get the clip's chroma location.
-
color_range–Get the clip's range.
-
matrix–Get the clip's matrix.
-
norm_clip–Get a "normalized" clip. This means color space and bitdepth are converted if necessary.
-
norm_seq–Normalize a value or sequence to a list mapped to the clip's planes.
-
normalize_planes–Normalize the given sequence of planes.
-
order–Get the clip's field order.
-
primaries–Get the clip's primaries.
-
return_clip–Merge back the chroma if necessary and convert the processed clip back to the original clip's format.
-
transfer–Get the clip's transfer.
-
with_planes– -
without_planes– -
work_clip–Get the "work clip" as specified from the input planes.
Attributes:
-
allowed_cfamilies– -
bitdepth– -
cfamily_converted– -
chroma(bool) –Whether any chroma planes get processed.
-
chroma_only(bool) –Whether only chroma planes get processed.
-
chroma_pplanes(list[int]) –A list of which chroma planes get processed based on the work clip.
-
clip– -
func– -
is_float(bool) –Whether the clip is of a float sample type.
-
is_hd(bool) –Whether the clip is of an HD resolution (>= 1280x720).
-
is_integer(bool) –Whether the clip is of an integer sample type.
-
luma(bool) –Whether the luma gets processed.
-
luma_only(bool) –Whether luma is the only channel that gets processed.
-
norm_planes– -
num_planes– -
planes–
Source code in vstools/functions/funcs.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
chroma_pplanes property ¶
A list of which chroma planes get processed based on the work clip.
This means that if you pass [0, 1, 2] but passed a GRAY clip, it will only return [0]. Similarly, if you pass GRAY and it gets converted to RGB, this will return [0, 1, 2].
chroma_planes ¶
chroma_planes() -> list[VideoNode]
Get a list of all chroma planes in the normalised clip.
Source code in vstools/functions/funcs.py
196 197 198 199 200 201 202 203 204 205 | |
chromaloc ¶
chromaloc() -> ChromaLocation
Get the clip's chroma location.
Source code in vstools/functions/funcs.py
239 240 241 242 243 244 245 | |
color_range ¶
color_range() -> Range
Get the clip's range.
Source code in vstools/functions/funcs.py
231 232 233 234 235 236 237 | |
matrix ¶
matrix() -> Matrix
Get the clip's matrix.
Source code in vstools/functions/funcs.py
207 208 209 210 211 212 213 | |
norm_clip ¶
norm_clip() -> VideoNode
Get a "normalized" clip. This means color space and bitdepth are converted if necessary.
Source code in vstools/functions/funcs.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 | |
norm_seq ¶
Normalize a value or sequence to a list mapped to the clip's planes.
Unprocessed planes will be set to the given "null" value.
Source code in vstools/functions/funcs.py
367 368 369 370 371 372 373 374 | |
normalize_planes ¶
Normalize the given sequence of planes.
Source code in vstools/functions/funcs.py
322 323 324 325 326 327 | |
order ¶
order() -> FieldBased
Get the clip's field order.
Source code in vstools/functions/funcs.py
247 248 249 250 251 252 253 | |
primaries ¶
primaries() -> Primaries
Get the clip's primaries.
Source code in vstools/functions/funcs.py
223 224 225 226 227 228 229 | |
return_clip ¶
Merge back the chroma if necessary and convert the processed clip back to the original clip's format.
If bitdepth != None, the bitdepth will also be converted if necessary.
Parameters:
-
(processed¶VideoNode) –The clip with all the processing applied to it.
-
(prop_src¶VideoNode | None, default:None) –Optional clip to copy frame properties from.
Returns:
-
VideoNode–Processed clip converted back to the original input clip's format.
Source code in vstools/functions/funcs.py
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | |
transfer ¶
transfer() -> Transfer
Get the clip's transfer.
Source code in vstools/functions/funcs.py
215 216 217 218 219 220 221 | |
with_planes ¶
Source code in vstools/functions/funcs.py
329 330 | |
without_planes ¶
Source code in vstools/functions/funcs.py
332 333 | |
work_clip ¶
work_clip() -> VideoNode
Get the "work clip" as specified from the input planes.
Source code in vstools/functions/funcs.py
188 189 190 191 192 193 194 | |