40 #define BITSTREAM_WRITER_LE
59 }
else if (avctx->
bit_rate == 5300) {
83 *iir = (buf[i] << 15) + ((-*fir) << 15) +
MULL2(*iir, 0x7f00);
85 buf[i] = av_clipl_int32((int64_t)*iir + (1 << 15)) >> 16;
114 autocorr[0] = av_clipl_int32((int64_t) (temp << scale) +
119 memset(autocorr + 1, 0,
LPC_ORDER *
sizeof(int16_t));
124 autocorr[i] = av_clipl_int32((int64_t) temp + (1 << 15)) >> 16;
140 int16_t partial_corr;
143 memset(lpc, 0,
LPC_ORDER *
sizeof(int16_t));
148 for (j = 0; j < i; j++)
149 temp -= lpc[j] * autocorr[i - j - 1];
150 temp = ((autocorr[i] << 13) + temp) << 3;
152 if (
FFABS(temp) >= (error << 16))
155 partial_corr = temp / (error << 1);
157 lpc[i] = av_clipl_int32((int64_t) (partial_corr << 14) +
161 temp =
MULL2(temp, partial_corr);
162 error = av_clipl_int32((int64_t) (error << 16) - temp +
165 memcpy(vector, lpc, i *
sizeof(int16_t));
166 for (j = 0; j < i; j++) {
167 temp = partial_corr * vector[i - j - 1] << 1;
168 lpc[j] = av_clipl_int32((int64_t) (lpc[j] << 16) - temp +
184 int16_t *autocorr_ptr = autocorr;
185 int16_t *lpc_ptr = lpc;
197 static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
212 f[0] = f[1] = 1 << 25;
215 for (i = 0; i < LPC_ORDER / 2; i++) {
217 f[2 * i + 2] = -f[2 * i] - ((lsp[i] + lsp[LPC_ORDER - 1 - i]) << 12);
219 f[2 * i + 3] = f[2 * i + 1] - ((lsp[i] - lsp[LPC_ORDER - 1 - i]) << 12);
224 f[LPC_ORDER + 1] >>= 1;
228 for (i = 1; i < LPC_ORDER + 2; i++)
233 for (i = 0; i < LPC_ORDER + 2; i++)
234 f[i] = av_clipl_int32((int64_t) (f[i] << shift) + (1 << 15)) >> 16;
242 for (i = 0; i <= LPC_ORDER / 2; i++)
244 prev_val = av_clipl_int32(temp << 1);
249 for (j = 0; j <= LPC_ORDER / 2; j++)
251 cur_val = av_clipl_int32(temp << 1);
254 if ((cur_val ^ prev_val) < 0) {
255 int abs_cur =
FFABS(cur_val);
256 int abs_prev =
FFABS(prev_val);
257 int sum = abs_cur + abs_prev;
261 abs_prev = abs_prev << shift >> 8;
262 lsp[count++] = ((i - 1) << 7) + (abs_prev >> 1) / (sum >> 16);
264 if (count == LPC_ORDER)
272 for (j = 0; j <= LPC_ORDER / 2; j++)
273 temp += f[LPC_ORDER - 2 * j + p] *
275 cur_val = av_clipl_int32(temp << 1);
280 if (count != LPC_ORDER)
281 memcpy(lsp, prev_lsp, LPC_ORDER *
sizeof(int16_t));
291 #define get_index(num, offset, size) \
293 int error, max = -1; \
297 for (i = 0; i < LSP_CB_SIZE; i++) { \
298 for (j = 0; j < size; j++){ \
299 temp[j] = (weight[j + (offset)] * lsp_band##num[i][j] + \
302 error = ff_g723_1_dot_product(lsp + (offset), temp, size) << 1; \
303 error -= ff_g723_1_dot_product(lsp_band##num[i], temp, size); \
306 lsp_index[num] = i; \
324 weight[0] = (1 << 20) / (lsp[1] - lsp[0]);
329 min =
FFMIN(lsp[i] - lsp[i - 1], lsp[i + 1] - lsp[i]);
331 weight[i] = (1 << 20) / min;
333 weight[i] = INT16_MAX;
339 max =
FFMAX(weight[i], max);
349 (((prev_lsp[i] -
dc_lsp[i]) * 12288 + (1 << 14)) >> 15);
366 int16_t *
src, int16_t *dest)
373 filter -= fir_coef[n - 1] * src[m -
n] -
374 iir_coef[n - 1] * dest[m -
n];
377 dest[
m] = av_clipl_int32((src[m] << 16) + (filter << 3) +
389 int16_t *unq_lpc, int16_t *
buf)
395 memcpy(vector, p->
fir_mem,
sizeof(int16_t) * LPC_ORDER);
396 memcpy(vector + LPC_ORDER, buf + LPC_ORDER,
sizeof(int16_t) *
FRAME_LEN);
402 flt_coef[k + 2 * l +
LPC_ORDER] = (unq_lpc[k + l] *
406 iir_filter(flt_coef + 2 * l, flt_coef + 2 * l + LPC_ORDER,
407 vector + i, buf + i);
410 memcpy(p->
iir_mem, buf + FRAME_LEN,
sizeof(int16_t) * LPC_ORDER);
411 memcpy(p->
fir_mem, vector + FRAME_LEN,
sizeof(int16_t) * LPC_ORDER);
423 int max_ccr = 0x4000;
424 int max_eng = 0x7fff;
428 int ccr, eng, orig_eng, ccr_eng,
exp;
435 for (i = PITCH_MIN; i <=
PITCH_MAX - 3; i++) {
447 ccr = av_clipl_int32((int64_t) (ccr << exp) + (1 << 15)) >> 16;
451 ccr = ccr << temp >> 16;
455 eng = av_clipl_int32((int64_t) (orig_eng << temp) + (1 << 15)) >> 16;
465 if (exp + 1 < max_exp)
469 if (exp + 1 == max_exp)
473 ccr_eng = ccr * max_eng;
474 diff = ccr_eng - eng *
temp;
475 if (diff > 0 && (i - index < PITCH_MIN || diff > ccr_eng >> 2)) {
495 int ccr, eng, max_ccr, max_eng;
500 for (i = 0, j = pitch_lag - 3; j <= pitch_lag + 3; i++, j++) {
512 for (i = 0; i < 15; i++)
516 for (i = 0; i < 15; i++) {
517 energy[i] = av_clipl_int32((int64_t)(energy[i] << exp) +
526 for (i = 0; i <= 6; i++) {
527 eng = energy[i << 1];
528 ccr = energy[(i << 1) + 1];
533 ccr = (ccr * ccr + (1 << 14)) >> 15;
534 diff = ccr * max_eng - eng * max_ccr;
542 if (hf->
index == -1) {
543 hf->
index = pitch_lag;
547 eng = energy[14] * max_eng;
548 eng = (eng >> 2) + (eng >> 3);
549 ccr = energy[(hf->
index << 1) + 1] * energy[(hf->
index << 1) + 1];
551 eng = energy[(hf->
index << 1) + 1];
556 hf->
gain = ((eng << 15) / max_eng * 0x2800 + (1 << 14)) >> 15;
558 hf->
index += pitch_lag - 3;
572 dest[i] = av_clipl_int32((src[i] << 16) - temp + (1 << 15)) >> 16;
581 dest[i] = av_clipl_int32(((dest[i] - src[i]) << 16) + temp +
596 int16_t *perf_fir, int16_t *perf_iir,
597 const int16_t *
src, int16_t *dest,
int scale)
605 memcpy(buf_16, perf_fir,
sizeof(int16_t) * LPC_ORDER);
606 memcpy(dest - LPC_ORDER, perf_iir,
sizeof(int16_t) * LPC_ORDER);
611 temp -= qnt_lpc[j - 1] * bptr_16[i - j];
613 buf[i] = (src[i] << 15) + (temp << 3);
614 bptr_16[i] = av_clipl_int32(buf[i] + (1 << 15)) >> 16;
618 int64_t fir = 0, iir = 0;
620 fir -= perf_lpc[j - 1] * bptr_16[i - j];
621 iir += perf_lpc[j + LPC_ORDER - 1] * dest[i - j];
623 dest[i] = av_clipl_int32(((buf[i] + (fir << 3)) << scale) + (iir << 3) +
626 memcpy(perf_fir, buf_16 + SUBFRAME_LEN,
sizeof(int16_t) * LPC_ORDER);
627 memcpy(perf_iir, dest + SUBFRAME_LEN - LPC_ORDER,
628 sizeof(int16_t) * LPC_ORDER);
638 int16_t *impulse_resp,
const int16_t *
buf,
647 int pitch_lag = p->
pitch_lag[index >> 1];
650 int odd_frame = index & 1;
651 int iter = 3 + odd_frame;
665 for (i = 0; i < iter; i++) {
670 for (k = 0; k <= j; k++)
671 temp += residual[
PITCH_ORDER - 1 + k] * impulse_resp[j - k];
672 flt_buf[
PITCH_ORDER - 1][j] = av_clipl_int32((temp << 1) +
677 flt_buf[j][0] = ((residual[j] << 13) + (1 << 14)) >> 15;
679 temp = (flt_buf[j + 1][k - 1] << 15) +
680 residual[j] * impulse_resp[k];
681 flt_buf[j][k] = av_clipl_int32((temp << 1) + (1 << 15)) >> 16;
688 ccr_buf[count++] = av_clipl_int32(temp << 1);
698 for (k = 0; k < j; k++) {
700 ccr_buf[count++] = av_clipl_int32(temp << 2);
707 for (i = 0; i < 20 * iter; i++)
712 for (i = 0; i < 20 * iter; i++)
713 ccr_buf[i] = av_clipl_int32((int64_t) (ccr_buf[i] << temp) +
717 for (i = 0; i < iter; i++) {
719 if (!odd_frame && pitch_lag + i - 1 >=
SUBFRAME_LEN - 2 ||
725 for (j = 0, k = 0; j < tbl_size; j++, k += 20) {
727 for (l = 0; l < 20; l++)
728 temp += ccr_buf[20 * i + l] * cb_tbl[k + l];
729 temp = av_clipl_int32(temp);
740 pitch_lag += acb_lag - 1;
761 int64_t
temp = buf[i] << 14;
762 for (j = 0; j <= i; j++)
763 temp -= residual[j] * impulse_resp[i - j];
765 buf[i] = av_clipl_int32((temp << 2) + (1 << 15)) >> 16;
776 int16_t *
buf,
int pulse_cnt,
int pitch_lag)
785 int amp, err, max, max_amp_index,
min, scale, i, j, k, l;
790 memcpy(impulse_r, impulse_resp,
sizeof(int16_t) *
SUBFRAME_LEN);
792 if (pitch_lag < SUBFRAME_LEN - 2) {
798 temp_corr[i] = impulse_r[i] >> 1;
804 impulse_corr[0] = av_clipl_int32((temp << scale) + (1 << 15)) >> 16;
809 impulse_corr[i] = av_clipl_int32((temp << scale) + (1 << 15)) >> 16;
817 ccr1[i] = temp >> -scale;
819 ccr1[i] = av_clipl_int32(temp << scale);
827 temp =
FFABS(ccr1[j]);
838 for (j = max_amp_index; j >= 2; j--) {
840 impulse_corr[0] << 1);
841 temp =
FFABS(temp - amp);
850 for (j = 1; j < 5; j++) {
861 for (k = 1; k < pulse_cnt; k++) {
867 temp = av_clipl_int32((int64_t) temp *
870 temp =
FFABS(ccr2[l]);
883 memset(temp_corr, 0,
sizeof(int16_t) * SUBFRAME_LEN);
885 for (k = 0; k < pulse_cnt; k++)
888 for (k = SUBFRAME_LEN - 1; k >= 0; k--) {
890 for (l = 0; l <= k; l++) {
891 int prod = av_clipl_int32((int64_t) temp_corr[l] *
892 impulse_r[k - l] << 1);
893 temp = av_clipl_int32(temp + prod);
895 temp_corr[k] = temp << 2 >> 16;
902 prod = av_clipl_int32((int64_t) buf[k] * temp_corr[k] << 1);
903 err = av_clipl_int32(err - prod);
904 prod = av_clipl_int32((int64_t) temp_corr[k] * temp_corr[k]);
905 err = av_clipl_int32(err + prod);
909 if (err < optim->min_err) {
915 for (k = 0; k < pulse_cnt; k++) {
931 int16_t *
buf,
int pulse_cnt)
940 for (i = 0; i < SUBFRAME_LEN >> 1; i++) {
982 for (i = 0; i < pulse_cnt; i++)
1086 memcpy(vector + LPC_ORDER + SUBFRAME_LEN, in,
1090 memcpy(in, vector + LPC_ORDER,
sizeof(int16_t) *
FRAME_LEN);
1094 memcpy(in, vector + LPC_ORDER,
sizeof(int16_t) * FRAME_LEN);
1096 memcpy(vector + PITCH_MAX, in,
sizeof(int16_t) * FRAME_LEN);
1107 memcpy(vector + PITCH_MAX, in,
sizeof(int16_t) * FRAME_LEN);
1108 memcpy(p->
prev_weight_sig, vector + FRAME_LEN,
sizeof(int16_t) * PITCH_MAX);
1116 memcpy(p->
prev_lsp, cur_lsp,
sizeof(int16_t) * LPC_ORDER);
1129 memset(zero, 0,
sizeof(int16_t) * LPC_ORDER);
1130 memset(vector, 0,
sizeof(int16_t) * PITCH_MAX);
1131 memset(flt_in, 0,
sizeof(int16_t) * SUBFRAME_LEN);
1133 flt_in[0] = 1 << 13;
1135 zero, zero, flt_in, vector + PITCH_MAX, 1);
1140 memcpy(fir, p->
perf_fir_mem,
sizeof(int16_t) * LPC_ORDER);
1141 memcpy(iir, p->
perf_iir_mem,
sizeof(int16_t) * LPC_ORDER);
1144 fir, iir, flt_in, vector + PITCH_MAX, 0);
1145 memcpy(vector, p->
harmonic_mem,
sizeof(int16_t) * PITCH_MAX);
1148 acb_search(p, residual, impulse_resp, in, i);
1162 sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN));
1164 in[j] = av_clip_int16((in[j] << 1) + impulse_resp[j]);
1166 sizeof(int16_t) * SUBFRAME_LEN);
1171 in, vector + PITCH_MAX, 0);
1173 sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN));
1174 memcpy(p->
harmonic_mem + PITCH_MAX - SUBFRAME_LEN, vector + PITCH_MAX,
1175 sizeof(int16_t) * SUBFRAME_LEN);
1186 *got_packet_ptr = 1;
const char const char void * val
static void pack_fcb_param(G723_1_Subframe *subfrm, FCBParam *optim, int16_t *buf, int pulse_cnt)
Encode the pulse position and gain of the current subframe.
static void comp_autocorr(int16_t *buf, int16_t *autocorr)
Estimate autocorrelation of the input vector.
static int shift(int a, int b)
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int64_t bit_rate
the average bitrate
int16_t prev_weight_sig[PITCH_MAX]
memory handling functions
static av_cold int init(AVCodecContext *avctx)
G723.1 unpacked data subframe.
int16_t fir_mem[LPC_ORDER]
static float cos_tab[256]
static const int8_t pulses[4]
Number of non-zero pulses in the MP-MLQ excitation.
static void skip_put_bits(PutBitContext *s, int n)
Skip the given number of bits.
void ff_g723_1_inverse_quant(int16_t *cur_lsp, int16_t *prev_lsp, uint8_t *lsp_index, int bad_frame)
Perform inverse quantization of LSP frequencies.
static void sub_acb_contrib(const int16_t *residual, const int16_t *impulse_resp, int16_t *buf)
Subtract the adaptive codebook contribution from the input to obtain the residual.
Optimized fixed codebook excitation parameters.
static const int16_t adaptive_cb_gain85[85 *20]
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, uint8_t clip)
static const int16_t percept_flt_tbl[2][LPC_ORDER]
0.5^i scaled by 2^15
static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error)
Use Levinson-Durbin recursion to compute LPC coefficients from autocorrelation values.
void ff_g723_1_lsp_interpolate(int16_t *lpc, int16_t *cur_lsp, int16_t *prev_lsp)
Quantize LSP frequencies by interpolation and convert them to the corresponding LPC coefficients...
int16_t prev_data[HALF_FRAME_LEN]
static const int16_t adaptive_cb_gain170[170 *20]
static const int32_t combinatorial_table[PULSE_MAX][SUBFRAME_LEN/GRID_SIZE]
Used for the coding/decoding of the pulses positions for the MP-MLQ codebook.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
AVCodec ff_g723_1_encoder
int ff_g723_1_normalize_bits(int num, int width)
Calculate the number of left-shifts required for normalizing the input.
static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_g723_1_gen_dirac_train(int16_t *buf, int pitch_lag)
Generate a train of dirac functions with period as pitch lag.
int pulse_sign[PULSE_MAX]
const char * name
Name of the codec implementation.
int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
Calculate the dot product of 2 int16_t vectors.
int16_t prev_excitation[PITCH_MAX]
static void harmonic_filter(HFParam *hf, const int16_t *src, int16_t *dest)
Apply the harmonic noise shaping filter.
static const uint8_t offset[127][2]
static void lsp_quantize(uint8_t *lsp_index, int16_t *lsp, int16_t *prev_lsp)
Vector quantize the LSP frequencies.
void ff_g723_1_gen_acb_excitation(int16_t *vector, int16_t *prev_excitation, int pitch_lag, G723_1_Subframe *subfrm, enum Rate cur_rate)
Generate adaptive codebook excitation.
G723_1_Subframe subframe[4]
static const int16_t fixed_cb_gain[GAIN_LEVELS]
static void fcb_search(G723_1_Context *p, int16_t *impulse_resp, int16_t *buf, int index)
Compute the fixed codebook excitation.
static av_cold int g723_1_encode_init(AVCodecContext *avctx)
static void harmonic_noise_sub(HFParam *hf, const int16_t *src, int16_t *dest)
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int64_t nb_samples_notify, AVRational time_base)
audio channel layout utility functions
static int pack_bitstream(G723_1_Context *p, AVPacket *avpkt)
Pack the frame parameters into output bitstream.
static void iir_filter(int16_t *fir_coef, int16_t *iir_coef, int16_t *src, int16_t *dest)
Perform IIR filtering.
static void comp_lpc_coeff(int16_t *buf, int16_t *lpc)
Calculate LPC coefficients for the current frame.
void ff_g723_1_get_residual(int16_t *residual, int16_t *prev_excitation, int lag)
Get delayed contribution from the previous excitation vector.
int ff_g723_1_dot_product(const int16_t *a, const int16_t *b, int length)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int frame_size
Number of samples per channel in an audio frame.
int ff_g723_1_scale_vector(int16_t *dst, const int16_t *vector, int length)
Scale vector contents based on the largest of their absolutes.
Libavcodec external API header.
static const int16_t dc_lsp[LPC_ORDER]
LSP DC component.
AVSampleFormat
Audio sample formats.
int sample_rate
samples per second
main external API structure.
static void highpass_filter(int16_t *buf, int16_t *fir, int *iir)
Remove DC component from the input signal.
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method!=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt)>2){ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc){av_free(ac);returnNULL;}returnac;}in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar){ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar?ac->channels:1;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
G.723.1 types, functions and data tables.
static void perceptual_filter(G723_1_Context *p, int16_t *flt_coef, int16_t *unq_lpc, int16_t *buf)
Apply the formant perceptual weighting filter.
static const int16_t hamming_window[LPC_FRAME]
Hamming window coefficients scaled by 2^15.
int16_t harmonic_mem[PITCH_MAX]
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
static void synth_percept_filter(int16_t *qnt_lpc, int16_t *perf_lpc, int16_t *perf_fir, int16_t *perf_iir, const int16_t *src, int16_t *dest, int scale)
Combined synthesis and formant perceptual weighting filer.
int16_t hpf_fir_mem
highpass filter fir
static int weight(int i, int blen, int offset)
static void get_fcb_param(FCBParam *optim, int16_t *impulse_resp, int16_t *buf, int pulse_cnt, int pitch_lag)
Quantize the residual signal using the fixed codebook (MP-MLQ).
#define get_index(num, offset, size)
Quantize the current LSP subvector.
int16_t prev_lsp[LPC_ORDER]
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int hpf_iir_mem
and iir memories
static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
common internal and external API header
int16_t perf_iir_mem[LPC_ORDER]
and iir memories
static int estimate_pitch(int16_t *buf, int start)
Estimate the open loop pitch period.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
Harmonic filter parameters.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
#define MULL2(a, b)
Bitexact implementation of 2ab scaled by 1/2^16.
int channels
number of audio channels
static void comp_harmonic_coeff(int16_t *buf, int16_t pitch_lag, HFParam *hf)
Compute harmonic noise filter parameters.
uint8_t lsp_index[LSP_BANDS]
static const int16_t bandwidth_expand[LPC_ORDER]
0.994^i scaled by 2^15
static enum AVSampleFormat sample_fmts[]
int16_t perf_fir_mem[LPC_ORDER]
perceptual filter fir
static void acb_search(G723_1_Context *p, int16_t *residual, int16_t *impulse_resp, const int16_t *buf, int index)
Compute the adaptive codebook contribution.
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
static const int16_t binomial_window[LPC_ORDER]
Binomial window coefficients scaled by 2^15.
int ad_cb_lag
adaptive codebook lag