• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

libavcodec/qcelp_lsp.c

Go to the documentation of this file.
00001 /*
00002  * QCELP decoder
00003  * Copyright (c) 2007 Reynaldo H. Verdejo Pinochet
00004  *
00005  * This file is part of FFmpeg.
00006  *
00007  * FFmpeg is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * FFmpeg is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with FFmpeg; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00020  */
00021 
00030 #include "libavutil/mathematics.h"
00031 
00039 #define QCELP_BANDWITH_EXPANSION_COEFF 0.9883
00040 
00051 static void lsp2polyf(const float *lspf, double *f, int lp_half_order)
00052 {
00053     int i, j;
00054 
00055     f[0] = 1.0;
00056     f[1] = -2 * cos(M_PI * lspf[0]);
00057     lspf -= 2;
00058     for(i=2; i<=lp_half_order; i++)
00059     {
00060         double val = -2 * cos(M_PI * lspf[2*i]);
00061         f[i] = val * f[i-1] + 2*f[i-2];
00062         for(j=i-1; j>1; j--)
00063             f[j] += f[j-1] * val + f[j-2];
00064         f[1] += val;
00065     }
00066 }
00067 
00080 void ff_qcelp_lspf2lpc(const float *lspf, float *lpc)
00081 {
00082     double pa[6], qa[6];
00083     int   i;
00084     double bandwith_expansion_coeff = QCELP_BANDWITH_EXPANSION_COEFF * 0.5;
00085 
00086     lsp2polyf(lspf,     pa, 5);
00087     lsp2polyf(lspf + 1, qa, 5);
00088 
00089     for (i=4; i>=0; i--)
00090     {
00091         double paf = pa[i+1] + pa[i];
00092         double qaf = qa[i+1] - qa[i];
00093 
00094         lpc[i  ] = paf + qaf;
00095         lpc[9-i] = paf - qaf;
00096     }
00097     for (i=0; i<10; i++)
00098     {
00099         lpc[i] *= bandwith_expansion_coeff;
00100         bandwith_expansion_coeff *= QCELP_BANDWITH_EXPANSION_COEFF;
00101     }
00102 }

Generated on Sat Feb 16 2013 09:23:13 for ffmpeg by  doxygen 1.7.1