📄 tty_dbg.c
字号:
/* patent, or copyright. */
/* */
/* Notice */
/* Permission is granted to 3GPP2 participants to copy any portion of*/
/* this contribution for the legitimate purpose of the 3GPP2. */
/* Copying this contribution for monetary gain or other non-3GPP2 */
/* purpose is prohibited. */
/* */
/*-------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include "typedef.h"
#include "tty.h"
#include "tty_dbg.h"
#define DUMP_DIR ""
#define OPEN ((FILE *) !NULL)
short tty_debug_flag = 0;
short tty_debug_print_flag = 0;
FILE *acbgain_fp = NULL;
FILE *dec_acbk_fp = NULL;
FILE *dec_fcbk_fp = NULL;
FILE *dit_fp = OPEN;
FILE *enc_fcbk_fp = NULL;
FILE *fcbgain_fp = NULL;
FILE *lag_fp = NULL;
FILE *pow_fp = OPEN;
FILE *pow01_fp = OPEN;
FILE *rate_fp = NULL;
FILE *debugfp = NULL; /* debug text file */
FILE *tempfp = NULL;
FILE *temp2fp = NULL;
/**********************************************************************
* open_dumpfile()
***********************************************************************/
void open_dumpfile( FILE **dumpfp, char *basename )
{
char filename[256];
if( *dumpfp != NULL )
{
sprintf(filename,"%s%s",DUMP_DIR,basename);
fprintf(stderr,"Opening file %s\n",filename);
if( (*dumpfp=fopen(filename,"wb")) == NULL )
{
fprintf(stderr,"debug.c: Error opening %s\n", filename );
exit(1);
}
}
return;
} /* end open_dumpfile() */
/**********************************************************************
* debug()
***********************************************************************/
void tty_debug()
{
char filename[256];
if( tty_debug_flag == 0 )
{
return;
}
/* File for dumping adaptive codebook gain */
open_dumpfile(&acbgain_fp, "acbgain.pcm");
/* File for dumping decoder's adaptive codebook */
open_dumpfile(&dec_acbk_fp, "dec_acbk.pcm");
/* File for dumping decoder's fixed codebook */
open_dumpfile(&dec_fcbk_fp, "dec_fcbk.pcm");
/* File for dumping dits */
open_dumpfile(&dit_fp, "dit.pcm");
/* File for dumping encoder's fixed codebook */
open_dumpfile(&enc_fcbk_fp, "enc_fcbk.pcm");
/* File for dumping fixed codebook gain */
open_dumpfile(&fcbgain_fp,"fcbgain.pcm");
/* File for dumping pitch lag */
open_dumpfile(&lag_fp,"lag.pcm");
/* File for dumping pitch lag */
open_dumpfile(&pow_fp,"pow.pcm");
/* File for dumping pitch lag */
open_dumpfile(&pow01_fp,"pow01.pcm");
/* File for dumping rate info */
open_dumpfile(&rate_fp,"rate.pcm");
/* File for dumping text */
if( debugfp != NULL )
{
sprintf(filename,"%s\\debug.txt",DUMP_DIR);
fprintf(stderr,"Opening file %s\n",filename);
if( (debugfp=fopen(filename,"w")) == NULL )
{
fprintf(stderr,"debug.c: Error opening %s\n", filename );
exit(1);
}
}
/* File for dumping rate */
open_dumpfile(&tempfp,"temp.pcm");
/* File for dumping rate */
open_dumpfile(&temp2fp,"temp2.pcm");
} /* end debug() */
/**********************************************************************
* dump_array(): Floating Point Version
***********************************************************************/
void dump_float_array( float buf[], short num, FILE *fp )
{
short short_temp;
int j;
if( fp != NULL && tty_debug_flag != 0 )
{
for( j=0 ; j < num ; j++ )
{
if( buf[j] > 32767.0 )
short_temp = (short) 32767;
else if( buf[j] < -32767.0 )
short_temp = (short) -32767;
else
short_temp = (short) buf[j];
fwrite(&short_temp,sizeof(short),1,fp);
}
}
} /* end dump_array */
/**********************************************************************
* dump_array(): Fixed Point Version
***********************************************************************/
void dump_short_array( short buf[], short num, FILE *fp )
{
if( fp != NULL && tty_debug_flag != 0 )
{
fwrite(buf,sizeof(short),num,fp);
}
} /* end dump_array */
/**********************************************************************
* dump_value(): Floating Point Version
***********************************************************************/
void dump_double_value( double value, short num, FILE *fp )
{
short short_temp;
int j;
if( fp != NULL && tty_debug_flag != 0 )
{
if( value > 32767.0 )
short_temp = (short) 32767;
else if( value < -32767.0 )
short_temp = (short) -32767;
else
short_temp = (short) value;
for( j=0 ; j < num ; j++ )
fwrite(&short_temp,sizeof(short),1,fp);
}
} /* end dump_array */
/**********************************************************************
* dump_value(): Fixed Point Version
***********************************************************************/
void dump_short_value( short value, short num, FILE *fp )
{
int j;
if( fp != NULL && fp != OPEN && tty_debug_flag != 0 )
{
for( j=0 ; j < num ; j++ )
{
fwrite(&value,sizeof(short),1,fp);
}
}
} /* end dump_array */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -