00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #include "common.h"
00034 #include "structs.h"
00035
00036 #ifdef SSR_DEC
00037
00038 #include "ssr.h"
00039 #include "ssr_ipqf.h"
00040
00041 static real_t **app_pqfbuf;
00042 static real_t **pp_q0, **pp_t0, **pp_t1;
00043
00044 void gc_set_protopqf(real_t *p_proto)
00045 {
00046 int j;
00047 static real_t a_half[48] =
00048 {
00049 1.2206911375946939E-05, 1.7261986723798209E-05, 1.2300093657077942E-05,
00050 -1.0833943097791965E-05, -5.7772498639901686E-05, -1.2764767618947719E-04,
00051 -2.0965186675013334E-04, -2.8166673689263850E-04, -3.1234860429017460E-04,
00052 -2.6738519958452353E-04, -1.1949424681824722E-04, 1.3965139412648678E-04,
00053 4.8864136409185725E-04, 8.7044629275148344E-04, 1.1949430269934793E-03,
00054 1.3519708175026700E-03, 1.2346314373964412E-03, 7.6953209114159191E-04,
00055 -5.2242432579537141E-05, -1.1516092887213454E-03, -2.3538469841711277E-03,
00056 -3.4033123072127277E-03, -4.0028551071986133E-03, -3.8745415659693259E-03,
00057 -2.8321073426874310E-03, -8.5038892323704195E-04, 1.8856751185350931E-03,
00058 4.9688741735340923E-03, 7.8056704536795926E-03, 9.7027909685901654E-03,
00059 9.9960423120166159E-03, 8.2019366335594487E-03, 4.1642072876103365E-03,
00060 -1.8364453822737758E-03, -9.0384863094167686E-03, -1.6241528177129844E-02,
00061 -2.1939551286300665E-02, -2.4533179947088161E-02, -2.2591663337768787E-02,
00062 -1.5122066420044672E-02, -1.7971713448186293E-03, 1.6903413428575379E-02,
00063 3.9672315874127042E-02, 6.4487527248102796E-02, 8.8850025474701726E-02,
00064 0.1101132906105560 , 0.1258540205143761 , 0.1342239368467012
00065 };
00066
00067 for (j = 0; j < 48; ++j)
00068 {
00069 p_proto[j] = p_proto[95-j] = a_half[j];
00070 }
00071 }
00072
00073 void gc_setcoef_eff_pqfsyn(int mm,
00074 int kk,
00075 real_t *p_proto,
00076 real_t ***ppp_q0,
00077 real_t ***ppp_t0,
00078 real_t ***ppp_t1)
00079 {
00080 int i, k, n;
00081 real_t w;
00082
00083
00084 *ppp_q0 = (real_t **) calloc(mm, sizeof(real_t *));
00085 for (n = 0; n < mm; ++n)
00086 {
00087 (*ppp_q0)[n] = (real_t *) calloc(mm, sizeof(real_t));
00088 }
00089 for (n = 0; n < mm/2; ++n)
00090 {
00091 for (i = 0; i < mm; ++i)
00092 {
00093 w = (2*i+1)*(2*n+1-mm)*M_PI/(4*mm);
00094 (*ppp_q0)[n][i] = 2.0 * cos((real_t) w);
00095
00096 w = (2*i+1)*(2*(mm+n)+1-mm)*M_PI/(4*mm);
00097 (*ppp_q0)[n + mm/2][i] = 2.0 * cos((real_t) w);
00098 }
00099 }
00100
00101
00102 *ppp_t0 = (real_t **) calloc(mm, sizeof(real_t *));
00103 *ppp_t1 = (real_t **) calloc(mm, sizeof(real_t *));
00104 for (n = 0; n < mm; ++n)
00105 {
00106 (*ppp_t0)[n] = (real_t *) calloc(kk, sizeof(real_t));
00107 (*ppp_t1)[n] = (real_t *) calloc(kk, sizeof(real_t));
00108 }
00109 for (n = 0; n < mm; ++n)
00110 {
00111 for (k = 0; k < kk; ++k)
00112 {
00113 (*ppp_t0)[n][k] = mm * p_proto[2*k *mm + n];
00114 (*ppp_t1)[n][k] = mm * p_proto[(2*k+1)*mm + n];
00115
00116 if (k%2 != 0)
00117 {
00118 (*ppp_t0)[n][k] = -(*ppp_t0)[n][k];
00119 (*ppp_t1)[n][k] = -(*ppp_t1)[n][k];
00120 }
00121 }
00122 }
00123 }
00124
00125 void ssr_ipqf(ssr_info *ssr, real_t *in_data, real_t *out_data,
00126 real_t buffer[SSR_BANDS][96/4],
00127 uint16_t frame_len, uint8_t bands)
00128 {
00129 static int initFlag = 0;
00130 real_t a_pqfproto[PQFTAPS];
00131
00132 int i;
00133
00134 if (initFlag == 0)
00135 {
00136 gc_set_protopqf(a_pqfproto);
00137 gc_setcoef_eff_pqfsyn(SSR_BANDS, PQFTAPS/(2*SSR_BANDS), a_pqfproto,
00138 &pp_q0, &pp_t0, &pp_t1);
00139 initFlag = 1;
00140 }
00141
00142 for (i = 0; i < frame_len / SSR_BANDS; i++)
00143 {
00144 int l, n, k;
00145 int mm = SSR_BANDS;
00146 int kk = PQFTAPS/(2*SSR_BANDS);
00147
00148 for (n = 0; n < mm; n++)
00149 {
00150 for (k = 0; k < 2*kk-1; k++)
00151 {
00152 buffer[n][k] = buffer[n][k+1];
00153 }
00154 }
00155
00156 for (n = 0; n < mm; n++)
00157 {
00158 real_t acc = 0.0;
00159 for (l = 0; l < mm; l++)
00160 {
00161 acc += pp_q0[n][l] * in_data[l*frame_len/SSR_BANDS + i];
00162 }
00163 buffer[n][2*kk-1] = acc;
00164 }
00165
00166 for (n = 0; n < mm/2; n++)
00167 {
00168 real_t acc = 0.0;
00169 for (k = 0; k < kk; k++)
00170 {
00171 acc += pp_t0[n][k] * buffer[n][2*kk-1-2*k];
00172 }
00173 for (k = 0; k < kk; ++k)
00174 {
00175 acc += pp_t1[n][k] * buffer[n + mm/2][2*kk-2-2*k];
00176 }
00177 out_data[i*SSR_BANDS + n] = acc;
00178
00179 acc = 0.0;
00180 for (k = 0; k < kk; k++)
00181 {
00182 acc += pp_t0[mm-1-n][k] * buffer[n][2*kk-1-2*k];
00183 }
00184 for (k = 0; k < kk; k++)
00185 {
00186 acc -= pp_t1[mm-1-n][k] * buffer[n + mm/2][2*kk-2-2*k];
00187 }
00188 out_data[i*SSR_BANDS + mm-1-n] = acc;
00189 }
00190 }
00191 }
00192
00193 #endif