g729編解碼的總結(2)
阿新 • • 發佈:2019-01-03
自己的g729程式碼在測試的時候,出現了錯誤,是自己以前沒注意的地方,所以,要明白一點:只要是沒解決的問題,就不是小問題。
自己修改了很多程式,可是老是通不過,自己最後才想到修改原始碼,然後成功了。下面是自己的原始碼,希望對大家有幫助吧。
int CG729aDec::G729aDec_Init(void) { for (Word16 i = 0; i < M; i++) { m_synth_buf[i] = 0; } m_synth = m_synth_buf + M; m_bad_lsf = 0; /* Initialize bad LSF indicator */ Init_Decod_ld8a(); Init_Post_Filter(); Init_Post_Process(); return 0; } int CG729aDec::G729aDec_Decode(char *szInBuf, int nInBufLen, char *szOutBuf, int& nOutBufLen) { char* sample = szInBuf; m_number = 0; while (sample - szInBuf <nInBufLen) { memcpy(m_serial, sample, SERIAL_SIZE); bits2prm_ld8k(m_serial, &m_parm[1]); /* the hardware detects frame erasures by checking if all bitsare set to zero */ m_parm[0] = 0; /* 假設沒有丟幀 */ m_parm[4] = 0; /* 假設資料效驗正常 */ Decod_ld8a(m_parm, m_synth, m_Az_dec, m_T2); Post_Filter(m_synth, m_Az_dec, m_T2); /* Post-filter */ Post_Process(m_synth, L_FRAME); memcpy(szOutBuf + m_number*L_FRAME*2, (char*)m_synth, L_FRAME * 2); sample += SERIAL_SIZE; m_number++; } nOutBufLen = m_number*L_FRAME * 2; sample = NULL; return 0; }