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

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>
This commit is contained in:
Andreas Rheinhardt
2025-03-13 21:56:23 +01:00
parent 7d70fb3530
commit 02b5aee879

View File

@ -150,7 +150,6 @@ static int decode_block(GetBitContext *gb, const VLCElem vlc[],
int ac_idx; int ac_idx;
int run, lev, pos = 0; int run, lev, pos = 0;
memset(block, 0, 64 * sizeof(*block));
dc = get_vlc2(gb, vlc, HQX_DC_VLC_BITS, 2); dc = get_vlc2(gb, vlc, HQX_DC_VLC_BITS, 2);
*last_dc += dc; *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 last_dc;
int i, ret; int i, ret;
memset(slice->block, 0, sizeof(*slice->block) * 8);
if (ctx->interlaced) if (ctx->interlaced)
flag = get_bits1(gb); flag = get_bits1(gb);
else else
@ -271,6 +272,8 @@ static int hqx_decode_444(HQXContext *ctx, int slice_no, int x, int y)
int last_dc; int last_dc;
int i, ret; int i, ret;
memset(slice->block, 0, sizeof(*slice->block) * 12);
if (ctx->interlaced) if (ctx->interlaced)
flag = get_bits1(gb); flag = get_bits1(gb);
else else