📄 lbccodec.c
字号:
/*
**
** File: "lbccodec.c"
**
** Description: Top-level source code for G.723 dual-rate codec
**
** Functions: main
** Process_files()
**
**
*/
/*
ITU-T G.723 Speech Coder ANSI-C Source Code Version 5.00
copyright (c) 1995, AudioCodes, DSP Group, France Telecom,
Universite de Sherbrooke. All rights reserved.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "typedef.h"
#include "basop.h"
#include "cst_lbc.h"
#include "tab_lbc.h"
#include "lbccodec.h"
#include "coder.h"
#include "exc_lbc.h"
#include "util_lbc.h"
#include "cod_cng.h"
#include "vad.h"
#include "tame.h"
#include "lsp.h"
#include "lpc.h"
#include "util_cng.h"
DECSTATDEF DecStat ; //解码静态变量
CODCNGDEF CodCng; //CNG (舒适噪声生产器)编码部分
CODSTATDEF CodStat ; //编码静态变量
VADSTATDEF VadStat ; //Vad(活动语音)静态变量
/* Global variables */
enum Crate WrkRate = Rate53 ;
int PackedFrameSize = 20 ;
Flag UseHp = True ;
Flag UsePf = True ;
Flag UseVx = False ; //判断编解码标志
Flag UsePr = True ; //应用输出(到标准设备)
char SignOn[] = "ACL/USH/FT/DSPG ANSI C CODEC ITU LBC Ver 5.00\n" ;
int main(int argc, char *argv[])
{
FILE *Ifp, *Ofp ; /* I/O File pointers */
long FrCnt = 0 ;
long FlLen ;
Word16 DataBuff[Frame] ; //240字节的侦缓冲区
char Line[20] ;
printf("%s", SignOn ) ;
/* Process arguments and open I/O files */
FlLen = Process_Files( &Ifp, &Ofp, argc, argv ) ;
/*
Init coder
*/
Init_Coder( ) ;
/* Init Comfort Noise Functions */
if( UseVx ) {
Init_Vad();
Init_Cod_Cng( );
}
/* Process all the input file */
do {
reset_max_time();
Read_lbc( DataBuff, Frame, Ifp ) ;
Coder( DataBuff, Line ) ;
Line_Wr( Line, Ofp ) ;
FrCnt ++ ;
if( UsePr) {
fprintf( stdout, "Done : %6ld %3ld\r", FrCnt, FrCnt*100/FlLen ) ;
fflush(stdout); //标准输出设备
}
} while ( FrCnt < FlLen ) ;
if(Ifp) { (void)fclose(Ifp); }
if(Ofp) { (void)fclose(Ofp); }
return 0 ;
}
/*
This function processes the argument parameters. The function
opens the IO files, and sets the global arguments accordingly
to the command line parameters.
*/
long Process_Files( FILE **Ifp, FILE **Ofp, int Argc, char *Argv[] )
{
int i ;
long Flen ;
/*
Process the argument list, if any
*/
if (Argc < 3 ) {
printf("Usage: %s [options] inputfile outputfile \n", Argv[0]);
exit(1);
}
for ( i = 1 ; i < Argc-2 ; i ++ ) {
if ( ! strcmp("-v", Argv[i]) ) {
UseVx = True ;
continue ;
}
if ( ! strcmp("-Noh", Argv[i]) ) {
UseHp = False;
continue ;
}
if ( ! strcmp("-Nop", Argv[i]) ) {
UsePf = False;
continue ;
}
if ( ! strcmp("-n", Argv[i]) ) {
UsePr = False;
continue ;
}
fprintf(stderr, "Illegal argument, %s\n", Argv[i] ) ;
exit(1) ;
}
*Ifp = fopen( Argv[Argc-2], "rb") ;
if ( *Ifp == NULL ) {
fprintf(stderr, "Invalid input file name: %s\n", Argv[Argc-2] ) ;
exit(1) ;
}
if ( UsePr )
printf("Input file: %s\n", Argv[Argc-2] ) ;
*Ofp = fopen( Argv[Argc-1], "wb") ;
if ( *Ofp == NULL ) {
fprintf(stderr, "Can't open output file: %s\n", Argv[Argc-1] ) ;
exit(1) ;
}
if ( UsePr )
printf("Output file: %s\n", Argv[Argc-1] ) ;
/* Options report */
if ( UsePr ) {
printf("Options:\n");
printf("Encoder\n");
printf("Rate 5.3 kb/s\n");
if (UseHp == 0 )
printf("Highpassfilter disabled\n");
else
printf("Highpassfilter enabled\n");
if (UseVx == 0 )
printf("VAD/CNG disabled\n");
else
printf("VAD/CNG enabled\n");
}
/*
Compute the file length
*/
fseek( *Ifp, 0L, SEEK_END ) ;
Flen = ftell( *Ifp ) ;
rewind( *Ifp ) ;
Flen /= sizeof(Word16)*Frame ;
return Flen ;
}
#include "basop.c"
#include "tab_lbc.c"
#include "coder.c"
#include "exc_lbc.c"
#include "util_lbc.c"
#include "cod_cng.c"
#include "vad.c"
#include "tame.c"
#include "lsp.c"
#include "lpc.c"
#include "util_cng.c"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -