dist=L_shl(dist,11);// cdbk_ptr is a 16 bit LUT with 3.12 values, used as 3.16. assumption: snsq_fx has the same representation. thus, the subtraction results are in 4.16, which leaves 11 bit headroom.
dist=Mpy_32_32(dist,dist);
dist=L_shr(dist,3);// make sure that the sum of 8 values does not overflow
dist_fx=L_add(dist_fx,dist);
}
IF(LT_32(dist_fx,dist_min_fx))
{
dist_min_fx=dist_fx;
move32();
index_split=i;
move16();
}
}
/* set quantized vector */
cdbk_ptr=&cdbk[imult1616(index_split,split_len)];
FOR(Word16j=j0;j<j1;++j)
{
Word32tmp_3=L_mult(means[j],means_fix);// Q16
Word32tmp_4=L_mult(*cdbk_ptr++,cdbk_fix);// Q16
snsq_fx[j]=L_add(tmp_4,tmp_3);// Q16
move32();
}
/* for second split shift by five bits to store both indices as one 10 bit value */