📄 decoder.c
字号:
/* 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.----------------------------------------------------------------------*//*-----------------------------------------------------------------* * Main program of the G.729a 8.0 kbit/s decoder. * * * * Usage : decoder bitstream_file synth_file * * * *-----------------------------------------------------------------*/#include "typedef.h"#include "ld8k.h"#include "cst_ld8c.h"#include "octet.h"/*-----------------------------------------------------------------* * Main decoder routine * *-----------------------------------------------------------------*/int main( int argc, char *argv[]){ static FLOAT synth_buf[L_FRAME+M]; /* Synthesis */ FLOAT *synth; static int parm[2+PRM_SIZE]; /* Synthesis parameters + BFI */ static INT16 serial[SERIAL_SIZE]; /* Serial stream */ static FLOAT Az_dec[MP1*2]; /* Decoded Az for post-filter */ FLOAT *ptr_Az; static int T2[2]; /* Decoded Pitch */ int t0_first; /* Pitch lag in 1st subframe */ FLOAT pst_out[L_FRAME]; /* Postfilter output */ int voicing; /* voicing from previous frame */ int sf_voic; /* voicing for subframe */ int count_frame; int i; int Vad; FILE *f_syn, *f_serial; /* New unstaticed states */ struct preproc_state_t postproc_s; struct dec_state_t dec_s; struct postfilt_state_t postfilt_s; printf("\n"); printf("************ ITU G.729 8.0 KBIT/S SPEECH DECODER ************\n"); printf(" (WITH ANNEX B) \n"); printf("\n"); printf("----------------- Floating point C simulation ----------------\n"); printf("\n"); printf("----------------- Version 1.04 ----------------\n"); printf("\n"); /* Passed arguments */ if ( argc != 3) { printf("Usage :%s bitstream_file outputspeech_file\n",argv[0]); 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("Format for outputspeech_file:\n"); printf(" Synthesis is written to a binary file of 16 bits data.\n"); exit( 1 ); } /* Open file for synthesis and packed serial stream */ if( (f_serial = fopen(argv[1],"rb") ) == NULL ) { printf("%s - Error opening file %s !!\n", argv[0], argv[1]); exit(0); } if( (f_syn = fopen(argv[2], "wb") ) == NULL ) { printf("%s - Error opening file %s !!\n", argv[0], argv[2]); exit(0); } printf("Input bitstream file : %s\n",argv[1]); printf("Synthesis speech file : %s\n",argv[2]);#ifndef OCTET_TX_MODE printf("OCTET TRANSMISSION MODE is disabled\n");#endif/*-----------------------------------------------------------------* * Initialization of decoder * *-----------------------------------------------------------------*/ for (i=0; i<M; i++) synth_buf[i] = (F)0.0; synth = synth_buf + M; init_decod_ld8c(&dec_s); init_post_filter(&postfilt_s); init_post_process(&postproc_s); voicing = 60; /* for G.729b */ init_dec_cng(&dec_s.cng_s);/*-----------------------------------------------------------------* * Loop for each "L_FRAME" speech data * *-----------------------------------------------------------------*/ count_frame = 0; while (read_frame(f_serial, parm) != 0) { printf("Frame = %d\r", count_frame++); decod_ld8c(&dec_s, parm, voicing, synth, Az_dec, &t0_first, &Vad); /* Postfilter */ voicing = 0; ptr_Az = Az_dec; for (i=0; i<L_FRAME; i+=L_SUBFR) { post(&postfilt_s, t0_first, synth + i, ptr_Az, pst_out + i, &sf_voic, Vad); if (sf_voic != 0) voicing = sf_voic; ptr_Az += MP1; } copy(&synth_buf[L_FRAME], &synth_buf[0], M); post_process(&postproc_s, pst_out, L_FRAME); fwrite16(pst_out, L_FRAME, f_syn); } return(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -