📄 coder.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 ITU-T G.729A 8 kbit/s encoder. *
* *
* Usage : coder speech_file bitstream_file *
*-------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include "typedef.h"
#include "basic_op.c"
#include "ld8a.h"
#include "util.c"
#include "pre_proc.c"
#include "cod_ld8a.c"
#include "bits.c"
int main( )
{
FILE *f_speech; /* File of speech data */
FILE *f_serial; /* File of serial bits for transmission */
extern Word16 *new_speech; /* Pointer to new speech data */
Word16 prm[PRM_SIZE]; /* Analysis parameters. */
unsigned char serial[SERIAL_SIZE]; /* Output bitstream buffer */
Word16 frame; /* frame counter */
unsigned char inputfile[10],outputfile[10];
Word16 i;
unsigned char ch;
printf("\n");
printf("*********** ITU G.729A 8 KBIT/S SPEECH CODER ***********\n");
printf("\n");
printf("------------------- Fixed point C simulation -----------------\n");
printf("\n");
/*--------------------------------------------------------------------------*
* Open speech file and result file (output serial bit stream) *
*--------------------------------------------------------------------------*/
printf("Enter the 16-bit PCM filename:\n");
scanf("%s",inputfile);
printf("Enter the pack filename:\n");
scanf("%s",outputfile);
if(!(f_speech=fopen(inputfile,"rb")))
{
printf("can not open the inputfile\n");
exit(0);
}
if(!(f_serial=fopen(outputfile,"wb")))
{
printf("can not open the outputfile\n");
exit(0);
}
/*--------------------------------------------------------------------------*
* Initialization of the coder. *
*--------------------------------------------------------------------------*/
Init_Pre_Process();
Init_Coder_ld8a();
Set_zero(prm, PRM_SIZE);
/* Loop for each "L_FRAME" speech data. */
frame =0;
f_speech=fopen(inputfile,"rb");
for(i=0;i<44;i++)/*wave头文件格式*/
{ch=fgetc(f_speech);
fputc(ch,f_serial);
}
fseek(f_speech,44L,0);
fseek(f_serial,44L,0);
while( fread(new_speech, sizeof(Word16), L_FRAME, f_speech) == L_FRAME)
{
printf("Frame =%d\r", frame++);
Pre_Process(new_speech, L_FRAME);
Coder_ld8a(prm);
prm2bits_ld8k( prm, serial);
fwrite(serial, 1, SERIAL_SIZE, f_serial);
}
return (0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -