Go to the documentation of this file.
32 #define BITSTREAM_READER_LE
41 #define CNG_RANDOM_SEED 12345
80 int temp, info_bits,
i;
100 if (info_bits == 2) {
210 enum Rate cur_rate,
int pitch_lag,
int index)
247 for (
i = 0;
i < 8;
i += 2) {
248 offset = ((cb_pos & 7) << 3) + cb_shift +
i;
249 vector[
offset] = (cb_sign & 1) ? cb_gain : -cb_gain;
261 vector[
i] += beta * vector[
i - lag] >> 15;
277 int pitch_lag,
int length,
int dir)
279 int limit, ccr, lag = 0;
286 limit = pitch_lag + 3;
288 for (
i = pitch_lag - 3;
i <= limit;
i++) {
291 if (ccr > *ccr_max) {
310 int tgt_eng,
int ccr,
int res_eng)
317 temp1 = tgt_eng * res_eng >> 1;
318 temp2 = ccr * ccr << 1;
321 if (ccr >= res_eng) {
324 ppf->
opt_gain = (ccr << 15) / res_eng *
328 temp1 = (tgt_eng << 15) + (ccr * ppf->
opt_gain << 1);
330 pf_residual = av_sat_add32(temp1, temp2 + (1 << 15)) >> 16;
332 if (tgt_eng >= pf_residual << 1) {
335 temp1 = (tgt_eng << 14) / pf_residual;
372 int energy[5] = {0, 0, 0, 0, 0};
384 if (!back_lag && !fwd_lag)
402 for (
i = 0;
i < 5;
i++)
403 temp1 =
FFMAX(energy[
i], temp1);
406 for (
i = 0;
i < 5;
i++)
407 energy[
i] = (energy[
i] << scale) >> 16;
409 if (fwd_lag && !back_lag) {
412 }
else if (!fwd_lag) {
421 temp1 = energy[4] * ((energy[1] * energy[1] + (1 << 14)) >> 15);
422 temp2 = energy[2] * ((energy[3] * energy[3] + (1 << 14)) >> 15);
423 if (temp1 >= temp2) {
444 int *exc_eng,
int *scale)
457 ccr = av_sat_add32(ccr, 1 << 15) >> 16;
461 *exc_eng = av_sat_add32(tgt_eng, 1 << 15) >> 16;
469 best_eng = av_sat_add32(best_eng, 1 << 15) >> 16;
471 temp = best_eng * *exc_eng >> 3;
473 if (
temp < ccr * ccr) {
489 int gain,
int *rseed)
495 for (
i = 0;
i < lag;
i++)
496 out[
i] = vector_ptr[
i - lag] * 3 >> 2;
501 *rseed = (int16_t)(*rseed * 521 + 259);
502 out[
i] = gain * *rseed >> 15;
517 #define iir_filter(fir_coef, iir_coef, src, dest, width)\
520 int res_shift = 16 & ~-(width);\
521 int in_shift = 16 - res_shift;\
523 for (m = 0; m < SUBFRAME_LEN; m++) {\
525 for (n = 1; n <= LPC_ORDER; n++) {\
526 filter -= (fir_coef)[n - 1] * (src)[m - n] -\
527 (iir_coef)[n - 1] * ((dest)[m - n] >> in_shift);\
530 (dest)[m] = av_clipl_int32(((src)[m] * 65536) + (filter * 8) +\
531 (1 << 15)) >> res_shift;\
552 denom = av_sat_dadd32(denom,
temp);
558 num = num << bits1 >> 1;
564 gain = (num >> 1) / (denom >> 16);
586 int16_t *
buf, int16_t *dst)
602 iir_filter(filter_coef[0], filter_coef[1],
buf +
i, filter_signal +
i, 1);
624 temp = auto_corr[1] >> 16;
633 dst[j] = av_sat_dadd32(signal_ptr[j],
634 (signal_ptr[j - 1] >> 16) *
temp) >> 16;
638 temp = 2 * scale + 4;
640 energy = av_clipl_int32((int64_t)auto_corr[1] << -
temp);
642 energy = auto_corr[1] >>
temp;
656 else if (gain < 0x20)
657 return gain - 8 << 7;
659 return gain - 20 << 8;
670 int i,
shift, seg, seg2, t,
val, val_add, x, y;
681 }
else if(
shift < -31) {
685 x = av_clipl_int32(t * (int64_t)
cng_filt[0] >> 16);
697 seg2 =
FFMIN(seg, 3);
702 t = seg * 32 + (
val << seg2);
711 t = seg * 32 + (
val << seg2);
714 t = seg * 32 + (
val + 1 << seg2);
716 val = (seg2 - 1) * 16 +
val;
720 t = seg * 32 + (
val - 1 << seg2);
722 val = (seg2 - 1) * 16 +
val;
753 for (j = 0; j < 11; j++) {
754 signs[
i * 11 + j] = ((t & 1) * 2 - 1) * (1 << 14);
764 for (j = 0; j <
pulses[
i]; j++, idx++) {
767 pos[idx] =
tmp[idx2] * 2 + off[
i];
786 t |=
FFABS(vector_ptr[j]);
787 t =
FFMIN(t, 0x7FFF);
798 t = vector_ptr[j] * (1 << -
shift);
804 t = vector_ptr[j] >>
shift;
811 for (j = 0; j < 11; j++)
812 b0 +=
tmp[pos[(
i / 2) * 11 + j]] * signs[(
i / 2) * 11 + j];
813 b0 = b0 * 2 * 2979LL + (1 << 29) >> 30;
816 if (
shift * 2 + 3 >= 0)
820 c = (av_clipl_int32(sum << 1) -
c) * 2979LL >> 15;
837 x = av_clip(x, -10000, 10000);
839 for (j = 0; j < 11; j++) {
840 idx = (
i / 2) * 11 + j;
841 vector_ptr[pos[idx]] = av_clip_int16(vector_ptr[pos[idx]] +
842 (x * signs[idx] >> 15));
846 memcpy(vector_ptr +
PITCH_MAX, vector_ptr,
856 int *got_frame_ptr,
AVPacket *avpkt)
861 int buf_size = avpkt->
size;
862 int dec_mode =
buf[0] & 3;
869 int bad_frame = 0,
i, j,
ret;
874 "Expected %d bytes, got %d - skipping packet\n",
886 int16_t *audio = p->
audio;
929 int v = av_clip_int16(vector_ptr[j] * 2);
930 vector_ptr[j] = av_clip_int16(v + acb_vector[j]);
950 vector_ptr +
i + ppf[j].
index,
969 memset(
frame->data[0], 0,
1011 if (
s->postfilter) {
1024 #define OFFSET(x) offsetof(G723_1_Context, x)
1025 #define AD AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM
1029 { .i64 = 1 }, 0, 1,
AD },
#define AV_LOG_WARNING
Something somehow does not look correct.
static int16_t square_root(unsigned val)
Bitexact implementation of sqrt(val/2).
static const AVClass g723_1dec_class
static av_cold int init(AVCodecContext *avctx)
int index
postfilter backward/forward lag
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
uint64_t channel_layout
Audio channel layout.
AVCodec ff_g723_1_decoder
static const int cng_filt[4]
#define AV_CH_LAYOUT_MONO
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(const uint8_t *) pi - 0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(const int16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(const int16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(const int32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(const int32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(const int64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64, *(const int64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(const float *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(const double *) pi *(INT64_C(1)<< 63))) #define FMT_PAIR_FUNC(out, in) static conv_func_type *const fmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={ FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64), };static void cpy1(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, len);} static void cpy2(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 2 *len);} static void cpy4(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 4 *len);} static void cpy8(uint8_t **dst, const uint8_t **src, int len){ memcpy(*dst, *src, 8 *len);} AudioConvert *swri_audio_convert_alloc(enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, const int *ch_map, int flags) { AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) return NULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) return NULL;if(channels==1){ in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);} ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map) { switch(av_get_bytes_per_sample(in_fmt)){ case 1:ctx->simd_f=cpy1;break;case 2:ctx->simd_f=cpy2;break;case 4:ctx->simd_f=cpy4;break;case 8:ctx->simd_f=cpy8;break;} } if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);return ctx;} void swri_audio_convert_free(AudioConvert **ctx) { av_freep(ctx);} int swri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, int len) { int ch;int off=0;const int os=(out->planar ? 1 :out->ch_count) *out->bps;unsigned misaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask) { int planes=in->planar ? in->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;} if(ctx->out_simd_align_mask) { int planes=out->planar ? out->ch_count :1;unsigned m=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;} if(ctx->simd_f &&!ctx->ch_map &&!misaligned){ off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){ if(out->planar==in->planar){ int planes=out->planar ? out->ch_count :1;for(ch=0;ch< planes;ch++){ ctx->simd_f(out-> ch ch
static void gen_fcb_excitation(int16_t *vector, G723_1_Subframe *subfrm, enum Rate cur_rate, int pitch_lag, int index)
Generate fixed codebook excitation vector.
This structure describes decoded (raw) audio or video data.
static const int32_t max_pos[4]
Size of the MP-MLQ fixed excitation codebooks.
int ad_cb_lag
adaptive codebook lag
int ff_celp_lp_synthesis_filter(int16_t *out, const int16_t *filter_coeffs, const int16_t *in, int buffer_length, int filter_length, int stop_on_overflow, int shift, int rounder)
LP synthesis filter.
static void generate_noise(G723_1_ChannelContext *p)
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.
int16_t prev_excitation[PITCH_MAX]
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.
int ff_g723_1_normalize_bits(int num, int width)
Calculate the number of left-shifts required for normalizing the input.
static unsigned int get_bits(GetBitContext *s, int n)
Read 1-25 bits.
void ff_g723_1_gen_dirac_train(int16_t *buf, int pitch_lag)
Generate a train of dirac functions with period as pitch lag.
int16_t synth_mem[LPC_ORDER]
enum FrameType cur_frame_type
#define AV_CH_LAYOUT_STEREO
static const AVOption options[]
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int init_get_bits8(GetBitContext *s, const uint8_t *buffer, int byte_size)
Initialize GetBitContext.
static void comp_ppf_gains(int lag, PPFParam *ppf, enum Rate cur_rate, int tgt_eng, int ccr, int res_eng)
Calculate pitch postfilter optimal and scaling gains.
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.
void av_memcpy_backptr(uint8_t *dst, int back, int cnt)
Overlapping memcpy() implementation.
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
int pf_gain
formant postfilter gain scaling unit memory
static const int16_t postfilter_tbl[2][LPC_ORDER]
0.65^i (Zero part) and 0.75^i (Pole part) scaled by 2^15
static void postfilter(AMRContext *p, float *lpc, float *buf_out)
Perform adaptive post-filtering to enhance the quality of the speech.
static const uint8_t bits1[81]
int16_t fir_mem[LPC_ORDER]
int16_t audio[FRAME_LEN+LPC_ORDER+PITCH_MAX+4]
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
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.
const char * av_default_item_name(void *ptr)
Return the context name.
static unsigned int get_bits1(GetBitContext *s)
int16_t sid_lsp[LPC_ORDER]
int ff_g723_1_dot_product(const int16_t *a, const int16_t *b, int length)
static void gain_scale(G723_1_ChannelContext *p, int16_t *buf, int energy)
Adjust gain of postfiltered signal.
G723_1_Subframe subframe[4]
static void formant_postfilter(G723_1_ChannelContext *p, int16_t *lpc, int16_t *buf, int16_t *dst)
Perform formant filtering.
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
enum FrameType past_frame_type
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() 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.
uint8_t lsp_index[LSP_BANDS]
enum AVSampleFormat sample_fmt
audio sample format
static const int16_t pitch_contrib[340]
@ ACTIVE_FRAME
Active speech.
int16_t excitation[PITCH_MAX+FRAME_LEN+4]
const char const char void * val
G723.1 unpacked data subframe.
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 void skip_bits1(GetBitContext *s)
static const int16_t fixed_cb_gain[GAIN_LEVELS]
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
int channels
number of audio channels
#define av_assert2(cond)
assert() equivalent, that does lie in speed critical code.
static const int cng_adaptive_cb_lag[4]
#define i(width, name, range_min, range_max)
int16_t opt_gain
optimal gain
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.
static int cng_rand(int *state, int base)
const char * name
Name of the codec implementation.
static int estimate_sid_gain(G723_1_ChannelContext *p)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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
int16_t prev_lsp[LPC_ORDER]
static int comp_interp_index(G723_1_ChannelContext *p, int pitch_lag, int *exc_eng, int *scale)
Classify frames as voiced/unvoiced.
static const int16_t dc_lsp[LPC_ORDER]
LSP DC component.
main external API structure.
static void residual_interp(int16_t *buf, int16_t *out, int lag, int gain, int *rseed)
Perform residual interpolation based on frame classification.
static const int16_t ppf_gain_weight[2]
Postfilter gain weighting factors scaled by 2^15.
@ SID_FRAME
Silence Insertion Descriptor frame.
static void comp_ppf_coeff(G723_1_ChannelContext *p, int offset, int pitch_lag, PPFParam *ppf, enum Rate cur_rate)
Calculate pitch postfilter parameters.
void ff_acelp_weighted_vector_sum(int16_t *out, const int16_t *in_a, const int16_t *in_b, int16_t weight_coeff_a, int16_t weight_coeff_b, int16_t rounder, int shift, int length)
weighted sum of two vectors with rounding.
static int shift(int a, int b)
#define AV_CODEC_CAP_SUBFRAMES
Codec can output multiple frames per AVPacket Normally demuxers return one frame at a time,...
This structure stores compressed data.
static const int cng_bseg[3]
#define iir_filter(fir_coef, iir_coef, src, dest, width)
Perform IIR filtering.
static int autocorr_max(const int16_t *buf, int offset, int *ccr_max, int pitch_lag, int length, int dir)
Estimate maximum auto-correlation around pitch lag.
static int sid_gain_to_lsp_index(int gain)
static av_cold int g723_1_decode_init(AVCodecContext *avctx)
static const int8_t pulses[4]
Number of non-zero pulses in the MP-MLQ excitation.
static const uint8_t bits2[81]
static int unpack_bitstream(G723_1_ChannelContext *p, const uint8_t *buf, int buf_size)
Unpack the frame into parameters.
int16_t sc_gain
scaling gain
Pitch postfilter parameters.
static int g723_1_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)