]> git.sesse.net Git - ffmpeg/commit
avcodec/smacker: Remove redundant checks when reading VLC codes
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Sat, 25 Jul 2020 13:14:53 +0000 (15:14 +0200)
committerAndreas Rheinhardt <andreas.rheinhardt@gmail.com>
Fri, 18 Sep 2020 00:00:34 +0000 (02:00 +0200)
commit3899adc29869301bfab77a9064a21da7a5a5163d
treec9ddd548b30c64a068a03823fd3e70a0d8fe6fe7
parent943a4581570728b4b1a2bf97e5601e24f3f80404
avcodec/smacker: Remove redundant checks when reading VLC codes

The VLC codes in question originate from a Huffmann tree and so every
sequence of bits that is longer than the longest code contains an
initial sequence that is a valid code. Given that it has been checked
during reading said tree (and once again in ff_init_vlc_sparse()) that
the length of each code is <= 3 * the number of bits read at once when
reading codes, get_vlc2() will always find a matching entry.

These checks have been added in 71d3c25a7ef442ac2dd7b6fbf7c489ebc0b58e9b
at a time when the length of the codes had not been checked when parsing
the tree.

For GCC 9 and the sample from ticket #2425 this led to a slight
performance regression: The time for one call to smka_decode_frame()
increased from 2053671 to 2064529 decicycles; for Clang 9, performance
improved from 1521288 to 1508459 decicycles.

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
libavcodec/smacker.c