static void dss_sp_unpack_coeffs(DssSpContext *p, const uint8_t *src)

{

    GetBitContext gb;

    DssSpFrame *fparam = &p->fparam;

    int i;

    int subframe_idx;

    uint32_t combined_pitch;

    uint32_t tmp;

    uint32_t pitch_lag;



    for (i = 0; i < DSS_SP_FRAME_SIZE; i += 2) {

        p->bits[i]     = src[i + 1];

        p->bits[i + 1] = src[i];

    }



    init_get_bits(&gb, p->bits, DSS_SP_FRAME_SIZE * 8);



    for (i = 0; i < 2; i++)

        fparam->filter_idx[i] = get_bits(&gb, 5);

    for (; i < 8; i++)

        fparam->filter_idx[i] = get_bits(&gb, 4);

    for (; i < 14; i++)

        fparam->filter_idx[i] = get_bits(&gb, 3);



    for (subframe_idx = 0; subframe_idx < 4; subframe_idx++) {

        fparam->sf_adaptive_gain[subframe_idx] = get_bits(&gb, 5);



        fparam->sf[subframe_idx].combined_pulse_pos = get_bits_long(&gb, 31);



        fparam->sf[subframe_idx].gain = get_bits(&gb, 6);



        for (i = 0; i < 7; i++)

            fparam->sf[subframe_idx].pulse_val[i] = get_bits(&gb, 3);

    }



    for (subframe_idx = 0; subframe_idx < 4; subframe_idx++) {

        unsigned int C72_binomials[PULSE_MAX] = {

            72, 2556, 59640, 1028790, 13991544, 156238908, 1473109704,

            3379081753

        };

        unsigned int combined_pulse_pos =

            fparam->sf[subframe_idx].combined_pulse_pos;

        int index = 6;



        if (combined_pulse_pos < C72_binomials[PULSE_MAX - 1]) {

            if (p->pulse_dec_mode) {

                int pulse, pulse_idx;

                pulse              = PULSE_MAX - 1;

                pulse_idx          = 71;

                combined_pulse_pos =

                    fparam->sf[subframe_idx].combined_pulse_pos;



                /* this part seems to be close to g723.1 gen_fcb_excitation()

                 * RATE_6300 */



                /* TODO: what is 7? size of subframe? */

                for (i = 0; i < 7; i++) {

                    for (;

                         combined_pulse_pos <

                         dss_sp_combinatorial_table[pulse][pulse_idx];

                         --pulse_idx)

                        ;

                    combined_pulse_pos -=

                        dss_sp_combinatorial_table[pulse][pulse_idx];

                    pulse--;

                    fparam->sf[subframe_idx].pulse_pos[i] = pulse_idx;

                }

            }

        } else {

            p->pulse_dec_mode = 0;



            /* why do we need this? */

            fparam->sf[subframe_idx].pulse_pos[6] = 0;



            for (i = 71; i >= 0; i--) {

                if (C72_binomials[index] <= combined_pulse_pos) {

                    combined_pulse_pos -= C72_binomials[index];



                    fparam->sf[subframe_idx].pulse_pos[6 - index] = i;



                    if (!index)

                        break;

                    --index;

                }

                --C72_binomials[0];

                if (index) {

                    int a;

                    for (a = 0; a < index; a++)

                        C72_binomials[a + 1] -= C72_binomials[a];

                }

            }

        }

    }



    combined_pitch = get_bits(&gb, 24);



    fparam->pitch_lag[0] = (combined_pitch % 151) + 36;



    combined_pitch /= 151;



    for (i = 1; i < SUBFRAMES; i++) {

        fparam->pitch_lag[i] = combined_pitch % 48;

        combined_pitch      /= 48;

    }



    pitch_lag = fparam->pitch_lag[0];

    for (i = 1; i < SUBFRAMES; i++) {

        if (pitch_lag > 162) {

            fparam->pitch_lag[i] += 162 - 23;

        } else {

            tmp = pitch_lag - 23;

            if (tmp < 36)

                tmp = 36;

            fparam->pitch_lag[i] += tmp;

        }

        pitch_lag = fparam->pitch_lag[i];

    }

}

static void dss_sp_unpack_coeffs(DssSpContext *p, const uint8_t *src)

{

    GetBitContext gb;

    DssSpFrame *fparam = &p->fparam;

    int i;

    int subframe_idx;

    uint32_t combined_pitch;

    uint32_t tmp;

    uint32_t pitch_lag;



    for (i = 0; i < DSS_SP_FRAME_SIZE; i += 2) {

        p->bits[i]     = src[i + 1];

        p->bits[i + 1] = src[i];

    }



    init_get_bits(&gb, p->bits, DSS_SP_FRAME_SIZE * 8);



    for (i = 0; i < 2; i++)

        fparam->filter_idx[i] = get_bits(&gb, 5);

    for (; i < 8; i++)

        fparam->filter_idx[i] = get_bits(&gb, 4);

    for (; i < 14; i++)

        fparam->filter_idx[i] = get_bits(&gb, 3);



    for (subframe_idx = 0; subframe_idx < 4; subframe_idx++) {

        fparam->sf_adaptive_gain[subframe_idx] = get_bits(&gb, 5);



        fparam->sf[subframe_idx].combined_pulse_pos = get_bits_long(&gb, 31);



        fparam->sf[subframe_idx].gain = get_bits(&gb, 6);



        for (i = 0; i < 7; i++)

            fparam->sf[subframe_idx].pulse_val[i] = get_bits(&gb, 3);

    }



    for (subframe_idx = 0; subframe_idx < 4; subframe_idx++) {

        unsigned int C72_binomials[PULSE_MAX] = {

            72, 2556, 59640, 1028790, 13991544, 156238908, 1473109704,

            3379081753

        };

        unsigned int combined_pulse_pos =

            fparam->sf[subframe_idx].combined_pulse_pos;

        int index = 6;



        if (combined_pulse_pos < C72_binomials[PULSE_MAX - 1]) {

            if (p->pulse_dec_mode) {

                int pulse, pulse_idx;

                pulse              = PULSE_MAX - 1;

                pulse_idx          = 71;

                combined_pulse_pos =

                    fparam->sf[subframe_idx].combined_pulse_pos;



                





                

                for (i = 0; i < 7; i++) {

                    for (;

                         combined_pulse_pos <

                         dss_sp_combinatorial_table[pulse][pulse_idx];

                         --pulse_idx)

                        ;

                    combined_pulse_pos -=

                        dss_sp_combinatorial_table[pulse][pulse_idx];

                    pulse--;

                    fparam->sf[subframe_idx].pulse_pos[i] = pulse_idx;

                }

            }

        } else {

            p->pulse_dec_mode = 0;



            

            fparam->sf[subframe_idx].pulse_pos[6] = 0;



            for (i = 71; i >= 0; i--) {

                if (C72_binomials[index] <= combined_pulse_pos) {

                    combined_pulse_pos -= C72_binomials[index];



                    fparam->sf[subframe_idx].pulse_pos[6 - index] = i;



                    if (!index)

                        break;

                    --index;

                }

                --C72_binomials[0];

                if (index) {

                    int a;

                    for (a = 0; a < index; a++)

                        C72_binomials[a + 1] -= C72_binomials[a];

                }

            }

        }

    }



    combined_pitch = get_bits(&gb, 24);



    fparam->pitch_lag[0] = (combined_pitch % 151) + 36;



    combined_pitch /= 151;



    for (i = 1; i < SUBFRAMES; i++) {

        fparam->pitch_lag[i] = combined_pitch % 48;

        combined_pitch      /= 48;

    }



    pitch_lag = fparam->pitch_lag[0];

    for (i = 1; i < SUBFRAMES; i++) {

        if (pitch_lag > 162) {

            fparam->pitch_lag[i] += 162 - 23;

        } else {

            tmp = pitch_lag - 23;

            if (tmp < 36)

                tmp = 36;

            fparam->pitch_lag[i] += tmp;

        }

        pitch_lag = fparam->pitch_lag[i];

    }

}

static void FUNC_0(DssSpContext *VAR_0, const uint8_t *VAR_1)

{

    GetBitContext gb;

    DssSpFrame *fparam = &VAR_0->fparam;

    int VAR_2;

    int VAR_3;

    uint32_t combined_pitch;

    uint32_t tmp;

    uint32_t pitch_lag;



    for (VAR_2 = 0; VAR_2 < DSS_SP_FRAME_SIZE; VAR_2 += 2) {

        VAR_0->bits[VAR_2]     = VAR_1[VAR_2 + 1];

        VAR_0->bits[VAR_2 + 1] = VAR_1[VAR_2];

    }



    init_get_bits(&gb, VAR_0->bits, DSS_SP_FRAME_SIZE * 8);



    for (VAR_2 = 0; VAR_2 < 2; VAR_2++)

        fparam->filter_idx[VAR_2] = get_bits(&gb, 5);

    for (; VAR_2 < 8; VAR_2++)

        fparam->filter_idx[VAR_2] = get_bits(&gb, 4);

    for (; VAR_2 < 14; VAR_2++)

        fparam->filter_idx[VAR_2] = get_bits(&gb, 3);



    for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {

        fparam->sf_adaptive_gain[VAR_3] = get_bits(&gb, 5);



        fparam->sf[VAR_3].VAR_5 = get_bits_long(&gb, 31);



        fparam->sf[VAR_3].gain = get_bits(&gb, 6);



        for (VAR_2 = 0; VAR_2 < 7; VAR_2++)

            fparam->sf[VAR_3].pulse_val[VAR_2] = get_bits(&gb, 3);

    }



    for (VAR_3 = 0; VAR_3 < 4; VAR_3++) {

        unsigned int VAR_4[PULSE_MAX] = {

            72, 2556, 59640, 1028790, 13991544, 156238908, 1473109704,

            3379081753

        };

        unsigned int VAR_5 =

            fparam->sf[VAR_3].VAR_5;

        int VAR_6 = 6;



        if (VAR_5 < VAR_4[PULSE_MAX - 1]) {

            if (VAR_0->pulse_dec_mode) {

                int VAR_7, VAR_8;

                VAR_7              = PULSE_MAX - 1;

                VAR_8          = 71;

                VAR_5 =

                    fparam->sf[VAR_3].VAR_5;



                





                

                for (VAR_2 = 0; VAR_2 < 7; VAR_2++) {

                    for (;

                         VAR_5 <

                         dss_sp_combinatorial_table[VAR_7][VAR_8];

                         --VAR_8)

                        ;

                    VAR_5 -=

                        dss_sp_combinatorial_table[VAR_7][VAR_8];

                    VAR_7--;

                    fparam->sf[VAR_3].pulse_pos[VAR_2] = VAR_8;

                }

            }

        } else {

            VAR_0->pulse_dec_mode = 0;



            

            fparam->sf[VAR_3].pulse_pos[6] = 0;



            for (VAR_2 = 71; VAR_2 >= 0; VAR_2--) {

                if (VAR_4[VAR_6] <= VAR_5) {

                    VAR_5 -= VAR_4[VAR_6];



                    fparam->sf[VAR_3].pulse_pos[6 - VAR_6] = VAR_2;



                    if (!VAR_6)

                        break;

                    --VAR_6;

                }

                --VAR_4[0];

                if (VAR_6) {

                    int VAR_9;

                    for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++)

                        VAR_4[VAR_9 + 1] -= VAR_4[VAR_9];

                }

            }

        }

    }



    combined_pitch = get_bits(&gb, 24);



    fparam->pitch_lag[0] = (combined_pitch % 151) + 36;



    combined_pitch /= 151;



    for (VAR_2 = 1; VAR_2 < SUBFRAMES; VAR_2++) {

        fparam->pitch_lag[VAR_2] = combined_pitch % 48;

        combined_pitch      /= 48;

    }



    pitch_lag = fparam->pitch_lag[0];

    for (VAR_2 = 1; VAR_2 < SUBFRAMES; VAR_2++) {

        if (pitch_lag > 162) {

            fparam->pitch_lag[VAR_2] += 162 - 23;

        } else {

            tmp = pitch_lag - 23;

            if (tmp < 36)

                tmp = 36;

            fparam->pitch_lag[VAR_2] += tmp;

        }

        pitch_lag = fparam->pitch_lag[VAR_2];

    }

}

static void FUNC_0(DssSpContext *VAR_0, const uint8_t *VAR_1)
{ GetBitContext gb; DssSpFrame *fparam = &VAR_0->fparam; int VAR_2; int VAR_3; uint32_t combined_pitch; uint32_t tmp; uint32_t pitch_lag; for (VAR_2 = 0; VAR_2 < DSS_SP_FRAME_SIZE; VAR_2 += 2) { VAR_0->bits[VAR_2]     = VAR_1[VAR_2 + 1]; VAR_0->bits[VAR_2 + 1] = VAR_1[VAR_2]; } init_get_bits(&gb, VAR_0->bits, DSS_SP_FRAME_SIZE * 8); for (VAR_2 = 0; VAR_2 < 2; VAR_2++) fparam->filter_idx[VAR_2] = get_bits(&gb, 5); for (; VAR_2 < 8; VAR_2++) fparam->filter_idx[VAR_2] = get_bits(&gb, 4); for (; VAR_2 < 14; VAR_2++) fparam->filter_idx[VAR_2] = get_bits(&gb, 3); for (VAR_3 = 0; VAR_3 < 4; VAR_3++) { fparam->sf_adaptive_gain[VAR_3] = get_bits(&gb, 5); fparam->sf[VAR_3].VAR_5 = get_bits_long(&gb, 31); fparam->sf[VAR_3].gain = get_bits(&gb, 6); for (VAR_2 = 0; VAR_2 < 7; VAR_2++) fparam->sf[VAR_3].pulse_val[VAR_2] = get_bits(&gb, 3); } for (VAR_3 = 0; VAR_3 < 4; VAR_3++) { unsigned int VAR_4[PULSE_MAX] = { 72, 2556, 59640, 1028790, 13991544, 156238908, 1473109704,
3379081753
}; unsigned int VAR_5 =
fparam->sf[VAR_3].VAR_5; int VAR_6 = 6; if (VAR_5 < VAR_4[PULSE_MAX - 1]) { if (VAR_0->pulse_dec_mode) { int VAR_7, VAR_8; VAR_7              = PULSE_MAX - 1; VAR_8          = 71; VAR_5 =
fparam->sf[VAR_3].VAR_5; for (VAR_2 = 0; VAR_2 < 7; VAR_2++) { for (; VAR_5 <
dss_sp_combinatorial_table[VAR_7][VAR_8]; --VAR_8)
; VAR_5 -=
dss_sp_combinatorial_table[VAR_7][VAR_8]; VAR_7--; fparam->sf[VAR_3].pulse_pos[VAR_2] = VAR_8; } } } else { VAR_0->pulse_dec_mode = 0; fparam->sf[VAR_3].pulse_pos[6] = 0; for (VAR_2 = 71; VAR_2 >= 0; VAR_2--) { if (VAR_4[VAR_6] <= VAR_5) { VAR_5 -= VAR_4[VAR_6]; fparam->sf[VAR_3].pulse_pos[6 - VAR_6] = VAR_2; if (!VAR_6)
break; --VAR_6; } --VAR_4[0]; if (VAR_6) { int VAR_9; for (VAR_9 = 0; VAR_9 < VAR_6; VAR_9++) VAR_4[VAR_9 + 1] -= VAR_4[VAR_9]; } } } } combined_pitch = get_bits(&gb, 24); fparam->pitch_lag[0] = (combined_pitch % 151) + 36; combined_pitch /= 151; for (VAR_2 = 1; VAR_2 < SUBFRAMES; VAR_2++) { fparam->pitch_lag[VAR_2] = combined_pitch % 48; combined_pitch      /= 48; } pitch_lag = fparam->pitch_lag[0]; for (VAR_2 = 1; VAR_2 < SUBFRAMES; VAR_2++) { if (pitch_lag > 162) { fparam->pitch_lag[VAR_2] += 162 - 23; } else { tmp = pitch_lag - 23; if (tmp < 36)
tmp = 36; fparam->pitch_lag[VAR_2] += tmp; } pitch_lag = fparam->pitch_lag[VAR_2]; } }