Go to the documentation of this file.
32 #define BITSTREAM_READER_LE
43 #define MAX_SUBFRAME_COUNT 5
73 .bits_per_frame = 160,
75 .frames_per_packet = 1,
76 .pitch_sharp_factor = 0.00,
78 .number_of_fc_indexes = 10,
79 .ma_predictor_bits = 1,
80 .vq_indexes_bits = {7, 8, 7, 7, 7},
81 .pitch_delay_bits = {9, 6},
83 .fc_index_bits = {4, 5, 4, 5, 4, 5, 4, 5, 4, 5},
89 .bits_per_frame = 152,
91 .frames_per_packet = 1,
92 .pitch_sharp_factor = 0.8,
94 .number_of_fc_indexes = 3,
95 .ma_predictor_bits = 0,
96 .vq_indexes_bits = {6, 7, 7, 7, 5},
97 .pitch_delay_bits = {8, 5, 5},
99 .fc_index_bits = {9, 9, 9},
105 .bits_per_frame = 232,
107 .frames_per_packet = 2,
108 .pitch_sharp_factor = 0.8,
110 .number_of_fc_indexes = 3,
111 .ma_predictor_bits = 0,
112 .vq_indexes_bits = {6, 7, 7, 7, 5},
113 .pitch_delay_bits = {8, 5, 5},
115 .fc_index_bits = {5, 5, 5},
121 .bits_per_frame = 296,
123 .frames_per_packet = 2,
124 .pitch_sharp_factor = 0.85,
126 .number_of_fc_indexes = 1,
127 .ma_predictor_bits = 0,
128 .vq_indexes_bits = {6, 7, 7, 7, 5},
129 .pitch_delay_bits = {8, 5, 8, 5, 5},
131 .fc_index_bits = {10},
137 1.0/(1 << 1), 1.0/(1 << 2), 1.0/(1 << 3), 1.0/(1 << 4),
138 1.0/(1 << 5), 1.0/(1 << 6), 1.0/(1 << 7), 1.0/(1 << 8),
139 1.0/(1 << 9), 1.0/(1 << 10), 1.0/(1 << 11), 1.0/(1 << 12),
140 1.0/(1 << 13), 1.0/(1 << 14), 1.0/(1 << 15), 1.0/(1 << 16)
143 static void dequant(
float *
out,
const int *idx,
const float *
const cbs[])
149 for (
i = 0;
i < num_vec;
i++)
163 lsfnew[
i] = lsf_history[
i] * 0.33 + lsf_tmp[
i] +
mean_lsf[
i];
175 lsfnew[
i] = cos(lsfnew[
i]);
186 fixed_vector[
i] += beta * fixed_vector[
i - pitch_lag_int];
202 for (
i = 0;
i < 5;
i++)
222 float t,
t0 = 1.0 / num_subfr;
225 for (
i = 0;
i < num_subfr;
i++) {
227 lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
238 static void eval_ir(
const float *Az,
int pitch_lag,
float *freq,
239 float pitch_sharp_factor)
249 memset(tmp1 + 11, 0, 37 *
sizeof(
float));
261 const float *shape,
int length)
265 memset(
out, 0, length*
sizeof(
float));
267 for (j =
pulses->x[
i]; j < length; j++)
316 for (
i = 0;
i < 3;
i++) {
317 fixed_sparse->
x[
i] = 3 * (
pulses[
i] & 0xf) +
i;
318 fixed_sparse->
y[
i] =
pulses[
i] & 0x10 ? -1 : 1;
323 for (
i = 0;
i < 3;
i++) {
324 fixed_sparse->
x[2*
i ] = 3 * ((
pulses[
i] >> 4) & 0
xf) +
i;
325 fixed_sparse->
x[2*
i + 1] = 3 * (
pulses[
i] & 0xf) +
i;
327 fixed_sparse->
y[2*
i ] = (
pulses[
i] & 0x100) ? -1.0: 1.0;
329 fixed_sparse->
y[2*
i + 1] =
330 (fixed_sparse->
x[2*
i + 1] < fixed_sparse->
x[2*
i]) ?
331 -fixed_sparse->
y[2*
i ] : fixed_sparse->
y[2*
i];
342 for (
i = 0;
i < 3;
i++) {
352 int pulse_subset = (
pulses[0] >> 8) & 1;
354 fixed_sparse->
x[0] = ((
pulses[0] >> 4) & 15) * 3 + pulse_subset;
355 fixed_sparse->
x[1] = (
pulses[0] & 15) * 3 + pulse_subset + 1;
357 fixed_sparse->
y[0] =
pulses[0] & 0x200 ? -1 : 1;
358 fixed_sparse->
y[1] = -fixed_sparse->
y[0];
376 float *synth =
ctx->synth_buf + 16;
390 for (
i = 0;
i < subframe_count;
i++) {
394 float pitch_gain, gain_code, avg_energy;
408 ctx->past_pitch_gain < 0.8);
423 avg_energy,
ctx->energy_history,
430 pitch_gain *= 0.5 * pitch_gain;
431 pitch_gain =
FFMIN(pitch_gain, 0.4);
433 ctx->gain_mem = 0.7 *
ctx->gain_mem + 0.3 * pitch_gain;
435 gain_code *=
ctx->gain_mem;
438 fixed_vector[j] = excitation[j] - gain_code * fixed_vector[j];
458 for (
i = 0;
i < subframe_count;
i++) {
474 (
const float[2]) {-1.99997 , 1.000000000},
475 (
const float[2]) {-1.93307352, 0.935891986},
477 ctx->highpass_filt_mem,
497 "Invalid block_align: %d. Mode %s guessed based on bitrate: %"PRId64
"\n",
513 for (
i = 0;
i < 4;
i++)
514 ctx->energy_history[
i] = -14;
524 int *got_frame_ptr,
AVPacket *avpkt)
527 const uint8_t *buf=avpkt->
data;
538 "Error processing packet: packet size (%d) too small\n",
#define AV_LOG_WARNING
Something somehow does not look correct.
static void eval_ir(const float *Az, int pitch_lag, float *freq, float pitch_sharp_factor)
Evaluate the adaptive impulse response.
float ff_amr_set_fixed_gain(float fixed_gain_factor, float fixed_mean_energy, float *prediction_error, float energy_mean, const float *pred_table)
Calculate fixed gain (part of section 6.1.3 of AMR spec)
void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index, const int prev_lag_int, const int subframe, int third_as_first, int resolution)
Decode the adaptive codebook index to the integer and fractional parts of the pitch lag for one subfr...
static void postfilter_5k0(SiprContext *ctx, const float *lpc, float *samples)
Apply postfilter, very similar to AMR one.
void ff_amrwb_lsp2lpc(const double *lsp, float *lp, int lp_order)
LSP to LP conversion (5.2.4 of AMR-WB)
const float ff_b60_sinc[61]
b60 hamming windowed sinc function coefficients
This structure describes decoded (raw) audio or video data.
void ff_acelp_apply_order_2_transfer_function(float *out, const float *in, const float zero_coeffs[2], const float pole_coeffs[2], float gain, float mem[2], int n)
Apply an order 2 rational transfer function in-place.
void ff_sipr_decode_frame_16k(SiprContext *ctx, SiprParameters *params, float *out_data)
#define AV_CHANNEL_LAYOUT_MONO
void ff_sort_nearly_sorted_floats(float *vals, int len)
Sort values in ascending order.
#define LP_FILTER_ORDER
linear predictive coding filter order
#define MAX_SUBFRAME_COUNT
void ff_celp_lp_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP synthesis filter.
const FFCodec ff_sipr_decoder
static int init_get_bits(GetBitContext *s, const uint8_t *buffer, int bit_size)
Initialize GetBitContext.
#define LSFQ_DIFF_MIN
minimum LSF distance (3.2.4) 0.0391 in Q13
uint8_t frames_per_packet
#define SUBFR_SIZE
Subframe size for all modes except 16k.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
AVCodec p
The public AVCodec.
const float ff_pow_0_55[10]
Table of pow(0.55,n)
AVChannelLayout ch_layout
Audio channel layout.
static void lsf_decode_fp(float *lsfnew, float *lsf_history, const SiprParameters *parm)
static void convolute_with_sparse(float *out, const AMRFixed *pulses, const float *shape, int length)
Evaluate the convolution of a vector with a sparse vector.
uint8_t number_of_fc_indexes
static double val(void *priv, double ch)
int gc_index[5]
fixed-codebook gain indexes
void ff_adaptive_gain_control(float *out, const float *in, float speech_energ, int size, float alpha, float *gain_mem)
Adaptive gain control (as used in AMR postfiltering)
static void decode_parameters(SiprParameters *parms, GetBitContext *pgb, const SiprModeParam *p)
Extract decoding parameters from the input bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define FF_CODEC_DECODE_CB(func)
static void dequant(float *out, const int *idx, const float *const cbs[])
Sparse representation for the algebraic codebook (fixed) vector.
static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az, int num_subfr)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void decode_fixed_sparse(AMRFixed *fixed_sparse, const int16_t *pulses, SiprMode mode, int low_gain)
int ma_pred_switch
switched moving average predictor
#define L_INTERPOL
Number of past samples needed for excitation interpolation.
uint8_t vq_indexes_bits[5]
size in bits of the i-th stage vector of quantizer
int64_t bit_rate
the average bitrate
int16_t fc_indexes[5][10]
fixed-codebook indexes
int pitch_delay[5]
pitch delay
void av_channel_layout_uninit(AVChannelLayout *channel_layout)
Free any allocated data in the channel layout and reset the channel count to 0.
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags)
Get a buffer for a frame.
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVSampleFormat sample_fmt
audio sample format
const float ff_pow_0_7[10]
Table of pow(0.7,n)
static int sipr_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static const float *const lsf_codebooks[]
void ff_tilt_compensation(float *mem, float tilt, float *samples, int size)
Apply tilt compensation filter, 1 - tilt * z-1.
static void pitch_sharpening(int pitch_lag_int, float beta, float *fixed_vector)
Apply pitch lag to the fixed vector (AMR section 6.1.2).
#define i(width, name, range_min, range_max)
void ff_sipr_init_16k(SiprContext *ctx)
static const SiprModeParam modes[MODE_COUNT]
static void decode_frame(SiprContext *ctx, SiprParameters *params, float *out_data)
#define xf(width, name, var, range_min, range_max, subs,...)
uint8_t gc_index_bits
size in bits of the gain codebook indexes
const float ff_pow_0_75[10]
Table of pow(0.75,n)
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
void ff_weighted_vector_sumf(float *out, const float *in_a, const float *in_b, float weight_coeff_a, float weight_coeff_b, int length)
float implementation of weighted sum of two vectors.
const char * name
Name of the codec implementation.
static const float gain_cb[128][2]
static const float pred[4]
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs.
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
void ff_celp_lp_zero_synthesis_filterf(float *out, const float *filter_coeffs, const float *in, int buffer_length, int filter_length)
LP zero synthesis filter.
uint8_t pitch_delay_bits[5]
size in bits of the adaptive-codebook index for every subframe
main external API structure.
static const float mean_lsf[10]
Filter the word “frame” indicates either a video frame or a group of audio samples
#define SUBFRAME_COUNT_16k
float avpriv_scalarproduct_float_c(const float *v1, const float *v2, int len)
Return the scalar product of two vectors.
uint8_t fc_index_bits[10]
size in bits of the fixed codebook indexes
This structure stores compressed data.
static av_cold int sipr_decoder_init(AVCodecContext *avctx)
int gp_index[5]
adaptive-codebook gain indexes
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static const int8_t pulses[4]
Number of non-zero pulses in the MP-MLQ excitation.
void ff_acelp_interpolatef(float *out, const float *in, const float *filter_coeffs, int precision, int frac_pos, int filter_length, int length)
Floating point version of ff_acelp_interpolate()
uint8_t ma_predictor_bits
size in bits of the switched MA predictor
void ff_set_min_dist_lsf(float *lsf, double min_spacing, int size)
Adjust the quantized LSFs so they are increasing and not too close.