ua.mobius.media.server.impl.dsp.audio.g729.LspGetq Maven / Gradle / Ivy
The newest version!
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat, Inc. and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
/*
* 15/07/13 - Change notice:
* This file has been modified by Mobius Software Ltd.
* For more information please visit http://www.mobius.ua
*/
package ua.mobius.media.server.impl.dsp.audio.g729;
public class LspGetq {
/*----------------------------------------------------------------------------
* lsp_get_quant - reconstruct quantized LSP parameter and check the stabilty
*----------------------------------------------------------------------------
*/
public static void lsp_get_quant(
float lspcb1[][], /*input : first stage LSP codebook */
float lspcb2[][], /*input : Second stage LSP codebook */
int code0, /*input : selected code of first stage */
int code1, /*input : selected code of second stage*/
int code2, /*input : selected code of second stage*/
float fg[][], /*input : MA prediction coef. */
float freq_prev[][], /*input : previous LSP vector */
float lspq[], /*output: quantized LSP parameters */
float fg_sum[] /*input : present MA prediction coef. */
)
{
int j;
float buf[] = new float[LD8KConstants.M];
for(j=0; j 0) {
buf[j-1] -= tmp;
buf[j] += tmp;
}
}
return;
}
/*----------------------------------------------------------------------------
* lsp_expand_2 - check for higher (5-9)
*----------------------------------------------------------------------------
*/
public static void lsp_expand_2(
float buf[], /*in/out: lsp vectors */
float gap
)
{
int j;
float diff, tmp;
for(j=LD8KConstants.NC; j 0) {
buf[j-1] -= tmp;
buf[j] += tmp;
}
}
return;
}
/*----------------------------------------------------------------------------
* lsp_expand_1_2 - ..
*----------------------------------------------------------------------------
*/
public static void lsp_expand_1_2(
float buf[], /*in/out: LSP parameters */
float gap /*input */
)
{
int j;
float diff, tmp;
for(j=1; j 0) {
buf[j-1] -= tmp;
buf[j] += tmp;
}
}
return;
}
/*
Functions which use previous LSP parameter (freq_prev).
*/
/*
compose LSP parameter from elementary LSP with previous LSP.
*/
public static void lsp_prev_compose(
float lsp_ele[], /* (i) Q13 : LSP vectors */
float lsp[], /* (o) Q13 : quantized LSP parameters */
float fg[][], /* (i) Q15 : MA prediction coef. */
float freq_prev[][], /* (i) Q13 : previous LSP vector */
float fg_sum[] /* (i) Q15 : present MA prediction coef. */
)
{
int j, k;
for(j=0; j 0 ; k-- )
Util.copy(freq_prev[k-1], freq_prev[k], LD8KConstants.M);
Util. copy(lsp_ele, freq_prev[0], LD8KConstants.M);
return;
}
/*----------------------------------------------------------------------------
* lsp_stability - check stability of lsp coefficients
*----------------------------------------------------------------------------
*/
public static void lsp_stability(
float buf[] /*in/out: LSP parameters */
)
{
int j;
float diff, tmp;
for(j=0; j LD8KConstants.M_LIMIT ) {
buf[LD8KConstants.M-1] = LD8KConstants.M_LIMIT;
System.out.println("warning LSP High \n");
}
return;
}
}