Editing Internal functions

From Avisynth wiki
Jump to: navigation, search

Warning: You are not logged in.

Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 18: Line 18:
 
# [[#Bit_functions|Bit functions]]
 
# [[#Bit_functions|Bit functions]]
 
# [[#Runtime_functions|Runtime functions]]
 
# [[#Runtime_functions|Runtime functions]]
# [[#Functions_for_frame_properties|Functions for frame properties]]
+
# [[#Runtime_functions_for_frame_properties|Runtime functions for frame properties]]
 
# [[#Script_functions|Script functions]]
 
# [[#Script_functions|Script functions]]
 
# [[#String_functions|String functions]]
 
# [[#String_functions|String functions]]
Line 394: Line 394:
 
: Sets the maximum memory that AviSynth uses (in MB) to the value of {{FuncArg|amount}}. Setting to zero just returns the current Memory Max value. In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB.
 
: Sets the maximum memory that AviSynth uses (in MB) to the value of {{FuncArg|amount}}. Setting to zero just returns the current Memory Max value. In the 2.5 series the default Memory Max value is 25% of the free physical memory, with a minimum of 16MB.
 
: The default Memory Max is also limited to 512MB.
 
: The default Memory Max is also limited to 512MB.
: {{AvsPluscon}}In Avisynth+ this limit for default Memory Max is 1024MB for 32 bits and 4096MB on the x64 version
+
: In Avisynth+ this limit for default Memory Max is 1024MB for 32 bits and 4096MB on the x64 version
 
: DefaultMemoryMax = minimum(physical_memory / 4, secondary_memory_max_limit)
 
: DefaultMemoryMax = minimum(physical_memory / 4, secondary_memory_max_limit)
 
: for classic Avisynth see the table below
 
: for classic Avisynth see the table below
Line 423: Line 423:
 
  SetMemoryMax(128)
 
  SetMemoryMax(128)
 
</div>
 
</div>
 
:{{AvsPluscon}}{{FuncDef|SetMemoryMax(int, int “type”, int “index”)}}
 
:With additional arguments for devices such as GPUs. Memory usage is managed individually for devices such as GPUs.
 
<br>
 
::{{Par2||int|}}
 
:::Device (including CPU) memory limit (MB)
 
::{{Par2|type|int|}}
 
:::Device type. The following values ​​are available:
 
::::DEV_TYPE_CPU: CPU (default)
 
::::DEV_TYPE_CUDA: GPU
 
::{{Par2|index|int|}}
 
:::Device number. Same as onCUDA device_index. Only 0 for DEV_TYPE_CPU.
 
:::Default value: 0
 
 
 
  
 
<div style="max-width:62em" >
 
<div style="max-width:62em" >
Line 1,261: Line 1,246:
 
</div>
 
</div>
  
== Functions for frame properties ==
+
== Runtime functions for frame properties ==
 
<div style="max-width:62em" >
 
<div style="max-width:62em" >
: Core and concept ported from VapourSynth.
+
: Core and concept ported from VapourSynth
: Frame properties are per-frame data. Source or other filters can store useful data into frame properties such as information on colorimetry.
+
: Frame properties are per-frame data which can only be read and written within runtime functions. e.g. Source or other filters can feed useful data into frame properties such as information on colorimetry.
 
: Imagine them as an array of zero or more elements of PropertyName=Value
 
: Imagine them as an array of zero or more elements of PropertyName=Value
: Reading them is possible only by runtime functions.
+
<br>
: <br>
+
: Frame property getter and setter functions are evaluated at every frame. They can be used inside the scripts passed to runtime filters ([[ScriptClip]]). They are allowed in [[FrameEvaluate]] but since it does not return an altered frame, writing a frame property there has zero effect.
: Note:
+
:* frame properties are key-value(s) pairs
: At the moment (v3.6.2test7) Avisynth+ provides only the necessary framework for handling (set, read, clear, pass) such properties. None of its internal functions (such as color space converters) set or work upon frame property values.
+
: There are already filters (like avsresize) and source plugins that are already using frame properties. Avisynth+ core will rely on frame in the future as well.
+
: <br>
+
: Developer info:
+
: On filter level the set of frame properties should be copied from a previous (or specific) input frame. When filter is using env->MakeWritable in its GetFrame method this happens automatically.
+
: But a simple env->NewVideoFrame means a dead-end for frame property passing mechanism. So filter must either use env->NewVideoFrameP which has an additional parameter: a source frame of the frame properties.
+
: Or frame properties have to be copied later, programatically by the copyFrameProps ScriptEnvironment function.
+
: For compatibility reasons NewVideoFrameP should be called adaptively instead of the traditional NewVideoFrame: usable after detecting Avisynth interface version 8 (NewVideoFrameP was introduced in v8).
+
: What happens if this copy is not done properly? Then the filter is a dead-end for frame properties since NewVideoFrame constructs new frame with no frame properties. All old filters will behave like this.<br>
+
: <br>
+
: Frame property getter functions are evaluated at every frame. They can be used inside the scripts passed to runtime filters ([[ScriptClip]]).<br>
+
: Frame property setters can be called both at script level and in runtime. When a property is set on script level it will be constant along the lifetime of the whole clip, unless it is changed in runtime, inside ScriptClip.
+
: Though using property setter functions are allowed in [[FrameEvaluate]] but since it does not return an altered frame, writing a frame property there has zero effect.<br>
+
: <br>
+
:* frame properties are stored as key-value pairs
+
 
:** Key is an alphanumeric identifier.
 
:** Key is an alphanumeric identifier.
 
:** Values can be of single value or array of type
 
:** Values can be of single value or array of type
:*** 64 bit integer (32 bit integer when converted to AVSValue inside Avisynth+, AVSValue limitation)
+
:*** 64 bit integers (32 bit integer when converted to AVSValue inside Avisynth+, AVSValue limitation)
:*** 64 bit double (32 bit float when converted to AVSValue inside Avisynth+, AVSValue limitation)
+
:*** 64 bit doubles (32 bit float when converted to AVSValue inside Avisynth+, AVSValue limitation)
:*** string (or byte data) with given length. Strings are null terminated.
+
:*** strings (or data) with given length. strings are null terminated
:*** frame reference (PVideoFrame)
+
:*** frame references (PVideoFrame)
:*** clip reference (PClip)
+
:*** clip references (PClip)
 
:* property setting has 3 modes: 0-replace 1-append 2-touch (see AVSPropAppendMode in avisynth.h)::
 
:* property setting has 3 modes: 0-replace 1-append 2-touch (see AVSPropAppendMode in avisynth.h)::
 
:** 0 - single value for that key is replaced
 
:** 0 - single value for that key is replaced
Line 1,296: Line 1,266:
 
:** 2 - touch
 
:** 2 - touch
  
==== Reserved frame property names ====
+
===== Property set =====
: There are quasi-standard frame property names which are used widespread.
+
: As frame properties came from VapourSynth (see "Reserved Frame Properties" at http://www.vapoursynth.com/doc/apireference.html), it is convenient that Avisynth plugins use the same properties and values.
+
: Keys starting with _ have strictly defined meanings specified below. It is acceptable to not set any of these keys if they are unknown. It is also a fatal error to set them to a value not specified below.
+
{{ScriptFunctionH5|_ChromaLocation||int _ChromaLocation}}
+
: Chroma sample position in YUV formats.
+
:: 0=left, 1=center, 2=topleft, 3=top, 4=bottomleft, 5=bottom.
+
  
{{ScriptFunctionH5|_ColorRange||int _ColorRange}}
+
===== Property get =====
: Full or limited range (PC/TV range). Primarily used with YUV formats.
+
:: 0=full range, 1=limited range.
+
 
+
{{ScriptFunctionH5|_Primaries||int _Primaries}}
+
: Color primaries as specified in ITU-T H.265 Table E.3.
+
 
+
{{ScriptFunctionH5|_Matrix||int _Matrix}}
+
: Matrix coefficients as specified in ITU-T H.265 Table E.5.
+
 
+
{{ScriptFunctionH5|_Transfer||int _Transfer}}
+
: Transfer characteristics as specified in ITU-T H.265 Table E.4.
+
 
+
{{ScriptFunctionH5|_FieldBased||int _FieldBased}}
+
: If the frame is composed of two independent fields (interlaced).
+
:: 0=frame based (progressive), 1=bottom field first, 2=top field first
+
 
+
{{ScriptFunctionH5|_AbsoluteTime||float _AbsoluteTime}}
+
: The frame’s absolute timestamp in seconds if reported by the source filter. Should only be set by the source filter and not be modified. Use durations for all operations that depend on frame length.
+
 
+
{{ScriptFunctionH5|_DurationNum||int _DurationNum}}
+
{{ScriptFunctionH5|_DurationDen||int _DurationDen}}
+
: The frame’s duration in seconds as a rational number. Filters that modify the framerate should also change these values.
+
: This fraction should always be normalized.
+
 
+
{{ScriptFunctionH5|_Combed||int _Combed (boolean)}}
+
: Whether or not the frame needs postprocessing, usually hinted from field matching filters.
+
 
+
{{ScriptFunctionH5|_Field||int _Field}}
+
: If the frame was produced by something like core.std.SeparateFields, this property signals which field was used to generate this frame.
+
:: 0=from bottom field, 1=from top field.
+
 
+
{{ScriptFunctionH5|_PictType||string _PictType}}
+
: A single character describing the frame type. It uses the common IPB letters but other letters may also be used for formats with additional frame types.
+
 
+
{{ScriptFunctionH5|_SARNum||int _SARNum}}
+
{{ScriptFunctionH5|_SARDen||int _SARDen}}
+
: Pixel (sample) aspect ratio as a rational number.
+
 
+
{{ScriptFunctionH5|_SceneChangeNext||int _SceneChangeNext (boolean)}}
+
: If 1, this frame is the last frame of the current scene. The next frame starts a new scene.
+
 
+
{{ScriptFunctionH5|_SceneChangePrev||int _SceneChangePrev (boolean)}}
+
: If 1, this frame starts a new scene.
+
 
+
==== Property set ====
+
: Input value of setter functions are to be come either
+
:*from the return value of "function objects"
+
:*direct value
+
: Property setter function names begin with propSet
+
 
+
: Common parameters:
+
::*clip c,
+
::*string key_name,
+
::*direct value of supported types (integer, float, string, array, clip) or a "function object"
+
::*int "mode": 0=replace (default), 1=append, 2=touch. There is no append mode for inserting a full array into the property.
+
 
+
{{ScriptFunctionH5|propSet|{{AvsPluscon}}|propSet(clip, string key_name, function func_obj [, integer "mode"])}}
+
: generic property setter, automatic type recognition by the return value of the function object
+
 
+
{{ScriptFunctionH5|propSet|{{AvsPluscon}}|propSet(clip, string key_name, integer value [, integer "mode"])}}
+
{{ScriptFunctionH5|propSet|{{AvsPluscon}}|propSet(clip, string key_name, float value [, integer "mode"])}}
+
{{ScriptFunctionH5|propSet|{{AvsPluscon}}|propSet(clip, string key_name, string value [, integer "mode"])}}
+
{{ScriptFunctionH5|propSet|{{AvsPluscon}}|propSet(clip, string key_name, array value)}}
+
{{ScriptFunctionH5|propSet|{{AvsPluscon}}|propSet(clip, string key_name, clip value [, integer "mode"])}}
+
 
+
: The above four functions are setting a property by a directly passed values
+
: note: array must contain only the similarly typed values, e.g. cannot mix strings with integers.
+
 
+
{{ScriptFunctionH5|propSetInt|{{AvsPluscon}}|propSetInt(clip, string key_name, function func_obj [, integer "mode"])}}
+
{{ScriptFunctionH5|propSetFloat|{{AvsPluscon}}|propSetFloat(clip, string key_name, function func_obj [, integer "mode"])}}
+
{{ScriptFunctionH5|propSetString|{{AvsPluscon}}|propSetString(clip, string key_name, function func_obj [, integer "mode"])}}
+
{{ScriptFunctionH5|propSetArray|{{AvsPluscon}}|propSetArray(clip, string key_name, function func_obj [, integer "mode"])}}
+
{{ScriptFunctionH5|propSetClip|{{AvsPluscon}}|propSetClip(clip, string key_name, function func_obj [, integer "mode"])}}
+
: these setters accept only the specific type
+
 
+
==== Property get ====
+
: Get properties by name or as a whole
+
: Common parameters:
+
:: clip c,
+
:: string key_name,
+
:: integer "index", (default 0): for zero based indexing array access
+
:: integer "offset" (default 0), similar to the other runtime functions: frame offset (e.g. -1: previous, 2: next next)
+
 
+
{{ScriptFunctionH5|propGetAny|{{AvsPluscon}}|propGetAny(clip, string key_name[, integer "index", integer "offset"])}}
+
: returns the automatically detected type
+
 
+
{{ScriptFunctionH5|propGetInt|{{AvsPluscon}}|propGetInt(clip, string key_name[, integer "index", integer "offset"])}}
+
: returns only if value is integer, throws an error otherwise (note: unlike Avisynth integer frame properties internally use 64 bit integers)
+
 
+
{{ScriptFunctionH5|propGetFloat|{{AvsPluscon}}|propGetFloat(clip, string key_name[, integer "index", integer "offset"])}}
+
: returns only if value is float, throws an error otherwise (note: unlike Avisynth float frame properties internally use 64 bit doubles)
+
 
+
{{ScriptFunctionH5|propGetString|{{AvsPluscon}}|propGetString(clip, string key_name[, integer "index", integer "offset"])}}
+
: returns only if value is string, throws an error otherwise
+
 
+
{{ScriptFunctionH5|propGetAsArray|{{AvsPluscon}}|propGetAsArray(clip, string key_name[, integer "index", integer "offset"])}}
+
: A frame property can hold multiple values of the same type: it can be an array
+
: propGetAsArray returns an array. For a single property array size will be 1. (only in array-aware AviSynth+ versions)
+
 
+
{{ScriptFunctionH5|propGetClip|{{AvsPluscon}}|propGetClip(clip, string key_name[, integer "index", integer "offset"])}}
+
: returns only if value is clip, throws an error otherwise (since 3.7.1)
+
 
+
{{ScriptFunctionH5|propGetAll|{{AvsPluscon}}|propGetAll(clip [, integer "offset"])}}
+
: Returns all frame properties in an array of [key-value] pairs. Array size will be 'numProps'
+
: Each key-value pair is contained in a two dimensional subarray.
+
: If the property value for a given key is an array again then "value" will be an array as well.
+
: Once you have the array with all properties you can access them with the "associative" feature of AviSynth array access
+
''Example:''
+
<div {{BoxWidthIndent|56|2}} >
+
  ScriptClip("""last.propSet("cica","hello"+String(current_frame)).\
+
    propSetInt("test_i1",function[](clip c) { return current_frame*3 }).\
+
    propSet("test_i2", current_frame * 2) """)
+
  ScriptClip("""p = propGetAll() \
+
    SubTitle("size:" + String(p.ArraySize()) + " " + \
+
                      String(p["test_i1"]) + " " + \
+
                      String(p["cica"]) + " " + \
+
                      String(p["test_i2"]))""")
+
  ScriptClip("""p = propGetAll() \
+
    SubTitle("size:" + String(p.ArraySize()) + " " + \
+
        String(p[0,1]) + " " + \
+
        String(p[1,1]) + " " + \
+
        String(p[2,1]), x=0, y=20)""")
+
</div>
+
 
+
''Example (read-write basic)''
+
<div {{BoxWidthIndent|80|2}} >
+
  ColorBars()
+
 
+
  # just practicing with function objects
+
  ScriptClip(function[](clip c) { c.Subtitle(String(current_frame)) })
+
 
+
  # write frame properties with function object
+
  ScriptClip("""propSetInt("frameprop_from_str",func(YPlaneMax))""")
+
  # write frame properties with traditional script string
+
  ScriptClip(function[](clip c) { propSetInt("frameluma_sc_func",func(AverageLuma)) })
+
 
+
  # read frame properties (function object, string)
+
  ScriptClip(function[](clip c) { SubTitle(string(propGetInt("frameprop_from_str")), y=20) })
+
  ScriptClip("""SubTitle(string(propGetInt("frameluma_sc_func")), y=40)""")
+
+
  return last
+
</div>
+
 
+
''Example (nearly everything)''
+
<div {{BoxWidthIndent|92|2}} >
+
  ColorBars(width=640, height=480, pixel_type="yv12", staticframes=true)
+
+
  ScriptClip(function[](clip c) { propSetString("s",function[](clip c) { return "Hello " + string(current_frame) }) })
+
  ScriptClip(function[](clip c) { propSetString("s",function[](clip c) { return "Hello array element #2 " }, mode=1) })
+
  ScriptClip(function[](clip c) { propSetString("s",function[](clip c) { return "Hello array element #3 "}, mode=1 ) })
+
+
  ScriptClip(function[](clip c) { propSetString("s2",function[](clip c) { return "Another property "} ) })
+
+
  ScriptClip(function[](clip c) { propSetInt("s_int",function[](clip c) { return current_frame*1 }) })
+
  ScriptClip(function[](clip c) { propSetInt("s_int",function[](clip c) { return current_frame*2 }, mode=1) })
+
  ScriptClip(function[](clip c) { propSetInt("s_int",function[](clip c) { return current_frame*4 }, mode=1 ) })
+
+
  ScriptClip(function[](clip c) { propSetFloat("s_float",function[](clip c) { return current_frame*1*3.14 }) })
+
  ScriptClip(function[](clip c) { propSetFloat("s_float",function[](clip c) { return current_frame*2*3.14 }, mode=1) })
+
  ScriptClip(function[](clip c) { propSetFloat("s_float",function[](clip c) { return current_frame*3*3.14 }, mode=1 ) })
+
+
  ScriptClip(function[](clip c) { propSetArray("s_float_arr",function[](clip c) { return [1.1, 2.2] } ) })
+
  ScriptClip(function[](clip c) { propSetArray("s_int_arr",function[](clip c) { return [-1,-2,-5] } ) })
+
  ScriptClip(function[](clip c) { propSetArray("s_string",function[](clip c) { return ["ArrayElementS_1", "ArrayElementS_2"] } ) })
+
  #ScriptClip("""propDelete("s")""")
+
  ScriptClip(function[](clip c) {
+
    y = 0
+
    SubTitle("Prop Key count =" + String(propNumKeys), y=y)
+
    y = y + 15
+
    numKeys = propNumKeys() - 1
+
    for ( i = 0 , numKeys) {
+
      propName = propGetKeyByIndex(index = i)
+
      propType = propGetType(propName)
+
      SubTitle("#"+String(i) + " property: '" + propName + "', Type = " + String(propType) , y=y)
+
      y = y + 15
+
+
      for(j=0, propNumElements(propName) - 1) {
+
        SubTitle("element #" + String(j) + ", size = " + String(propType == 3 ? propGetDataSize(propName, index=j) : 0) + ", Value = " + String(propGetAny(propName, index=j)), y = y)
+
        #SubTitle("element #" + String(j) + " size = " + String(propType == 3 ? propGetDataSize(propName, index=j) : 0) + ", Value = " + String(propGetAny(propName, index=j)), y = y)
+
        y = y + 15
+
      }
+
    }
+
    return last
+
  })
+
+
  ScriptClip(function[](clip c) {
+
    a = propGetAsArray("s")
+
    y = 100
+
    x = 400
+
    SubTitle(string(a.ArraySize()), x=x, y=y)
+
    for(i=0, a.ArraySize()-1) {
+
      SubTitle("["+String(i)+"]="+ String(a[i]),x=x,y=y)
+
      y = y + 15
+
    }
+
    return last
+
  })
+
+
  # get int array one pass
+
  ScriptClip(function[](clip c) {
+
    a = propGetAsArray("s_int")
+
    y = 440
+
    x = 400
+
    SubTitle("Array size=" + string(a.ArraySize()), x=x, y=y)
+
    y = y + 15
+
    for(i=0, a.ArraySize()-1) {
+
      SubTitle("["+String(i)+"]="+ String(a[i]),x=x,y=y)
+
      y = y + 15
+
    }
+
    return last
+
  })
+
+
  # get float array one pass
+
  ScriptClip(function[](clip c) {
+
    a = propGetAsArray("s_float")
+
    y = 440
+
    x = 200
+
    SubTitle("Array size=" + string(a.ArraySize()), x=x, y=y)
+
    y = y + 15
+
    for(i=0, a.ArraySize()-1) {
+
      SubTitle("["+String(i)+"]="+ String(a[i]),x=x,y=y)
+
      y = y + 15
+
    }
+
    return last
+
  })
+
+
  # get string array
+
  ScriptClip(function[](clip c) {
+
    a = propGetAsArray("s_string")
+
    y = 440
+
    x = 000
+
    SubTitle("Array size=" + string(a.ArraySize()), x=x, y=y)
+
    y = y + 15
+
    for(i=0, a.ArraySize()-1) {
+
      SubTitle("["+String(i)+"]="+ String(a[i]),x=x,y=y)
+
      y = y + 15
+
    }
+
    return last
+
  })
+
</div>
+
 
+
'''AviSynth 3.7.1''': allow propGetXXX property getter functions called as normal functions, outside runtime.<br>
+
By default frame property values are read from frame#0 which index can be overridden by the offset parameter.
+
 
+
''Example:''
+
<div {{BoxWidthIndent|92|2}} >
+
 
+
    Colorbars()
+
    PropSet(last, "hello", 1) # Set to 1 for all frames
+
    # Override to 2 with runtime function except for frameNo=1
+
    ScriptClip("""if(current_frame!=1) {propSet("hello",2)}""")
+
    n0 = propGetInt("hello") # same as propGetInt("hello",offset=0)
+
    # or get the frame property from the Nth frame
+
    n1 = propGetInt("hello",offset=1)
+
    n2 = propGetInt("hello",offset=2)
+
    # n0 and n2 is 2 (overridden in runtime)
+
    # n1 will be 1 (keeps global setting)
+
    SubTitle("n0/n1/n2=" + "{n0}/{n1}/{n2}".Format)
+
</div>
+
  
 
==== Deleting properties ====
 
==== Deleting properties ====
Line 1,583: Line 1,289:
 
==== Other property functions ====
 
==== Other property functions ====
 
{{ScriptFunctionH5|propShow|{{AvsPluscon}}|propShow(clip, integer "size", bool "showtype")}}
 
{{ScriptFunctionH5|propShow|{{AvsPluscon}}|propShow(clip, integer "size", bool "showtype")}}
: This debug filter lists all frame properties on screen.
+
: The filter is not a runtime function but is shown here. This debug filter lists all frame properties on screen.
: Listing appears as a name = value list. Arrays values are displayed between [ and ]
+
: Listing appears as a name = value list. Arrays values are put between [ and ]
 
: Top line contains the number of properties. If no properties found, nothing is displayed.
 
: Top line contains the number of properties. If no properties found, nothing is displayed.
 
:* {{FuncArg|clip}} (required) specifies clip.
 
:* {{FuncArg|clip}} (required) specifies clip.
 
:* {{FuncArg|integer}} "size" default(16), font size to use (the "Text" filter is used for display, sizes are of limited set)
 
:* {{FuncArg|integer}} "size" default(16), font size to use (the "Text" filter is used for display, sizes are of limited set)
 
:* {{FuncArg|bool}} "showtype" default(false), if true, the data type in parenthesis appears next to the property key name
 
:* {{FuncArg|bool}} "showtype" default(false), if true, the data type in parenthesis appears next to the property key name
 
{{ScriptFunctionH5|propGetDataSize|{{AvsPluscon}}|propGetDataSize(clip, string key_name [, integer "index", integer "offset"])}}
 
: returns the size of the string or underlying data array
 
 
{{ScriptFunctionH5|propNumElements|{{AvsPluscon}}|propNumElements(clip, string key_name [, integer "offset"])}}
 
: returns the array size of a given property. 1=single value
 
 
{{ScriptFunctionH5|propNumKeys|{{AvsPluscon}}|propNumKeys(clip, [, integer "offset"])}}
 
: returns number of entries (keys) for a frame
 
 
{{ScriptFunctionH5|propGetKeyByIndex|{{AvsPluscon}}|propGetKeyByIndex(clip, integer "index" [, integer "offset")}}
 
: returns the key name for the Nth property (zero based, 0<=index<propNumKeys)
 
 
{{ScriptFunctionH5|propGetType|{{AvsPluscon}}(v3.7.0)|propGetType(clip, string key_name [, integer "offset"])}}
 
: returns the type of the given key
 
::*unset: 0
 
::*integer: 1
 
::*float: 2
 
::*string: 3
 
::*clip: 4
 
::*frame: 5
 
 
{{ScriptFunctionH5|propCopy|{{AvsPluscon}}(v3.7.1)|propCopy(clip, clip [,bool "merge"])}}
 
: Copies the frame properties of the second clip to the first.
 
::*Parameter 'merge' (default false):
 
:::*when false: exact copy (original target properties will be lost)
 
:::*when true: keeps original properties, appends all parameters from source but overwrite if a parameter with the same name already exists.
 
  
 
== Script functions ==
 
== Script functions ==
Line 2,082: Line 1,761:
 
  isAtLeast3_5_1 = IsVersionOrGreater(3,5,1)
 
  isAtLeast3_5_1 = IsVersionOrGreater(3,5,1)
 
</div>
 
</div>
 
</div>
 
 
== Array functions ==
 
<div style="max-width:62em" >
 
: {{AvsPluscon}}
 
: Array manipulator functions for AviSynth+.
 
 
{{ScriptFunctionH5|ArrayAdd||ArrayAdd(array_to_mod, value_to_append [, index1, index2, index3...])}}
 
: Appends value to the end of an array or its subarray
 
: Returns a new array with value_to_append appended to array_to_mod (1D array) or array_to_mod[index1 (, index2, index3...)] (multi-dimensional array).
 
: Original array (as with the other functions) remains untouched.
 
 
{{ScriptFunctionH5|ArrayDel||ArrayDel(array_to_mod, index1 (, index2, index3...])}}
 
: Returns a new array in which the requested position was deleted.
 
: Original array (as with the other functions) remains untouched.
 
 
{{ScriptFunctionH5|ArrayIns||ArrayIns (array_to_mod, value_to_insert, index1 [, index2, index3...])}}
 
: Insert a value into an array or into its subarray.
 
: Returns a new array with value_to_insert inserted into array_to_mod (1D array) or array_to_mod[index1 (, index2, index3...)] (multi-dimensional array)
 
: The indexes point to the insertion point. Index 0 will insert at the beginning of the array.
 
: Index (ArraySize) will insert after the last element (same as ArrayAdd - append)
 
: Original array (as with the other functions) remains untouched.
 
 
{{ScriptFunctionH5|ArraySet||ArraySet(array_to_mod, replacement_value, index1 [, index2, index3...])}}
 
: Returns a new array with array_to_mod[index1 (, index2, index3...)] = replacement_value
 
: Original array (as with the other functions) remains untouched.
 
 
 
''Examples:''
 
<div {{BoxWidthIndent|56|2}} >
 
ColorbarsHD()
 
# array indexes are zero based
 
a = []
 
a=ArrayAdd(a,[1,2]) # <nowiki>[[1,2]]</nowiki>
 
a=ArrayIns(a,3,0) # [3,[1,2]]
 
a=ArrayAdd(a,"s1") # [3,[1,2],"s1"]
 
a=ArrayAdd(a,"s2") # [3,[1,2],"s1","s2"]
 
a=ArrayDel(a,2) # [3,[1,2],"s2"]
 
a=ArraySet(a,"g",1,0) # [3,["g",2],"s2"]
 
a=ArrayAdd(a,"h",1) # [3,["g",2,"h"],"s2"]
 
a=ArrayAdd(a,[10,11,12],1) # append to (1) -> [3,["g",2,"h",[10,11,12]],"s2"]
 
a=ArrayDel(a,1,3,0) # del from (1,3,0) -> [3,["g",2,"h",[11,12]],"s2"]
 
a=ArrayAdd(a,"added") # [3,["g",2,"h",[11,12]],"s2","added"]
 
a=ArrayAdd(a,["yet","another","sub"]) # [3,["g",2,"h",[11,12]],"s2","added",["yet","another","sub"]]
 
x=a[0] #3
 
x=a[1,0] #g
 
x=a[1,2] #h
 
x=a[1,3,1] #12
 
x=a[3] #"added"
 
x=a[4,1] #"another"
 
SubTitle("x = " + String(x) + " Size=" + String(a.ArraySize()))
 
</div>
 
: For more examples see the [[User_defined_script_functions#Facts_about_user_defined_script_functions|Facts about user defined script functions]] section.
 
  
 
</div>
 
</div>

Please note that all contributions to Avisynth wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Avisynth wiki:Copyrights for details). Do not submit copyrighted work without permission!

Cancel | Editing help (opens in new window)
Personal tools