* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <stdlib.h>
+
#include <inttypes.h>
-#include <limits.h>
-#include <stdio.h>
#include <string.h>
-#include <math.h>
-#include <assert.h>
#include "avcodec.h"
#include "libavutil/avutil.h"
return voice_decision;
}
+static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order, int shift)
+{
+ int res = 0;
+
+ while (order--)
+ res += (*v1++ * *v2++) >> shift;
+
+ return res;
+}
+
static av_cold int decoder_init(AVCodecContext * avctx)
{
G729Context* ctx = avctx->priv_data;
for(i=0; i<4; i++)
ctx->quant_energy[i] = -14336; // -14 in (5.10)
- avctx->dsp_mask = FF_MM_MMX | FF_MM_SSE2;
dsputil_init(&ctx->dsp, avctx);
+ ctx->dsp.scalarproduct_int16 = scalarproduct_int16_c;
return 0;
}
int buf_size = avpkt->size;
int16_t *out_frame = data;
GetBitContext gb;
- G729FormatDescription format;
+ const G729FormatDescription *format;
int frame_erasure = 0; ///< frame erasure detected during decoding
int bad_pitch = 0; ///< parity check failed
int i;
if (buf_size == 10) {
packet_type = FORMAT_G729_8K;
- format = format_g729_8k;
+ format = &format_g729_8k;
//Reset voice decision
ctx->onset = 0;
ctx->voice_decision = DECISION_VOICE;
av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729 @ 8kbit/s");
} else if (buf_size == 8) {
packet_type = FORMAT_G729D_6K4;
- format = format_g729d_6k4;
+ format = &format_g729d_6k4;
av_log(avctx, AV_LOG_DEBUG, "Packet type: %s\n", "G.729D @ 6.4kbit/s");
} else {
av_log(avctx, AV_LOG_ERROR, "Packet size %d is unknown.\n", buf_size);
frame_erasure |= buf[i];
frame_erasure = !frame_erasure;
- init_get_bits(&gb, buf, buf_size);
+ init_get_bits(&gb, buf, 8*buf_size);
ma_predictor = get_bits(&gb, 1);
quantizer_1st = get_bits(&gb, VQ_1ST_BITS);
uint8_t gc_1st_index; ///< gain codebook (first stage) index
uint8_t gc_2nd_index; ///< gain codebook (second stage) index
- ac_index = get_bits(&gb, format.ac_index_bits[i]);
- if(!i && format.parity_bit)
+ ac_index = get_bits(&gb, format->ac_index_bits[i]);
+ if(!i && format->parity_bit)
bad_pitch = get_parity(ac_index) == get_bits1(&gb);
- fc_indexes = get_bits(&gb, format.fc_indexes_bits);
- pulses_signs = get_bits(&gb, format.fc_signs_bits);
- gc_1st_index = get_bits(&gb, format.gc_1st_index_bits);
- gc_2nd_index = get_bits(&gb, format.gc_2nd_index_bits);
+ fc_indexes = get_bits(&gb, format->fc_indexes_bits);
+ pulses_signs = get_bits(&gb, format->fc_signs_bits);
+ gc_1st_index = get_bits(&gb, format->gc_1st_index_bits);
+ gc_2nd_index = get_bits(&gb, format->gc_2nd_index_bits);
if (frame_erasure)
pitch_delay_3x = 3 * ctx->pitch_delay_int_prev;
if (frame_erasure) {
ctx->rand_value = g729_prng(ctx->rand_value);
- fc_indexes = ctx->rand_value & ((1 << format.fc_indexes_bits) - 1);
+ fc_indexes = ctx->rand_value & ((1 << format->fc_indexes_bits) - 1);
ctx->rand_value = g729_prng(ctx->rand_value);
pulses_signs = ctx->rand_value;
SUBFRAME_SIZE,
10,
1,
+ 0,
0x800))
/* Overflow occured, downscale excitation signal... */
for (j = 0; j < 2 * SUBFRAME_SIZE + PITCH_DELAY_MAX + INTERPOL_LEN; j++)
SUBFRAME_SIZE,
10,
0,
+ 0,
0x800);
} else {
ff_celp_lp_synthesis_filter(
SUBFRAME_SIZE,
10,
0,
+ 0,
0x800);
}
/* Save data (without postfilter) for use in next subframe. */
gain_before += FFABS(synth[j+10]);
/* Call postfilter and also update voicing decision for use in next frame. */
- g729_postfilter(
+ ff_g729_postfilter(
&ctx->dsp,
&ctx->ht_prev_data,
&is_periodic,
for(j=0; j<SUBFRAME_SIZE; j++)
gain_after += FFABS(synth[j+10]);
- ctx->gain_coeff = g729_adaptive_gain_control(
+ ctx->gain_coeff = ff_g729_adaptive_gain_control(
gain_before,
gain_after,
synth+10,