| FFmpeg
    | 
AMR wideband decoder. More...
#include "libavutil/channel_layout.h"#include "libavutil/common.h"#include "libavutil/float_dsp.h"#include "libavutil/lfg.h"#include "avcodec.h"#include "lsp.h"#include "celp_filters.h"#include "celp_math.h"#include "acelp_filters.h"#include "acelp_vectors.h"#include "acelp_pitch_delay.h"#include "internal.h"#include "amr.h"#include "amrwbdata.h"#include "mips/amrwbdec_mips.h"Go to the source code of this file.
| Data Structures | |
| struct | AMRWBContext | 
| Macros | |
| #define | AMR_USE_16BIT_TABLES | 
| #define | BIT_STR(x, lsb, len) av_mod_uintp2((x) >> (lsb), (len)) | 
| Get x bits in the index interval [lsb,lsb+len-1] inclusive.  More... | |
| #define | BIT_POS(x, p) (((x) >> (p)) & 1) | 
| Get the bit at specified position.  More... | |
| Functions | |
| static av_cold int | amrwb_decode_init (AVCodecContext *avctx) | 
| static int | decode_mime_header (AMRWBContext *ctx, const uint8_t *buf) | 
| Decode the frame header in the "MIME/storage" format.  More... | |
| static void | decode_isf_indices_36b (uint16_t *ind, float *isf_q) | 
| Decode quantized ISF vectors using 36-bit indexes (6K60 mode only).  More... | |
| static void | decode_isf_indices_46b (uint16_t *ind, float *isf_q) | 
| Decode quantized ISF vectors using 46-bit indexes (except 6K60 mode).  More... | |
| static void | isf_add_mean_and_past (float *isf_q, float *isf_past) | 
| Apply mean and past ISF values using the prediction factor.  More... | |
| static void | interpolate_isp (double isp_q[4][LP_ORDER], const double *isp4_past) | 
| Interpolate the fourth ISP vector from current and past frames to obtain an ISP vector for each subframe.  More... | |
| static void | decode_pitch_lag_high (int *lag_int, int *lag_frac, int pitch_index, uint8_t *base_lag_int, int subframe) | 
| Decode an adaptive codebook index into pitch lag (except 6k60, 8k85 modes).  More... | |
| static void | decode_pitch_lag_low (int *lag_int, int *lag_frac, int pitch_index, uint8_t *base_lag_int, int subframe, enum Mode mode) | 
| Decode an adaptive codebook index into pitch lag for 8k85 and 6k60 modes.  More... | |
| static void | decode_pitch_vector (AMRWBContext *ctx, const AMRWBSubFrame *amr_subframe, const int subframe) | 
| Find the pitch vector by interpolating the past excitation at the pitch delay, which is obtained in this function.  More... | |
| static void | decode_1p_track (int *out, int code, int m, int off) | 
| The next six functions decode_[i]p_track decode exactly i pulses positions and amplitudes (-1 or 1) in a subframe track using an encoded pulse indexing (TS 26.190 section 5.8.2).  More... | |
| static void | decode_2p_track (int *out, int code, int m, int off) | 
| code: 2m+1 bits  More... | |
| static void | decode_3p_track (int *out, int code, int m, int off) | 
| code: 3m+1 bits  More... | |
| static void | decode_4p_track (int *out, int code, int m, int off) | 
| code: 4m bits  More... | |
| static void | decode_5p_track (int *out, int code, int m, int off) | 
| code: 5m bits  More... | |
| static void | decode_6p_track (int *out, int code, int m, int off) | 
| code: 6m-2 bits  More... | |
| static void | decode_fixed_vector (float *fixed_vector, const uint16_t *pulse_hi, const uint16_t *pulse_lo, const enum Mode mode) | 
| Decode the algebraic codebook index to pulse positions and signs, then construct the algebraic codebook vector.  More... | |
| static void | decode_gains (const uint8_t vq_gain, const enum Mode mode, float *fixed_gain_factor, float *pitch_gain) | 
| Decode pitch gain and fixed gain correction factor.  More... | |
| static void | pitch_sharpening (AMRWBContext *ctx, float *fixed_vector) | 
| Apply pitch sharpening filters to the fixed codebook vector.  More... | |
| static float | voice_factor (float *p_vector, float p_gain, float *f_vector, float f_gain, CELPMContext *ctx) | 
| Calculate the voicing factor (-1.0 = unvoiced to 1.0 = voiced).  More... | |
| static float * | anti_sparseness (AMRWBContext *ctx, float *fixed_vector, float *buf) | 
| Reduce fixed vector sparseness by smoothing with one of three IR filters, also known as "adaptive phase dispersion".  More... | |
| static float | stability_factor (const float *isf, const float *isf_past) | 
| Calculate a stability factor {teta} based on distance between current and past isf.  More... | |
| static float | noise_enhancer (float fixed_gain, float *prev_tr_gain, float voice_fac, float stab_fac) | 
| Apply a non-linear fixed gain smoothing in order to reduce fluctuation in the energy of excitation.  More... | |
| static void | pitch_enhancer (float *fixed_vector, float voice_fac) | 
| Filter the fixed_vector to emphasize the higher frequencies.  More... | |
| static void | synthesis (AMRWBContext *ctx, float *lpc, float *excitation, float fixed_gain, const float *fixed_vector, float *samples) | 
| Conduct 16th order linear predictive coding synthesis from excitation.  More... | |
| static void | de_emphasis (float *out, float *in, float m, float mem[1]) | 
| Apply to synthesis a de-emphasis filter of the form: H(z) = 1 / (1 - m * z^-1)  More... | |
| static void | upsample_5_4 (float *out, const float *in, int o_size, CELPMContext *ctx) | 
| Upsample a signal by 5/4 ratio (from 12.8kHz to 16kHz) using a FIR interpolation filter.  More... | |
| static float | find_hb_gain (AMRWBContext *ctx, const float *synth, uint16_t hb_idx, uint8_t vad) | 
| Calculate the high-band gain based on encoded index (23k85 mode) or on the low-band speech signal and the Voice Activity Detection flag.  More... | |
| static void | scaled_hb_excitation (AMRWBContext *ctx, float *hb_exc, const float *synth_exc, float hb_gain) | 
| Generate the high-band excitation with the same energy from the lower one and scaled by the given gain.  More... | |
| static float | auto_correlation (float *diff_isf, float mean, int lag) | 
| Calculate the auto-correlation for the ISF difference vector.  More... | |
| static void | extrapolate_isf (float isf[LP_ORDER_16k]) | 
| Extrapolate a ISF vector to the 16kHz range (20th order LP) used at mode 6k60 LP filter for the high frequency band.  More... | |
| static void | lpc_weighting (float *out, const float *lpc, float gamma, int size) | 
| Spectral expand the LP coefficients using the equation: y[i] = x[i] * (gamma ** i)  More... | |
| static void | hb_synthesis (AMRWBContext *ctx, int subframe, float *samples, const float *exc, const float *isf, const float *isf_past) | 
| Conduct 20th order linear predictive coding synthesis for the high frequency band excitation at 16kHz.  More... | |
| static void | hb_fir_filter (float *out, const float fir_coef[HB_FIR_SIZE+1], float mem[HB_FIR_SIZE], const float *in) | 
| Apply a 15th order filter to high-band samples.  More... | |
| static void | update_sub_state (AMRWBContext *ctx) | 
| Update context state before the next subframe.  More... | |
| static int | amrwb_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) | 
| Variables | |
| AVCodec | ff_amrwb_decoder | 
AMR wideband decoder.
Definition in file amrwbdec.c.
| #define AMR_USE_16BIT_TABLES | 
Definition at line 41 of file amrwbdec.c.
Get x bits in the index interval [lsb,lsb+len-1] inclusive.
Definition at line 358 of file amrwbdec.c.
Referenced by decode_1p_track(), decode_2p_track(), decode_3p_track(), decode_4p_track(), decode_5p_track(), and decode_6p_track().
| #define BIT_POS | ( | x, | |
| p | |||
| ) | (((x) >> (p)) & 1) | 
Get the bit at specified position.
Definition at line 361 of file amrwbdec.c.
Referenced by decode_1p_track(), decode_2p_track(), decode_3p_track(), decode_4p_track(), decode_5p_track(), and decode_6p_track().
| 
 | static | 
Definition at line 96 of file amrwbdec.c.
| 
 | static | 
Decode the frame header in the "MIME/storage" format.
This format is simpler and does not carry the auxiliary frame information.
| [in] | ctx | The Context | 
| [in] | buf | Pointer to the input buffer | 
Definition at line 140 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Decode quantized ISF vectors using 36-bit indexes (6K60 mode only).
| [in] | ind | Array of 5 indexes | 
| [out] | isf_q | Buffer for isf_q[LP_ORDER] | 
Definition at line 155 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Decode quantized ISF vectors using 46-bit indexes (except 6K60 mode).
| [in] | ind | Array of 7 indexes | 
| [out] | isf_q | Buffer for isf_q[LP_ORDER] | 
Definition at line 181 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Apply mean and past ISF values using the prediction factor.
Updates past ISF vector.
| [in,out] | isf_q | Current quantized ISF | 
| [in,out] | isf_past | Past quantized ISF | 
Definition at line 214 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Interpolate the fourth ISP vector from current and past frames to obtain an ISP vector for each subframe.
| [in,out] | isp_q | ISPs for each subframe | 
| [in] | isp4_past | Past ISP for subframe 4 | 
Definition at line 234 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Decode an adaptive codebook index into pitch lag (except 6k60, 8k85 modes).
Calculate integer lag and fractional lag always using 1/4 resolution. In 1st and 3rd subframes the index is relative to last subframe integer lag.
| [out] | lag_int | Decoded integer pitch lag | 
| [out] | lag_frac | Decoded fractional pitch lag | 
| [in] | pitch_index | Adaptive codebook pitch index | 
| [in,out] | base_lag_int | Base integer lag used in relative subframes | 
| [in] | subframe | Current subframe index (0 to 3) | 
Definition at line 256 of file amrwbdec.c.
Referenced by decode_pitch_vector().
| 
 | static | 
Decode an adaptive codebook index into pitch lag for 8k85 and 6k60 modes.
The description is analogous to decode_pitch_lag_high, but in 6k60 the relative index is used for all subframes except the first.
Definition at line 289 of file amrwbdec.c.
Referenced by decode_pitch_vector().
| 
 | static | 
Find the pitch vector by interpolating the past excitation at the pitch delay, which is obtained in this function.
| [in,out] | ctx | The context | 
| [in] | amr_subframe | Current subframe data | 
| [in] | subframe | Current subframe index (0 to 3) | 
Definition at line 318 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
The next six functions decode_[i]p_track decode exactly i pulses positions and amplitudes (-1 or 1) in a subframe track using an encoded pulse indexing (TS 26.190 section 5.8.2).
The results are given in out[], in which a negative number means amplitude -1 and vice versa (i.e., ampl(x) = x / abs(x) ).
| [out] | out | Output buffer (writes i elements) | 
| [in] | code | Pulse index (no. of bits varies, see below) | 
| [in] | m | (log2) Number of potential positions | 
| [in] | off | Offset for decoded positions | 
code: m+1 bits
Definition at line 376 of file amrwbdec.c.
Referenced by decode_3p_track(), decode_4p_track(), decode_6p_track(), and decode_fixed_vector().
code: 2m+1 bits
Definition at line 383 of file amrwbdec.c.
Referenced by decode_3p_track(), decode_4p_track(), decode_5p_track(), decode_6p_track(), and decode_fixed_vector().
code: 3m+1 bits
Definition at line 393 of file amrwbdec.c.
Referenced by decode_4p_track(), decode_5p_track(), decode_6p_track(), and decode_fixed_vector().
code: 4m bits
Definition at line 402 of file amrwbdec.c.
Referenced by decode_6p_track(), and decode_fixed_vector().
code: 5m bits
Definition at line 438 of file amrwbdec.c.
Referenced by decode_6p_track(), and decode_fixed_vector().
| 
 | static | 
Decode the algebraic codebook index to pulse positions and signs, then construct the algebraic codebook vector.
| [out] | fixed_vector | Buffer for the fixed codebook excitation | 
| [in] | pulse_hi | MSBs part of the pulse index array (higher modes only) | 
| [in] | pulse_lo | LSBs part of the pulse index array | 
| [in] | mode | Mode of the current frame | 
Definition at line 492 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Decode pitch gain and fixed gain correction factor.
| [in] | vq_gain | Vector-quantized index for gains | 
| [in] | mode | Mode of the current frame | 
| [out] | fixed_gain_factor | Decoded fixed gain correction factor | 
| [out] | pitch_gain | Decoded pitch gain | 
Definition at line 563 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Apply pitch sharpening filters to the fixed codebook vector.
| [in] | ctx | The context | 
| [in,out] | fixed_vector | Fixed codebook excitation | 
Definition at line 581 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Calculate the voicing factor (-1.0 = unvoiced to 1.0 = voiced).
| [in] | p_vector,f_vector | Pitch and fixed excitation vectors | 
| [in] | p_gain,f_gain | Pitch and fixed gains | 
| [in] | ctx | The context | 
Definition at line 603 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Reduce fixed vector sparseness by smoothing with one of three IR filters, also known as "adaptive phase dispersion".
| [in] | ctx | The context | 
| [in,out] | fixed_vector | Unfiltered fixed vector | 
| [out] | buf | Space for modified vector if necessary | 
Definition at line 627 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Calculate a stability factor {teta} based on distance between current and past isf.
A value of 1 shows maximum signal stability.
Definition at line 691 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Apply a non-linear fixed gain smoothing in order to reduce fluctuation in the energy of excitation.
| [in] | fixed_gain | Unsmoothed fixed gain | 
| [in,out] | prev_tr_gain | Previous threshold gain (updated) | 
| [in] | voice_fac | Frame voicing factor | 
| [in] | stab_fac | Frame stability factor | 
Definition at line 715 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Filter the fixed_vector to emphasize the higher frequencies.
| [in,out] | fixed_vector | Fixed codebook vector | 
| [in] | voice_fac | Frame voicing factor | 
Definition at line 742 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Conduct 16th order linear predictive coding synthesis from excitation.
| [in] | ctx | Pointer to the AMRWBContext | 
| [in] | lpc | Pointer to the LPC coefficients | 
| [out] | excitation | Buffer for synthesis final excitation | 
| [in] | fixed_gain | Fixed codebook gain for synthesis | 
| [in] | fixed_vector | Algebraic codebook vector | 
| [in,out] | samples | Pointer to the output samples and memory | 
Definition at line 770 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Apply to synthesis a de-emphasis filter of the form: H(z) = 1 / (1 - m * z^-1)
| [out] | out | Output buffer | 
| [in] | in | Input samples array with in[-1] | 
| [in] | m | Filter coefficient | 
| [in,out] | mem | State from last filtering | 
Definition at line 807 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Upsample a signal by 5/4 ratio (from 12.8kHz to 16kHz) using a FIR interpolation filter.
Uses past data from before *in address.
| [out] | out | Buffer for interpolated signal | 
| [in] | in | Current signal data (length 0.8*o_size) | 
| [in] | o_size | Output signal length | 
| [in] | ctx | The context | 
Definition at line 828 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Calculate the high-band gain based on encoded index (23k85 mode) or on the low-band speech signal and the Voice Activity Detection flag.
| [in] | ctx | The context | 
| [in] | synth | LB speech synthesis at 12.8k | 
| [in] | hb_idx | Gain index for mode 23k85 only | 
| [in] | vad | VAD flag for the frame | 
Definition at line 860 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Generate the high-band excitation with the same energy from the lower one and scaled by the given gain.
| [in] | ctx | The context | 
| [out] | hb_exc | Buffer for the excitation | 
| [in] | synth_exc | Low-band excitation used for synthesis | 
| [in] | hb_gain | Wanted excitation gain | 
Definition at line 890 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Calculate the auto-correlation for the ISF difference vector.
Definition at line 909 of file amrwbdec.c.
Referenced by extrapolate_isf().
| 
 | static | 
Extrapolate a ISF vector to the 16kHz range (20th order LP) used at mode 6k60 LP filter for the high frequency band.
| [out] | isf | Buffer for extrapolated isf; contains LP_ORDER values on input | 
Definition at line 928 of file amrwbdec.c.
Referenced by hb_synthesis().
Spectral expand the LP coefficients using the equation: y[i] = x[i] * (gamma ** i)
| [out] | out | Output buffer (may use input array) | 
| [in] | lpc | LP coefficients array | 
| [in] | gamma | Weighting factor | 
| [in] | size | LP array size | 
Definition at line 993 of file amrwbdec.c.
Referenced by hb_synthesis().
| 
 | static | 
Conduct 20th order linear predictive coding synthesis for the high frequency band excitation at 16kHz.
| [in] | ctx | The context | 
| [in] | subframe | Current subframe index (0 to 3) | 
| [in,out] | samples | Pointer to the output speech samples | 
| [in] | exc | Generated white-noise scaled excitation | 
| [in] | isf | Current frame isf vector | 
| [in] | isf_past | Past frame final isf vector | 
Definition at line 1015 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Apply a 15th order filter to high-band samples.
The filter characteristic depends on the given coefficients.
| [out] | out | Buffer for filtered output | 
| [in] | fir_coef | Filter coefficients | 
| [in,out] | mem | State from last filtering (updated) | 
| [in] | in | Input speech data (high-band) | 
Definition at line 1056 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Update context state before the next subframe.
Definition at line 1078 of file amrwbdec.c.
Referenced by amrwb_decode_frame().
| 
 | static | 
Definition at line 1094 of file amrwbdec.c.
| AVCodec ff_amrwb_decoder | 
Definition at line 1270 of file amrwbdec.c.
 1.8.6
 1.8.6