From b28200cd38a0a875d34b9d9359bb2d8e36f7b254 Mon Sep 17 00:00:00 2001 From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Date: Thu, 13 Mar 2025 21:56:23 +0100 Subject: [PATCH 11/17] avcodec/hqx: Don't zero in small chunks, don't zero twice Up until now, decode_block() zeroed every block (of 128 bytes) before decoding a block; yet this is suboptimal for all modes, because all modes need to reset all the blocks they use anyway and so it should be done in one go for all blocks. For the alpha modes (where blocks need not be coded) all blocks are zeroed initially anyway, because decode_block() might not be doing it, so zeroing there again for the coded blocks is a waste. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/hqx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/hqx.c b/libavcodec/hqx.c index c6f0989ee5..c28c274b24 100644 --- a/libavcodec/hqx.c +++ b/libavcodec/hqx.c @@ -150,7 +150,6 @@ static int decode_block(GetBitContext *gb, const VLCElem vlc[], int ac_idx; int run, lev, pos = 0; - memset(block, 0, 64 * sizeof(*block)); dc = get_vlc2(gb, vlc, HQX_DC_VLC_BITS, 2); *last_dc += dc; @@ -190,6 +189,8 @@ static int hqx_decode_422(HQXContext *ctx, int slice_no, int x, int y) int last_dc; int i, ret; + memset(slice->block, 0, sizeof(*slice->block) * 8); + if (ctx->interlaced) flag = get_bits1(gb); else @@ -271,6 +272,8 @@ static int hqx_decode_444(HQXContext *ctx, int slice_no, int x, int y) int last_dc; int i, ret; + memset(slice->block, 0, sizeof(*slice->block) * 12); + if (ctx->interlaced) flag = get_bits1(gb); else -- 2.45.2