|
|
|
@ -130,7 +130,6 @@ typedef struct { |
|
|
|
|
AVCodecContext *avctx; |
|
|
|
|
DSPContext dsp; |
|
|
|
|
|
|
|
|
|
SiprModeParam m; |
|
|
|
|
SiprMode mode; |
|
|
|
|
|
|
|
|
|
float past_pitch_gain; |
|
|
|
@ -410,7 +409,8 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, |
|
|
|
|
float *out_data) |
|
|
|
|
{ |
|
|
|
|
int i, j; |
|
|
|
|
int frame_size = ctx->m.subframe_count * SUBFR_SIZE; |
|
|
|
|
int subframe_count = modes[ctx->mode].subframe_count; |
|
|
|
|
int frame_size = subframe_count * SUBFR_SIZE; |
|
|
|
|
float Az[LP_FILTER_ORDER * MAX_SUBFRAME_COUNT]; |
|
|
|
|
float *excitation; |
|
|
|
|
float ir_buf[SUBFR_SIZE + LP_FILTER_ORDER]; |
|
|
|
@ -424,13 +424,13 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, |
|
|
|
|
memset(ir_buf, 0, LP_FILTER_ORDER * sizeof(float)); |
|
|
|
|
lsf_decode_fp(lsf_new, ctx->lsf_history, params); |
|
|
|
|
|
|
|
|
|
sipr_decode_lp(lsf_new, ctx->lsp_history, Az, ctx->m.subframe_count); |
|
|
|
|
sipr_decode_lp(lsf_new, ctx->lsp_history, Az, subframe_count); |
|
|
|
|
|
|
|
|
|
memcpy(ctx->lsp_history, lsf_new, LP_FILTER_ORDER * sizeof(float)); |
|
|
|
|
|
|
|
|
|
excitation = ctx->excitation + PITCH_DELAY_MAX + L_INTERPOL; |
|
|
|
|
|
|
|
|
|
for (i = 0; i < ctx->m.subframe_count; i++) { |
|
|
|
|
for (i = 0; i < subframe_count; i++) { |
|
|
|
|
float *pAz = Az + i*LP_FILTER_ORDER; |
|
|
|
|
float fixed_vector[SUBFR_SIZE]; |
|
|
|
|
int T0,T0_frac; |
|
|
|
@ -450,7 +450,7 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, |
|
|
|
|
decode_fixed_sparse(&fixed_cb, params->fc_indexes[i], ctx->mode, |
|
|
|
|
ctx->past_pitch_gain < 0.8); |
|
|
|
|
|
|
|
|
|
eval_ir(pAz, T0, impulse_response, ctx->m.pitch_sharp_factor); |
|
|
|
|
eval_ir(pAz, T0, impulse_response, modes[ctx->mode].pitch_sharp_factor); |
|
|
|
|
|
|
|
|
|
convolute_with_sparse(fixed_vector, &fixed_cb, impulse_response, |
|
|
|
|
SUBFR_SIZE); |
|
|
|
@ -497,7 +497,7 @@ static void decode_frame(SiprContext *ctx, SiprParameters *params, |
|
|
|
|
LP_FILTER_ORDER * sizeof(float)); |
|
|
|
|
|
|
|
|
|
if (ctx->mode == MODE_5k0) { |
|
|
|
|
for (i = 0; i < ctx->m.subframe_count; i++) { |
|
|
|
|
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); |
|
|
|
@ -532,8 +532,7 @@ static av_cold int sipr_decoder_init(AVCodecContext * avctx) |
|
|
|
|
else if (avctx->bit_rate > 5750 ) ctx->mode = MODE_6k5; |
|
|
|
|
else ctx->mode = MODE_5k0; |
|
|
|
|
|
|
|
|
|
ctx->m = modes[ctx->mode]; |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", ctx->m.mode_name); |
|
|
|
|
av_log(avctx, AV_LOG_DEBUG, "Mode: %s\n", modes[ctx->mode].mode_name); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < LP_FILTER_ORDER; i++) |
|
|
|
|
ctx->lsp_history[i] = cos((i+1) * M_PI / (LP_FILTER_ORDER + 1)); |
|
|
|
@ -560,12 +559,13 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap, |
|
|
|
|
SiprContext *ctx = avctx->priv_data; |
|
|
|
|
const uint8_t *buf=avpkt->data; |
|
|
|
|
SiprParameters parm; |
|
|
|
|
const SiprModeParam *mode_par = &modes[ctx->mode]; |
|
|
|
|
GetBitContext gb; |
|
|
|
|
float *data = datap; |
|
|
|
|
int i; |
|
|
|
|
|
|
|
|
|
ctx->avctx = avctx; |
|
|
|
|
if (avpkt->size < (ctx->m.bits_per_frame >> 3)) { |
|
|
|
|
if (avpkt->size < (mode_par->bits_per_frame >> 3)) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
|
"Error processing packet: packet size (%d) too small\n", |
|
|
|
|
avpkt->size); |
|
|
|
@ -573,7 +573,7 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap, |
|
|
|
|
*data_size = 0; |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
if (*data_size < SUBFR_SIZE * ctx->m.subframe_count * sizeof(float)) { |
|
|
|
|
if (*data_size < SUBFR_SIZE * mode_par->subframe_count * sizeof(float)) { |
|
|
|
|
av_log(avctx, AV_LOG_ERROR, |
|
|
|
|
"Error processing packet: output buffer (%d) too small\n", |
|
|
|
|
*data_size); |
|
|
|
@ -582,19 +582,19 @@ static int sipr_decode_frame(AVCodecContext *avctx, void *datap, |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
init_get_bits(&gb, buf, ctx->m.bits_per_frame); |
|
|
|
|
init_get_bits(&gb, buf, mode_par->bits_per_frame); |
|
|
|
|
|
|
|
|
|
for (i = 0; i < ctx->m.frames_per_packet; i++) { |
|
|
|
|
decode_parameters(&parm, &gb, &ctx->m); |
|
|
|
|
for (i = 0; i < mode_par->frames_per_packet; i++) { |
|
|
|
|
decode_parameters(&parm, &gb, mode_par); |
|
|
|
|
decode_frame(ctx, &parm, data); |
|
|
|
|
|
|
|
|
|
data += SUBFR_SIZE * ctx->m.subframe_count; |
|
|
|
|
data += SUBFR_SIZE * mode_par->subframe_count; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
*data_size = ctx->m.frames_per_packet * SUBFR_SIZE * |
|
|
|
|
ctx->m.subframe_count * sizeof(float); |
|
|
|
|
*data_size = mode_par->frames_per_packet * SUBFR_SIZE * |
|
|
|
|
mode_par->subframe_count * sizeof(float); |
|
|
|
|
|
|
|
|
|
return ctx->m.bits_per_frame >> 3; |
|
|
|
|
return mode_par->bits_per_frame >> 3; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
AVCodec sipr_decoder = { |
|
|
|
|