1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-04 22:03:09 +02:00

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@outlook.com>
This commit is contained in:
Andreas Rheinhardt
2025-03-14 02:31:51 +01:00
parent c228ae2b40
commit be7642b198
2 changed files with 4 additions and 4 deletions

View File

@ -34,6 +34,7 @@
#include <math.h> #include <math.h>
#include <stddef.h> #include <stddef.h>
#include "libavutil/attributes.h"
#include "libavutil/channel_layout.h" #include "libavutil/channel_layout.h"
#include "libavutil/mem_internal.h" #include "libavutil/mem_internal.h"
#include "libavutil/thread.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) static int qdm2_get_vlc(GetBitContext *gb, const VLC *vlc, int flag, int depth)
{ {
int value; int value = get_vlc2(gb, vlc->table, vlc->bits,
av_builtin_constant_p(depth) ? depth : 2);
value = get_vlc2(gb, vlc->table, vlc->bits, depth);
/* stage-2, 3 bits exponent escape sequence */ /* stage-2, 3 bits exponent escape sequence */
if (value < 0) if (value < 0)

View File

@ -1150,7 +1150,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
ff_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth); ff_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth);
/* read temp vector */ /* read temp vector */
vec_off = get_vlc2(&vc->gb, codebook.vlc.table, vec_off = get_vlc2(&vc->gb, codebook.vlc.table,
codebook.nb_bits, codebook.maxdepth); codebook.nb_bits, 3);
if (vec_off < 0) if (vec_off < 0)
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
vec_off *= codebook.dimensions; vec_off *= codebook.dimensions;