?? coder.c
字號(hào):
/* ITU-T G.729 Annex C - Reference C code for floating point implementation of G.729 Annex A Version 1.01 of 15.September.98*//*---------------------------------------------------------------------- COPYRIGHT NOTICE---------------------------------------------------------------------- ITU-T G.729 Annex C ANSI C source code Copyright (C) 1998, AT&T, France Telecom, NTT, University of Sherbrooke. All rights reserved.----------------------------------------------------------------------*//* File : CODERA.C Used for the floating point version of G.729A only (not for G.729 main body)*//*-------------------------------------------------------------------* * Main program of the ITU-T G.729A 8 kbit/s encoder. * * * * Usage : coder speech_file bitstream_file * *-------------------------------------------------------------------*/#include "typedef.h"#include "ld8a.h"#include "cst_ld8a.h"#include "octet.h"int main( int argc, char *argv[]){ FILE *f_speech; /* Speech data */ FILE *f_serial; /* Serial bit stream */ static int prm[1+PRM_SIZE]; /* Transmitted parameters */ static INT16 serial[SERIAL_SIZE]; /* Output bit stream buffer */ static INT16 sp16[L_FRAME]; /* Buffer to read 16 bits speech */ /* For G.729B */ int nb_words; int vad_enable; /* New unstaticed states */ struct preproc_state_t preproc_s; struct cod_state_t cod_s; int i; int frame; int count_frame; printf("\n"); printf("*********** ITU G.729A 8 KBIT/S SPEECH CODER ***********\n"); printf(" (WITH ANNEX B) \n"); printf("\n"); printf("----------------- Floating point C simulation ----------------\n"); printf("\n"); printf("------------------- Version 1.4 -----------------\n"); printf("\n"); /*-----------------------------------------------------------------------* * Open speech file and result file (output serial bit stream) * *-----------------------------------------------------------------------*/ if ( argc != 4 ){ printf("Usage :%s speech_file bitstream_file VAD_flag\n", argv[0]); printf("\n"); printf("Format for speech_file:\n"); printf(" Speech is read from a binary file of 16 bits PCM data.\n"); printf("\n"); printf("Format for bitstream_file:\n"); printf(" One (2-byte) synchronization word \n"); printf(" One (2-byte) size word,\n"); printf(" 80 words (2-byte) containing 80 bits.\n"); printf("\n"); printf("VAD flag:\n"); printf(" 0 to disable the VAD\n"); printf(" 1 to enable the VAD\n"); exit(1); } if ( (f_speech = fopen(argv[1], "rb")) == NULL) { printf("%s - Error opening file %s !!\n", argv[0], argv[1]); exit(0); } printf(" Input speech file: %s\n", argv[1]); if ( (f_serial = fopen(argv[2], "wb")) == NULL) { printf("%s - Error opening file %s !!\n", argv[0], argv[2]); exit(0); } printf(" Output bitstream file: %s\n", argv[2]); vad_enable = atoi(argv[3]); if (vad_enable == 1) printf(" VAD enabled\n"); else printf(" VAD disabled\n");#ifndef OCTET_TX_MODE printf(" OCTET TRANSMISSION MODE is disabled\n");#endif /*-------------------------------------------------* * Initialization of the coder. * *-------------------------------------------------*/ init_pre_process(&preproc_s); init_coder_ld8a(&cod_s); /* Initialize the coder */ /* for G.729B */ init_cod_cng(&cod_s.cng_s); /*-------------------------------------------------------------------------* * Loop for every analysis/transmission frame. * * -New L_FRAME data are read. (L_FRAME = number of speech data per frame) * * -Conversion of the speech data from 16 bit integer to real * * -Call cod_ld8a to encode the speech. * * -The compressed serial output stream is written to a file. * * -The synthesis speech is written to a file * *-------------------------------------------------------------------------* */ frame = 0; count_frame = 0; while( fread((void *)sp16, sizeof(INT16), L_FRAME, f_speech) == L_FRAME) { frame++; printf(" Frame: %d\r", count_frame++); if (frame == 32767) frame = 256; else frame++; for (i = 0; i < L_FRAME; i++) cod_s.new_speech[i] = (FLOAT) sp16[i]; pre_process(&preproc_s, cod_s.new_speech, L_FRAME); coder_ld8a(&cod_s, prm, frame, vad_enable); prm2bits_ld8k(prm, serial); nb_words = serial[1] + 2; fwrite(serial, sizeof(INT16), nb_words, f_serial); } return 0;} /* end of main() */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -