⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 funcg722.c

📁 ITU-T G.191中包含的G.722语音压缩编解码程序
💻 C
📖 第 1 页 / 共 4 页
字号:
/*                                                   Version: 2.00 - 01.Jul.95  ============================================================================                          U    U   GGG    SSSS  TTTTT                          U    U  G       S       T                          U    U  G  GG   SSSS    T                          U    U  G   G       S   T                           UUU     GG     SSS     T                   ========================================                    ITU-T - USER'S GROUP ON SOFTWARE TOOLS                   ========================================       =============================================================       COPYRIGHT NOTE: This source code, and all of its derivations,       is subject to the "ITU-T General Public License". Please have       it  read  in    the  distribution  disk,   or  in  the  ITU-T       Recommendation G.191 on "SOFTWARE TOOLS FOR SPEECH AND  AUDIO       CODING STANDARDS".        ** This code has  (C) Copyright by CNET Lannion A TSS/CMC **       =============================================================MODULE:         G722.C 7kHz ADPCM AT 64 KBIT/S MODULE ENCODER AND                 DECODER FUNCTIONSORIGINAL BY:    J-P PETIT     CNET - Centre Lannion A    LAA-TSS                         Tel: +33-96-05-39-41    Route de Tregastel - BP 40      Fax: +33-96-05-13-16    F-22301 Lannion CEDEX           Email: petitjp@lannion.cnet.fr    FRANCE       History:   14.Mar.95    v1.0    Released for use ITU-T UGST software package Tool                        based on the CNET's 07/01/90 version 2.00   01.Jul.95    v2.0    Changed function declarations to work with                         many compilers; reformated <simao@ctd.comsat.com>  ============================================================================*/#include <stdio.h>/* Include state variable definition, function and operator prototypes */#include "g722.h"/* Local pseudo-functions */#define parrec( a, b)  add( a, b )#define recons( a, b)  add( a, b )#define subtra( a, b)  sub( a, b )#define predic( a, b)  add( a, b )/*___________________________________________________________________________                                                                                Function Name : lsbcod                                                                                                                                  Purpose :                                                                                                                                                Encode lower subband of incomung speech/music.                                                                                                         Inputs :                                                                      xh - Low sub-band portion of the input sample                               rs - reset flag (read-only)                                                 s  - pointer to state variable (read/write)                                                                                                           Return Value :                                                               Encoded sample as a 16-bit word                                         ___________________________________________________________________________*/#define AL   s->al#define BL   s->bl#define DETL s->detl#define DLT  s->dlt#define NBL  s->nbl#define PLT  s->plt#define RLT  s->rlt#define SL   s->sl#define SPL  s->spl#define SZL  s->szlWord16 lsbcod (xl, rs, s)Word16 xl;Word16 rs;g722_state *s;{  Word16          el, nbpl, il;  if (rs == 1)  {    DETL = 32;    SL = SPL = SZL = NBL = 0;    AL[1] = AL[2] = 0;    BL[1] = BL[2] = BL[3] = BL[4] = BL[5] = BL[6] = 0;    DLT[0] = DLT[1] = DLT[2] = DLT[3] = DLT[4] = DLT[5] = DLT[6] = 0;    PLT[0] = PLT[1] = PLT[2] = 0;    RLT[0] = RLT[1] = RLT[2] = 0;    return (0);  }  el = subtra (xl, SL);  il = quantl (el, DETL);  DLT[0] = invqal (il, DETL);  nbpl = logscl (il, NBL);  NBL = nbpl;  DETL = scalel (nbpl);  PLT[0] = parrec (DLT[0], SZL);  RLT[0] = recons (SL, DLT[0]);  upzero (DLT, BL);  uppol2 (AL, PLT);  uppol1 (AL, PLT);  SZL = filtez (DLT, BL);  SPL = filtep (RLT, AL);  SL = predic (SPL, SZL);  /* Return encoded sample */  return (il);}#undef AL#undef BL#undef DETL#undef DLT#undef NBL#undef PLT#undef RLT#undef SL#undef SPL#undef SZL/* ........................ End of lsbcod() ........................ *//*___________________________________________________________________________                                                                                Function Name : hsbcod                                                                                                                                  Purpose :                                                                                                                                                Encode upper sub-band of incoming speech or music.                                                                                                     Inputs :                                                                      xh - High sub-band portion of the input sample                              rs - reset flag (read-only)                                                 s  - pointer to state variable (read/write)                                                                                                           Return Value :                                                               ADPCM code for the high-band portion of the input sample as a               16-bit word.                                                                                                                                        ___________________________________________________________________________*/#define AH   s->ah#define BH   s->bh#define DETH s->deth#define DH  s->dh #define NBH  s->nbh#define PH  s->ph #define RH  s->rh #define SH   s->sh#define SPH  s->sph #define SZH  s->szhWord16 hsbcod (xh, rs, s)Word16 xh;Word16 rs;g722_state *s;{  Word16          eh, nbph, ih;  if (rs == 1)  {    DETH = 8;    SH = SPH = SZH = NBH = 0;    AH[1] = AH[2] = 0;    BH[1] = BH[2] = BH[3] = BH[4] = BH[5] = BH[6] = 0;    DH[0] = DH[1] = DH[2] = DH[3] = DH[4] = DH[5] = DH[6] = 0;    PH[0] = PH[1] = PH[2] = 0;    RH[0] = RH[1] = RH[2] = 0;    return (0);  }  eh = subtra (xh, SH);  ih = quanth (eh, DETH);  DH[0] = invqah (ih, DETH);  nbph = logsch (ih, NBH);  NBH = nbph;  DETH = scaleh (nbph);  PH[0] = parrec (DH[0], SZH);  RH[0] = recons (SH, DH[0]);  upzero (DH, BH);  uppol2 (AH, PH);  uppol1 (AH, PH);  SZH = filtez (DH, BH);  SPH = filtep (RH, AH);  SH = predic (SPH, SZH);  return (ih);}#undef AH#undef BH#undef DETH#undef DH#undef NBH#undef PH#undef RH#undef SH#undef SPH#undef SZH/* ........................ End of hsbcod() ........................ *//*___________________________________________________________________________                                                                                Function Name : lsbdec                                                                                                                                  Purpose :                                                                                                                                                Decode lower subband of incomung speech/music.                                                                                                         Inputs :                                                                      ilr - ADPCM encoding of the low sub-band                                    mode - G.722 operation mode                                                 rs  - reset flag (read-only)                                                s   - pointer to state variable (read/write)                                                                                                          Return Value :                                                               Decoded low-band portion of the recovered sample as a 16-bit word       ___________________________________________________________________________*/#define AL   s->al#define BL   s->bl#define DETL s->detl#define DLT  s->dlt#define NBL  s->nbl#define PLT  s->plt#define RLT  s->rlt#define SL   s->sl#define SPL  s->spl#define SZL  s->szlWord16 lsbdec (ilr, mode, rs, s)Word16 ilr;Word16 mode;Word16 rs;g722_state *s;{  Word16          dl, rl, nbpl, yl;  if (rs == 1)  {    DETL = 32;    SL = SPL = SZL = NBL = 0;    AL[1] = AL[2] = 0;    BL[1] = BL[2] = BL[3] = BL[4] = BL[5] = BL[6] = 0;    DLT[0] = DLT[1] = DLT[2] = DLT[3] = DLT[4] = DLT[5] = DLT[6] = 0;    PLT[0] = PLT[1] = PLT[2] = 0;    RLT[0] = RLT[1] = RLT[2] = 0;    return (0);  }  dl = invqbl (ilr, DETL, mode);  rl = recons (SL, dl);  yl = limit (rl);  DLT[0] = invqal (ilr, DETL);  nbpl = logscl (ilr, NBL);  NBL = nbpl;  DETL = scalel (nbpl);  PLT[0] = parrec (DLT[0], SZL);  RLT[0] = recons (SL, DLT[0]);  upzero (DLT, BL);  uppol2 (AL, PLT);  uppol1 (AL, PLT);  SZL = filtez (DLT, BL);  SPL = filtep (RLT, AL);  SL = predic (SPL, SZL);  return (yl);}#undef AL#undef BL#undef DETL#undef DLT#undef NBL#undef PLT#undef RLT#undef SL#undef SPL#undef SZL/* ........................ End of lsbdec() ........................ *//*___________________________________________________________________________                                                                                Function Name : hsbdec                                                                                                                                  Purpose :                                                                                                                                                Decode lower subband of incomung speech/music.                                                                                                         Inputs :                                                                      ih  - ADPCM encoding of the high sub-band                                   rs  - reset flag (read-only)                                                s   - pointer to state variable (read/write)                                                                                                          Return Value :                                                               Decoded high-band portion of the recovered sample as a 16-bit word      ___________________________________________________________________________

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -