00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <inttypes.h>
00023 #include <string.h>
00024
00025 #include "avcodec.h"
00026 #include "libavutil/avutil.h"
00027 #include "get_bits.h"
00028 #include "dsputil.h"
00029 #include "internal.h"
00030
00031
00032 #include "g729.h"
00033 #include "lsp.h"
00034 #include "celp_math.h"
00035 #include "celp_filters.h"
00036 #include "acelp_filters.h"
00037 #include "acelp_pitch_delay.h"
00038 #include "acelp_vectors.h"
00039 #include "g729data.h"
00040 #include "g729postfilter.h"
00041
00046 #define LSFQ_MIN 40
00047
00052 #define LSFQ_MAX 25681
00053
00058 #define LSFQ_DIFF_MIN 321
00059
00061 #define INTERPOL_LEN 11
00062
00067 #define SHARP_MIN 3277
00068
00076 #define SHARP_MAX 13017
00077
00081 #define MR_ENERGY 1018156
00082
00083 #define DECISION_NOISE 0
00084 #define DECISION_INTERMEDIATE 1
00085 #define DECISION_VOICE 2
00086
00087 typedef enum {
00088 FORMAT_G729_8K = 0,
00089 FORMAT_G729D_6K4,
00090 FORMAT_COUNT,
00091 } G729Formats;
00092
00093 typedef struct {
00094 uint8_t ac_index_bits[2];
00095 uint8_t parity_bit;
00096 uint8_t gc_1st_index_bits;
00097 uint8_t gc_2nd_index_bits;
00098 uint8_t fc_signs_bits;
00099 uint8_t fc_indexes_bits;
00100 } G729FormatDescription;
00101
00102 typedef struct {
00103 DSPContext dsp;
00104 AVFrame frame;
00105
00107 int16_t exc_base[2*SUBFRAME_SIZE+PITCH_DELAY_MAX+INTERPOL_LEN];
00108
00109 int16_t* exc;
00110 int pitch_delay_int_prev;
00111
00113 int16_t past_quantizer_output_buf[MA_NP + 1][10];
00114 int16_t* past_quantizer_outputs[MA_NP + 1];
00115
00116 int16_t lsfq[10];
00117 int16_t lsp_buf[2][10];
00118 int16_t *lsp[2];
00119
00120 int16_t quant_energy[4];
00121
00123 int16_t syn_filter_data[10];
00124
00125
00127 int16_t residual[SUBFRAME_SIZE + RES_PREV_DATA_SIZE];
00128
00130 int16_t res_filter_data[SUBFRAME_SIZE+10];
00131
00133 int16_t pos_filter_data[SUBFRAME_SIZE+10];
00134
00136 int16_t past_gain_pitch[6];
00137
00139 int16_t past_gain_code[2];
00140
00142 int16_t voice_decision;
00143
00144 int16_t onset;
00145 int16_t was_periodic;
00146 int16_t ht_prev_data;
00147 int gain_coeff;
00148 uint16_t rand_value;
00149 int ma_predictor_prev;
00150
00152 int hpf_f[2];
00153
00155 int16_t hpf_z[2];
00156 } G729Context;
00157
00158 static const G729FormatDescription format_g729_8k = {
00159 .ac_index_bits = {8,5},
00160 .parity_bit = 1,
00161 .gc_1st_index_bits = GC_1ST_IDX_BITS_8K,
00162 .gc_2nd_index_bits = GC_2ND_IDX_BITS_8K,
00163 .fc_signs_bits = 4,
00164 .fc_indexes_bits = 13,
00165 };
00166
00167 static const G729FormatDescription format_g729d_6k4 = {
00168 .ac_index_bits = {8,4},
00169 .parity_bit = 0,
00170 .gc_1st_index_bits = GC_1ST_IDX_BITS_6K4,
00171 .gc_2nd_index_bits = GC_2ND_IDX_BITS_6K4,
00172 .fc_signs_bits = 2,
00173 .fc_indexes_bits = 9,
00174 };
00175
00179 static inline uint16_t g729_prng(uint16_t value)
00180 {
00181 return 31821 * value + 13849;
00182 }
00183
00187 static inline int get_parity(uint8_t value)
00188 {
00189 return (0x6996966996696996ULL >> (value >> 2)) & 1;
00190 }
00191
00201 static void lsf_decode(int16_t* lsfq, int16_t* past_quantizer_outputs[MA_NP + 1],
00202 int16_t ma_predictor,
00203 int16_t vq_1st, int16_t vq_2nd_low, int16_t vq_2nd_high)
00204 {
00205 int i,j;
00206 static const uint8_t min_distance[2]={10, 5};
00207 int16_t* quantizer_output = past_quantizer_outputs[MA_NP];
00208
00209 for (i = 0; i < 5; i++) {
00210 quantizer_output[i] = cb_lsp_1st[vq_1st][i ] + cb_lsp_2nd[vq_2nd_low ][i ];
00211 quantizer_output[i + 5] = cb_lsp_1st[vq_1st][i + 5] + cb_lsp_2nd[vq_2nd_high][i + 5];
00212 }
00213
00214 for (j = 0; j < 2; j++) {
00215 for (i = 1; i < 10; i++) {
00216 int diff = (quantizer_output[i - 1] - quantizer_output[i] + min_distance[j]) >> 1;
00217 if (diff > 0) {
00218 quantizer_output[i - 1] -= diff;
00219 quantizer_output[i ] += diff;
00220 }
00221 }
00222 }
00223
00224 for (i = 0; i < 10; i++) {
00225 int sum = quantizer_output[i] * cb_ma_predictor_sum[ma_predictor][i];
00226 for (j = 0; j < MA_NP; j++)
00227 sum += past_quantizer_outputs[j][i] * cb_ma_predictor[ma_predictor][j][i];
00228
00229 lsfq[i] = sum >> 15;
00230 }
00231
00232 ff_acelp_reorder_lsf(lsfq, LSFQ_DIFF_MIN, LSFQ_MIN, LSFQ_MAX, 10);
00233 }
00234
00242 static void lsf_restore_from_previous(int16_t* lsfq,
00243 int16_t* past_quantizer_outputs[MA_NP + 1],
00244 int ma_predictor_prev)
00245 {
00246 int16_t* quantizer_output = past_quantizer_outputs[MA_NP];
00247 int i,k;
00248
00249 for (i = 0; i < 10; i++) {
00250 int tmp = lsfq[i] << 15;
00251
00252 for (k = 0; k < MA_NP; k++)
00253 tmp -= past_quantizer_outputs[k][i] * cb_ma_predictor[ma_predictor_prev][k][i];
00254
00255 quantizer_output[i] = ((tmp >> 15) * cb_ma_predictor_sum_inv[ma_predictor_prev][i]) >> 12;
00256 }
00257 }
00258
00267 static void g729d_get_new_exc(
00268 int16_t* out,
00269 const int16_t* in,
00270 const int16_t* fc_cur,
00271 int dstate,
00272 int gain_code,
00273 int subframe_size)
00274 {
00275 int i;
00276 int16_t fc_new[SUBFRAME_SIZE];
00277
00278 ff_celp_convolve_circ(fc_new, fc_cur, phase_filter[dstate], subframe_size);
00279
00280 for(i=0; i<subframe_size; i++)
00281 {
00282 out[i] = in[i];
00283 out[i] -= (gain_code * fc_cur[i] + 0x2000) >> 14;
00284 out[i] += (gain_code * fc_new[i] + 0x2000) >> 14;
00285 }
00286 }
00287
00295 static int g729d_onset_decision(int past_onset, const int16_t* past_gain_code)
00296 {
00297 if((past_gain_code[0] >> 1) > past_gain_code[1])
00298 return 2;
00299 else
00300 return FFMAX(past_onset-1, 0);
00301 }
00302
00311 static int16_t g729d_voice_decision(int onset, int prev_voice_decision, const int16_t* past_gain_pitch)
00312 {
00313 int i, low_gain_pitch_cnt, voice_decision;
00314
00315 if(past_gain_pitch[0] >= 14745)
00316 voice_decision = DECISION_VOICE;
00317 else if (past_gain_pitch[0] <= 9830)
00318 voice_decision = DECISION_NOISE;
00319 else
00320 voice_decision = DECISION_INTERMEDIATE;
00321
00322 for(i=0, low_gain_pitch_cnt=0; i<6; i++)
00323 if(past_gain_pitch[i] < 9830)
00324 low_gain_pitch_cnt++;
00325
00326 if(low_gain_pitch_cnt > 2 && !onset)
00327 voice_decision = DECISION_NOISE;
00328
00329 if(!onset && voice_decision > prev_voice_decision + 1)
00330 voice_decision--;
00331
00332 if(onset && voice_decision < DECISION_VOICE)
00333 voice_decision++;
00334
00335 return voice_decision;
00336 }
00337
00338 static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order)
00339 {
00340 int res = 0;
00341
00342 while (order--)
00343 res += *v1++ * *v2++;
00344
00345 return res;
00346 }
00347
00348 static av_cold int decoder_init(AVCodecContext * avctx)
00349 {
00350 G729Context* ctx = avctx->priv_data;
00351 int i,k;
00352
00353 if (avctx->channels != 1) {
00354 av_log(avctx, AV_LOG_ERROR, "Only mono sound is supported (requested channels: %d).\n", avctx->channels);
00355 return AVERROR(EINVAL);
00356 }
00357 avctx->sample_fmt = AV_SAMPLE_FMT_S16;
00358
00359
00360 avctx->frame_size = SUBFRAME_SIZE << 1;
00361
00362 ctx->gain_coeff = 16384;
00363
00364 for (k = 0; k < MA_NP + 1; k++) {
00365 ctx->past_quantizer_outputs[k] = ctx->past_quantizer_output_buf[k];
00366 for (i = 1; i < 11; i++)
00367 ctx->past_quantizer_outputs[k][i - 1] = (18717 * i) >> 3;
00368 }
00369
00370 ctx->lsp[0] = ctx->lsp_buf[0];
00371 ctx->lsp[1] = ctx->lsp_buf[1];
00372 memcpy(ctx->lsp[0], lsp_init, 10 * sizeof(int16_t));
00373
00374 ctx->exc = &ctx->exc_base[PITCH_DELAY_MAX+INTERPOL_LEN];
00375
00376 ctx->pitch_delay_int_prev = PITCH_DELAY_MIN;
00377
00378
00379 ctx->rand_value = 21845;
00380
00381
00382 for(i=0; i<4; i++)
00383 ctx->quant_energy[i] = -14336;
00384
00385 ff_dsputil_init(&ctx->dsp, avctx);
00386 ctx->dsp.scalarproduct_int16 = scalarproduct_int16_c;
00387
00388 avcodec_get_frame_defaults(&ctx->frame);
00389 avctx->coded_frame = &ctx->frame;
00390
00391 return 0;
00392 }
00393
00394 static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr,
00395 AVPacket *avpkt)
00396 {
00397 const uint8_t *buf = avpkt->data;
00398 int buf_size = avpkt->size;
00399 int16_t *out_frame;
00400 GetBitContext gb;
00401 const G729FormatDescription *format;
00402 int frame_erasure = 0;
00403 int bad_pitch = 0;
00404 int i;
00405 int16_t *tmp;
00406 G729Formats packet_type;
00407 G729Context *ctx = avctx->priv_data;
00408 int16_t lp[2][11];
00409 uint8_t ma_predictor;
00410 uint8_t quantizer_1st;
00411 uint8_t quantizer_2nd_lo;
00412 uint8_t quantizer_2nd_hi;
00413
00414 int pitch_delay_int[2];
00415 int pitch_delay_3x;
00416 int16_t fc[SUBFRAME_SIZE];
00417 int16_t synth[SUBFRAME_SIZE+10];
00418 int j, ret;
00419 int gain_before, gain_after;
00420 int is_periodic = 0;
00421
00422 ctx->frame.nb_samples = SUBFRAME_SIZE<<1;
00423 if ((ret = ff_get_buffer(avctx, &ctx->frame)) < 0) {
00424 av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
00425 return ret;
00426 }
00427 out_frame = (int16_t*) ctx->frame.data[0];
00428
00429 if (buf_size == 10) {
00430 packet_type = FORMAT_G729_8K;
00431 format = &format_g729_8k;
00432
00433 ctx->onset = 0;
00434 ctx->voice_decision = DECISION_VOICE;
00435 av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729 @ 8kbit/s");
00436 } else if (buf_size == 8) {
00437 packet_type = FORMAT_G729D_6K4;
00438 format = &format_g729d_6k4;
00439 av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729D @ 6.4kbit/s");
00440 } else {
00441 av_log(avctx, AV_LOG_ERROR, "Packet size %d is unknown.\n", buf_size);
00442 return AVERROR_INVALIDDATA;
00443 }
00444
00445 for (i=0; i < buf_size; i++)
00446 frame_erasure |= buf[i];
00447 frame_erasure = !frame_erasure;
00448
00449 init_get_bits(&gb, buf, 8*buf_size);
00450
00451 ma_predictor = get_bits(&gb, 1);
00452 quantizer_1st = get_bits(&gb, VQ_1ST_BITS);
00453 quantizer_2nd_lo = get_bits(&gb, VQ_2ND_BITS);
00454 quantizer_2nd_hi = get_bits(&gb, VQ_2ND_BITS);
00455
00456 if(frame_erasure)
00457 lsf_restore_from_previous(ctx->lsfq, ctx->past_quantizer_outputs,
00458 ctx->ma_predictor_prev);
00459 else {
00460 lsf_decode(ctx->lsfq, ctx->past_quantizer_outputs,
00461 ma_predictor,
00462 quantizer_1st, quantizer_2nd_lo, quantizer_2nd_hi);
00463 ctx->ma_predictor_prev = ma_predictor;
00464 }
00465
00466 tmp = ctx->past_quantizer_outputs[MA_NP];
00467 memmove(ctx->past_quantizer_outputs + 1, ctx->past_quantizer_outputs,
00468 MA_NP * sizeof(int16_t*));
00469 ctx->past_quantizer_outputs[0] = tmp;
00470
00471 ff_acelp_lsf2lsp(ctx->lsp[1], ctx->lsfq, 10);
00472
00473 ff_acelp_lp_decode(&lp[0][0], &lp[1][0], ctx->lsp[1], ctx->lsp[0], 10);
00474
00475 FFSWAP(int16_t*, ctx->lsp[1], ctx->lsp[0]);
00476
00477 for (i = 0; i < 2; i++) {
00478 int gain_corr_factor;
00479
00480 uint8_t ac_index;
00481 uint8_t pulses_signs;
00482 int fc_indexes;
00483 uint8_t gc_1st_index;
00484 uint8_t gc_2nd_index;
00485
00486 ac_index = get_bits(&gb, format->ac_index_bits[i]);
00487 if(!i && format->parity_bit)
00488 bad_pitch = get_parity(ac_index) == get_bits1(&gb);
00489 fc_indexes = get_bits(&gb, format->fc_indexes_bits);
00490 pulses_signs = get_bits(&gb, format->fc_signs_bits);
00491 gc_1st_index = get_bits(&gb, format->gc_1st_index_bits);
00492 gc_2nd_index = get_bits(&gb, format->gc_2nd_index_bits);
00493
00494 if (frame_erasure)
00495 pitch_delay_3x = 3 * ctx->pitch_delay_int_prev;
00496 else if(!i) {
00497 if (bad_pitch)
00498 pitch_delay_3x = 3 * ctx->pitch_delay_int_prev;
00499 else
00500 pitch_delay_3x = ff_acelp_decode_8bit_to_1st_delay3(ac_index);
00501 } else {
00502 int pitch_delay_min = av_clip(ctx->pitch_delay_int_prev - 5,
00503 PITCH_DELAY_MIN, PITCH_DELAY_MAX - 9);
00504
00505 if(packet_type == FORMAT_G729D_6K4)
00506 pitch_delay_3x = ff_acelp_decode_4bit_to_2nd_delay3(ac_index, pitch_delay_min);
00507 else
00508 pitch_delay_3x = ff_acelp_decode_5_6_bit_to_2nd_delay3(ac_index, pitch_delay_min);
00509 }
00510
00511
00512 pitch_delay_int[i] = (pitch_delay_3x + 1) / 3;
00513 if (pitch_delay_int[i] > PITCH_DELAY_MAX) {
00514 av_log(avctx, AV_LOG_WARNING, "pitch_delay_int %d is too large\n", pitch_delay_int[i]);
00515 pitch_delay_int[i] = PITCH_DELAY_MAX;
00516 }
00517
00518 if (frame_erasure) {
00519 ctx->rand_value = g729_prng(ctx->rand_value);
00520 fc_indexes = ctx->rand_value & ((1 << format->fc_indexes_bits) - 1);
00521
00522 ctx->rand_value = g729_prng(ctx->rand_value);
00523 pulses_signs = ctx->rand_value;
00524 }
00525
00526
00527 memset(fc, 0, sizeof(int16_t) * SUBFRAME_SIZE);
00528 switch (packet_type) {
00529 case FORMAT_G729_8K:
00530 ff_acelp_fc_pulse_per_track(fc, ff_fc_4pulses_8bits_tracks_13,
00531 ff_fc_4pulses_8bits_track_4,
00532 fc_indexes, pulses_signs, 3, 3);
00533 break;
00534 case FORMAT_G729D_6K4:
00535 ff_acelp_fc_pulse_per_track(fc, ff_fc_2pulses_9bits_track1_gray,
00536 ff_fc_2pulses_9bits_track2_gray,
00537 fc_indexes, pulses_signs, 1, 4);
00538 break;
00539 }
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549 ff_acelp_weighted_vector_sum(fc + pitch_delay_int[i],
00550 fc + pitch_delay_int[i],
00551 fc, 1 << 14,
00552 av_clip(ctx->past_gain_pitch[0], SHARP_MIN, SHARP_MAX),
00553 0, 14,
00554 SUBFRAME_SIZE - pitch_delay_int[i]);
00555
00556 memmove(ctx->past_gain_pitch+1, ctx->past_gain_pitch, 5 * sizeof(int16_t));
00557 ctx->past_gain_code[1] = ctx->past_gain_code[0];
00558
00559 if (frame_erasure) {
00560 ctx->past_gain_pitch[0] = (29491 * ctx->past_gain_pitch[0]) >> 15;
00561 ctx->past_gain_code[0] = ( 2007 * ctx->past_gain_code[0] ) >> 11;
00562
00563 gain_corr_factor = 0;
00564 } else {
00565 if (packet_type == FORMAT_G729D_6K4) {
00566 ctx->past_gain_pitch[0] = cb_gain_1st_6k4[gc_1st_index][0] +
00567 cb_gain_2nd_6k4[gc_2nd_index][0];
00568 gain_corr_factor = cb_gain_1st_6k4[gc_1st_index][1] +
00569 cb_gain_2nd_6k4[gc_2nd_index][1];
00570
00571
00572
00573
00574 gain_corr_factor = FFMAX(gain_corr_factor, 1024);
00575 #ifndef G729_BITEXACT
00576 gain_corr_factor >>= 1;
00577 #endif
00578 } else {
00579 ctx->past_gain_pitch[0] = cb_gain_1st_8k[gc_1st_index][0] +
00580 cb_gain_2nd_8k[gc_2nd_index][0];
00581 gain_corr_factor = cb_gain_1st_8k[gc_1st_index][1] +
00582 cb_gain_2nd_8k[gc_2nd_index][1];
00583 }
00584
00585
00586 ctx->past_gain_code[0] = ff_acelp_decode_gain_code(&ctx->dsp, gain_corr_factor,
00587 fc, MR_ENERGY,
00588 ctx->quant_energy,
00589 ma_prediction_coeff,
00590 SUBFRAME_SIZE, 4);
00591 #ifdef G729_BITEXACT
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601 if (packet_type == FORMAT_G729D_6K4) {
00602 gain_corr_factor >>= 1;
00603 ctx->past_gain_code[0] >>= 1;
00604 }
00605 #endif
00606 }
00607 ff_acelp_update_past_gain(ctx->quant_energy, gain_corr_factor, 2, frame_erasure);
00608
00609
00610 ff_acelp_interpolate(ctx->exc + i * SUBFRAME_SIZE,
00611 ctx->exc + i * SUBFRAME_SIZE - pitch_delay_3x / 3,
00612 ff_acelp_interp_filter, 6,
00613 (pitch_delay_3x % 3) << 1,
00614 10, SUBFRAME_SIZE);
00615
00616 ff_acelp_weighted_vector_sum(ctx->exc + i * SUBFRAME_SIZE,
00617 ctx->exc + i * SUBFRAME_SIZE, fc,
00618 (!ctx->was_periodic && frame_erasure) ? 0 : ctx->past_gain_pitch[0],
00619 ( ctx->was_periodic && frame_erasure) ? 0 : ctx->past_gain_code[0],
00620 1 << 13, 14, SUBFRAME_SIZE);
00621
00622 memcpy(synth, ctx->syn_filter_data, 10 * sizeof(int16_t));
00623
00624 if (ff_celp_lp_synthesis_filter(
00625 synth+10,
00626 &lp[i][1],
00627 ctx->exc + i * SUBFRAME_SIZE,
00628 SUBFRAME_SIZE,
00629 10,
00630 1,
00631 0,
00632 0x800))
00633
00634 for (j = 0; j < 2 * SUBFRAME_SIZE + PITCH_DELAY_MAX + INTERPOL_LEN; j++)
00635 ctx->exc_base[j] >>= 2;
00636
00637
00638 if (packet_type == FORMAT_G729D_6K4) {
00639 int16_t exc_new[SUBFRAME_SIZE];
00640
00641 ctx->onset = g729d_onset_decision(ctx->onset, ctx->past_gain_code);
00642 ctx->voice_decision = g729d_voice_decision(ctx->onset, ctx->voice_decision, ctx->past_gain_pitch);
00643
00644 g729d_get_new_exc(exc_new, ctx->exc + i * SUBFRAME_SIZE, fc, ctx->voice_decision, ctx->past_gain_code[0], SUBFRAME_SIZE);
00645
00646 ff_celp_lp_synthesis_filter(
00647 synth+10,
00648 &lp[i][1],
00649 exc_new,
00650 SUBFRAME_SIZE,
00651 10,
00652 0,
00653 0,
00654 0x800);
00655 } else {
00656 ff_celp_lp_synthesis_filter(
00657 synth+10,
00658 &lp[i][1],
00659 ctx->exc + i * SUBFRAME_SIZE,
00660 SUBFRAME_SIZE,
00661 10,
00662 0,
00663 0,
00664 0x800);
00665 }
00666
00667 memcpy(ctx->syn_filter_data, synth+SUBFRAME_SIZE, 10 * sizeof(int16_t));
00668
00669
00670 gain_before = 0;
00671 for (j = 0; j < SUBFRAME_SIZE; j++)
00672 gain_before += FFABS(synth[j+10]);
00673
00674
00675 ff_g729_postfilter(
00676 &ctx->dsp,
00677 &ctx->ht_prev_data,
00678 &is_periodic,
00679 &lp[i][0],
00680 pitch_delay_int[0],
00681 ctx->residual,
00682 ctx->res_filter_data,
00683 ctx->pos_filter_data,
00684 synth+10,
00685 SUBFRAME_SIZE);
00686
00687
00688 gain_after = 0;
00689 for(j=0; j<SUBFRAME_SIZE; j++)
00690 gain_after += FFABS(synth[j+10]);
00691
00692 ctx->gain_coeff = ff_g729_adaptive_gain_control(
00693 gain_before,
00694 gain_after,
00695 synth+10,
00696 SUBFRAME_SIZE,
00697 ctx->gain_coeff);
00698
00699 if (frame_erasure)
00700 ctx->pitch_delay_int_prev = FFMIN(ctx->pitch_delay_int_prev + 1, PITCH_DELAY_MAX);
00701 else
00702 ctx->pitch_delay_int_prev = pitch_delay_int[i];
00703
00704 memcpy(synth+8, ctx->hpf_z, 2*sizeof(int16_t));
00705 ff_acelp_high_pass_filter(
00706 out_frame + i*SUBFRAME_SIZE,
00707 ctx->hpf_f,
00708 synth+10,
00709 SUBFRAME_SIZE);
00710 memcpy(ctx->hpf_z, synth+8+SUBFRAME_SIZE, 2*sizeof(int16_t));
00711 }
00712
00713 ctx->was_periodic = is_periodic;
00714
00715
00716 memmove(ctx->exc_base, ctx->exc_base + 2 * SUBFRAME_SIZE, (PITCH_DELAY_MAX+INTERPOL_LEN)*sizeof(int16_t));
00717
00718 *got_frame_ptr = 1;
00719 *(AVFrame*)data = ctx->frame;
00720 return buf_size;
00721 }
00722
00723 AVCodec ff_g729_decoder = {
00724 .name = "g729",
00725 .type = AVMEDIA_TYPE_AUDIO,
00726 .id = AV_CODEC_ID_G729,
00727 .priv_data_size = sizeof(G729Context),
00728 .init = decoder_init,
00729 .decode = decode_frame,
00730 .capabilities = CODEC_CAP_DR1,
00731 .long_name = NULL_IF_CONFIG_SMALL("G.729"),
00732 };