TIMD modes ascending cost reordering after refinement. OBIC check of division by zero
Derivation of weighted OBIC triggered a zero division, which should not happen by intent. This comes from TIMD modes which may not be ordered by ascending cost after refinement and in the particular case where the secondary TIMD modes reach a perfect template matching cost (weight is then maximum for the secondary TIMD mode and set to 0 for the primary mode). Here is provided a zero division check for OBIC and the root cause in TIMD is fixed by proposing a straighforward TIMD modes swapping in case secondary TIMD cost is less than primary TIMD cost.