📄 iqlsf.c
字号:
/* ******************************************************************************** * * This material contains proprietary software of Entropic Speech, Inc. * Any reproduction, distribution, or publication without the the prior * written permission of Entropic Speech, Inc. is strictly prohibited. * Any public distribution of copies of this work authorized in writing * by Entropic Speech, Inc. must bear the notice: * * "Copyright (c) 1987 Entropic Speech, Inc.; all rights reserved" * * Program: iqlsf * * Written by: Jim Elliott * * Creates a reconstructed FEA_ANA file from the quantization indices * for spectral data, pulse length, and power. * ******************************************************************************** *//* * SCCS program and date keywords. */#ifndef lintstatic char *sccs_id = "@(#)iqlsf.c 1.2 11/30/87 ESI";#endif/* * System include files. */#include <stdio.h>/* * ESPS include files. */#include <esps/esps.h>#include <esps/anafea.h>#include <esps/fea.h>#include <esps/feaquant.h>/* * Defines. */#define ERROR_EXIT( text ) \{ \ Fprintf( stderr, "iqlsf: %s - exiting\n", text ); \ exit( 1 ); \}#define SYNTAX USAGE \( \ "iqlsf -z infile.fea outfile.fea" \)/* * System functions and variables. */char *strcpy();int getopt(), strcmp();void exit(), perror();extern optind;extern char *optarg;/* * ESPS functions and variables. */char *get_cmd_line();/* ******************************************************************************** * Main program. ******************************************************************************** */main( argc, argv )char *argv[];int argc;{ char *cmd_line, /* String for command line */ *date = "11/30/87", *ifn = NULL, /* Input file name */ *lsf_quant, /* LSF quantization method */ *ofn = NULL, /* Output file name */ *pitch_quant, /* Pitch quantization method */ *power_quant, /* Power quantization method */ *version = "1.2"; FILE *ifp = stdin, /* Input file pointer */ *ofp = stdout; /* Output file pointer */ int c, /* For getopt() return */ quiet = NO; /* Flag to silence debug output */ long maxpulses, /* Maximum pulses per frame */ maxraw, /* Maximum raw powers per frame */ order_vcd, /* Voiced filter order */ order_unvcd, /* Unvoiced filter order */ prev_length = 0, /* Previous frame length */ tag = 1; /* FEA_ANA frame tag */ short unvoiced_steps, /* Steps per octave - unvoiced LSFs */ voiced_steps; /* Steps per octave - voiced LSFs */ struct anafea *anafea_rec; /* FEA_ANA record */ struct auxana *auxana_rec; /* Auxiliary FEA_ANA record */ struct header *ih, /* Input file header */ *oh; /* Output file header *//* * Read command line and process command line options. */ cmd_line = get_cmd_line( argc, argv ); while ( ( c = getopt( argc, argv, "z" ) ) != EOF ) { switch ( c ) { case 'z': quiet = YES; break; default: SYNTAX; } }/* * Process file arguments. */ if ( optind < argc ) { ifn = argv[ optind++ ]; if ( strcmp( ifn, "-" ) == 0 ) ifn = "<stdin>"; else TRYOPEN( argv[0], ifn, "r", ifp ); } else { Fprintf( stderr, "iqlsf: No input file specified\n" ); SYNTAX; } if ( optind < argc ) { ofn = argv[ optind++ ]; if ( strcmp( ofn, "-" ) == 0 ) ofn = "<stdout>"; else TRYOPEN( argv[0], ofn, "w", ofp ); } else { Fprintf( stderr, "iqlsf: No output file specified\n" ); SYNTAX; }/* * Read and check values from header of input file. */ if ( ( ih = read_header( ifp ) ) == NULL ) NOTSPS( argv[0], ifn ); if ( ih->common.type != FT_FEA ) ERROR_EXIT( "Input file is not a FEA file" ); if ( ih->hd.fea->fea_type != FEA_ANA ) ERROR_EXIT( "Input file is not FEA_ANA type" ); lsf_quant = get_genhd( "lsf_quant", ih ); maxpulses = *(long *) get_genhd( "maxpulses", ih ); maxraw = *(long *) get_genhd( "maxraw", ih ); order_unvcd = *(long *) get_genhd( "order_unvcd", ih ); order_vcd = *(long *) get_genhd( "order_vcd", ih ); pitch_quant = get_genhd( "pitch_quant", ih ); power_quant = get_genhd( "power_quant", ih ); unvoiced_steps = *(short *) get_genhd( "unvoiced_steps", ih ); voiced_steps = *(short *) get_genhd( "voiced_steps", ih );/* * Create header for output file. */ oh = copy_header( ih ); add_source_file( oh, ifn, ih ); (void) strcpy( oh->common.prog, "iqlsf" ); (void) strcpy( oh->common.vers, version ); (void) strcpy( oh->common.progdate, date ); add_comment( oh, cmd_line ); oh->common.tag = YES; oh->variable.refer = ifn; write_header( oh, ofp );/* * Allocate storage for input and output data records. */ anafea_rec = allo_anafea_rec( ih ); auxana_rec = allo_auxana_rec( ih, anafea_rec );/* * Main program loop. */ while( get_anafea_rec( anafea_rec, ih, ifp ) != EOF ) { invert_lsf( auxana_rec, order_unvcd, order_vcd, lsf_quant, unvoiced_steps, voiced_steps, quiet, &anafea_rec ); invert_power( auxana_rec, maxraw, power_quant, &anafea_rec ); invert_pitch( auxana_rec, maxpulses, pitch_quant, &anafea_rec ); tag += prev_length; prev_length = *anafea_rec->frame_len; *anafea_rec->tag = tag; put_anafea_rec( anafea_rec, oh, ofp ); } exit( 0 );}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -