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 00059 SiprMode mode; 00060 00061 float past_pitch_gain; 00062 float lsf_history[LP_FILTER_ORDER_16k]; 00063 00064 float excitation[L_INTERPOL + PITCH_MAX + 2 * L_SUBFR_16k]; 00065 00066 DECLARE_ALIGNED(16, float, synth_buf)[LP_FILTER_ORDER + 5*SUBFR_SIZE + 6]; 00067 00068 float lsp_history[LP_FILTER_ORDER]; 00069 float gain_mem; 00070 float energy_history[4]; 00071 float highpass_filt_mem[2]; 00072 float postfilter_mem[PITCH_DELAY_MAX + LP_FILTER_ORDER]; 00073 00074 /* 5k0 */ 00075 float tilt_mem; 00076 float postfilter_agc; 00077 float postfilter_mem5k0[PITCH_DELAY_MAX + LP_FILTER_ORDER]; 00078 float postfilter_syn5k0[LP_FILTER_ORDER + SUBFR_SIZE*5]; 00079 00080 /* 16k */ 00081 int pitch_lag_prev; 00082 float iir_mem[LP_FILTER_ORDER_16k+1]; 00083 float filt_buf[2][LP_FILTER_ORDER_16k+1]; 00084 float *filt_mem[2]; 00085 float mem_preemph[LP_FILTER_ORDER_16k]; 00086 float synth[LP_FILTER_ORDER_16k]; 00087 double lsp_history_16k[16]; 00088 } SiprContext; 00089 00090 typedef struct { 00091 int ma_pred_switch; 00092 int vq_indexes[5]; 00093 int pitch_delay[5]; 00094 int gp_index[5]; 00095 int16_t fc_indexes[5][10]; 00096 int gc_index[5]; 00097 } SiprParameters; 00098 00099 extern const float ff_pow_0_5[16]; 00100 00101 void ff_sipr_init_16k(SiprContext *ctx); 00102 00103 void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params, 00104 float *out_data); 00105 00106 #endif /* AVCODEC_SIPR_H */