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

📄 decoder.c

📁 一份不错的经编译调试通过的G729A标准 C语言源代码!
💻 C
字号:
/*
   ITU-T G.729A Speech Coder    ANSI-C Source Code
   Version 1.1    Last modified: September 1996

   Copyright (c) 1996,
   AT&T, France Telecom, NTT, Universite de Sherbrooke
   All rights reserved.
*/

/*-----------------------------------------------------------------*
 * Main program of the G.729a 8.0 kbit/s decoder.                  *
 *                                                                 *
 *    Usage : decoder  bitstream_file  synth_file                  *
 *                                                                 *
 *-----------------------------------------------------------------*/

#include <stdlib.h>
#include <stdio.h>

#include "typedef.h"
#include "basic_op.c"
#include "ld8a.h"

#include "post_pro.c"
#include "postfilt.c"
#include"dec_ld8a.c"
#include "bits.c"
 Word16 bad_lsf;        /* bad LSF indicator   */

/*
   This variable should be always set to zero unless transmission errors
   in LSP indices are detected.
   This variable is useful if the channel coding designer decides to
   perform error checking on these important parameters. If an error is
   detected on the  LSP indices, the corresponding flag is
   set to 1 signalling to the decoder to perform parameter substitution.
   (The flags should be set back to 0 for correct transmission).
*/

/*-----------------------------------------------------------------*
 *            Main decoder routine                                 *
 *-----------------------------------------------------------------*/

int main( )
{
  Word16  synth_buf[L_FRAME+M], *synth; /* Synthesis                   */
  Word16  parm[PRM_SIZE+1];             /* Synthesis parameters        */
  unsigned char  serial[SERIAL_SIZE];          /* Serial stream               */
  Word16  Az_dec[MP1*2];                /* Decoded Az for post-filter  */
  Word16  T2[2];                        /* vPitch lag for 2 subframes   */


  Word16  i, frame;
  FILE   *f_syn, *f_serial;
  Word16  j;
  unsigned char ch;


  unsigned char inputfile[10],outputfile[10];

  printf("\n");
  printf("************   G.729a 8.0 KBIT/S SPEECH DECODER  ************\n");
  printf("\n");
  printf("------------------- Fixed point C simulation ----------------\n");
  printf("\n");
  

   /* Passed arguments */


   /* Open file for synthesis and packed serial stream */
    printf("Enter the packed filename:\n");
    scanf("%s",inputfile);
    printf("Enter the unpacked filename:\n");
	scanf("%s",outputfile);
    if(!(f_serial=fopen(inputfile,"rb")))
	{
		printf("can not open the inputfile\n");
		exit(0);
	}

    if(!(f_syn=fopen(outputfile,"wb")))
	{
		printf("can not open the outputfile\n");
		exit(0);
	}
/*-----------------------------------------------------------------*
 *           Initialization of decoder                             *
 *-----------------------------------------------------------------*/

  for (i=0; i<M; i++) synth_buf[i] = 0;
  synth = synth_buf + M;

  bad_lsf = 0;          /* Initialize bad LSF indicator */
  Init_Decod_ld8a();
  Init_Post_Filter();
  Init_Post_Process();


/*-----------------------------------------------------------------*
 *            Loop for each "L_FRAME" speech data                  *
 *-----------------------------------------------------------------*/

  frame = 0;
  for(j=0;j<44;j++)/*wave头文件格式*/
  {ch=fgetc(f_serial);
   fputc(ch,f_syn);
   }
   fseek(f_serial,44L,0);
   fseek(f_syn,44L,0);
while(fread(serial, 1, SERIAL_SIZE, f_serial) == SERIAL_SIZE)
  {
    printf("Frame =%d\r", frame++);
    bits2prm_ld8k(serial, &parm[1]); 
    parm[0] = 0;  
    parm[4] = 0;
    Decod_ld8a(parm, synth, Az_dec, T2);
    Post_Filter(synth, Az_dec, T2); 
    Post_Process(synth, L_FRAME);
    fwrite(synth, sizeof(short), L_FRAME, f_syn);
  }
  return (0) ; 
}

⌨️ 快捷键说明

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