www.pudn.com > va_g729.zip > va_g729a_decoder.c
/*--------------------------------------------------------------------------------*
* *
* Copyright © 1995-2001 VoiceAge Corporation. All Rights Reserved. *
* *
* All warranties implied or expressed, including but not limited to implied *
* warranties of merchantability, or fitness for purpose, are excluded. *
* *
* ACELP and VoiceAge are a registered trademark and trademark of VoiceAge *
* Corporation in Canada and / or other countries. Any unauthorized use is *
* strictly prohibited. *
* *
*--------------------------------------------------------------------------------*
* *
* VoiceAge Corporation *
* www.voiceage.com *
* *
*--------------------------------------------------------------------------------*
* va_g729a_decoder.c *
* ~~~~~~~~~~~~~~~~~~ *
* Example of the ITU G.729 CS-ACELP 8.0kbps speech decoder *
* *
*--------------------------------------------------------------------------------*/
#include "stdio.h"
#include "va_g729a.h"
void main(int argc, char *argv[])
{
int nb_frame;
FILE* fp_in;
FILE* fp_out;
unsigned char serial[L_FRAME_COMPRESSED];
short synth[L_FRAME];
int bfi;
printf("\n----------------- VoiceAge Corporation ----------------");
printf("\n www.voiceage.com ");
printf("\n");
printf("\n------------- G729a floating-point Decoder ------------");
printf("\n");
/*-----------------------------------------------------------------------*
* Open all files. *
*-----------------------------------------------------------------------*/
if (argc != 3)
{
printf("\nUsage: %s infile outfile\n", argv[0]);
return;
}
if ( (fp_in = fopen(argv[1], "rb")) == NULL)
{
printf("\nError opening input file %s!", argv[1]);
return;
}
if ( (fp_out = fopen(argv[2], "wb")) == NULL)
{
printf("\nError opening output file %s!", argv[2]);
return;
}
/*-----------------------------------------------------------------------*
* Decode *
*-----------------------------------------------------------------------*/
va_g729a_init_decoder();
nb_frame = 0;
while (fread(serial, sizeof(char), L_FRAME_COMPRESSED, fp_in) == L_FRAME_COMPRESSED)
{
printf("Decode frame %d\r", ++nb_frame);
/*--------------------------------------------------------------*
* Bad frame *
* *
* bfi = 0 to indicate that we have a correct frame *
* bfi = 1 to indicate that we lost the current frame *
*--------------------------------------------------------------*/
bfi = 0;
/*--------------------------------------------------------------*
* Call the decoder. *
*--------------------------------------------------------------*/
va_g729a_decoder(serial, synth, bfi);
/*--------------------------------------------------------------*
* Output synthesis to disk *
*--------------------------------------------------------------*/
fwrite(synth, sizeof(short), L_FRAME, fp_out);
}
fclose(fp_out);
fclose(fp_in);
} /* end of main() */