hevc_filter: move some conditions out of loops