Re: [Ekiga-list] G729 codec




Please swap the src/main.c file with the attached one and recompile.
This is a small test program for g729 codec. It encodes test.wav file to
test.g729 and then decodes it back to test_out.raw.

Let me know if the test.wav and test_out.raw files contain the same
audio sample. (Except for lower quality, of course ;)) You just take any
wav sample and put it in bin/ directory with the name test.wav.

Oh, the resulting test_out.raw file is in WAV format, but it doesn't
contain appropriate headers, so you will have to import it as "raw
audio" with audacity or something similar.


Also, if you start ekiga from the console with -d 4 option, you will see
some output from the codec. Can you paste this here, please? 





On Sun, 2007-11-04 at 16:51 +0100, PawelCarqowski wrote:
> have you got any ideas?
#include <stdio.h>
#include <stdlib.h>
#include "myg729.h"

const int SAMPLE_FRAME = 160;
const int BIT_FRAME = 10;


int main() {

	char* buffer; // buffer for file read
	char* output = malloc(BIT_FRAME);
	char* p; // loops pointer: p, f
	char* f;
	int file_size=0;
	int count_encode=0;
	int count_decode=0;
	
	printf("Opening files test.wav and test.g729 for ENCODING...\n");
	FILE *f_in = fopen("test.wav", "r");
 	FILE *f_out = fopen("test.g729", "w");

	fseek(f_in, 0, SEEK_END);
	file_size = ftell(f_in);
	printf("ENCODE_FILESIZE: %d\n", file_size);
	fseek(f_in, 0, SEEK_SET);

	buffer = malloc(file_size);
	fread(buffer, file_size, 1, f_in);
	p = buffer;
	f = buffer + file_size;
	
	printf("P: %p\n", p);
	printf("F: %p\n", f);
	
	
	struct G729STRUCT_ENCODE* test;
	test = g729_encoder_init();


	while (p < f) {	

		g729_encode(test, p, output);
		printf("Writing frame: %d, p: %p, f: %p\n", count_encode, p, f);
		fwrite(output, BIT_FRAME, 1, f_out);
		p = p + SAMPLE_FRAME;
		count_encode++;
	}
	
	fclose(f_out);
	fclose(f_in);

// Starting decode operation


	printf("\n");
	printf("Opening files test.g729 and test.wav for DECODING...\n");
	printf("\n");
	printf("\n");
	

	f_in = fopen("test.g729", "r");
 	f_out = fopen("test_out.raw", "w");
	
	fseek(f_in, 0, SEEK_END);
	file_size = ftell(f_in);
	fseek(f_in, 0, SEEK_SET);

	buffer = malloc(file_size);
	output = malloc(SAMPLE_FRAME);
	
	fread(buffer, file_size, 1, f_in);
	p = buffer;
	f = buffer + file_size;
	
	
	struct G729STRUCT_DECODE* test2 = g729_decoder_init();
	
	while (p < f) {	


		g729_decode(test2, p, output);
		printf("Writing frame: %d\n", count_decode);
		fwrite(output, SAMPLE_FRAME, 1, f_out);
		p = p + BIT_FRAME;
		count_decode++;
	}

	fclose(f_out);
	fclose(f_in);	
	g729_encoder_destroy(test);
	g729_decoder_destroy(test2);
}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]