X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fffv1.h;h=147fe7ae165a5d63c60004a2c0984564c393d0c7;hb=252500a78fe1a31abc79e6070d16f50382c39343;hp=653138b0702196f186b930df4eb940da774b573c;hpb=f8377ffce35251bba043aeda5d81df0d411a0595;p=ffmpeg diff --git a/libavcodec/ffv1.h b/libavcodec/ffv1.h index 653138b0702..147fe7ae165 100644 --- a/libavcodec/ffv1.h +++ b/libavcodec/ffv1.h @@ -33,7 +33,6 @@ #include "libavutil/opt.h" #include "libavutil/imgutils.h" #include "libavutil/pixdesc.h" -#include "libavutil/timer.h" #include "avcodec.h" #include "get_bits.h" #include "internal.h" @@ -153,9 +152,7 @@ static av_always_inline int fold(int diff, int bits) if (bits == 8) diff = (int8_t)diff; else { - diff += 1 << (bits - 1); - diff = av_mod_uintp2(diff, bits); - diff -= 1 << (bits - 1); + diff = sign_extend(diff, bits); } return diff; @@ -176,19 +173,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;