User:Raffriff42/Utils-r41 Quick Reference

From Avisynth wiki
< User:Raffriff42(Difference between revisions)
Jump to: navigation, search
m (typoe)
m (update)
Line 4: Line 4:
  
 
__TOC__
 
__TOC__
 +
 +
=== Miscellaneous functions ===
 +
----
 +
{{FuncDefH4|IsAvsPlus}}
 +
{{FuncDef|IsAvsPlus()}}
 +
: Return true if running in Avisynth+, false otherwise
  
 
=== String functions ===
 
=== String functions ===
Line 56: Line 62:
 
{{FuncDef|f2c(float f)}}
 
{{FuncDef|f2c(float f)}}
 
: Scale "normal" float arguments to [[ColorYUV]]'s ''gain_x'', ''gamma_x'' & ''cont_x''   
 
: Scale "normal" float arguments to [[ColorYUV]]'s ''gain_x'', ''gamma_x'' & ''cont_x''   
 +
 +
{{FuncDefH4|ssrc_ok}}
 +
{{FuncDef|ssrc_ok(int rate1, int rate2)}}
 +
: return True if [[SSRC]] can handle converting {{FuncArg|rate1}} into {{FuncArg|rate2}}. 
  
 
{{FuncDefH4|_gcd}}
 
{{FuncDefH4|_gcd}}
Line 182: Line 192:
 
}}  
 
}}  
 
: Scale 0-255 [[Levels]] arguments to current bit depth
 
: Scale 0-255 [[Levels]] arguments to current bit depth
 +
 +
{{FuncDefH4|SGradation2C}}
 +
{{FuncDef|SGradation2C(clip ''C'',<br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''gammaWht'', float ''gammaBlk'',<br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''gammaBlu'', float ''gammaYel'',<br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float ''gammaRed'', float ''gammaCyn'' )
 +
}}
 +
: Enhanced [[SGradation]].
 +
 +
{{FuncDefH4|LayerAligned}}
 +
{{FuncDef|LayerAligned(clip base, clip over,<br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string ''op'', int ''level'', int ''x'', int ''y'', <br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int ''threshold'', bool ''use_chroma'',<br>
 +
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clip ''mask'', float ''opacity'', int ''align'' )
 +
}}
 +
: [[Layer]] with support for {{FuncArg|mask}}, {{FuncArg|opacity}} and {{FuncArg|align}} parameters.
  
 
{{FuncDefH4|OverlayAligned}}
 
{{FuncDefH4|OverlayAligned}}
Line 223: Line 249:
 
: Switch (or fade) between three [[Resize]] clips depending on scale factor
 
: Switch (or fade) between three [[Resize]] clips depending on scale factor
 
: Calls 'private' resizers ''ScaleSize_small'', ''ScaleSize_medium'' and ''ScaleSize_large'' by default, but you can specify other resizers.
 
: Calls 'private' resizers ''ScaleSize_small'', ''ScaleSize_medium'' and ''ScaleSize_large'' by default, but you can specify other resizers.
 +
 +
{{FuncDefH4|CropAspectPanTilt}}
 +
{{FuncDef|CropAspectPanTilt(clip C, float aspect, [float ''zoom'', float ''panRt'', float ''tiltDn'', int "mod"]}}
 +
: crop to aspect ratio with optional zoom, smooth pan & tilt
  
 
{{FuncDefH4|CropPanTilt}}
 
{{FuncDefH4|CropPanTilt}}
Line 233: Line 263:
  
 
{{FuncDefH4|CropEx}}
 
{{FuncDefH4|CropEx}}
{{FuncDef|CropEx(clip C, float wid, float hgt, [int ''mod'', <br>
+
{{FuncDef|CropEx(clip C, float wid, float hgt, <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int ''border'', string ''mode'', bool ''debug''])}}
+
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [int ''mod'', int ''border'', string ''mode'', bool ''debug''])}}
 
: Symmetrically crop or expand a clip to ensure it is a certain size, with size forced to mod-4, mod-8 etc
 
: Symmetrically crop or expand a clip to ensure it is a certain size, with size forced to mod-4, mod-8 etc
 +
 +
{{FuncDefH4|CropMatch}}
 +
{{FuncDef|CropMatch(clip C, clip T, int left, int top, int width, int height )}}
 +
: [[Crop]], then resize to match template clip {{FuncArg|T}} and maintain aspect ratio
  
 
{{FuncDefH4|Shift}}
 
{{FuncDefH4|Shift}}

Revision as of 11:36, 3 October 2017

This list serves only as a quick reference; see the Utils-r41.avsi source for full documentation.

Contents


Miscellaneous functions


IsAvsPlus

IsAvsPlus()

Return true if running in Avisynth+, false otherwise

String functions


SplitLines

SplitLines(string s, [int lastcol, int cc])

Split long lines for Subtitle line wrap

TrimLeft

TrimLeft(string s)

SplitLines helper – trim spaces from left side of string

GetNameFromPath

GetNameFromPath(string path)

Given a valid file path, get the filename only

GetParentFolder

GetParentFolder(string path)

Given a valid file path, get the parent folder path

Numeric functions


_mod

_mod(int m, float f)

Return argument f as integer and ensure it is modulo m

StrinF

StrinF(float f, [int decimals])

Format a Float as a String with (by default) 2 decimals

Hex2

Hex2(int i)

Hex with leading "0" if less than 2 chars long

IsReallyFloat

IsReallyFloat(val v)

Bugfixed IsFloat

MakeYUVColor

MakeYUVColor(float y, float u, float v, [float a])

Given Y, U, V [, A], return an Avisynth color_yuv

MakeRGBColor

MakeRGBColor(float r, [float g, float b, float a])

Given R, G, B [, A], return an Avisynth color

transparent_color

transparent_color(float a, int color)

Given Avisynth color, set its transparency

f2c

f2c(float f)

Scale "normal" float arguments to ColorYUV's gain_x, gamma_x & cont_x

ssrc_ok

ssrc_ok(int rate1, int rate2)

return True if SSRC can handle converting rate1 into rate2.

_gcd

_gcd(int x, int y)

MatchAudioFormat helper – Greatest Common Divisor

CalcWidth

CalcWidth(clip C, int new_hgt, [int mod, int lim])

Given new height, calulate new width, preserving aspect ratio

CalcHeight

CalcHeight(clip C, int new_wid, [int mod, int lim])

Given new width, calulate new height, preserving aspect ratio

Deep color argument scaling functions


getTVBlack

getTVBlack(int bits)

Return TV-black level for given bit depth

getFullscale

getFullscale(int bits)

Return integer fullscale value for given bit depth (mostly internal use)

scff

scff(int fs_in, int fs_out, float f, [bool cx])

Scale a value from one fullscale range to another

scbf

scbf(int bits_in, int bits_out, float f, bool cx])

Scale a value from one bit depth to another

scbx

scbx(int bits_in, int bits_out, float f)

Scale a value from one bit depth to another; clamp output

scbs

scbs(int bits_in, int bits_out, float f, [int decimals])

Scale a value from one bit depth to another; string result

sc8f

sc8f(clip T, float f, [bool cx])

Scale an 8-bit value for target clip T

sc8x

sc8x(clip T, float f)

Scale an 8-bit value for target clip T; clamp output

sc8s

sc8s(clip T, float f, [int decimals])

Scale an 8-bit value for target clip T; string result

Utility filters


ToRGB

ToRGB(clip C [, string matrix, int bits_out, clip A] )

Convert from anything to planar RGB(A); YUV>RGB conversions always done at 16-bit

To444

To444(clip C [, string matrix, int bits_out, clip A] )

Convert from anything to YUV(A)444; RGB>YUV conversions always done at 16-bit

To16bit

To16bit(clip C [, clip A] )

Convert from anything to 'best' equivalent 16-bit version (keep RGB, 444, etc)

To8bit

To8bit(clip C [, bool dither] )

Convert from anything to 'best' (v2.6x compatible) equivalent 8-bit version

ToVdubFM

ToVdubFM(clip C)

Make changes needed to display on VirtualDub FilterMod

MatchColorFormat

MatchColorFormat(clip C, clip T, [string matrix, bool matchbits, bool dither])

Match color format of source C to template T

MatchAudioFormat

MatchAudioFormat(clip C, clip T, [bool allowresample])

Match audio properties of source C to template T

GBR2YUV

GBR2YUV(clip C, [bool yuva])

Transport RGB in YV24 – G=>Y, B=>U, R=>V

YUV2GBR

YUV2GBR(clip C, [clip A, bool rgb32])

Transport YV24 in RGB – Y=>G, U=>B, V=>R

PC2TV

PC2TV(clip C)

PC->TV: convert levels from 'PC' (black=0d, white=255d) to 'TV' (black=16d, white=235d)

TV2PC

TV2PC(clip C(

TV->PC: convert levels from 'TV' (black=16d, white=235d) to 'PC' (black=0d, white=255d)

stack_to_wid

stack_to_wid(clip C, int wid, [clip R, bool flip])

Stack clip C horizontally until it is at least wid wide

stack_to_hgt

stack_to_hgt(clip C, int hgt, [clip R, bool flip])

Stack clip C vertically until it is at least hgt high

stack_to_size

stack_to_size(clip C, int wid, int hgt, [bool flip])

Stack clip C until it is wid x hgt

remove_gamma

remove_gamma(clip C, [bool enable, int mode])

Remove gamma transfer function (if bit depth > 8) for linear-light processing.

restore_gamma

restore_gamma(clip C, [bool enable, int mode])

Apply standard gamma transfer function (if bit depth > 8)

Color and overlay filters


LevelsPlus

LevelsPlus(clip C,
     int input_low, float gamma, int input_high,
     int output_low, int output_high,
     bool coring, bool dither )

Scale 0-255 Levels arguments to current bit depth

SGradation2C

SGradation2C(clip C,
     float gammaWht, float gammaBlk,
     float gammaBlu, float gammaYel,
     float gammaRed, float gammaCyn )

Enhanced SGradation.

LayerAligned

LayerAligned(clip base, clip over,
     string op, int level, int x, int y,
     int threshold, bool use_chroma,
     clip mask, float opacity, int align )

Layer with support for mask, opacity and align parameters.

OverlayAligned

OverlayAligned(clip base, clip over,
      [int x, int y, clip mask, float opacity, string mode,
      bool greymask, string output, bool ignore_conditional,
      bool pc_range, int align, int borderwidth, int bordercolor])

Overlay with support for align parameter and adding borders/letterboxing to inset clip

Timeline filters


Slip

Slip(clip C, int offset)

"Slip" a clip in time.

ChangeSpeed

ChangeSpeed(
      clip C, float factor, [bool pitchfix, bool noblend])

ChangeAudioSpeed

ChangeAudioSpeed(
      clip C, float factor, [bool pitchfix])

Change speed over a wide range with frame blending in fast forward by default.

Crop, resize and transform filters


Cropa

Cropa(clip C, int x, int y, int wid, int hgt, [bool align, int mod])

Crop with <align> true by default; optionally enforce Mod

Cropd

Cropd(clip C, int x, int y, int wid, int hgt, [bool align, int mod])

Show a diagnostic string on Crop failure; optionally enforce Mod

ScaleSize

ScaleSize(clip C, float factor, int mod,
      [string sm, string med, string lg,
      float thrSm, float thrLg, bool fade, bool ident, bool gamma])

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])

Switch (or fade) between three Resize clips depending on scale factor
Calls 'private' resizers ScaleSize_small, ScaleSize_medium and ScaleSize_large by default, but you can specify other resizers.

CropAspectPanTilt

CropAspectPanTilt(clip C, float aspect, [float zoom, float panRt, float tiltDn, int "mod"]

crop to aspect ratio with optional zoom, smooth pan & tilt

CropPanTilt

CropPanTilt(clip C, int wid, int hgt, [float pan, float tilt])

Crop to size with smooth animated pan & tilt, expressed as percentage (center @ pan=0, tilt=0)

CropShift

CropShift(clip C, int wid, int hgt, [float off_x, float off_y])

Crop to size with smooth animated pan & tilt, expressed as pixels (center @ off_x=0, off_y=0)

CropEx

CropEx(clip C, float wid, float hgt,
      [int mod, int border, string mode, bool debug])

Symmetrically crop or expand a clip to ensure it is a certain size, with size forced to mod-4, mod-8 etc

CropMatch

CropMatch(clip C, clip T, int left, int top, int width, int height )

Crop, then resize to match template clip T and maintain aspect ratio

Shift

Shift(clip C, float offh, float offv)

Shift a clip up-down and left-right (sub-pixel precision);

ShiftUV

ShiftUV(clip C, [float ux, float uy, float vx, float vy])

Shift Chroma relative to Luma

ShiftRedBlue

ShiftRedBlue(clip C,
      [float rx, float ry,
      float bx, float by,
      float rxd, float ryd,
      float bxd, float byd])

Shift and/or resize Red and Blue relative to Green
float  rxd, ryd, bxd, byd = 0.0
"delta" width & height

Debugging filters


bigsub

bigsub(clip C, string s, [, float sizeMult, bool enable])

For clip identification – show a semitransparent text string, very large by default

EvalShow

EvalShow(clip C, string s, [bool bypass, float size, int align])

Execute a script snippet; show script & result on screen

ShowMask

ShowMask(clip C, clip M, [string mode, float opacity])

Show a mask clip overlaid on another clip for visualization
string  mode = ""
One of (""|"luma"|"cyan")

ColorbarsHD2

ColorbarsHD2(clip T, [float tonedb])
ColorbarsHD2([int width, int height, bool rgb_out,
      int bits_out, int bits_gen, bool dither, float tonedb])

ColorBarsHD with optional RGB & deep color output; size & audio level changes
(1280x720, TV-range, 29.97 fps, 1 hour long, audio tone @ -18dB, 48kz float)

Grayramp

Grayramp(clip T, [int height, bool dither])
Grayramp([int width, int height, bool rgb_out, int bits_out, bool dither])

Return grayscale ramp

VideoScopes

VideoScopes(clip C, [bool shrink, bool vector, string matrix, bool parade])

Show waveform on top plus optional vectorscope; accepts RGB.

Analyze

Analyze(clip C)

Print color channel statistics on the screen; auto RGB / YUV (cf. ColorYUV(analyze=true)

HistogramOverlay

HistogramOverlay(clip B, clip F, [bool "autocrop", int "align",
      int "x", int "y", int "wid", int "hgt", int "margin",
      float "opacity", string "mode", bool "pc_range")])

Overlay a user-supplied histogram clip

HistogramTurn

HistogramTurn(clip C)

Classic Histogram, waveform on top

Histogram8

Histogram8(clip C, [string mode, float factor])

8-bit Histogram for deep color

ShowChannels

ShowChannels(clip C, [bool analyze])

Show original & 3 channels in quad split

ShowFrameNumberAligned

ShowFrameNumberAligned(
      clip C, [bool scroll, int offset,
      float x, float y, string font, int size,
      int text_color, int halo_color,
      float font_width, float font_angle,
      float opacity, int align])

ShowFrameNumber with support for opacity and align

StackTwoAcrossCropped

StackTwoAcrossCropped(clip A, clip B, [clip S,
      int border, float pan, int wid,
      string titleA, string titleB, int align])

Make side-by-side split clip (normally, for comparison or preview purposes)

Changes


v0.41 May-2017 Published
Personal tools