40 #define BITSTREAM_WRITER_LE 47 2621, 2631, 2659, 2705, 2770, 2853, 2955, 3074, 3212, 3367,
48 3541, 3731, 3939, 4164, 4405, 4663, 4937, 5226, 5531, 5851,
49 6186, 6534, 6897, 7273, 7661, 8062, 8475, 8899, 9334, 9780,
50 10235, 10699, 11172, 11653, 12141, 12636, 13138, 13645, 14157, 14673,
51 15193, 15716, 16242, 16769, 17298, 17827, 18356, 18884, 19411, 19935,
52 20457, 20975, 21489, 21999, 22503, 23002, 23494, 23978, 24455, 24924,
53 25384, 25834, 26274, 26704, 27122, 27529, 27924, 28306, 28675, 29031,
54 29373, 29700, 30012, 30310, 30592, 30857, 31107, 31340, 31557, 31756,
55 31938, 32102, 32249, 32377, 32488, 32580, 32654, 32710, 32747, 32766,
56 32766, 32747, 32710, 32654, 32580, 32488, 32377, 32249, 32102, 31938,
57 31756, 31557, 31340, 31107, 30857, 30592, 30310, 30012, 29700, 29373,
58 29031, 28675, 28306, 27924, 27529, 27122, 26704, 26274, 25834, 25384,
59 24924, 24455, 23978, 23494, 23002, 22503, 21999, 21489, 20975, 20457,
60 19935, 19411, 18884, 18356, 17827, 17298, 16769, 16242, 15716, 15193,
61 14673, 14157, 13645, 13138, 12636, 12141, 11653, 11172, 10699, 10235,
62 9780, 9334, 8899, 8475, 8062, 7661, 7273, 6897, 6534, 6186,
63 5851, 5531, 5226, 4937, 4663, 4405, 4164, 3939, 3731, 3541,
64 3367, 3212, 3074, 2955, 2853, 2770, 2705, 2659, 2631, 2621
71 32749, 32695, 32604, 32477, 32315, 32118, 31887, 31622, 31324, 30995
78 32571, 32376, 32182, 31989, 31797, 31606, 31416, 31228, 31040, 30854
86 {29491, 26542, 23888, 21499, 19349, 17414, 15673, 14106, 12695, 11425},
88 {16384, 8192, 4096, 2048, 1024, 512, 256, 128, 64, 32}
108 }
else if (avctx->
bit_rate == 5300) {
133 *iir = (buf[
i] << 15) + ((-*fir) << 15) +
MULL2(*iir, 0x7f00);
169 memset(autocorr + 1, 0,
LPC_ORDER *
sizeof(int16_t));
190 int16_t partial_corr;
193 memset(lpc, 0,
LPC_ORDER *
sizeof(int16_t));
198 for (j = 0; j <
i; j++)
199 temp -= lpc[j] * autocorr[i - j - 1];
200 temp = ((autocorr[
i] << 13) + temp) << 3;
202 if (
FFABS(temp) >= (error << 16))
205 partial_corr = temp / (error << 1);
211 temp =
MULL2(temp, partial_corr);
215 memcpy(vector, lpc, i *
sizeof(int16_t));
216 for (j = 0; j <
i; j++) {
217 temp = partial_corr * vector[i - j - 1] << 1;
234 int16_t *autocorr_ptr = autocorr;
235 int16_t *lpc_ptr = lpc;
247 static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
262 f[0] = f[1] = 1 << 25;
265 for (i = 0; i < LPC_ORDER / 2; i++) {
267 f[2 * i + 2] = -f[2 *
i] - ((lsp[
i] + lsp[LPC_ORDER - 1 -
i]) << 12);
269 f[2 * i + 3] = f[2 * i + 1] - ((lsp[
i] - lsp[LPC_ORDER - 1 -
i]) << 12);
274 f[LPC_ORDER + 1] >>= 1;
278 for (i = 1; i < LPC_ORDER + 2; i++)
283 for (i = 0; i < LPC_ORDER + 2; i++)
284 f[i] =
av_clipl_int32((int64_t) (f[i] << shift) + (1 << 15)) >> 16;
292 for (i = 0; i <= LPC_ORDER / 2; i++)
299 for (j = 0; j <= LPC_ORDER / 2; j++)
304 if ((cur_val ^ prev_val) < 0) {
305 int abs_cur =
FFABS(cur_val);
306 int abs_prev =
FFABS(prev_val);
307 int sum = abs_cur + abs_prev;
311 abs_prev = abs_prev << shift >> 8;
312 lsp[count++] = ((i - 1) << 7) + (abs_prev >> 1) / (sum >> 16);
314 if (count == LPC_ORDER)
322 for (j = 0; j <= LPC_ORDER / 2; j++)
323 temp += f[LPC_ORDER - 2 * j + p] *
330 if (count != LPC_ORDER)
331 memcpy(lsp, prev_lsp, LPC_ORDER *
sizeof(int16_t));
341 #define get_index(num, offset, size) \ 343 int error, max = -1; \ 347 for (i = 0; i < LSP_CB_SIZE; i++) { \ 348 for (j = 0; j < size; j++){ \ 349 temp[j] = (weight[j + (offset)] * ff_g723_1_lsp_band##num[i][j] + \ 352 error = ff_g723_1_dot_product(lsp + (offset), temp, size) << 1; \ 353 error -= ff_g723_1_dot_product(ff_g723_1_lsp_band##num[i], temp, size); \ 356 lsp_index[num] = i; \ 374 weight[0] = (1 << 20) / (lsp[1] - lsp[0]);
379 min =
FFMIN(lsp[i] - lsp[i - 1], lsp[i + 1] - lsp[i]);
381 weight[
i] = (1 << 20) / min;
383 weight[
i] = INT16_MAX;
389 max =
FFMAX(weight[i], max);
399 (((prev_lsp[
i] -
dc_lsp[
i]) * 12288 + (1 << 14)) >> 15);
416 int16_t *
src, int16_t *dest)
423 filter -= fir_coef[n - 1] * src[m - n] -
424 iir_coef[n - 1] * dest[m - n];
439 int16_t *unq_lpc, int16_t *buf)
445 memcpy(vector, p->
fir_mem,
sizeof(int16_t) * LPC_ORDER);
446 memcpy(vector + LPC_ORDER, buf + LPC_ORDER,
sizeof(int16_t) *
FRAME_LEN);
452 flt_coef[k + 2 * l +
LPC_ORDER] = (unq_lpc[k + l] *
456 iir_filter(flt_coef + 2 * l, flt_coef + 2 * l + LPC_ORDER,
457 vector + i, buf + i);
460 memcpy(p->
iir_mem, buf + FRAME_LEN,
sizeof(int16_t) * LPC_ORDER);
461 memcpy(p->
fir_mem, vector + FRAME_LEN,
sizeof(int16_t) * LPC_ORDER);
473 int max_ccr = 0x4000;
474 int max_eng = 0x7fff;
478 int ccr, eng, orig_eng, ccr_eng,
exp;
485 for (i = PITCH_MIN; i <=
PITCH_MAX - 3; i++) {
501 ccr = ccr << temp >> 16;
505 eng =
av_clipl_int32((int64_t) (orig_eng << temp) + (1 << 15)) >> 16;
515 if (exp + 1 < max_exp)
519 if (exp + 1 == max_exp)
523 ccr_eng = ccr * max_eng;
524 diff = ccr_eng - eng *
temp;
525 if (diff > 0 && (i - index < PITCH_MIN || diff > ccr_eng >> 2)) {
545 int ccr, eng, max_ccr, max_eng;
550 for (i = 0, j = pitch_lag - 3; j <= pitch_lag + 3; i++, j++) {
562 for (i = 0; i < 15; i++)
566 for (i = 0; i < 15; i++) {
576 for (i = 0; i <= 6; i++) {
577 eng = energy[i << 1];
578 ccr = energy[(i << 1) + 1];
583 ccr = (ccr * ccr + (1 << 14)) >> 15;
584 diff = ccr * max_eng - eng * max_ccr;
592 if (hf->
index == -1) {
593 hf->
index = pitch_lag;
597 eng = energy[14] * max_eng;
598 eng = (eng >> 2) + (eng >> 3);
599 ccr = energy[(hf->
index << 1) + 1] * energy[(hf->
index << 1) + 1];
601 eng = energy[(hf->
index << 1) + 1];
606 hf->
gain = ((eng << 15) / max_eng * 0x2800 + (1 << 14)) >> 15;
608 hf->
index += pitch_lag - 3;
646 int16_t *perf_fir, int16_t *perf_iir,
647 const int16_t *
src, int16_t *dest,
int scale)
655 memcpy(buf_16, perf_fir,
sizeof(int16_t) * LPC_ORDER);
656 memcpy(dest - LPC_ORDER, perf_iir,
sizeof(int16_t) * LPC_ORDER);
661 temp -= qnt_lpc[j - 1] * bptr_16[i - j];
663 buf[
i] = (src[
i] << 15) + (temp << 3);
668 int64_t fir = 0, iir = 0;
670 fir -= perf_lpc[j - 1] * bptr_16[i - j];
671 iir += perf_lpc[j + LPC_ORDER - 1] * dest[i - j];
673 dest[
i] =
av_clipl_int32(((buf[i] + (fir << 3)) << scale) + (iir << 3) +
676 memcpy(perf_fir, buf_16 + SUBFRAME_LEN,
sizeof(int16_t) * LPC_ORDER);
677 memcpy(perf_iir, dest + SUBFRAME_LEN - LPC_ORDER,
678 sizeof(int16_t) * LPC_ORDER);
688 int16_t *impulse_resp,
const int16_t *buf,
697 int pitch_lag = p->
pitch_lag[index >> 1];
700 int odd_frame = index & 1;
701 int iter = 3 + odd_frame;
715 for (i = 0; i < iter; i++) {
720 for (k = 0; k <= j; k++)
721 temp += residual[
PITCH_ORDER - 1 + k] * impulse_resp[j - k];
727 flt_buf[j][0] = ((residual[j] << 13) + (1 << 14)) >> 15;
729 temp = (flt_buf[j + 1][k - 1] << 15) +
730 residual[j] * impulse_resp[k];
748 for (k = 0; k < j; k++) {
757 for (i = 0; i < 20 * iter; i++)
762 for (i = 0; i < 20 * iter; i++)
767 for (i = 0; i < iter; i++) {
769 if (!odd_frame && pitch_lag + i - 1 >=
SUBFRAME_LEN - 2 ||
775 for (j = 0, k = 0; j < tbl_size; j++, k += 20) {
777 for (l = 0; l < 20; l++)
778 temp += ccr_buf[20 * i + l] * cb_tbl[k + l];
790 pitch_lag += acb_lag - 1;
811 int64_t
temp = buf[
i] << 14;
812 for (j = 0; j <=
i; j++)
813 temp -= residual[j] * impulse_resp[i - j];
826 int16_t *buf,
int pulse_cnt,
int pitch_lag)
835 int amp, err,
max, max_amp_index,
min, scale,
i, j, k, l;
840 memcpy(impulse_r, impulse_resp,
sizeof(int16_t) *
SUBFRAME_LEN);
842 if (pitch_lag < SUBFRAME_LEN - 2) {
848 temp_corr[i] = impulse_r[i] >> 1;
854 impulse_corr[0] =
av_clipl_int32((temp << scale) + (1 << 15)) >> 16;
867 ccr1[
i] = temp >> -scale;
877 temp =
FFABS(ccr1[j]);
888 for (j = max_amp_index; j >= 2; j--) {
890 impulse_corr[0] << 1);
891 temp =
FFABS(temp - amp);
900 for (j = 1; j < 5; j++) {
911 for (k = 1; k < pulse_cnt; k++) {
920 temp =
FFABS(ccr2[l]);
933 memset(temp_corr, 0,
sizeof(int16_t) * SUBFRAME_LEN);
935 for (k = 0; k < pulse_cnt; k++)
938 for (k = SUBFRAME_LEN - 1; k >= 0; k--) {
940 for (l = 0; l <= k; l++) {
942 impulse_r[k - l] << 1);
945 temp_corr[k] = temp << 2 >> 16;
959 if (err < optim->min_err) {
965 for (k = 0; k < pulse_cnt; k++) {
981 int16_t *buf,
int pulse_cnt)
990 for (i = 0; i < SUBFRAME_LEN >> 1; i++) {
1016 int16_t *buf,
int index)
1032 for (i = 0; i < pulse_cnt; i++)
1116 int16_t *
in, *start;
1137 memcpy(vector + LPC_ORDER + SUBFRAME_LEN, in,
1141 memcpy(in, vector + LPC_ORDER,
sizeof(int16_t) *
FRAME_LEN);
1145 memcpy(in, vector + LPC_ORDER,
sizeof(int16_t) * FRAME_LEN);
1147 memcpy(vector + PITCH_MAX, in,
sizeof(int16_t) * FRAME_LEN);
1158 memcpy(vector + PITCH_MAX, in,
sizeof(int16_t) * FRAME_LEN);
1159 memcpy(p->
prev_weight_sig, vector + FRAME_LEN,
sizeof(int16_t) * PITCH_MAX);
1167 memcpy(p->
prev_lsp, cur_lsp,
sizeof(int16_t) * LPC_ORDER);
1180 memset(zero, 0,
sizeof(int16_t) * LPC_ORDER);
1181 memset(vector, 0,
sizeof(int16_t) * PITCH_MAX);
1182 memset(flt_in, 0,
sizeof(int16_t) * SUBFRAME_LEN);
1184 flt_in[0] = 1 << 13;
1186 zero, zero, flt_in, vector + PITCH_MAX, 1);
1191 memcpy(fir, p->
perf_fir_mem,
sizeof(int16_t) * LPC_ORDER);
1192 memcpy(iir, p->
perf_iir_mem,
sizeof(int16_t) * LPC_ORDER);
1195 fir, iir, flt_in, vector + PITCH_MAX, 0);
1196 memcpy(vector, p->
harmonic_mem,
sizeof(int16_t) * PITCH_MAX);
1199 acb_search(p, residual, impulse_resp, in, i);
1213 sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN));
1217 sizeof(int16_t) * SUBFRAME_LEN);
1222 in, vector + PITCH_MAX, 0);
1224 sizeof(int16_t) * (PITCH_MAX - SUBFRAME_LEN));
1225 memcpy(p->
harmonic_mem + PITCH_MAX - SUBFRAME_LEN, vector + PITCH_MAX,
1226 sizeof(int16_t) * SUBFRAME_LEN);
1237 *got_packet_ptr = 1;
1255 .defaults = defaults,
static void perceptual_filter(G723_1_ChannelContext *p, int16_t *flt_coef, int16_t *unq_lpc, int16_t *buf)
Apply the formant perceptual weighting filter.
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.
const int16_t ff_g723_1_fixed_cb_gain[GAIN_LEVELS]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int64_t bit_rate
the average bitrate
Memory handling functions.
G723_1_Subframe subframe[4]
static av_cold int init(AVCodecContext *avctx)
G723.1 unpacked data subframe.
static const int8_t pulses[4]
Number of non-zero pulses in the MP-MLQ excitation.
static void error(const char *err)
uint8_t lsp_index[LSP_BANDS]
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
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.
static const int16_t percept_flt_tbl[2][LPC_ORDER]
0.5^i scaled by 2^15
Optimized fixed codebook excitation parameters.
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
int hpf_iir_mem
and iir memories
static void levinson_durbin(int16_t *lpc, int16_t *autocorr, int16_t error)
Use Levinson-Durbin recursion to compute LPC coefficients from autocorrelation values.
int16_t prev_data[HALF_FRAME_LEN]
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...
static int pack_bitstream(G723_1_ChannelContext *p, AVPacket *avpkt)
Pack the frame parameters into output bitstream.
static const int16_t bandwidth_expand[LPC_ORDER]
0.994^i scaled by 2^15
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define G723_1_COS_TAB_FIRST_ELEMENT
filter_frame For filters that do not use the this method is called when a frame is pushed to the filter s input It can be called at any time except in a reentrant way If the input frame is enough to produce then the filter should push the output frames on the output link immediately As an exception to the previous rule if the input frame is enough to produce several output frames then the filter needs output only at least one per link The additional frames can be left buffered in the filter
AVCodec ff_g723_1_encoder
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int current_sample, int64_t nb_samples_notify, AVRational time_base)
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.
static const int16_t hamming_window[LPC_FRAME]
Hamming window coefficients scaled by 2^15.
int64_t ff_dot_product(const int16_t *a, const int16_t *b, int length)
Calculate the dot product of 2 int16_t vectors.
static void acb_search(G723_1_ChannelContext *p, int16_t *residual, int16_t *impulse_resp, const int16_t *buf, int index)
Compute the adaptive codebook contribution.
static void harmonic_filter(HFParam *hf, const int16_t *src, int16_t *dest)
Apply the harmonic noise shaping filter.
const int16_t ff_g723_1_adaptive_cb_gain170[170 *20]
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.
static av_cold int g723_1_encode_init(AVCodecContext *avctx)
static void harmonic_noise_sub(HFParam *hf, const int16_t *src, int16_t *dest)
audio channel layout utility functions
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)
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
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
const int32_t ff_g723_1_combinatorial_table[PULSE_MAX][SUBFRAME_LEN/GRID_SIZE]
Used for the coding/decoding of the pulses positions for the MP-MLQ codebook.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int frame_size
Number of samples per channel in an audio frame.
int16_t harmonic_mem[PITCH_MAX]
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.
const int16_t ff_g723_1_adaptive_cb_gain85[85 *20]
G.723.1 types, functions and data tables.
int16_t fir_mem[LPC_ORDER]
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31))))#define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac){}void ff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map){AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;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);return NULL;}return ac;}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;}else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->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);return ac;}int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){int use_generic=1;int len=in->nb_samples;int p;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
G723_1_ChannelContext ch[2]
int16_t prev_lsp[LPC_ORDER]
const int16_t ff_g723_1_cos_tab[COS_TBL_SIZE+1]
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.
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.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
static void lpc2lsp(int16_t *lpc, int16_t *prev_lsp, int16_t *lsp)
static const int16_t binomial_window[LPC_ORDER]
Binomial window coefficients scaled by 2^15.
int16_t perf_fir_mem[LPC_ORDER]
perceptual filter fir
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
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.
int16_t hpf_fir_mem
highpass filter fir
int16_t prev_weight_sig[PITCH_MAX]
Harmonic filter parameters.
static void fcb_search(G723_1_ChannelContext *p, int16_t *impulse_resp, int16_t *buf, int index)
Compute the fixed codebook excitation.
static av_always_inline int diff(const uint32_t a, const uint32_t b)
static const AVCodecDefault defaults[]
#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.
static enum AVSampleFormat sample_fmts[]
int16_t perf_iir_mem[LPC_ORDER]
and iir memories
int16_t prev_excitation[PITCH_MAX]
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
static double val(void *priv, double ch)
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
int ad_cb_lag
adaptive codebook lag