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 #include "syntax.h"
00037 #include "is.h"
00038
00039 #ifdef FIXED_POINT
00040 static real_t pow05_table[] = {
00041 COEF_CONST(1.68179283050743),
00042 COEF_CONST(1.41421356237310),
00043 COEF_CONST(1.18920711500272),
00044 COEF_CONST(1.0),
00045 COEF_CONST(0.84089641525371),
00046 COEF_CONST(0.70710678118655),
00047 COEF_CONST(0.59460355750136)
00048 };
00049 #endif
00050
00051 void is_decode(ic_stream *ics, ic_stream *icsr, real_t *l_spec, real_t *r_spec,
00052 uint16_t frame_len)
00053 {
00054 uint8_t g, sfb, b;
00055 uint16_t i;
00056 #ifndef FIXED_POINT
00057 real_t scale;
00058 #else
00059 int32_t exp, frac;
00060 #endif
00061
00062 uint16_t nshort = frame_len/8;
00063 uint8_t group = 0;
00064
00065 for (g = 0; g < icsr->num_window_groups; g++)
00066 {
00067
00068 for (b = 0; b < icsr->window_group_length[g]; b++)
00069 {
00070 for (sfb = 0; sfb < icsr->max_sfb; sfb++)
00071 {
00072 if (is_intensity(icsr, g, sfb))
00073 {
00074 #ifdef MAIN_DEC
00075
00076
00077
00078
00079 ics->pred.prediction_used[sfb] = 0;
00080 icsr->pred.prediction_used[sfb] = 0;
00081 #endif
00082
00083 #ifndef FIXED_POINT
00084 scale = (real_t)pow(0.5, (0.25*icsr->scale_factors[g][sfb]));
00085 #else
00086 exp = icsr->scale_factors[g][sfb] >> 2;
00087 frac = icsr->scale_factors[g][sfb] & 3;
00088 #endif
00089
00090
00091
00092 for (i = icsr->swb_offset[sfb]; i < icsr->swb_offset[sfb+1]; i++)
00093 {
00094 #ifndef FIXED_POINT
00095 r_spec[(group*nshort)+i] = MUL_R(l_spec[(group*nshort)+i], scale);
00096 #else
00097 if (exp < 0)
00098 r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] << -exp;
00099 else
00100 r_spec[(group*nshort)+i] = l_spec[(group*nshort)+i] >> exp;
00101 r_spec[(group*nshort)+i] = MUL_C(r_spec[(group*nshort)+i], pow05_table[frac + 3]);
00102 #endif
00103 if (is_intensity(icsr, g, sfb) != invert_intensity(ics, g, sfb))
00104 r_spec[(group*nshort)+i] = -r_spec[(group*nshort)+i];
00105 }
00106 }
00107 }
00108 group++;
00109 }
00110 }
00111 }