avfilter/tonemap_opencl: vectorize Dolby Vision reshaping
Vectorize the Dolby Vision reshaping process to handle 4 pixels at a time, similar
to what is used in the tone mapping stage. This change allows us to read the dovi
buffer once and reuse parameters for 4 pixels which reduces memory load.
Most of the pipeline, including the common polynomial reshaping, benefits from
vectorization. The only exceptions are the coefficients lookup for intensity channel
and MMR reshaping: intensity lookup remains scalar because it processes 4 vec4
values that must be handled sequentially, and MMR reshaping cannot be vectorized
due to its inter-channel dot products.
With this optimization, 4K60 Dolby Vision tone mapping is now reliably achievable
on the RK3588.
This is requried for GPU platforms with unideal compilers like
Qualcomm GPUs on Windows. When the compiler unrolls the IPT
reshaping loop badly the performance suffers a lot. Unroll it by
hand mitigates this, and I noticed no performance difference on
arm mali.
So that users can install Intel OpenCL runtime more
conveniently by adding --install-suggests to apt-get.
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
The global static nb_streams is dynamic and can be extended to a
number that would cause out of bounds access. Always use the
nb_streams from the input file structure and stop rescaling our
checking bitmask with the dynamic nb_streams. This should still
work for all video files.
D3D11VA and MSDK QSV decoders still only support fixed-size frame
pools. However, deriving OpenCL images from these arrayed DX11
textures takes a long time on Gen12.0 GFX. Defer mapping these
images until the decoder outputs it. This significantly reduces
startup latency - from 5s to 1s for a 4K transcoding w/ tonemap.
Signed-off-by: nyanmisaka <nst799610810@gmail.com>
The orignial logic ported from the GPU shader uses (fused) multiply
and add to compute the dovi coefficients. But we are not actually
blending the values, and we are selecting all lanes based on one
boolean condition, a simple conditional assignment is much faster
on CPU.
This commit also uses casting instead of extraction to get the low 128b
for the avx code path. Casting is free but extraction is an instruction
with 3-cycle latency.