Skip to main content
Version: v5.9.0

ni_quadra_scale

The ni_quadra_scale filter provides up or down scaling to any picture size. It works just like the FFmpeg software scale filter but uses the hardware to do the scaling. Quadra does not support the FFmpeg scale interlacing mode parameter or the libswscale flags and parameters. Scaling is supported for yuv420p, yuv420p10le, nv12, p010le, rgba, argb, abgr, bgra, bgr0, nv16, yuyv422 and uyvy422. The bgrp format cannot be scaled but can be used as an output in the format parameter.

ni_quadra_scale only supports hardware AVFrames as input and output. To scale a software frame, use ni_quadra_hwupload to upload the frame to the Quadra device. If the hardware frame is on the same device as the scaler, it can be accessed directly.

note

The ni_quadra_scale filter only supports limited color range video (also known as “TV” range). While full range video (or “PC” range) can be passed through the filter, the ni_quadra_scale filter will clamp the video to limited color range video before processing. This clamping causes a slight color shift in the output video.

The scaling of the decoder PPU supports both full/PC or limited/tv range video. When using the ni_quadra_scale filter to convert from rgb to yuv, only bt709 and bt2020 are supported. When converting yuv to rgb, only bt709 is supported.

Parameters​

width, w​

height, h

Set the output video dimension.

If the width or w value is 0, the input width is used for the output. If the height or h value is 0, the input height is used for the output.

If one and only one of the values is -n with n > = 1, the ni_quadra_scale filter will use a value that maintains the aspect ratio of the input image, calculated from the other specified dimension. After that it will, however, make sure that the calculated dimension is divisible by n and adjust the value if necessary.

If both values are -n with n > = 1, the behavior will be identical to both values being set to 0 as previously detailed.

size, s​

Set the video size using an FFmpeg abbreviation.

Supported Valuesntsc (720x480), pal (720x576), qntsc (352x240), qpal (352x288), sntsc (640x480), spal (768x576), film (352x240), ntsc-film (352x240), sqcif (128x96), qcif (176x144), cif (352x288), 4cif (704x576), 16cif (1408x1152), qqvga (160x120), qvga (320x240), vga (640x480), svga (800x600), xga (1024x768), uxga (1600x1200), qxga (2048x1536), sxga (1280x1024), qsxga (2560x2048), hsxga (5120x4096), wvga (852x480), wxga (1366x768), wsxga (1600x1024), wuxga (1920x1200), woxga (2560x1600), wqsxga (3200x2048), wquxga (3840x2400), whsxga (6400x4096), whuxga (7680x4800), cga (320x200), ega (640x350), hd480 (852x480), hd720 (1280x720), hd1080 (1920x1080), 2k (2048x1080), 2kflat (1998x1080), 2kscope (2048x858), 4k (4096x2160), 4kflat (3996x2160), 4kscope (4096x1716), nhd (640x360), hqvga (240x160), wqvga (400x240), fwqvga (432x240), hvga (480x320), qhd (960x540), 2kdci (2048x1080), 4kdci (4096x2160), uhd2160 (3840x2160), uhd4320 (7680x4320)
Defaultnone

force_original_aspect_ratio​

Enable decreasing or increasing output video width or height to maintain the original aspect ratio. If a user knows in advance the maximum allowed resolution for a device, then this option can be used to limit the output video to that resolution, while also retaining the aspect ratio.

For example, Device A allows 1280x720 playback and your video source is 1920x800. Enabling this option with the value decrease, and specifying 1280x720 on the command line, will cause the output resolution to be 1280x534.  

note

this option is different to specifying -1 for the w or h, because for this option the output resolution must also be specified.

Supported Values- decrease
- increase
Defaultsdisable

force_divisible_by​

Ensures that the output resolution is divisible by the given integer when used with force_original_aspect_ratio. This option respects the value set for force_original_aspect_ratio and will increase or decrease the resolution accordingly.

This option is useful if you want to have a video fit within a defined resolution using force_original_aspect_ratio but have encoder restrictions when it comes to width or height.

Supported ValuesInteger in the range 1 to 256
Defaults1

format​

Changes the output pixel format.

Supported Values- auto: use same pixel format as input
- yuv420p: change output format to 8-bit yuv420 planar
- nv12 – change output format to 8-bit yuv420 semi-planar
- yuv420p10le: change output format to 10-bit yuv420 planar
- p010le: change output format to 10-bit yuv420 semi-planar
- rgba – change output format to 32-bit rgba
- argb – change output format to 32-bit argb
- abgr – change output format to 32-bit abgr
- bgra – change output format to 32-bit bgra
- bgr0 – change output format to 32-bit bgr0
- bgrp – change output format to 24-bit bgrp
- nv16 – change output format to 64-bit YUV422 semi-planar
- yuyv422 – change output format to 8-bit YUV422
- uyvy422 – change output format to 8-bit YUV422
Defaultsauto

keep_alive_timeout​

Specifies a session keep alive timeout value. This is a periodic request/response between libxcoder and XCoder firmware that when timed out, terminates the session instance in the XCoder firmware.

Supported ValuesInteger in the range 1 to 100
Defaults3

buffer_limit​

Whether to limit the number of output buffers. If enabled, the buffering count of the filter is its buffer pool size(default 4) plus encoding buffering count if its downstream is encoder. It’s enabled by default in FFmpeg-n6.1, FFmpeg-n7.1, FFmpeg 7.1.3, FFmpeg-n8.0.1 and FFmpeg-n8.1.

Supported ValuesInteger 0 and 1.
Defaults0

filterblit​

Specifies the scaling algorithm.The default is a simple blit function that uses an algorithm similar to the nearest neighbor algorithm.

When the filterblit parameter is set to 1, then the filterblit algorithm will be used for scaling. The filterblit function uses a FIR filter algorithm that is similar in quality to the bicubic algorithm.

When the filterblit parameter is set to 2, a bicubic algorithm is used.
When the filterblit parameter is set to 3, a bicubic variant algorithm 1 is used. Compared to filterblit 2, this algorithm can sacrifice image quality but avoid moiré effects under high downscaling ratios. It is recommended for compression ratios greater than 3:1.
When the filterblit parameter is set to 4, a bicubic variant algorithm 2 is used. Compared to filterblit 3, its moiré-reduction performance is slightly weaker, but it sacrifices less image quality. It is recommended for compression ratios between 2:1 and 3:1.
When the filterblit parameter is set to 5, a lanczos algorithm is used.

When the filterblit parameter is set to 6, allow customers to use their own scaling algorithm and configure kernel information.

Supported ValuesInteger in the range 0 to 6
Defaults0

autoselect​

It selects the filterblit mode automatically according to the output resolution when it is enabled. It sets filterblit parameter to 2 when resolution is larger than 540p and sets filterblit parameter to 1 in other cases.

Supported ValuesInteger in the range 0 to 1
Defaults0

in_color_matrix​

Set the input YCbCr color space type. Only applicable to YUV formats. Used when converting YCbCr to RGB.

Supported Valuesbt709
Defaultsbt709

out_color_matrix​

Set the output YCbCr color space type. Only applicable to YUV formats. Used when converting RGB to YCbCr.

Supported Valuesbt709 and bt2020
Defaultsbt709

is_p2p​

Specifies if output buffer of the filter is p2p buffer. When is_p2p is set to 1, the output buffer of the filter is set as p2p buffer and can be read out by p2p read. Else the output buffer is normal and cannot perform p2p.

Supported ValuesBool 0 and 1.
Defaults0

auto_skip​

Specifies if to skip the hardware scale when input is the same as the output. When auto-skip is set to 1, frames will pass through the scale filter and no hardware operations will be executed. When auto_skip is set to 0, hardware scale will always be executed regardless of whether the input is the same as the output.

note

need to disable adaptive buffers with “disableAdaptiveBuffers” parameter in decoder and encoder to avoid buffer resource unavailable.

note

auto-skip is only supported with FFmpeg version > 3.4.2. If the FFmpeg version is lower than 3.4.2 then the hardware operation will always be skipped when the input is the same as the output.

Supported ValuesBool 0 and 1
Defaults0

param_b​

Set parameter B of bicubic.This param only effect when filterblit is set to 2.

note

Please try to use the same value on the same device. Otherwise, it may have some impact on FW load

Supported ValuesDouble 0 to 5
Defaults0

param_c​

Set parameter C of bicubic.This param only effect when filterblit is set to 2.

note

Please try to use the same value on the same device. Otherwise, it may have some impact on FW load

Supported ValuesDouble 0 to 5
Defaults0.75

Kernel_taps​

Set number of active filter taps in the user kernel.

note

This param will be effect only with filterblit=6.

Supported Valuesint 1 to 5
Defaults5

The following example uses the NETINT ni_quadra_scale filter with all processing on the same device with no YUV transfers. The decoder is on device 0 and outputs hardware frames. The ni_quadra_scale filter automatically co-locates with the decoder and outputs hardware frames on the same device. Since the encoder device ID is -1, the encoder will be co-located with its scaled hardware frame input. If the encoder were to be placed on a different device, then the scaled frame would be automatically transferred to the host and then to the encoder device which is sub-optimal.

ffmpeg -c:v h264_ni_quadra_dec -dec 0 –xcoder-params "out=hw" -i input1080p.264 -vf ni_quadra_scale=1280:720 -c:v h265_ni_quadra_enc -enc -1 -xcoder-params "RcEnable=1:bitrate=1000000" output720p.265