[FFmpeg-cvslog] avcodec/rl: Avoid branch in index lookup

Andreas Rheinhardt git at videolan.org
Thu Jul 3 21:55:07 EEST 2025


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sat Jun 14 23:53:36 2025 +0200| [ba79fff6d523e04758aa59f82ddfe2dc06ae4678] | committer: Andreas Rheinhardt

avcodec/rl: Avoid branch in index lookup

This uses the same logic as the MPEG-1/2 and SpeedHQ encoders.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>

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

 libavcodec/rl.h | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/libavcodec/rl.h b/libavcodec/rl.h
index c45d8659d1..2588de2440 100644
--- a/libavcodec/rl.h
+++ b/libavcodec/rl.h
@@ -100,13 +100,9 @@ do {                                                    \
 
 static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
 {
-    int index;
-    index = rl->index_run[last][run];
-    if (index >= rl->n)
-        return rl->n;
     if (level > rl->max_level[last][run])
         return rl->n;
-    return index + level - 1;
+    return rl->index_run[last][run] + level - 1;
 }
 
 #endif /* AVCODEC_RL_H */



More information about the ffmpeg-cvslog mailing list