Skip to main content
Version: v5.9.0

PPU Scale Adaptive

We support three configuration methods for PPU scale adaptation, which can be configured through parameter " enablePpuScaleAdapt", parameter " scale0LongShortAdapt", and “scale0=0xheight or Widthx0”.

warning

We do not recommend using the parameter "enablePpuScaleAdapt" because after enabling this parameter, it defaults to rounding down 2. And after enabling this parameter, it will synchronously apply to ppu0, ppu1, ppu2

. The other two configuration methods are rounded up by 2 by default, and ppu0 ppu1 ppu2 can be configured separately through scale0LongShortAdapt scale1LongShortAdapt and scale2LongShortAdapt (scale0=0xheight, scale1=0xheight, scale2=0xheight).

This will be introduced with parameter “scale0LongShortAdapt”. It must be used with scale0=widthxheight. It can set 3 values, 0, 1, 2. The default value is 0, 1 is to enable long edge resolution adaptation, while short edge resolution remains unchanged. 2 is to enable short edge resolution adaptation while keeping long edge resolution unchanged. We will use in_w, in_h represents the input stream resolution, out_w, out_h represents the final output stream resolution, scale0_w. scale0_h represents the expected ppu output resolution set.

With “scale0LongShortAdapt = 0,scale0=scale0_w X scale0_h”, If scale0_w is larger than in_w or scale0_h is larger than in_h, then the output resolution is consistent with the input resolution, (out_w = in_w, out_h = in_h). otherwise, the output resolution is the set resolution, (out_w = scale0_w, out_h = scale0_h). And if “scale0=0x0”, the output resolution is consistent with the input resolution, If “scale0=0xheight”, it is same as “scale0LongShortAdapt=1”, If “scale0=widthx0”, it is same as “scale0LongShortAdapt=2”. Additionally, if exactly one of scale0_w or scale0_h is -n (n ≥ 1), the filter scales to preserve the aspect ratio using the other dimension and then rounds it up to the next multiple of n. (e.g. “scale0=-2xheight” means n=2 — scale to keep aspect ratio based on height, then round width up to a multiple of 2.) The same behavior exists in ni_quadra_scale. If both are -n, the behavior is the same as when both are 0.

For example, we set scale0LongShortAdapt = 1, if the initial input stream is 1920x1080, scale0 is set to 960x360. At this point, the long side is 1920 and the short side is 1080, so the output short side remains unchanged and is 360. The long side is calculated to be 1920x360/1080=640, and the output resolution is 640x360. Then, when the input stream is changed to 1080x1920, the output stream will be changed to 360x640. If the subsequent input stream is changed to 1080x720, the output stream will be changed to 540x360. Therefore, when we set long edge adaptation, we set the output resolution to 960x360, The resolution change of the input stream is 1920x1080- > 1080x1920- > 1080x720, and the output resolution is 640x360- > 360x640- > 540x360. If short edge adaptation is enabled and other conditions remain unchanged, the output resolution is 960x540- > 540x960- > 960x640.

Here is an example using scale0LongShortAdapt = 0 and scale0=-2x720:

If the input resolution is 1080×1920, the output will be scaled to a height of 720 while preserving the aspect ratio. The calculated width is (1080/1920)×720 = 405. This is then rounded up to the next multiple of 2, resulting in 406×720. Note that the encoder may apply additional alignment: For H.264, final resolution becomes 408×720. For H.265, final resolution becomes 416×720.

note

If scale0LongShortAdapt = 1 or 2, when scale0=0x0, 0xh, or wx0, it will return error code from libxocoder.

For “scale0LongShortAdapt = 1 or 2” and “scale0=0xh, or wx0”, we will also check the output width and height is larger or not than the input stream. For example, the input stream is 640x360, scale0=0x720, in this case, the resolution of the short side remains unchanged, and when calculating the resolution of the long side, the calculated resolution is 1280x720. Because we do not support expansion on either side, the final resolution is 640x360.

Difference of “scale0LongShortAdapt = 1 or 2” and “scale0=0xh or wx0”:

For “scale0LongShortAdapt” we will check the area of input stream and scale stream. For example, the input stream is 1280x720, and scale0=3000x360, due to 3000x360 is larger than 1280x720, so the output stream is 1280x720. And for “scale0=0xh, scale0=wx0”, we don’t check the area. And for “scale0=0xh or wx0”, we don’t check the area.

ffmpeg -c:v h264_ni_quadra_dec -xcoder-params out=hw:scale0=720x1280:scale0LongShortAdapt=0 -I input.h264 -c:v h265_ni_quadra_enc output.h265