]> git.sesse.net Git - ffmpeg/commit
avcodec/cook: Make tables to initialize VLCs smaller
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 27 Oct 2020 13:15:58 +0000 (14:15 +0100)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Tue, 8 Dec 2020 16:51:45 +0000 (17:51 +0100)
commit530d86b90d5f776844a936d5fcf1393cc0cd439c
treebc25e34d5dd4b5c17c41b9f370264d185aaf3804
parent8887232c770f0b191e559945a05e3b99ca8d8561
avcodec/cook: Make tables to initialize VLCs smaller

Up until now, the Cook decoder used tables for the lengths of codes and
tables of the codes itself to initialize VLCs; the tables for the codes
were of type uint16_t because the codes were so long. It did not use
explicit symbol tables. This commit instead reorders the tables so that
the code tables are sorted from left to right in the tree. Then the
codes can be easily derived from the lengths and therefore be omitted.
This comes at the price of explicitly coding the symbols, but this is
nevertheless a net win because most of the symbols tables can be coded
on one byte. Furthermore, Cook actually does not use a contiguous range
of symbols for its main VLC tables and the old code compensated for that
by adding holes (codes of length zero) to the tables (that are skipped by
ff_init_vlc_sparse()). This is no longer necessary with the new
approach. All in all, this saves about 1.7KB.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/cook.c
libavcodec/cookdata.h