[FFmpeg-cvslog] avcodec/hqxvlc: Include implicit +1 run in RL VLC tables
Andreas Rheinhardt
git at videolan.org
Mon Mar 17 04:40:20 EET 2025
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Thu Mar 13 20:04:16 2025 +0100| [09411fef3d0819e3a15ec25a0debeff848f5d365] | committer: Andreas Rheinhardt
avcodec/hqxvlc: Include implicit +1 run in RL VLC tables
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=09411fef3d0819e3a15ec25a0debeff848f5d365
---
libavcodec/hqx.c | 8 ++++----
libavcodec/hqxvlc.c | 3 ++-
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c
index b31c35bbcc..32acca79ac 100644
--- a/libavcodec/hqx.c
+++ b/libavcodec/hqx.c
@@ -115,7 +115,7 @@ static int decode_block(GetBitContext *gb, VLC *vlc,
{
int q, dc;
int ac_idx;
- int run, lev, pos = 1;
+ int run, lev, pos = 0;
memset(block, 0, 64 * sizeof(*block));
dc = get_vlc2(gb, vlc->table, HQX_DC_VLC_BITS, 2);
@@ -140,10 +140,10 @@ static int decode_block(GetBitContext *gb, VLC *vlc,
do {
hqx_get_ac(gb, &ff_hqx_ac[ac_idx], &run, &lev);
pos += run;
- if (pos >= 64)
+ if (pos > 63)
break;
- block[ff_zigzag_direct[pos++]] = lev * q;
- } while (pos < 64);
+ block[ff_zigzag_direct[pos]] = lev * q;
+ } while (pos < 63);
return 0;
}
diff --git a/libavcodec/hqxvlc.c b/libavcodec/hqxvlc.c
index 94ab21724c..63ca5cc33c 100644
--- a/libavcodec/hqxvlc.c
+++ b/libavcodec/hqxvlc.c
@@ -726,7 +726,8 @@ HQXAC ff_hqx_ac[NUM_HQX_AC] = {
};
// level is in -255..255 range, run 0..64, so it fits into 16 bits.
-#define E(level, run) ((level * 128) | run)
+// We offset run by 1 in order to include the implicit run of 1.
+#define E(level, run) ((level * 128) | (run + 1))
static const int16_t hqx_ac_run_level[] = {
// AC table Q0 - 815 elements
More information about the ffmpeg-cvslog
mailing list