[FFmpeg-cvslog] avcodec/smacker: Remove redundant check when decoding header trees

Andreas Rheinhardt git at videolan.org
Fri Sep 18 03:31:58 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Fri Jul 24 20:56:46 2020 +0200| [943a4581570728b4b1a2bf97e5601e24f3f80404] | committer: Andreas Rheinhardt

avcodec/smacker: Remove redundant check when decoding header trees

When length is zero for a leaf node (which happens iff the Huffman tree
consists of one leaf node only), prefix is also automatically zero.

Performance impact is negligible: For GCC 9 and the sample from #2425,
the time for one call to smka_decode_frame() decreased from 2053758 to
2053671 decicycles; for Clang 9 it went from 1523153 to 1521288.

Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

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

 libavcodec/smacker.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/libavcodec/smacker.c b/libavcodec/smacker.c
index c249ce7514..991622eb0e 100644
--- a/libavcodec/smacker.c
+++ b/libavcodec/smacker.c
@@ -105,13 +105,8 @@ static int smacker_decode_tree(GetBitContext *gb, HuffContext *hc, uint32_t pref
             av_log(NULL, AV_LOG_ERROR, "Tree size exceeded!\n");
             return AVERROR_INVALIDDATA;
         }
-        if(length){
-            hc->bits[hc->current] = prefix;
-            hc->lengths[hc->current] = length;
-        } else {
-            hc->bits[hc->current] = 0;
-            hc->lengths[hc->current] = 0;
-        }
+        hc->bits[hc->current]    = prefix;
+        hc->lengths[hc->current] = length;
         hc->values[hc->current] = get_bits(gb, 8);
         hc->current++;
         return 0;



More information about the ffmpeg-cvslog mailing list