[FFmpeg-cvslog] avcodec/ffv1: Simplify update_vlc_state()

Michael Niedermayer git at videolan.org
Thu Jan 31 18:18:30 EET 2019


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Jan 27 00:56:59 2019 +0100| [a53c4f3689996f6090078f36de32bce1744f395b] | committer: Michael Niedermayer

avcodec/ffv1: Simplify update_vlc_state()

About 0.5% faster

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

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

 libavcodec/ffv1.h | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h
index 7c29d01f51..f0bb19350a 100644
--- a/libavcodec/ffv1.h
+++ b/libavcodec/ffv1.h
@@ -174,19 +174,13 @@ static inline void update_vlc_state(VlcState *const state, const int v)
     count++;
 
     if (drift <= -count) {
-        if (state->bias > -128)
-            state->bias--;
+        state->bias = FFMAX(state->bias - 1, -128);
 
-        drift += count;
-        if (drift <= -count)
-            drift = -count + 1;
+        drift = FFMAX(drift + count, -count + 1);
     } else if (drift > 0) {
-        if (state->bias < 127)
-            state->bias++;
+        state->bias = FFMIN(state->bias + 1, 127);
 
-        drift -= count;
-        if (drift > 0)
-            drift = 0;
+        drift = FFMIN(drift - count, 0);
     }
 
     state->drift = drift;



More information about the ffmpeg-cvslog mailing list