User:Raffriff42/Utils-r41 Quick Reference
From Avisynth wiki
< User:Raffriff42(Difference between revisions)
Raffriff42 (Talk | contribs) m (update) |
Raffriff42 (Talk | contribs) (v2017-11-20 condensed summary) |
||
Line 1: | Line 1: | ||
<div style="max-width:62em" > | <div style="max-width:62em" > | ||
+ | ==== {{AvsPluscon}} utilities ==== | ||
− | ''' | + | :Download: '''[[media:Utils-r41.avsi|Utils-r41.avsi]]''' |
+ | <br> | ||
− | + | ==== Some of the most useful functions (a short selection) ==== | |
− | === | + | ===== sc8f ===== |
− | - | + | :* Scale an 8-bit value for target clip {{FuncArg|T}} |
− | {{ | + | :: [[Autoscale_parameter|Autoscale]] filter arguments to [[Deep_Color|high bit depth]]. Used in ''eg'', [[#LevelsPlus|LevelsPlus]]. |
− | {{ | + | :: This function provides the basis for two others which are more useful in practice (see full script): |
− | + | ::*'''sc8x''' – int result, clamped to legal range | |
+ | ::*'''sc8s''' – string result, suitable for use in [[MaskTools2|MaskTools]] expressions | ||
+ | :: For example, if clip {{FuncArg|C}}'s bit depth = 10, <span style="font-size:104%"><code>C.sc8x('''255''')</code></span> == <span style="font-size:96%">''255'' × 2<sup>(''10''-8)</sup> == 1023</span>. | ||
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ T - clip with target bit depth | ||
+ | ## @ f - argument; 0_255 scale | ||
+ | ## @ cx - if true, clamp output to legal range | ||
+ | ## @ returns float if not clamped; | ||
+ | ## else returns int for int formats, float for float | ||
+ | ## | ||
+ | function sc8f(clip T, float f, bool "cx") | ||
+ | </div> | ||
− | === | + | ===== ToRGB ===== |
− | + | :* Convert from anything to planar RGB[A] | |
− | {{ | + | :: Attempts YUV'''→'''RGB conversion with best possible quality; |
− | + | :: hides the details of conversion from [[Interleaved]] to [[Planar]]. | |
− | + | <div {{BoxWidthIndent|56|2}} > | |
+ | ## @ matrix - ignored if not converting from YUV; default "Rec601" | ||
+ | ## @ bits_out - output bit depth, one of (8|10|12|14|16); default same as source | ||
+ | ## @ A - if supplied, becomes the alpha channel of the resulting clip; | ||
+ | ## overrides any existing alpha channel. | ||
+ | ## * if 'A' is RGBA or YUVA, the A channel is used; | ||
+ | ## * if 'A' YUV or Y-only, the Y channel is used; | ||
+ | ## * if 'A' == "none", any existing alpha channel is removed; | ||
+ | ## * if 'A' == "add", a new opaque alpha channel is added; | ||
+ | ## * else, 'A' is ignored. | ||
+ | ## | ||
+ | function ToRGB(clip C, string "matrix", int "bits_out", clip "A") | ||
+ | </div> | ||
− | {{ | + | ===== To444 ===== |
− | + | :* Convert from anything to YUV[A]444 | |
− | + | :: Attempts RGB'''→'''YUV conversion with best possible quality; | |
+ | :: hides the details of conversion from [[Interleaved]] to [[Planar]]. | ||
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ matrix - ignored if not converting from RGB; default "Rec601" | ||
+ | ## @ bits_out - output bit depth, one of (8|10|12|14|16); default same as source | ||
+ | ## @ A - if supplied, becomes the alpha channel of the resulting clip; | ||
+ | ## overrides any existing alpha channel. | ||
+ | ## * if 'A' is RGBA or YUVA, the A channel is used; | ||
+ | ## * if 'A' YUV or Y-only, the Y channel is used; | ||
+ | ## * if 'A' == "none", any existing alpha channel is removed; | ||
+ | ## * if 'A' == "add", a new opaque alpha channel is added; | ||
+ | ## * else, 'A' is ignored. | ||
+ | ## | ||
+ | ## Return YUV(A)444, max 16-bit (no float output) | ||
+ | ## | ||
+ | function To444(clip C, string "matrix", int "bits_out", clip "A") | ||
+ | </div> | ||
− | + | ===== To16bit ===== | |
− | {{ | + | :* Convert from anything to best equivalent 16-bit version; no RGB'''↔'''YUV conversions |
− | + | <div {{BoxWidthIndent|56|2}} > | |
+ | ## @ A - if supplied, becomes the alpha channel of the resulting clip; | ||
+ | ## overrides any existing alpha channel. | ||
+ | ## * if 'A' is RGBA or YUVA, the A channel is used; | ||
+ | ## * if 'A' YUV or Y-only, the Y channel is used; | ||
+ | ## * else, 'A' is ignored. | ||
+ | ## | ||
+ | ## Returns: | ||
+ | ## any RGB(A) -> RGB(A)P16 | ||
+ | ## any 444 -> YUV(A)444P16 | ||
+ | ## any 422 -> YUV(A)422P16 | ||
+ | ## any 420 -> YUV(A)420P16 | ||
+ | ## any Yxx -> YxxP16 // no alpha | ||
+ | ## | ||
+ | function To16bit(clip C, clip "A") | ||
+ | </div> | ||
− | + | ===== To8bit ===== | |
− | {{ | + | :* Convert from anything to 'best' (v2.6.x compatible) equivalent 8-bit version |
− | : | + | :: Automatically converts [[Avisynthplus_color_formats|Planar RGB]] to RGB24/RGB32; removes any [[Avisynthplus_color_formats|alpha channel on YUV]]. |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ dither - if true, add dither when applicable; default false | ||
+ | ## | ||
+ | ## Returns: | ||
+ | ## any RGBA -> RGB32 | ||
+ | ## any RGB -> RGB24 | ||
+ | ## any 444 -> YV24 | ||
+ | ## any 422 -> YUY2 | ||
+ | ## any 420 -> YV12 | ||
+ | ## any Yxx -> Y8 | ||
+ | ## YV411 (no change) | ||
+ | ## (no YUVA output, so save your alpha channel elsewhere) | ||
+ | ## | ||
+ | function To8bit(clip C, bool "dither") | ||
+ | </div> | ||
− | === | + | ===== ToVdubFM ===== |
− | + | :* Make minimal color format conversion needed to view in [https://sourceforge.net/projects/vdfiltermod/ VirtualDub FilterMod]. | |
− | {{ | + | <div {{BoxWidthIndent|56|2}} > |
− | + | ## @ dither - if true, reduce bit depth to 8 bit with dithering if applicable; | |
− | : | + | ## default false |
+ | ## | ||
+ | ## vdubFM does not currently (AFAIK) support all AVS+ color spaces; | ||
+ | ## ToVdubFM does minimally-destructive translation | ||
+ | ## per docs, vdubFM accepts: | ||
+ | ## 10-bit 422 (v210 interleaved) | ||
+ | ## 16-bit 422, 444, 420 (planar) | ||
+ | ## 16-bit RGBA | ||
+ | ## this filter returns: | ||
+ | ## 8-bit formats unchanged, except YV411->YV420 | ||
+ | ## 10-bit 422 (planar, not interleaved) | ||
+ | ## 16-bit 422 (planar) | ||
+ | ## 16-bit RGBA | ||
+ | ## | ||
+ | function ToVdubFM(clip C, bool "dither") | ||
+ | </div> | ||
− | {{ | + | ===== MatchColorFormat ===== |
− | {{ | + | :* Match color format of source {{FuncArg|C}} to template {{FuncArg|T}} |
− | : | + | :: Useful when temporarily changing color format and to splice disparate clips together. |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ matrix - ignored if not converting between RGB<>YUV; default "Rec601" | ||
+ | ## @ keepbits - if true, retain original bit depth; | ||
+ | ## else (default) force bit depth to match 'T' | ||
+ | ## @ dither - if true, add dither when converting to lower bit depth; default false | ||
+ | ## | ||
+ | function MatchColorFormat(clip C, clip T, string "matrix", | ||
+ | \ bool "keepbits", bool "dither") | ||
+ | </div> | ||
− | {{ | + | ===== MatchAudioFormat ===== |
− | {{ | + | :* Match audio properties of source {{FuncArg|C}} to template {{FuncArg|T}} |
− | : [[ | + | :: For ease of splicing, interleaving etc. |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## Properties matched: | ||
+ | ## number of channels (see note), bit depth, | ||
+ | ## sample rate (if allowresample=true) | ||
+ | ## | ||
+ | ## AudioChannels handling: | ||
+ | ## if 'T' has no audio, returns 'C'.KillAudio; | ||
+ | ## if 'C' has no audio, copies silenced audio from 'T'; | ||
+ | ## if 'T' and 'C' have the same channel count, no change is made; | ||
+ | ## if 'T' has 1 channel, returns 'C'.ConvertToMono; | ||
+ | ## if 'T' has 2 channels and 'C' has 1, returns 'C' with split mono; | ||
+ | ## otherwise, an error is raised (manual intervention is needed) | ||
+ | ## | ||
+ | ## @ allowresample - if true, resample audio to match template if needed; | ||
+ | ## if false (the default), use [[AssumeSampleRate]], | ||
+ | ## which may affect audio/video sync. | ||
+ | ## | ||
+ | function MatchAudioFormat(clip C, clip T, bool "allowresample") | ||
+ | </div> | ||
− | + | ===== remove_gamma ===== | |
− | + | :* Remove [[wikipedia:sRGB|sRGB]] gamma transfer function (if bit depth > 8) | |
− | : | + | :: Improves appearance of certain filters like [[Resize]]; must call [[#restore_gamma|restore_gamma]] before final output; requires [[MaskTools2|MaskTools]] v2.2.x |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ enable - default true; if false, do nothing (bypass) | ||
+ | function remove_gamma(clip C, bool enable) | ||
+ | </div> | ||
− | {{ | + | ===== restore_gamma ===== |
− | + | :* Apply standard gamma transfer function (if bit depth > 8) | |
− | + | :: Reverses effect of [[#remove_gamma|remove_gamma]]. | |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ enable - default true; if false, do nothing (bypass) | ||
+ | function restore_gamma(clip C, bool enable) | ||
+ | </div> | ||
− | {{ | + | ===== LevelsPlus ===== |
− | {{ | + | :* Scale [[D_Notation|0-255]]{{D}} [[Levels]] arguments to current bit depth. |
− | + | :: {{FuncArg|coring}}=''false'' by default. | |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | function LevelsPlus(clip C, | ||
+ | \ int input_low, float gamma, int input_high, | ||
+ | \ int output_low, int output_high, | ||
+ | \ bool "coring", bool "dither") | ||
+ | </div> | ||
− | {{ | + | ===== ScaleSize ===== |
− | + | :* Switch (or fade) between three [[Resize]] clips depending on scale factor. | |
− | : | + | :: Resizers may be user-specified; default resizers are [[#remove_gamma|gamma-aware]]. |
+ | ::* default 'small' (< 65%) resizer: gamma-aware <tt>[[BicubicResize]] (b=-0.5, c=0.25)</tt> | ||
+ | ::* default 'medium' resizer: gamma-aware <tt>[[Spline64Resize]]</tt> | ||
+ | ::* default 'large' (> 133%) resizer: gamma-aware <tt>[[GaussResize]] (p=50)</tt> | ||
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ fwid - new width | ||
+ | ## @ fhgt - new height | ||
+ | ## (if 'fwid' <= 0, it is calculated from 'fhgt' and aspect ratio) | ||
+ | ## (if 'fhgt' <= 0, it is calculated from 'fwid' and aspect ratio) | ||
+ | ## (if both <= 0, an error is raised) | ||
+ | ## @ mod - new size modulo; if <= 0, | ||
+ | ## 'mod'=1 if source is RGB or YUV 4:4:4 or Y-only; else 'mod'=2 | ||
+ | ## | ||
+ | ## (see script for more, advanced options) | ||
+ | ## | ||
+ | function ScaleSize(clip C, float fwid, float fhgt, int mod, | ||
+ | \ string "sm", string "med", string "lg", | ||
+ | \ float "thrSm", float "thrLg", bool "fade", bool "ident", bool "gamma") | ||
+ | </div> | ||
− | {{ | + | ===== CropEx ===== |
− | + | :* Symmetrically [[Crop|crop]] or [[AddBorders|expand]] a clip to ensure it is a certain size, with size forced to [[Modulo|mod]]-4, mod-8 etc. | |
− | : | + | :: Quick & easy way to [[Splice|splice]] or [[StackHorizontal|stack]] disparate clips together. |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ wid, hgt - New desired width & height (will be rounded to nearest 'mod') | ||
+ | ## @ mod - [[Mod]] value; one of (1|2|4|8|16|32); default 2 | ||
+ | ## @ border - Border color; default 0 (black border) | ||
+ | ## @ mode - Expand method: (extend|mirror|blur|border) | ||
+ | ## default/fallback="border" | ||
+ | ## @ dx, dy - Shift output in x/y direction. Positive = right/down. Default 0. | ||
+ | ## Note output shift rounded to nearest mod-2 unless 'mod'=1. | ||
+ | ## | ||
+ | function CropEx(clip C, float wid, float hgt, int "mod", | ||
+ | \ int "border", string "mode", | ||
+ | \ int "dx", int "dy", bool "debug") | ||
+ | </div> | ||
− | + | ===== EvalShow ===== | |
− | + | :* [[Internal_functions/Eval#Eval|Evaluate]] a script snippet; display the script and its result on screen. | |
− | : | + | <div {{BoxWidthIndent|56|2}} > |
+ | ## @ s - a snippet of AviSynth code; any string allowed as an argument to [[Internal_functions/Eval#Eval|Eval]]. | ||
+ | ## @ size, align - cf. [[Subtitle]]. 'size' is quite small by default; | ||
+ | ## you may prefer size=24. Disable subtitle w/ size = 0. | ||
+ | ## @ opacity - 1.0 = opaque text, 0.0 = transparent. Default 0.7 | ||
+ | ## | ||
+ | function EvalShow(clip C, string s, float "size", int "align", float "opacity") | ||
+ | </div> | ||
− | {{ | + | ===== Grayramp ===== |
− | {{ | + | :* Return grayscale ramp clip w/ same specs as template clip {{FuncArg|T}} |
− | + | :: Useful for measuring luma response curve when used in combination with [[#HistogramTurn|HistogramTurn]]. | |
+ | :: See script for ''ColorRampEx'' – ramp between any two colors. | ||
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ T - Any color format (8, 10, 12, 14 or 16-bit); | ||
+ | ## determines all properties except Height. | ||
+ | ## @ height - default 80 | ||
+ | ## @ zigs - if true, 8 pixels on left and right reverse ramp direction; | ||
+ | ## useful for determining whether clipping has occurred. | ||
+ | ## @ stack - if true, stack on top of clip 'T'; | ||
+ | ## resulting audio is taken from 'T' | ||
+ | ## @ noise - if > 0, add fixed, random noise; range 0_4, default 0 | ||
+ | ## | ||
+ | function Grayramp(clip T, int "height", bool "zigs", bool "stack", int "noise") | ||
+ | </div> | ||
− | {{ | + | ===== ScopeR ===== |
− | + | :* Show waveform + vectorscope; accepts RGB | |
− | + | :: Rotates waveform 90° CCW and makes brighter; rotates vector 180°. | |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ shrink - if true, shrink clip+scopes & add side borders so output size = input; | ||
+ | ## if false (default), height increases by 264 px | ||
+ | ## @ vector - if true, show Histogram("color2") (inverted so red is top-left) | ||
+ | ## @ matrix - if source is RGB and 'vector'=true, use this matrix; default "Rec709" | ||
+ | ## otherwise 'matrix' is ignored (does not affect waveform or main image) | ||
+ | ## @ parade - if true, show RGB waveforms side-by-side; | ||
+ | ## else (default), show RGB waveforms superimposed | ||
+ | ## @ bottom - if true, put scopes below video (default false) | ||
+ | ## | ||
+ | function ScopeR(clip C, bool "shrink", bool "vector", string "matrix", | ||
+ | \ bool "parade", bool "bottom") | ||
+ | </div> | ||
− | {{ | + | ===== ScopeY ===== |
− | + | :* Simple waveform + vector scope. Accepts 8-bit, YUV only. | |
− | + | :: Rotates waveform 90° CCW and makes brighter; rotates vector 180°. | |
+ | <div {{BoxWidthIndent|56|2}} > | ||
+ | ## @ shrink - if true, shrink clip+scopes & add side borders so | ||
+ | ## output size = input (within range 360_1440); | ||
+ | ## if false (default), height increases by 264 px | ||
+ | ## @ vector - if true (default), show Histogram("color2") | ||
+ | ## (inverted so red is top-left) | ||
+ | ## @ levels - if true, show Histogram("levels", 1.0); default false. | ||
+ | ## @ bottom - if true, put scopes below video (default false) | ||
+ | ## | ||
+ | ## * Smaller heights are faster to process; scopes look relatively bigger; | ||
+ | ## (at height=512, scopes occupy the bottom half of the output; | ||
+ | ## at 720, about 1/3; at 1080, 1/4) | ||
+ | ## | ||
+ | function ScopeY(clip C, bool "shrink", bool "vector", bool "levels", bool "bottom") | ||
+ | </div> | ||
− | === | + | ===== HistogramTurn ===== |
− | + | :* Classic [[Histogram]], waveform on top (or on bottom); supports RGB | |
− | {{ | + | :: Rotates waveform 90° CCW and makes brighter. |
− | + | <div {{BoxWidthIndent|56|2}} > | |
− | + | ## @ parade - if true (default), show RGB waveforms side-by-side; | |
− | + | ## else, show RGB waveforms superimposed | |
− | + | ## @ shrink - if true, shrink clip+waveform & add side borders so output size = input | |
− | + | ## if false (default), height increases by 264 px | |
− | + | ## @ bottom - if true, put histogram below video (default false) | |
− | + | ## | |
− | + | function HistogramTurn(clip C, bool "parade", bool "shrink", bool "bottom") | |
− | + | </div> | |
− | + | ||
− | |||
− | |||
− | |||
− | + | ==== File history ==== | |
− | + | :see [[File:Utils-r41.avsi]]. | |
− | : | + | |
− | + | <br> | |
− | + | ||
− | + | ||
− | + | __NOTOC__ | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</div> | </div> | ||
Revision as of 19:55, 24 November 2017
AVS+ utilities
- Download: Utils-r41.avsi
Some of the most useful functions (a short selection)
sc8f
- Scale an 8-bit value for target clip T
- Autoscale filter arguments to high bit depth. Used in eg, LevelsPlus.
- This function provides the basis for two others which are more useful in practice (see full script):
- sc8x – int result, clamped to legal range
- sc8s – string result, suitable for use in MaskTools expressions
- For example, if clip C's bit depth = 10,
C.sc8x(255)
== 255 × 2(10-8) == 1023.
## @ T - clip with target bit depth ## @ f - argument; 0_255 scale ## @ cx - if true, clamp output to legal range ## @ returns float if not clamped; ## else returns int for int formats, float for float ## function sc8f(clip T, float f, bool "cx")
ToRGB
- Convert from anything to planar RGB[A]
- Attempts YUV→RGB conversion with best possible quality;
- hides the details of conversion from Interleaved to Planar.
## @ matrix - ignored if not converting from YUV; default "Rec601" ## @ bits_out - output bit depth, one of (8|10|12|14|16); default same as source ## @ A - if supplied, becomes the alpha channel of the resulting clip; ## overrides any existing alpha channel. ## * if 'A' is RGBA or YUVA, the A channel is used; ## * if 'A' YUV or Y-only, the Y channel is used; ## * if 'A' == "none", any existing alpha channel is removed; ## * if 'A' == "add", a new opaque alpha channel is added; ## * else, 'A' is ignored. ## function ToRGB(clip C, string "matrix", int "bits_out", clip "A")
To444
- Convert from anything to YUV[A]444
- Attempts RGB→YUV conversion with best possible quality;
- hides the details of conversion from Interleaved to Planar.
## @ matrix - ignored if not converting from RGB; default "Rec601" ## @ bits_out - output bit depth, one of (8|10|12|14|16); default same as source ## @ A - if supplied, becomes the alpha channel of the resulting clip; ## overrides any existing alpha channel. ## * if 'A' is RGBA or YUVA, the A channel is used; ## * if 'A' YUV or Y-only, the Y channel is used; ## * if 'A' == "none", any existing alpha channel is removed; ## * if 'A' == "add", a new opaque alpha channel is added; ## * else, 'A' is ignored. ## ## Return YUV(A)444, max 16-bit (no float output) ## function To444(clip C, string "matrix", int "bits_out", clip "A")
To16bit
- Convert from anything to best equivalent 16-bit version; no RGB↔YUV conversions
## @ A - if supplied, becomes the alpha channel of the resulting clip; ## overrides any existing alpha channel. ## * if 'A' is RGBA or YUVA, the A channel is used; ## * if 'A' YUV or Y-only, the Y channel is used; ## * else, 'A' is ignored. ## ## Returns: ## any RGB(A) -> RGB(A)P16 ## any 444 -> YUV(A)444P16 ## any 422 -> YUV(A)422P16 ## any 420 -> YUV(A)420P16 ## any Yxx -> YxxP16 // no alpha ## function To16bit(clip C, clip "A")
To8bit
- Convert from anything to 'best' (v2.6.x compatible) equivalent 8-bit version
- Automatically converts Planar RGB to RGB24/RGB32; removes any alpha channel on YUV.
## @ dither - if true, add dither when applicable; default false ## ## Returns: ## any RGBA -> RGB32 ## any RGB -> RGB24 ## any 444 -> YV24 ## any 422 -> YUY2 ## any 420 -> YV12 ## any Yxx -> Y8 ## YV411 (no change) ## (no YUVA output, so save your alpha channel elsewhere) ## function To8bit(clip C, bool "dither")
ToVdubFM
- Make minimal color format conversion needed to view in VirtualDub FilterMod.
## @ dither - if true, reduce bit depth to 8 bit with dithering if applicable; ## default false ## ## vdubFM does not currently (AFAIK) support all AVS+ color spaces; ## ToVdubFM does minimally-destructive translation ## per docs, vdubFM accepts: ## 10-bit 422 (v210 interleaved) ## 16-bit 422, 444, 420 (planar) ## 16-bit RGBA ## this filter returns: ## 8-bit formats unchanged, except YV411->YV420 ## 10-bit 422 (planar, not interleaved) ## 16-bit 422 (planar) ## 16-bit RGBA ## function ToVdubFM(clip C, bool "dither")
MatchColorFormat
- Match color format of source C to template T
- Useful when temporarily changing color format and to splice disparate clips together.
## @ matrix - ignored if not converting between RGB<>YUV; default "Rec601" ## @ keepbits - if true, retain original bit depth; ## else (default) force bit depth to match 'T' ## @ dither - if true, add dither when converting to lower bit depth; default false ## function MatchColorFormat(clip C, clip T, string "matrix", \ bool "keepbits", bool "dither")
MatchAudioFormat
- Match audio properties of source C to template T
- For ease of splicing, interleaving etc.
## Properties matched: ## number of channels (see note), bit depth, ## sample rate (if allowresample=true) ## ## AudioChannels handling: ## if 'T' has no audio, returns 'C'.KillAudio; ## if 'C' has no audio, copies silenced audio from 'T'; ## if 'T' and 'C' have the same channel count, no change is made; ## if 'T' has 1 channel, returns 'C'.ConvertToMono; ## if 'T' has 2 channels and 'C' has 1, returns 'C' with split mono; ## otherwise, an error is raised (manual intervention is needed) ## ## @ allowresample - if true, resample audio to match template if needed; ## if false (the default), use AssumeSampleRate, ## which may affect audio/video sync. ## function MatchAudioFormat(clip C, clip T, bool "allowresample")
remove_gamma
- Remove sRGB gamma transfer function (if bit depth > 8)
- Improves appearance of certain filters like Resize; must call restore_gamma before final output; requires MaskTools v2.2.x
## @ enable - default true; if false, do nothing (bypass) function remove_gamma(clip C, bool enable)
restore_gamma
- Apply standard gamma transfer function (if bit depth > 8)
- Reverses effect of remove_gamma.
## @ enable - default true; if false, do nothing (bypass) function restore_gamma(clip C, bool enable)
LevelsPlus
function LevelsPlus(clip C, \ int input_low, float gamma, int input_high, \ int output_low, int output_high, \ bool "coring", bool "dither")
ScaleSize
- Switch (or fade) between three Resize clips depending on scale factor.
- Resizers may be user-specified; default resizers are gamma-aware.
- default 'small' (< 65%) resizer: gamma-aware BicubicResize (b=-0.5, c=0.25)
- default 'medium' resizer: gamma-aware Spline64Resize
- default 'large' (> 133%) resizer: gamma-aware GaussResize (p=50)
## @ fwid - new width ## @ fhgt - new height ## (if 'fwid' <= 0, it is calculated from 'fhgt' and aspect ratio) ## (if 'fhgt' <= 0, it is calculated from 'fwid' and aspect ratio) ## (if both <= 0, an error is raised) ## @ mod - new size modulo; if <= 0, ## 'mod'=1 if source is RGB or YUV 4:4:4 or Y-only; else 'mod'=2 ## ## (see script for more, advanced options) ## function ScaleSize(clip C, float fwid, float fhgt, int mod, \ string "sm", string "med", string "lg", \ float "thrSm", float "thrLg", bool "fade", bool "ident", bool "gamma")
CropEx
## @ wid, hgt - New desired width & height (will be rounded to nearest 'mod') ## @ mod - Mod value; one of (1|2|4|8|16|32); default 2 ## @ border - Border color; default 0 (black border) ## @ mode - Expand method: (extend|mirror|blur|border) ## default/fallback="border" ## @ dx, dy - Shift output in x/y direction. Positive = right/down. Default 0. ## Note output shift rounded to nearest mod-2 unless 'mod'=1. ## function CropEx(clip C, float wid, float hgt, int "mod", \ int "border", string "mode", \ int "dx", int "dy", bool "debug")
EvalShow
- Evaluate a script snippet; display the script and its result on screen.
## @ s - a snippet of AviSynth code; any string allowed as an argument to Eval. ## @ size, align - cf. Subtitle. 'size' is quite small by default; ## you may prefer size=24. Disable subtitle w/ size = 0. ## @ opacity - 1.0 = opaque text, 0.0 = transparent. Default 0.7 ## function EvalShow(clip C, string s, float "size", int "align", float "opacity")
Grayramp
- Return grayscale ramp clip w/ same specs as template clip T
- Useful for measuring luma response curve when used in combination with HistogramTurn.
- See script for ColorRampEx – ramp between any two colors.
## @ T - Any color format (8, 10, 12, 14 or 16-bit); ## determines all properties except Height. ## @ height - default 80 ## @ zigs - if true, 8 pixels on left and right reverse ramp direction; ## useful for determining whether clipping has occurred. ## @ stack - if true, stack on top of clip 'T'; ## resulting audio is taken from 'T' ## @ noise - if > 0, add fixed, random noise; range 0_4, default 0 ## function Grayramp(clip T, int "height", bool "zigs", bool "stack", int "noise")
ScopeR
- Show waveform + vectorscope; accepts RGB
- Rotates waveform 90° CCW and makes brighter; rotates vector 180°.
## @ shrink - if true, shrink clip+scopes & add side borders so output size = input; ## if false (default), height increases by 264 px ## @ vector - if true, show Histogram("color2") (inverted so red is top-left) ## @ matrix - if source is RGB and 'vector'=true, use this matrix; default "Rec709" ## otherwise 'matrix' is ignored (does not affect waveform or main image) ## @ parade - if true, show RGB waveforms side-by-side; ## else (default), show RGB waveforms superimposed ## @ bottom - if true, put scopes below video (default false) ## function ScopeR(clip C, bool "shrink", bool "vector", string "matrix", \ bool "parade", bool "bottom")
ScopeY
- Simple waveform + vector scope. Accepts 8-bit, YUV only.
- Rotates waveform 90° CCW and makes brighter; rotates vector 180°.
## @ shrink - if true, shrink clip+scopes & add side borders so ## output size = input (within range 360_1440); ## if false (default), height increases by 264 px ## @ vector - if true (default), show Histogram("color2") ## (inverted so red is top-left) ## @ levels - if true, show Histogram("levels", 1.0); default false. ## @ bottom - if true, put scopes below video (default false) ## ## * Smaller heights are faster to process; scopes look relatively bigger; ## (at height=512, scopes occupy the bottom half of the output; ## at 720, about 1/3; at 1080, 1/4) ## function ScopeY(clip C, bool "shrink", bool "vector", bool "levels", bool "bottom")
HistogramTurn
- Classic Histogram, waveform on top (or on bottom); supports RGB
- Rotates waveform 90° CCW and makes brighter.
## @ parade - if true (default), show RGB waveforms side-by-side; ## else, show RGB waveforms superimposed ## @ shrink - if true, shrink clip+waveform & add side borders so output size = input ## if false (default), height increases by 264 px ## @ bottom - if true, put histogram below video (default false) ## function HistogramTurn(clip C, bool "parade", bool "shrink", bool "bottom")
File history
- see File:Utils-r41.avsi.