[FFmpeg-devel] New iteration for the color quantization in palette{gen, use}

Clément Bœsch u at pkh.me
Wed Dec 28 01:17:42 EET 2022


Here is a new version of the palette filters patchset. A lot changed
since last iteration. Here are a few highlights:

- The previous version had a terrible typo in the transfer function,
  this is now fixed
- There is now a warning when the frames are not using sRGB transfer
  function (I'm assuming there is no way to automatically insert a
  convert during filter negotiation yet?)
- All the code is now using integer arithmetic so it should be fully
  deterministic WRT tests. For more info, see
  http://blog.pkh.me/p/38-porting-oklab-colorspace-to-integer-arithmetic.html
- The license of the palette utils is now LGPL to align with FFmpeg; the
  OkLab code from Björn Ottosson as well as mine in integers are
  distributed under public domain and MIT so this should be compatible
- The scoring algorithms in the palette generation (heuristics for
  selecting the box and axis) changed after doing an extensive study for
  which you can find the results here:
  https://github.com/ubitux/research/tree/main/color-quantization#results
- Output is more deterministic/stable due to a change in the color
  sorting
- Overall performance is improved quite significantly from previous
  patchset but overall it's still slower than master (with a rough test
  1.06x slower for palettegen and 1.11x slower for paletteuse, your
  mileage may vary), which is expected given the new model. I think
  that's an acceptable trade-off.
- The patchset includes a lot of cleanups and drop of code, leading to
  an overall net negative: 12 files changed, 856 insertions(+), 878
  deletions(-)

Like before, I generated a bunch of outputs at key points in the
history which you can consult here: http://big.pkh.me/pal/ (will be
removed after patchset is merged)

Also, the branch is accessible on github/ubitux/FFmpeg branch
lavfi-palette for convenience.

And happy xmas (a bit late) for those who celebrate it




More information about the ffmpeg-devel mailing list