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

📄 easyg7231_decoder.c

📁 ITU G.723.1 编解码程序(附带测试代码)
💻 C
字号:
/*--------------------------------------------------------------------------------*
 *                                                                                *
 * This material is trade secret owned by imtelephone.com                         *
 * and is strictly confidential and shall remain as such.                         *
 *                                                                                *
 * Copyright ?2003-2004 imtelephone.com. All Rights Reserved. No part of         *
 * this material may be reproduced, stored in a retrieval system, or transmitted, *
 * in any form or by any means, including, but not limited to, photocopying,      *
 *  electronic, mechanical, recording, or otherwise, without the prior written    *
 * permission of imtelephone.com.                                                 *
 *                                                                                *
 * This material is subject to continuous developments and improvements. All      *
 * warranties implied or expressed, including but not limited to implied          *
 * warranties of merchantability, or fitness for purpose, are excluded.           *
 *                                                                                *
 *--------------------------------------------------------------------------------*
 *                                                                                *
 * support@imtelephone.com                                                        *
 *                                                                                *
 *--------------------------------------------------------------------------------*
 *
 *--------------------------------------------------------------------------------*
 *                         EasyG7231_decoder.c                                    *
 *                         ~~~~~~~~~~~~~~~~~~                                     *
 * Example of the ITU G.723.1 6.3/5.3kbps speech decoder                              *
 *                                                                                *
 *--------------------------------------------------------------------------------*/
 

#include "stdio.h"
#include "EasyG7231.h"
#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_G7231_FRAME_COMPRESSED_53];
	short			synth[L_G7231_FRAME];

	CODER_HANDLE hDecoder;

	printf("\n**************         imtelephone.com       **************");
	printf("\n");
	printf("\n-------------      G723.1 Decoder      ------------");
	printf("\n");

	/*-----------------------------------------------------------------------*
	 * Open all files.                                                       *
	 *-----------------------------------------------------------------------*/

	if (argc != 3)
	{
		printf("Usage: %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                                                                *
	 *-----------------------------------------------------------------------*/

	hDecoder = EasyG7231_init_decoder( false );

	nb_frame = 0;
  	start = clock();

	while (fread(serial, sizeof(char), L_G7231_FRAME_COMPRESSED_53, fp_in) == L_G7231_FRAME_COMPRESSED_53) 
	{

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

		/*--------------------------------------------------------------*
		 * Call the decoder.                                            *
		 *--------------------------------------------------------------*/

		EasyG7231_decoder(hDecoder, serial, synth );

		/*--------------------------------------------------------------*
		 * Output synthesis to disk                                     *
		 *--------------------------------------------------------------*/

		fwrite(synth, sizeof(short), L_G7231_FRAME, fp_out);
	}

   EasyG7231_release_decoder( hDecoder );
 
   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 + -