ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinha...@outlook.com> | 
Thu Mar 13 21:56:23 2025 +0100| [02b5aee87949d8dd0e626e5354a3322c7620a34a] | 
committer: Andreas Rheinhardt

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.rheinha...@outlook.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=02b5aee87949d8dd0e626e5354a3322c7620a34a
---

 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

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to