[FFmpeg-cvslog] avcodec/vp6: Don't reload unnecessarily often in get_vlc2()
Andreas Rheinhardt
git at videolan.org
Sat Apr 26 01:14:59 EEST 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Apr 17 19:48:05 2025 +0200| [e946ba64bf716c0f36909459516e7972d2fd600a] | committer: Andreas Rheinhardt
avcodec/vp6: Don't reload unnecessarily often in get_vlc2()
The VLC trees used here have very few different codes
and are therefore guaranteed to not be very deep: The AC/DC
VLCs have 12 elements and therefore a depth <= 11 whereas
the run VLCs have only nine elements and therefore a depth <= 8.
This allows to reduce the worst-case number of reloads for
reading a VLC code.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e946ba64bf716c0f36909459516e7972d2fd600a
---
libavcodec/vp6.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libavcodec/vp6.c b/libavcodec/vp6.c
index 926694ae11..de60ae93bb 100644
--- a/libavcodec/vp6.c
+++ b/libavcodec/vp6.c
@@ -415,7 +415,7 @@ static int vp6_parse_coeff_huffman(VP56Context *s)
VP56Model *model = s->modelp;
uint8_t *permute = s->idct_scantable;
VLC *vlc_coeff;
- int coeff, sign, coeff_idx;
+ int sign, coeff_idx;
int b, cg, idx;
int pt = 0; /* plane type (0 for Y, 1 for U or V) */
@@ -433,11 +433,11 @@ static int vp6_parse_coeff_huffman(VP56Context *s)
} else {
if (get_bits_left(&s->gb) <= 0)
return AVERROR_INVALIDDATA;
- coeff = get_vlc2(&s->gb, vlc_coeff->table, FF_HUFFMAN_BITS, 3);
+ int coeff = get_vlc2(&s->gb, vlc_coeff->table, FF_HUFFMAN_BITS, 2);
if (coeff == 0) {
if (coeff_idx) {
int pt = (coeff_idx >= 6);
- run += get_vlc2(&s->gb, s->runv_vlc[pt].table, FF_HUFFMAN_BITS, 3);
+ run += get_vlc2(&s->gb, s->runv_vlc[pt].table, FF_HUFFMAN_BITS, 1);
if (run >= 9)
run += get_bits(&s->gb, 6);
} else
More information about the ffmpeg-cvslog
mailing list