00001 /* 00002 * SIPR / ACELP.NET decoder 00003 * 00004 * Copyright (c) 2008 Vladimir Voroshilov 00005 * Copyright (c) 2009 Vitor Sessak 00006 * 00007 * This file is part of FFmpeg. 00008 * 00009 * FFmpeg is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 2.1 of the License, or (at your option) any later version. 00013 * 00014 * FFmpeg is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with FFmpeg; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #ifndef AVCODEC_SIPR_H 00025 #define AVCODEC_SIPR_H 00026 00027 #include "avcodec.h" 00028 #include "dsputil.h" 00029 #include "acelp_pitch_delay.h" 00030 00031 #define LP_FILTER_ORDER_16k 16 00032 #define L_SUBFR_16k 80 00033 #define PITCH_MIN 30 00034 #define PITCH_MAX 281 00035 00036 #define LSFQ_DIFF_MIN (0.0125 * M_PI) 00037 00038 #define LP_FILTER_ORDER 10 00039 00041 #define L_INTERPOL (LP_FILTER_ORDER + 1) 00042 00044 #define SUBFR_SIZE 48 00045 00046 #define SUBFRAME_COUNT_16k 2 00047 00048 typedef enum { 00049 MODE_16k, 00050 MODE_8k5, 00051 MODE_6k5, 00052 MODE_5k0, 00053 MODE_COUNT 00054 } SiprMode; 00055 00056 typedef struct { 00057 AVCodecContext *avctx; 00058 DSPContext dsp; 00059 00060 SiprMode mode; 00061 00062 float past_pitch_gain; 00063 float lsf_history[LP_FILTER_ORDER_16k]; 00064 00065 float excitation[L_INTERPOL + PITCH_MAX + 2 * L_SUBFR_16k]; 00066 00067 DECLARE_ALIGNED(16, float, synth_buf)[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6]; 00068 00069 float lsp_history[LP_FILTER_ORDER]; 00070 float gain_mem; 00071 float energy_history[4]; 00072 float highpass_filt_mem[2]; 00073 float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER]; 00074 00075 /* 5k0 */ 00076 float tilt_mem; 00077 float postfilter_agc; 00078 float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER]; 00079 float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5]; 00080 00081 /* 16k */ 00082 int pitch_lag_prev; 00083 float iir_mem[LP_FILTER_ORDER_16k+1]; 00084 float filt_buf[2][LP_FILTER_ORDER_16k+1]; 00085 float *filt_mem[2]; 00086 float mem_preemph[LP_FILTER_ORDER_16k]; 00087 float synth[LP_FILTER_ORDER_16k]; 00088 double lsp_history_16k[16]; 00089 } SiprContext; 00090 00091 typedef struct { 00092 int ma_pred_switch; 00093 int vq_indexes[5]; 00094 int pitch_delay[5]; 00095 int gp_index[5]; 00096 int16_t fc_indexes[5][10]; 00097 int gc_index[5]; 00098 } SiprParameters; 00099 00100 extern const float ff_pow_0_5[16]; 00101 00102 void ff_sipr_init_16k(SiprContext *ctx); 00103 00104 void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params, 00105 float *out_data); 00106 00107 #endif /* AVCODEC_SIPR_H */