⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 va_9729_decoder.cpp

📁 音频文件编码为G729.VS2005编写,已测试
💻 CPP
字号:
// va_9729_decoder.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include "stdio.h"
extern "C"
{
#include "va_g729.h"
}

#define READ_FILE "C:\\Documents and Settings\\Qun.Zhang\\Desktop\\32\\write.txt"
#define WRITE_FILE "C:\\Documents and Settings\\Qun.Zhang\\Desktop\\32\\32.txt"

#include <time.h>

void main(int argc, char *argv[])
{
	int nb_frame;

	clock_t start, finish;
	double duration;

	FILE* fp_in;
	FILE* fp_out;

	unsigned char	serial[L_FRAME_COMPRESSED];
	short			synth[L_FRAME];
	int				bfi;

	printf("\n**************         VoiceAge Corporation        **************");
	printf("\n");
	printf("\n-------------      G729 floating-point Decoder      ------------");
	printf("\n");

	/*-----------------------------------------------------------------------*
	* Open all files.                                                       *
	*-----------------------------------------------------------------------*/
	if ( (fp_in = fopen(READ_FILE, "rb")) == NULL)
	{
		printf("\nError opening input file %s!", argv[1]);
		return;
	} 

	if ( (fp_out = fopen(WRITE_FILE, "wb")) == NULL)
	{
		printf("\nError opening output file %s!", argv[2]);
		return;
	}
	/*-----------------------------------------------------------------------*
	* Decode                                                                *
	*-----------------------------------------------------------------------*/

	va_g729a_init_decoder();

	nb_frame = 0;
	start = clock();

	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);
	}

	finish = clock();

	duration = (double)(finish - start) / CLOCKS_PER_SEC;
	printf( "\n%2.1f seconds\n", duration );

	fclose(fp_out);
	fclose(fp_in);

} /* end of main() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -