Mercurial > libavcodec.hg
comparison twinvq.c @ 10557:f2f4d6fe3f6d libavcodec
Make sorting function used in TwinVQ a shared function
author | vitor |
---|---|
date | Sun, 22 Nov 2009 22:25:58 +0000 |
parents | 6d653bb57c58 |
children | 51b5f85c5064 |
comparison
equal
deleted
inserted
replaced
10556:54e322044750 | 10557:f2f4d6fe3f6d |
---|---|
534 lsp[i-1] = avg - min_dist2; | 534 lsp[i-1] = avg - min_dist2; |
535 lsp[i ] = avg + min_dist2; | 535 lsp[i ] = avg + min_dist2; |
536 } | 536 } |
537 } | 537 } |
538 | 538 |
539 static void bubblesort(float *lsp, int lp_order) | |
540 { | |
541 int i,j; | |
542 | |
543 /* sort lsp in ascending order. float bubble agorithm, | |
544 O(n) if data already sorted, O(n^2) - otherwise */ | |
545 for (i = 0; i < lp_order - 1; i++) | |
546 for (j = i; j >= 0 && lsp[j] > lsp[j+1]; j--) | |
547 FFSWAP(float, lsp[j], lsp[j+1]); | |
548 } | |
549 | |
550 static void decode_lsp(TwinContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, | 539 static void decode_lsp(TwinContext *tctx, int lpc_idx1, uint8_t *lpc_idx2, |
551 int lpc_hist_idx, float *lsp, float *hist) | 540 int lpc_hist_idx, float *lsp, float *hist) |
552 { | 541 { |
553 const ModeTab *mtab = tctx->mtab; | 542 const ModeTab *mtab = tctx->mtab; |
554 int i, j; | 543 int i, j; |
581 lsp[i] = lsp[i] * tmp1 + tmp2; | 570 lsp[i] = lsp[i] * tmp1 + tmp2; |
582 } | 571 } |
583 | 572 |
584 rearrange_lsp(mtab->n_lsp, lsp, 0.0001); | 573 rearrange_lsp(mtab->n_lsp, lsp, 0.0001); |
585 rearrange_lsp(mtab->n_lsp, lsp, 0.000095); | 574 rearrange_lsp(mtab->n_lsp, lsp, 0.000095); |
586 bubblesort(lsp, mtab->n_lsp); | 575 ff_sort_nearly_sorted_floats(lsp, mtab->n_lsp); |
587 } | 576 } |
588 | 577 |
589 static void dec_lpc_spectrum_inv(TwinContext *tctx, float *lsp, | 578 static void dec_lpc_spectrum_inv(TwinContext *tctx, float *lsp, |
590 enum FrameType ftype, float *lpc) | 579 enum FrameType ftype, float *lpc) |
591 { | 580 { |