[FFmpeg-cvslog] avcodec/qdm2, vorbisdec: Use compile-time const max_depth in get_vlc2
Andreas Rheinhardt
git at videolan.org
Mon Mar 17 04:40:43 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Fri Mar 14 02:31:51 2025 +0100| [be7642b198c51e65dc7a1fc4ff1f68d29cd6dc54] | committer: Andreas Rheinhardt
avcodec/qdm2, vorbisdec: Use compile-time const max_depth in get_vlc2
It makes no sense to try to be exact with max depth
in get_vlc2(): It will mean that the compiler emits code
for all three stages of parsing and runtime checks for
whether max_depth is big enough to parse the next stage
when a not yet complete code has been encountered.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=be7642b198c51e65dc7a1fc4ff1f68d29cd6dc54
---
libavcodec/qdm2.c | 6 +++---
libavcodec/vorbisdec.c | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/libavcodec/qdm2.c b/libavcodec/qdm2.c
index e629e3b42a..ffb44015ec 100644
--- a/libavcodec/qdm2.c
+++ b/libavcodec/qdm2.c
@@ -34,6 +34,7 @@
#include <math.h>
#include <stddef.h>
+#include "libavutil/attributes.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem_internal.h"
#include "libavutil/thread.h"
@@ -199,9 +200,8 @@ static const int switchtable[23] = {
static int qdm2_get_vlc(GetBitContext *gb, const VLC *vlc, int flag, int depth)
{
- int value;
-
- value = get_vlc2(gb, vlc->table, vlc->bits, depth);
+ int value = get_vlc2(gb, vlc->table, vlc->bits,
+ av_builtin_constant_p(depth) ? depth : 2);
/* stage-2, 3 bits exponent escape sequence */
if (value < 0)
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 11111e7eb3..a778dc6b58 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -1150,7 +1150,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
ff_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth);
/* read temp vector */
vec_off = get_vlc2(&vc->gb, codebook.vlc.table,
- codebook.nb_bits, codebook.maxdepth);
+ codebook.nb_bits, 3);
if (vec_off < 0)
return AVERROR_INVALIDDATA;
vec_off *= codebook.dimensions;
More information about the ffmpeg-cvslog
mailing list