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

📄 va_g729_encoder.cpp

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

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

#include <time.h>
#define READ_FILE "C:\\Documents and Settings\\Qun.Zhang\\Desktop\\32\\read.txt"
#define WRITE_FILE "C:\\Documents and Settings\\Qun.Zhang\\Desktop\\32\\write.txt"

void main(int argc, char *argv[])
{
	int nb_frame;
	clock_t start, finish;
	double duration;

	FILE* fp_in;
	FILE* fp_out;

	short			speech[L_FRAME];
	unsigned char	serial[L_FRAME_COMPRESSED];

	/*-----------------------------------------------------------------------*
	* Open all files.                                                       *
	*-----------------------------------------------------------------------*/
	printf("\n**************         VoiceAge Corporation        **************");
	printf("\n");
	printf("\n-------------      G729 floating-point Encoder      ------------");
	printf("\n");

	//if (argc != 3)
	//{
	//	printf("Usage: %s infile outfile\n", argv[0]);
	//	return;
	//}

	fp_in = fopen(READ_FILE, "rb");
	if ( fp_in == 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;
	}

	/*-----------------------------------------------------------------------*
	* Encode                                                                *
	*-----------------------------------------------------------------------*/

	va_g729a_init_encoder();

	nb_frame = 0;

	start = clock();

	while (fread(speech, sizeof(short), L_FRAME, fp_in) == L_FRAME) 
	{

		printf("Encode frame %d\r", ++nb_frame);

		/*--------------------------------------------------------------*
		* Call the encoder.                                            *
		*--------------------------------------------------------------*/

		va_g729a_encoder(speech, serial);

		/*--------------------------------------------------------------*
		* Output serial stream to disk                                 *
		*--------------------------------------------------------------*/

		fwrite(serial, sizeof(char), L_FRAME_COMPRESSED, 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 + -