Esempio n. 1
0
void rmlt_coefs_to_samples(int16_t coefs[],
                           int16_t old_samples[],
                           int16_t out_samples[],
                           int dct_length,
                           int16_t mag_shift)
{
    int i;
    int half_dct_length;
    int last;
    int16_t new_samples[MAX_DCT_LENGTH];
    const int16_t *win;
    int32_t sum;

    half_dct_length = dct_length >> 1;

    /* Perform a Type IV (inverse) DCT on the coefficients */
    dct_type_iv_s(coefs, new_samples, dct_length);

    if (mag_shift > 0)
    {
        for (i = 0;  i < dct_length;  i++)
            new_samples[i] = shr(new_samples[i], mag_shift);
    }
    else if (mag_shift < 0)
    {
        mag_shift = negate(mag_shift);
        for (i = 0;  i < dct_length;  i++)
            new_samples[i] = shl(new_samples[i], mag_shift);
    }

    win = (dct_length == DCT_LENGTH)  ?  rmlt_to_samples_window  :  max_rmlt_to_samples_window;
    last = half_dct_length - 1;
    for (i = 0;  i < half_dct_length;  i++)
    {
        /* Get the first half of the windowed samples */
        sum = L_mult(win[i], new_samples[last - i]);
        sum = L_mac(sum, win[dct_length - i - 1], old_samples[i]);
        out_samples[i] = xround(L_shl(sum, 2));
        /* Get the second half of the windowed samples */
        sum = L_mult(win[half_dct_length + i], new_samples[i]);
        sum = L_mac(sum, negate(win[last - i]), old_samples[last - i]);
        out_samples[half_dct_length + i] = xround(L_shl(sum, 2));
    }

    /* Save the second half of the new samples for
       next time, when they will be the old samples. */
    vec_copyi16(old_samples, &new_samples[half_dct_length], half_dct_length);
}
Esempio n. 2
0
void rmlt_coefs_to_samples(Int16 *coefs,     
                           Int16 *out_samples,           
                           Int16 dct_length,
                           Int16 mag_shift,
                           Uint16 chn)
{
    Int16	i;
    Int16	*new_ptr, *old_ptr;
    Int16	*win_new, *win_old;
    Int16	*out_ptr;
    Int16   half_dct_size;
    Int32   sum;

    half_dct_size = dct_length >> 1;

    /* Perform a Type IV (inverse) DCT on the coefficients */
    dct_type_iv_s(coefs, windowed_data, dct_length);

	if(mag_shift != 0)
	    for(i =  dct_length; i--; )
    	    windowed_data[i] = shr(windowed_data[i], mag_shift);

    /* Get the first half of the windowed samples */

    out_ptr = out_samples;
    if (dct_length != MAX_DCT_LENGTH)
        win_new = rmlt_to_samples_window;
    else
        win_new = max_rmlt_to_samples_window;

	win_old = win_new + dct_length;

    old_ptr = &old_samples[chn * dct_length];
    new_ptr = windowed_data + half_dct_size;

    for (i = half_dct_size; i--; )
    {
        sum = L_mult(*win_new++, *--new_ptr);
        sum = L_mac(sum, *--win_old, *old_ptr++);
        *out_ptr++ = round16(L_shl(sum, 2));
    }

    /* Get the second half of the windowed samples */

    for (i = half_dct_size; i--; )
    {
        sum = L_mult(*win_new++, *new_ptr++);
        sum = L_msu(sum, *--win_old, *--old_ptr);
        *out_ptr++ = round16(L_shl(sum, 2));
    }

    /* Save the second half of the new samples for   */
    /* next time, when they will be the old samples. */

    /* pointer arithmetic */

	DSP_memcpy(&old_samples[chn*dct_length], &windowed_data[half_dct_size], half_dct_size);
//
//  new_ptr = windowed_data + (DCT_LENGTH>>1);
//    old_ptr = old_samples;
//    for (i = 0; i < (DCT_LENGTH>>1); i++)
//        *old_ptr++ = *new_ptr++;
}