avcodec/mjpegenc_huffman: Avoid AV_QSORT to sort entries by length

It is unnecessary, as we already have the entries sorted by
probability and therefore implicitly by length. All we need
on top of that to build the tree is the number of entries
of a given length.
Doing so gives a 3.6% speedup of ff_mjpeg_encode_huffman_close()
here; it also saves about 640B of .text here.

The new code puts values with higher probability to the left
of the tree. The old code did not and therefore
the FATE checksums needed to be updated. Due to MJPEG's
0xFF unescaping file sizes as well as file checksums
needed to be updated; the decoded picture hashes stayed
the same. Given that codes on the left of the tree have
on average fewer bits set than codes on the right, the
file sizes mostly improve (all except vsynth3-mjpeg-444).

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
Andreas Rheinhardt 2025-04-02 15:06:43 +02:00
parent c8ce9de5a0
commit ff9f3fb607
22 changed files with 118 additions and 133 deletions

View file

@ -1,3 +1,3 @@
64885ae70c3450b50196ce687a672dbe *tests/data/images/jpg/02.jpg
26062 tests/data/images/jpg/02.jpg
c7b9382883d021b6535096f58d83c72c *tests/data/images/jpg/02.jpg
26057 tests/data/images/jpg/02.jpg
tests/data/images/jpg/%02d.jpg CRC=0x1c357a3e

View file

@ -1,3 +1,3 @@
659757345ce01f8a5c4c1373bd073d41 *tests/data/lavf/lavf.smjpeg
728268 tests/data/lavf/lavf.smjpeg
9278aa4b2eafa6b863fc6085b43abd8d *tests/data/lavf/lavf.smjpeg
728177 tests/data/lavf/lavf.smjpeg
tests/data/lavf/lavf.smjpeg CRC=0x29d58fb8