📄 decode.c
字号:
/*
$Log: decode.c,v $
Revision 1.1.1.1 2002/07/28 05:23:23 freeman_yong
lpc10 codec
* Revision 1.2 1996/08/20 20:22:39 jaf
* Removed all static local variables that were SAVE'd in the Fortran
* code, and put them in struct lpc10_decoder_state that is passed as an
* argument.
*
* Removed init function, since all initialization is now done in
* init_lpc10_decoder_state().
*
* Revision 1.1 1996/08/19 22:32:38 jaf
* Initial revision
*
*/
#ifdef P_R_O_T_O_T_Y_P_E_S
extern int decode_(integer *ipitv, integer *irms, integer *irc, integer *voice, integer *pitch, real *rms, real *rc, struct lpc10_decoder_state *st);
/* comlen contrl_ 12 */
/*:ref: ham84_ 14 3 4 4 4 */
/*:ref: median_ 4 3 4 4 4 */
#endif
/* -- translated by f2c (version 19951025).
You must link the resulting object file with the libraries:
-lf2c -lm (in that order)
*/
#include "f2c.h"
/* Common Block Declarations */
extern struct {
integer order, lframe;
logical corrp;
} contrl_;
#define contrl_1 contrl_
/* Table of constant values */
static integer c__2 = 2;
/* ***************************************************************** */
/* DECODE Version 54 */
/* $Log: decode.c,v $
/* Revision 1.1.1.1 2002/07/28 05:23:23 freeman_yong
/* lpc10 codec
/*
* Revision 1.2 1996/08/20 20:22:39 jaf
* Removed all static local variables that were SAVE'd in the Fortran
* code, and put them in struct lpc10_decoder_state that is passed as an
* argument.
*
* Removed init function, since all initialization is now done in
* init_lpc10_decoder_state().
*
* Revision 1.1 1996/08/19 22:32:38 jaf
* Initial revision
* */
/* Revision 1.5 1996/05/23 20:06:03 jaf */
/* Assigned PITCH a "default" value on the first call, since otherwise it */
/* would be left uninitialized. */
/* Revision 1.4 1996/03/26 19:35:18 jaf */
/* Commented out trace statements. */
/* Revision 1.3 1996/03/21 21:10:50 jaf */
/* Added entry INITDECODE to reinitialize the local state of subroutine */
/* DECODE. */
/* Revision 1.2 1996/03/21 21:04:50 jaf */
/* Determined which local variables should be saved from one invocation */
/* to the next, and guessed initial values for some that should have been */
/* saved, but weren't given initial values. Many of the arrays are */
/* "constants", and many local variables are only used if the "global" */
/* variable CORRP is .TRUE. */
/* Added comments explaining which indices of array arguments are read or */
/* written. */
/* Revision 1.1 1996/02/12 03:21:10 jaf */
/* Initial revision */
/* ***************************************************************** */
/* This subroutine provides error correction and decoding */
/* for all LPC parameters */
/* Input: */
/* IPITV - Index value of pitch */
/* IRMS - Coded Energy */
/* CORRP - Error correction: */
/* If FALSE, parameters are decoded directly with no delay. If TRUE, */
/* most important parameter bits are protected by Hamming code and */
/* median smoothed. This requires an additional frame of delay. */
/* Input/Output: */
/* IRC - Coded Reflection Coefficients */
/* Indices 1 through ORDER always read, then written. */
/* Output: */
/* VOICE - Half frame voicing decisions */
/* Indices 1 through 2 written. */
/* PITCH - Decoded pitch */
/* RMS - Energy */
/* RC - Reflection coefficients */
/* Indices 1 through ORDER written. */
/* NOTE: Zero RC's should be done more directly, but this would affect */
/* coded parameter printout. */
/* This subroutine maintains local state from one call to the next. If */
/* you want to switch to using a new audio stream for this filter, or */
/* reinitialize its state for any other reason, call the ENTRY */
/* INITDECODE. */
/* Subroutine */ int decode_(integer *ipitv, integer *irms,
integer *irc, integer *voice, integer *pitch, real *rms, real *rc,
struct lpc10_decoder_state *st)
{
/* Initialized data */
logical *first;
static integer ethrs = 2048;
static integer ethrs1 = 128;
static integer ethrs2 = 1024;
static integer ethrs3 = 2048;
static integer ivtab[32] = { 24960,24960,24960,24960,25480,25480,25483,
25480,16640,1560,1560,1560,16640,1816,1563,1560,24960,24960,24859,
24856,26001,25881,25915,25913,1560,1560,7800,3640,1561,1561,3643,
3641 };
static real corth[32] /* was [4][8] */ = { 32767.f,10.f,5.f,0.f,
32767.f,8.f,4.f,0.f,32.f,6.4f,3.2f,0.f,32.f,6.4f,3.2f,0.f,32.f,
11.2f,6.4f,0.f,32.f,11.2f,6.4f,0.f,16.f,5.6f,3.2f,0.f,16.f,5.6f,
3.2f,0.f };
static integer detau[128] = { 0,0,0,3,0,3,3,31,0,3,3,21,3,3,29,30,0,3,3,
20,3,25,27,26,3,23,58,22,3,24,28,3,0,3,3,3,3,39,33,32,3,37,35,36,
3,38,34,3,3,42,46,44,50,40,48,3,54,3,56,3,52,3,3,1,0,3,3,108,3,78,
100,104,3,84,92,88,156,80,96,3,3,74,70,72,66,76,68,3,62,3,60,3,64,
3,3,1,3,116,132,112,148,152,3,3,140,3,136,3,144,3,3,1,124,120,128,
3,3,3,3,1,3,3,3,1,3,1,1,1 };
static integer rmst[64] = { 1024,936,856,784,718,656,600,550,502,460,420,
384,352,328,294,270,246,226,206,188,172,158,144,132,120,110,102,
92,84,78,70,64,60,54,50,46,42,38,34,32,30,26,24,22,20,18,17,16,15,
14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 };
static integer detab7[32] = { 4,11,18,25,32,39,46,53,60,66,72,77,82,87,92,
96,101,104,108,111,114,115,117,119,121,122,123,124,125,126,127,
127 };
static real descl[8] = { .6953f,.625f,.5781f,.5469f,.5312f,.5391f,.4688f,
.3828f };
integer *ivp2h;
static integer deadd[8] = { 1152,-2816,-1536,-3584,-1280,-2432,768,-1920 }
;
static integer qb[8] = { 511,511,1023,1023,1023,1023,2047,4095 };
static integer nbit[10] = { 8,8,5,5,4,4,4,4,3,2 };
static integer zrc[10] = { 0,0,0,0,0,3,0,2,0,0 };
static integer bit[5] = { 2,4,8,16,32 };
integer *iovoic;
integer *iavgp;
integer *iptold;
integer *erate;
integer *drc;
integer *dpit;
integer *drms;
/* System generated locals */
integer i__1, i__2;
/* Builtin functions */
integer pow_ii(integer *, integer *);
/* Local variables */
extern /* Subroutine */ int ham84_(integer *, integer *, integer *);
integer ipit, iout, i__, icorf, index, ivoic, ixcor, i1, i2, i4;
extern integer median_(integer *, integer *, integer *);
integer ishift, errcnt, lsb;
/* $Log: decode.c,v $
/* Revision 1.1.1.1 2002/07/28 05:23:23 freeman_yong
/* lpc10 codec
/*
* Revision 1.2 1996/08/20 20:22:39 jaf
* Removed all static local variables that were SAVE'd in the Fortran
* code, and put them in struct lpc10_decoder_state that is passed as an
* argument.
*
* Removed init function, since all initialization is now done in
* init_lpc10_decoder_state().
*
* Revision 1.1 1996/08/19 22:32:38 jaf
* Initial revision
* */
/* Revision 1.3 1996/03/29 22:03:47 jaf */
/* Removed definitions for any constants that were no longer used. */
/* Revision 1.2 1996/03/26 19:34:33 jaf */
/* Added comments indicating which constants are not needed in an */
/* application that uses the LPC-10 coder. */
/* Revision 1.1 1996/02/07 14:43:51 jaf */
/* Initial revision */
/* LPC Configuration parameters: */
/* Frame size, Prediction order, Pitch period */
/* Arguments */
/* $Log: decode.c,v $
/* Revision 1.1.1.1 2002/07/28 05:23:23 freeman_yong
/* lpc10 codec
/*
* Revision 1.2 1996/08/20 20:22:39 jaf
* Removed all static local variables that were SAVE'd in the Fortran
* code, and put them in struct lpc10_decoder_state that is passed as an
* argument.
*
* Removed init function, since all initialization is now done in
* init_lpc10_decoder_state().
*
* Revision 1.1 1996/08/19 22:32:38 jaf
* Initial revision
* */
/* Revision 1.3 1996/03/29 22:05:55 jaf */
/* Commented out the common block variables that are not needed by the */
/* embedded version. */
/* Revision 1.2 1996/03/26 19:34:50 jaf */
/* Added comments indicating which constants are not needed in an */
/* application that uses the LPC-10 coder. */
/* Revision 1.1 1996/02/07 14:44:09 jaf */
/* Initial revision */
/* LPC Processing control variables: */
/* *** Read-only: initialized in setup */
/* Files for Speech, Parameter, and Bitstream Input & Output, */
/* and message and debug outputs. */
/* Here are the only files which use these variables: */
/* lpcsim.f setup.f trans.f error.f vqsetup.f */
/* Many files which use fdebug are not listed, since it is only used in */
/* those other files conditionally, to print trace statements. */
/* integer fsi, fso, fpi, fpo, fbi, fbo, pbin, fmsg, fdebug */
/* LPC order, Frame size, Quantization rate, Bits per frame, */
/* Error correction */
/* Subroutine SETUP is the only place where order is assigned a value, */
/* and that value is 10. It could increase efficiency 1% or so to */
/* declare order as a constant (i.e., a Fortran PARAMETER) instead of as
*/
/* a variable in a COMMON block, since it is used in many places in the */
/* core of the coding and decoding routines. Actually, I take that back.
*/
/* At least when compiling with f2c, the upper bound of DO loops is */
/* stored in a local variable before the DO loop begins, and then that is
*/
/* compared against on each iteration. */
/* Similarly for lframe, which is given a value of MAXFRM in SETUP. */
/* Similarly for quant, which is given a value of 2400 in SETUP. quant */
/* is used in only a few places, and never in the core coding and */
/* decoding routines, so it could be eliminated entirely. */
/* nbits is similar to quant, and is given a value of 54 in SETUP. */
/* corrp is given a value of .TRUE. in SETUP, and is only used in the */
/* subroutines ENCODE and DECODE. It doesn't affect the speed of the */
/* coder significantly whether it is .TRUE. or .FALSE., or whether it is
*/
/* a constant or a variable, since it is only examined once per frame. */
/* Leaving it as a variable that is set to .TRUE. seems like a good */
/* idea, since it does enable some error-correction capability for */
/* unvoiced frames, with no change in the coding rate, and no noticeable
*/
/* quality difference in the decoded speech. */
/* integer quant, nbits */
/* *** Read/write: variables for debugging, not needed for LPC algorithm
*/
/* Current frame, Unstable frames, Output clip count, Max onset buffer,
*/
/* Debug listing detail level, Line count on listing page */
/* nframe is not needed for an embedded LPC10 at all. */
/* nunsfm is initialized to 0 in SETUP, and incremented in subroutine */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -