X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Flsp.c;h=71124920018282452e7165c1b88238cc33857c91;hb=73c44cb2869bfdbea829942eb35efa6d4c4e2f91;hp=ffd2410b48f137816936400507b26d8df739e735;hpb=00fa73f052c1c0c0185ee4d2accb8fba065132f1;p=ffmpeg diff --git a/libavcodec/lsp.c b/libavcodec/lsp.c index ffd2410b48f..71124920018 100644 --- a/libavcodec/lsp.c +++ b/libavcodec/lsp.c @@ -47,7 +47,7 @@ void ff_acelp_reorder_lsf(int16_t* lsfq, int lsfq_min_distance, int lsfq_min, in lsfq[lp_order-1] = FFMIN(lsfq[lp_order-1], lsfq_max);//Is warning required ? } -void ff_set_min_dist_lsf(float *lsf, float min_spacing, int size) +void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size) { int i; float prev = 0.0; @@ -90,8 +90,8 @@ static void lsp2poly(int* f, const int16_t* lsp, int lp_half_order) void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) { int i; - int f1[lp_half_order+1]; // (3.22) - int f2[lp_half_order+1]; // (3.22) + int f1[MAX_LP_HALF_ORDER+1]; // (3.22) + int f2[MAX_LP_HALF_ORDER+1]; // (3.22) lsp2poly(f1, lsp , lp_half_order); lsp2poly(f2, lsp+1, lp_half_order); @@ -111,7 +111,7 @@ void ff_acelp_lsp2lpc(int16_t* lp, const int16_t* lsp, int lp_half_order) void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd, const int16_t* lsp_prev, int lp_order) { - int16_t lsp_1st[lp_order]; // (0.15) + int16_t lsp_1st[MAX_LP_ORDER]; // (0.15) int i; /* LSP values for first subframe (3.2.5 of G.729, Equation 24)*/ @@ -128,17 +128,7 @@ void ff_acelp_lp_decode(int16_t* lp_1st, int16_t* lp_2nd, const int16_t* lsp_2nd ff_acelp_lsp2lpc(lp_2nd, lsp_2nd, lp_order >> 1); } -/** - * Computes the Pa / (1 + z(-1)) or Qa / (1 - z(-1)) coefficients - * needed for LSP to LPC conversion. - * We only need to calculate the 6 first elements of the polynomial. - * - * @param lsp line spectral pairs in cosine domain - * @param f [out] polynomial input/output as a vector - * - * TIA/EIA/IS-733 2.4.3.3.5-1/2 - */ -static void lsp2polyf(const double *lsp, double *f, int lp_half_order) +void ff_lsp2polyf(const double *lsp, double *f, int lp_half_order) { int i, j; @@ -162,8 +152,8 @@ void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order) assert(lp_half_order <= MAX_LP_HALF_ORDER); - lsp2polyf(lsp, pa, lp_half_order); - lsp2polyf(lsp + 1, qa, lp_half_order); + ff_lsp2polyf(lsp, pa, lp_half_order); + ff_lsp2polyf(lsp + 1, qa, lp_half_order); while (lp_half_order--) { double paf = pa[lp_half_order+1] + pa[lp_half_order]; @@ -173,3 +163,12 @@ void ff_acelp_lspd2lpc(const double *lsp, float *lpc, int lp_half_order) lpc2[-lp_half_order] = 0.5*(paf-qaf); } } + +void ff_sort_nearly_sorted_floats(float *vals, int len) +{ + int i,j; + + for (i = 0; i < len - 1; i++) + for (j = i; j >= 0 && vals[j] > vals[j+1]; j--) + FFSWAP(float, vals[j], vals[j+1]); +}