aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vlc.c
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-09-26 21:50:45 +0200
committerPaul B Mahol <onemda@gmail.com>2023-09-26 22:43:18 +0200
commit58d9b5caf3d332c6495f9af437158bf45531a05e (patch)
treef707c98fe090cc441d0463ae795a26bbde9de558 /libavcodec/vlc.c
parent14015b9e157014b24c74098daee9c6eab15cb6c8 (diff)
downloadffmpeg-58d9b5caf3d332c6495f9af437158bf45531a05e.tar.gz
avcodec/vlc: fix min/max bits calculation in multi vlc
Improves speed with >8 bit depth inputs.
Diffstat (limited to 'libavcodec/vlc.c')
-rw-r--r--libavcodec/vlc.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libavcodec/vlc.c b/libavcodec/vlc.c
index 8beab9a0a2..21b9fffe27 100644
--- a/libavcodec/vlc.c
+++ b/libavcodec/vlc.c
@@ -403,8 +403,14 @@ static int vlc_multi_gen(VLC_MULTI_ELEM *table, const VLC *single,
unsigned count[VLC_MULTI_MAX_SYMBOLS-1] = { 0, };
VLC_MULTI_ELEM info = { { 0, }, 0, };
- minbits = buf[nb_codes-1].bits;
- maxbits = FFMIN(buf[0].bits, numbits);
+ minbits = buf[0].bits;
+ maxbits = buf[0].bits;
+
+ for (int n = 1; n < nb_codes; n++) {
+ minbits = FFMIN(minbits, buf[n].bits);
+ maxbits = FFMAX(maxbits, buf[n].bits);
+ }
+ maxbits = FFMIN(maxbits, numbits);
while (max >= nb_codes/2) {
if (buf[max].bits+minbits > maxbits)