123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
-
-
- #include "q_plsf.h"
- const char q_plsf_5_id[] = "@(#)$Id $" q_plsf_h;
-
- #include <stdlib.h>
- #include <stdio.h>
- #include "typedef.h"
- #include "basic_op.h"
- #include "count.h"
- #include "lsp_lsf.h"
- #include "reorder.h"
- #include "lsfwt.h"
- #include "q_plsf_5.tab"
-
- static Word16 Vq_subvec (
- Word16 *lsf_r1,
- Word16 *lsf_r2,
- const Word16 *dico,
- Word16 *wf1,
- Word16 *wf2,
- Word16 dico_size
- )
- {
- Word16 index = 0;
- Word16 i, temp;
- const Word16 *p_dico;
- Word32 dist_min, dist;
- dist_min = MAX_32; move32 ();
- p_dico = dico; move16 ();
- for (i = 0; i < dico_size; i++)
- {
- temp = sub_ex (lsf_r1[0], *p_dico++);
- temp = mult_ex (wf1[0], temp);
- dist = L_mult_ex (temp, temp);
- temp = sub_ex (lsf_r1[1], *p_dico++);
- temp = mult_ex (wf1[1], temp);
- dist = L_mac_ex (dist, temp, temp);
- temp = sub_ex (lsf_r2[0], *p_dico++);
- temp = mult_ex (wf2[0], temp);
- dist = L_mac_ex (dist, temp, temp);
- temp = sub_ex (lsf_r2[1], *p_dico++);
- temp = mult_ex (wf2[1], temp);
- dist = L_mac_ex (dist, temp, temp);
- test ();
- if (L_sub_ex (dist, dist_min) < (Word32) 0)
- {
- dist_min = dist; move32 ();
- index = i; move16 ();
- }
- }
-
- p_dico = &dico[shl_ex (index, 2)]; move16 ();
- lsf_r1[0] = *p_dico++; move16 ();
- lsf_r1[1] = *p_dico++; move16 ();
- lsf_r2[0] = *p_dico++; move16 ();
- lsf_r2[1] = *p_dico++; move16 ();
- return index;
- }
- static Word16 Vq_subvec_s (
- Word16 *lsf_r1,
- Word16 *lsf_r2,
- const Word16 *dico,
- Word16 *wf1,
- Word16 *wf2,
- Word16 dico_size)
- {
- Word16 index = 0;
- Word16 sign = 0;
- Word16 i, temp;
- const Word16 *p_dico;
- Word32 dist_min, dist;
- dist_min = MAX_32; move32 ();
- p_dico = dico; move16 ();
- for (i = 0; i < dico_size; i++)
- {
-
- temp = sub_ex (lsf_r1[0], *p_dico++);
- temp = mult_ex (wf1[0], temp);
- dist = L_mult_ex (temp, temp);
- temp = sub_ex (lsf_r1[1], *p_dico++);
- temp = mult_ex (wf1[1], temp);
- dist = L_mac_ex (dist, temp, temp);
- temp = sub_ex (lsf_r2[0], *p_dico++);
- temp = mult_ex (wf2[0], temp);
- dist = L_mac_ex (dist, temp, temp);
- temp = sub_ex (lsf_r2[1], *p_dico++);
- temp = mult_ex (wf2[1], temp);
- dist = L_mac_ex (dist, temp, temp);
- test ();
- if (L_sub_ex (dist, dist_min) < (Word32) 0)
- {
- dist_min = dist; move32 ();
- index = i; move16 ();
- sign = 0; move16 ();
- }
-
- p_dico -= 4; move16 ();
- temp = add_ex (lsf_r1[0], *p_dico++);
- temp = mult_ex (wf1[0], temp);
- dist = L_mult_ex (temp, temp);
- temp = add_ex (lsf_r1[1], *p_dico++);
- temp = mult_ex (wf1[1], temp);
- dist = L_mac_ex (dist, temp, temp);
- temp = add_ex (lsf_r2[0], *p_dico++);
- temp = mult_ex (wf2[0], temp);
- dist = L_mac_ex (dist, temp, temp);
- temp = add_ex (lsf_r2[1], *p_dico++);
- temp = mult_ex (wf2[1], temp);
- dist = L_mac_ex (dist, temp, temp);
- test ();
- if (L_sub_ex (dist, dist_min) < (Word32) 0)
- {
- dist_min = dist; move32 ();
- index = i; move16 ();
- sign = 1; move16 ();
- }
- }
-
- p_dico = &dico[shl_ex (index, 2)]; move16 ();
- test ();
- if (sign == 0)
- {
- lsf_r1[0] = *p_dico++; move16 ();
- lsf_r1[1] = *p_dico++; move16 ();
- lsf_r2[0] = *p_dico++; move16 ();
- lsf_r2[1] = *p_dico++; move16 ();
- }
- else
- {
- lsf_r1[0] = negate_ex (*p_dico++); move16 ();
- lsf_r1[1] = negate_ex (*p_dico++); move16 ();
- lsf_r2[0] = negate_ex (*p_dico++); move16 ();
- lsf_r2[1] = negate_ex (*p_dico++); move16 ();
- }
- index = shl_ex (index, 1);
- index = add_ex (index, sign);
- return index;
- }
-
- void Q_plsf_5 (
- Q_plsfState *st,
- Word16 *lsp1,
- Word16 *lsp2,
- Word16 *lsp1_q,
- Word16 *lsp2_q,
- Word16 *indice
- )
- {
- Word16 i;
- Word16 lsf1[M], lsf2[M], wf1[M], wf2[M], lsf_p[M], lsf_r1[M], lsf_r2[M];
- Word16 lsf1_q[M], lsf2_q[M];
-
- Lsp_lsf (lsp1, lsf1, M);
- Lsp_lsf (lsp2, lsf2, M);
-
-
- Lsf_wt (lsf1, wf1);
- Lsf_wt (lsf2, wf2);
-
- for (i = 0; i < M; i++)
- {
- lsf_p[i] = add_ex (mean_lsf[i], mult_ex (st->past_rq[i], LSP_PRED_FAC_MR122));
- move16 ();
- lsf_r1[i] = sub_ex (lsf1[i], lsf_p[i]); move16 ();
- lsf_r2[i] = sub_ex (lsf2[i], lsf_p[i]); move16 ();
- }
-
- indice[0] = Vq_subvec (&lsf_r1[0], &lsf_r2[0], dico1_lsf,
- &wf1[0], &wf2[0], DICO1_SIZE);
- move16 ();
- indice[1] = Vq_subvec (&lsf_r1[2], &lsf_r2[2], dico2_lsf,
- &wf1[2], &wf2[2], DICO2_SIZE);
- move16 ();
- indice[2] = Vq_subvec_s (&lsf_r1[4], &lsf_r2[4], dico3_lsf,
- &wf1[4], &wf2[4], DICO3_SIZE);
- move16 ();
- indice[3] = Vq_subvec (&lsf_r1[6], &lsf_r2[6], dico4_lsf,
- &wf1[6], &wf2[6], DICO4_SIZE);
- move16 ();
- indice[4] = Vq_subvec (&lsf_r1[8], &lsf_r2[8], dico5_lsf,
- &wf1[8], &wf2[8], DICO5_SIZE);
- move16 ();
-
- for (i = 0; i < M; i++)
- {
- lsf1_q[i] = add_ex (lsf_r1[i], lsf_p[i]); move16 ();
- lsf2_q[i] = add_ex (lsf_r2[i], lsf_p[i]); move16 ();
- st->past_rq[i] = lsf_r2[i]; move16 ();
- }
-
- Reorder_lsf (lsf1_q, LSF_GAP, M);
- Reorder_lsf (lsf2_q, LSF_GAP, M);
-
-
- Lsf_lsp (lsf1_q, lsp1_q, M);
- Lsf_lsp (lsf2_q, lsp2_q, M);
- }
|