123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- #include "g_pitch.h"
- const char g_pitch_id[] = "@(#)$Id $" g_pitch_h;
-
- #include <stdlib.h>
- #include <stdio.h>
- #include "typedef.h"
- #include "mode.h"
- #include "basic_op.h"
- #include "oper_32b.h"
- #include "count.h"
- #include "cnst.h"
-
- Word16 G_pitch (
- enum Mode mode,
- Word16 xn[],
- Word16 y1[],
- Word16 g_coeff[],
- Word16 L_subfr
- )
- {
- Word16 i;
- Word16 xy, yy, exp_xy, exp_yy, gain;
- Word32 s;
- Word16 scaled_y1[L_SUBFR];
-
- for (i = 0; i < L_subfr; i++)
- {
- scaled_y1[i] = shr_ex (y1[i], 2); move16 ();
- }
-
-
- Overflow = 0; move16 ();
- s = 1L; move32 ();
- for (i = 0; i < L_subfr; i++)
- {
- s = L_mac_ex (s, y1[i], y1[i]);
- }
- test ();
- if (Overflow == 0)
- {
- exp_yy = norm_l_ex (s);
- yy = round_ex (L_shl_ex (s, exp_yy));
- }
- else
- {
- s = 1L; move32 ();
- for (i = 0; i < L_subfr; i++)
- {
- s = L_mac_ex (s, scaled_y1[i], scaled_y1[i]);
- }
- exp_yy = norm_l_ex (s);
- yy = round_ex (L_shl_ex (s, exp_yy));
- exp_yy = sub_ex (exp_yy, 4);
- }
-
-
-
- Overflow = 0; move16 ();
- s = 1L; move32 ();
-
- for (i = 0; i < L_subfr; i++)
- {
- s = L_mac_ex(s, xn[i], y1[i]);
- }
- test ();
- if (Overflow == 0)
- {
- exp_xy = norm_l_ex (s);
- xy = round_ex (L_shl_ex (s, exp_xy));
- }
- else
- {
- s = 1L; move32 ();
- for (i = 0; i < L_subfr; i++)
- {
- s = L_mac_ex (s, xn[i], scaled_y1[i]);
- }
- exp_xy = norm_l_ex (s);
- xy = round_ex (L_shl_ex (s, exp_xy));
- exp_xy = sub_ex (exp_xy, 2);
- }
- g_coeff[0] = yy; move16 ();
- g_coeff[1] = sub_ex (15, exp_yy); move16 ();
- g_coeff[2] = xy; move16 ();
- g_coeff[3] = sub_ex (15, exp_xy); move16 ();
-
-
- i = sub_ex (xy, 4);
- test ();
- if (i < 0)
- return ((Word16) 0);
-
- xy = shr_ex (xy, 1);
- gain = div_s (xy, yy);
- i = sub_ex (exp_xy, exp_yy);
- gain = shr_ex (gain, i);
-
-
-
- test ();
- if (sub_ex (gain, 19661) > 0)
- {
- gain = 19661; move16 ();
- }
- test ();
- if (sub_ex(mode, MR122) == 0)
- {
-
- gain = gain & 0xfffC; logic16 ();
- }
-
- return (gain);
- }
|