changeset 10872:a4fbfc917c2e libavcodec

Remove the struct SiprModeParam of the context. This will simplify splitting the file for future 16k mode decoder code.
author vitor
date Wed, 13 Jan 2010 04:29:55 +0000
parents c06d95ce2db0
children fb42dfc877cc
files sipr.c
diffstat 1 files changed, 17 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/sipr.c	Wed Jan 13 03:11:02 2010 +0000
+++ b/sipr.c	Wed Jan 13 04:29:55 2010 +0000
@@ -130,7 +130,6 @@
     AVCodecContext *avctx;
     DSPContext dsp;
 
-    SiprModeParam m;
     SiprMode mode;
 
     float past_pitch_gain;
@@ -410,7 +409,8 @@
                          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 @@
     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 @@
         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 @@
            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 @@
     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 @@
     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 @@
         *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 @@
         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 = {