Avsresize

From Avisynth wiki
Jump to: navigation, search
Abstract
Author sekrit-twc
Version r1f
Download avsresize_r1f.7z
Category Resize
License Open source
Discussion Doom9 Forum


Contents

Description

z.lib resizers for AviSynth+

Requirements


Syntax and Parameters

z_ConvertFormat

Scaling, colorspace conversion, and depth conversion.

z_ConvertFormat (clip clip, int "width", int "height", str "pixel_type", string "colorspace_op", string "chromaloc_op", bool "interlaced", float "src_left", float "src_top", float "src_width", float "src_height", string "resample_filter", float "filter_param_a", float "filter_param_b", string "resample_filter_uv", float "filter_param_a_uv", float "filter_param_b_uv", string "dither_type", string "cpu_type", float "nominal_luminance", bool "approximate_gamma")


clip   =
Input clip.


int  width =
int  height =
Output width and height in pixels.


string  pixel_type =
Output pixel type ("YV12", "YUV420P16", etc.).
Bit Depth Grey YUV420 YUVA420 YUV422 YUVA422 YUV444 YUVA444 RGB RGBA
8 Y8 YV12
YUV420
YUV420P8
YUVA420
YUVA420P8
YV16
YUV422
YUV422P8
YUVA422
YUVA422P8
YV24
YUV444
YUV444P8
YUVA444
YUVA444P8
RGBP
RGBP8
RGBAP
RGBAP8
10 Y10 YUV420P10 YUVA420P10 YUV422P10 YUVA422P10 YUV444P10 YUVA444P10 RGBP10 RGBAP10
12 Y12 YUV420P12 YUVA420P12 YUV422P12 YUVA422P12 YUV444P12 YUVA444P12 RGBP12 RGBAP12
14 Y14 YUV420P14 YUVA420P14 YUV422P14 YUVA422P14 YUV444P14 YUVA444P14 RGBP14 RGBAP14
16 Y16 YUV420P16 YUVA420P16 YUV422P16 YUVA422P16 YUV444P16 YUVA444P16 RGBP16 RGBAP16
32-bit Float Y32 YUV420PS YUVA420PS YUV422PS YUVA422PS YUV444PS YUVA444PS RGBPS RGBAPS
All colorspaces are planar. "YUV9" and "YV411" ("YUV411", "YUV411P8") were committed from table above. See AviSynth+ color formats table.


string  colorspace_op =
Colorspace operation description.
Format is "matS[:transS[:primS[:rangeS]]]=>matD[:transD[:primD[:rangeD]]]"
Example JPEG to MPEG: "170m:709:709:f=>709:709:709:l"
MATRIX COEFFICIENTS TRANSFER CHARACTERISTICS COLOR PRIMARIES PIXEL RANGE
"rgb" "709" "709" "limited"
"709" "unspec" "unspec" "l"
"unspec" "470m" "470m" "full"
"fcc" "470bg" "470bg" "f"
"470bg" "601" "170m"
"170m" "240m" "240m"
"240" "linear" "film"
"ycgco" "log100" "2020"
"2020ncl" "log316" "st428"
"2020cl" "xvycc" "st431-2"
"chromancl" "srgb" "st432-1"
"chromacl" "2020_10" "jedec-p22"
"ictcp" "2020_12" Compatibility aliases
Compatibility aliases "st2084" "xyz" same as "st428"
"601" same as "470bg" "std-b67" "dci-p3" same as "st431-2"
"2020" same as "2020ncl" Compatibility aliases "display-p3" same as "st432-1"
"2020" same as "2020_10"
see tables on VapourSynth resize documentation


string  chromaloc_op =
Chroma location operation description.
Format is "[locS]=>[locD]"
Chroma location table, names in parenthesis are compatibility aliases:
  • "left" ("mpeg2") | "center" ("jpeg" and "mpeg1") | "top_left"
Example JPEG to MPEG2: "center=>left"


bool  interlaced = false
Whether to use interlaced mode (default: false)


float  src_left =
float  src_top =
float  src_width =
float  src_height =
Optional crop rectangle in the input frame.


string  resample_filter =
Resampling modes: "point" | "bilinear" | "bicubic" | "spline16" | "spline36" | "spline64" | "lanczos"


float  filter_param_a =
float  filter_param_b =
First and second parameter to resampler.
Example Bicubic (Mitchell-Netravali): resample_filter="bicubic", filter_param_a=0.333, filter_param_b=0.333
Example 4-tap Lanczos: resample_filter="lanczos", filter_param_a=4


string  resample_filter_uv =
Resampling mode for chroma.


float  filter_param_a_uv =
float  filter_param_b_uv =
First and second parameter to chroma resampler.


string  dither_type = "none"
Dithering type: "none" | "ordered" | "random" | "error_diffusion"


string  cpu_type =
CPU type, names in parenthesis are compatibility aliases:
  • "none" | "avx" | "avx_e" ("ivy") | "avx2" | "avx512f | "avx512_skx" ("skx") | "avx512_clx" | "avx512_pmc" ("cannon") | "avx512_snc" ("ice")


float  nominal_luminance = 100.0
Nominal peak luminance in cd/m^2 when converting HDR content to RGB Linear.


bool  approximate_gamma = true
Evaluating transfer functions at reduced precision.


Resizers

z.lib compatibility wrappers with same syntax as built-in resizers.

z_PointResize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", string "chromaloc_op", string "dither")
z_BilinearResize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", string "chromaloc_op", string "dither")
z_BicubicResize (clip, float "b", float "c", int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", string "chromaloc_op", string "dither")
z_LanczosResize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", int "taps", string "chromaloc_op", string "dither")
z_Lanczos4Resize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", int "taps", string "chromaloc_op", string "dither")
z_Spline16Resize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", string "chromaloc_op", string "dither")
z_Spline36Resize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", string "chromaloc_op", string "dither")
z_Spline64Resize (clip, int "target_width", int "target_height", float "src_left", float "src_top", float "src_width", float "src_height", string "chromaloc_op", string "dither")



clip   =
A clip to process. All planar formats are supported.


float  b = 0.0
float  c = 0.5
Parameters for z_BicubicResize only.
b and c can be used to tweak the filter’s behavior. For upscaling, it is recommended to use values that satisfy the equation b + 2c = 1.
Roughly speaking, raising B will cause blurring and raising C will cause ringing.
  • b=1.0, c=0.0 : B-Spline
  • b=0.0, c=0.0 : Hermite
  • b=1/3, c=1/3 : Mitchell-Netravali cubic filter
  • b=0.0, c=0.5 : Catmull-Rom spline (default)
  • b=0.0, c=0.75 : VirtualDub's "Precise Bicubic"
  • b=0.0, c=1.0 : Sharp Bicubic
Hermite is often considered one of the best choices for downscaling, as it produces only minimal artifacts, at the cost of slight blurriness.[1]


int  target_width =
The width of the output.


int  target_height =
The height of the output.


float  src_left = 0.0
Cropping of the left edge.


float  src_top = 0.0
Cropping of the top edge.


float  src_width = Source width
If > 0.0 it sets the width of the clip before resizing.
If <= 0.0 it sets the cropping of the right edges before resizing.


float  src_height = Source height
If > 0.0 it sets the height of the clip before resizing.
If <= 0.0 it sets the cropping of the bottom edges before resizing


int  taps =
Parameter for z_LanczosResize only.
Controls the filter’s number of lobes, or taps. Increasing the number of lobes improves sharpness at the cost of increased ringing.
You might occasionally see the tap count appended to the filter name to clarify the exact filter used, e.g. Lanczos2 for 2 taps.
For downscaling, higher tap counts might help in suppressing Moiré effects.


string  chromaloc_op = "left=>left"
Chroma location operation description.
Format is "[locS]=>[locD]"
Chroma location table, names in parenthesis are compatibility aliases:
  • "left" ("mpeg2") | "center" ("jpeg" and "mpeg1") | "top_left"
Example JPEG to MPEG2: "center=>left"


string  dither = "none"
Dithering type: "none" | "ordered" | "random" | "error_diffusion"


Examples

HD YUV 4:2:0 Rec. 709 to 16-bit RGB:

AviSource("blah.avi") 
z_ConvertFormat(pixel_type="RGBP16", colorspace_op="709:709:709:limited=>rgb:709:709:full")


RGB to 8-bit YV12 (YUV 4:2:0 Rec. 709):

AviSource("blah.avi") 
ConvertToPlanarRGB()
z_ConvertFormat(pixel_type="YUV420P8", colorspace_op="rgb:709:709:full=>709:709:709:limited")

Note: RGB input must be planar, use ConvertToPlanarRGB().


Changelog

Version      Date            Changes
r1f 2020/08/25 - Changes by StvG - added @Losko patch, zimg v3.0.1, added support for frame properties.
r1e 2020/04/23 - Changes by StvG - Update to zimg@8815111; - z_ConvertFormat: added pixel type RGBP8, RGBAP8, YUV444, YUV444P8, YUVA444P8, YUV422, YUV422P8, YUVA422P8, YUV420, YUV420P8 , YUVA420P8, YUV411, YUV411P8 - added version.
2020/04/08 - Changes by StvG - Update to zimg@5896a26 - z_ConvertFormat: add "cpu_type", "nominal_luminance", and "approximate_gamma" parameters - z_ConvertFormat: remove "gauss", "lanczos4", "blackman", and "sinc" compatibility aliases - z_ConvertFormat: remove "dv" compatibility alias from chromaloc_op - Resizers: add "chromaloc_op" and "dither" parameters - Resizers: remove z_BlackmanResize(), z_GaussResize(), and z_SincResize() compatibility aliases.
r1d 2018/03/21 - ...............
r1 2016/10/29 - initial release


Archived Downloads

Version Download Mirror
r1f avsresize_r1f.7z avsresize_r1f.7z
r1e avsresize_r1e.7z avsresize_r1e.7z
2020/04/08 avsresize.7z avsresize_20200408.7z
r1d avsresize-r1d.7z avsresize-r1d.7z


External Links

  • Doom9 Forum - 8bit or greater (AviSynth+) linear/gamma light aware resizing?
  • Doom9 Forum - HDRTools vs DitherTools vs ColorMatrix




Back to External Filters

Personal tools