/* Rearrange the LSP coefficients so that they have a minimum distance of min_dist. This function does it exactly as described in section of 3.2.4 of the G.729 specification (but interestingly is different from what the reference decoder actually does).  */
static void rearrange_lsp(int order, float *lsp, float min_dist)
/* Rearrange the LSP coefficients so that they have a minimum distance of min_dist. This function does it exactly as described in section of 3.2.4 of the G.729 specification (but interestingly is different from what the reference decoder actually does).  */
static void rearrange_lsp(int order, float *lsp, float min_dist)
{
    int i;
    float min_dist2 = min_dist * 0.5;
    for (i = 1; i < order; i++)
        if (lsp[i] - lsp[i-1] < min_dist) {
            float avg = (lsp[i] + lsp[i-1]) * 0.5;
            lsp[i-1] = avg - min_dist2;
            lsp[i  ] = avg + min_dist2;
        }
}