Some loop counters were initialized incorrectly. This patch enhances the handling of loop iterations and residual parts. Reviewed-by: 陈昊 <chenhao@loongson.cn> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>