#include <stdint.h>
#include <string.h>
+#include "libavutil/audioconvert.h"
#include "libavutil/mathematics.h"
#include "avcodec.h"
#define BITSTREAM_READER_LE
#include "dsputil.h"
#include "lsp.h"
-#include "celp_math.h"
#include "acelp_vectors.h"
#include "acelp_pitch_delay.h"
#include "acelp_filters.h"
SUBFR_SIZE);
avg_energy =
- (0.01 + ff_dot_productf(fixed_vector, fixed_vector, SUBFR_SIZE))/
+ (0.01 + ff_scalarproduct_float_c(fixed_vector, fixed_vector, SUBFR_SIZE)) /
SUBFR_SIZE;
ctx->past_pitch_gain = pitch_gain = gain_cb[params->gc_index[i]][0];
if (ctx->mode == MODE_5k0) {
for (i = 0; i < subframe_count; i++) {
- float energy = ff_dot_productf(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
- ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*SUBFR_SIZE,
- SUBFR_SIZE);
+ float energy = ff_scalarproduct_float_c(ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
+ ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * SUBFR_SIZE,
+ SUBFR_SIZE);
ff_adaptive_gain_control(&synth[i * SUBFR_SIZE],
&synth[i * SUBFR_SIZE], energy,
SUBFR_SIZE, 0.9, &ctx->postfilter_agc);
case 29: ctx->mode = MODE_6k5; break;
case 37: ctx->mode = MODE_5k0; break;
default:
- av_log(avctx, AV_LOG_ERROR, "Invalid block_align: %d\n", avctx->block_align);
- return AVERROR(EINVAL);
+ if (avctx->bit_rate > 12200) ctx->mode = MODE_16k;
+ else if (avctx->bit_rate > 7500 ) ctx->mode = MODE_8k5;
+ else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5;
+ else ctx->mode = MODE_5k0;
+ av_log(avctx, AV_LOG_WARNING,
+ "Invalid block_align: %d. Mode %s guessed based on bitrate: %d\n",
+ avctx->block_align, modes[ctx->mode].mode_name, avctx->bit_rate);
}
av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name);
for (i = 0; i < 4; i++)
ctx->energy_history[i] = -14;
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
+ avctx->channels = 1;
+ avctx->channel_layout = AV_CH_LAYOUT_MONO;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
avcodec_get_frame_defaults(&ctx->frame);
avctx->coded_frame = &ctx->frame;
AVCodec ff_sipr_decoder = {
.name = "sipr",
.type = AVMEDIA_TYPE_AUDIO,
- .id = CODEC_ID_SIPR,
+ .id = AV_CODEC_ID_SIPR,
.priv_data_size = sizeof(SiprContext),
.init = sipr_decoder_init,
.decode = sipr_decode_frame,
.capabilities = CODEC_CAP_DR1,
- .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
+ .long_name = NULL_IF_CONFIG_SMALL("RealAudio SIPR / ACELP.NET"),
};