[FFmpeg-soc] [soc]AMR-WB decoder branch, master, updated.

Marcelo Póvoa marspeoplester at gmail.com
Thu Jul 29 05:10:18 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "AMR-WB decoder".

The branch, master has been updated
       via  42461e43223b4da99bbfa00a08e844fa8d6acd85 (commit)
       via  0b3e35bc80eb44f58e222244e165a8edc89e031a (commit)
       via  33c6d2a788ee89d1340cecf89470ba1446db794c (commit)
       via  6bcfe4400dde8897b6095f076d0e71119aa14b09 (commit)
      from  5116d7f3e4f7d3dfb7436506d9d9771e3c0cf2a4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 42461e43223b4da99bbfa00a08e844fa8d6acd85
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Thu Jul 29 00:09:30 2010 -0300

    Bugfixes: Correct the fixed vector update and
    past excitation generation

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 3bd6e13..83303ed 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -427,15 +427,15 @@ static void decode_pitch_vector(AMRWBContext *ctx,
                               &ctx->base_pitch_lag, subframe);
 
     ctx->pitch_lag_int = pitch_lag_int + (pitch_lag_frac < 0 ? -1 : 0);
-    pitch_lag_int     += pitch_lag_frac > 0;
+    pitch_lag_int      = ctx->pitch_lag_int + (pitch_lag_frac ? 1 : 0);
 
     /* Calculate the pitch vector by interpolating the past excitation at the
        pitch lag using a hamming windowed sinc function. */
     /* XXX: Not tested yet, need to ensure correct excitation construction before */
     ff_acelp_interpolatef(exc, exc + 1 - pitch_lag_int,
                           ac_inter, 4,
-                          pitch_lag_frac + 4 - 4*(pitch_lag_frac > 0),
-                          LP_ORDER, AMRWB_SUBFRAME_SIZE);
+                          pitch_lag_frac + (pitch_lag_frac > 0 ? 0 : 4),
+                          LP_ORDER, AMRWB_SUBFRAME_SIZE + 1);
 
     /* Check which pitch signal path should be used.
      * 6k60 and 8k85 modes have the ltp flag set to 0 */
@@ -444,6 +444,7 @@ static void decode_pitch_vector(AMRWBContext *ctx,
     } else {
         for (i = 0; i < AMRWB_SUBFRAME_SIZE; i++)
             ctx->pitch_vector[i] = 0.18 * exc[i - 1] + 0.64 * exc[i] + 0.18 * exc[i + 1];
+        memcpy(exc, ctx->pitch_vector, AMRWB_SUBFRAME_SIZE * sizeof(float));
     }
 }
 
@@ -1100,6 +1101,8 @@ static void update_sub_state(AMRWBContext *ctx)
             LP_ORDER * sizeof(float));
     memmove(&ctx->samples_up[0], &ctx->samples_up[AMRWB_SUBFRAME_SIZE],
             UPS_MEM_SIZE * sizeof(float));
+
+    memset(ctx->fixed_vector, 0, AMRWB_SUBFRAME_SIZE * sizeof(float));
 }
 
 static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
@@ -1226,8 +1229,6 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         scaled_hb_excitation(ctx, hb_exc, synth_exc, hb_gain);
 
         /* Update buffers and history */
-        ff_clear_fixed_vector(ctx->fixed_vector, &fixed_sparse,
-                              AMRWB_SUBFRAME_SIZE);
         update_sub_state(ctx);
     }
 

commit 0b3e35bc80eb44f58e222244e165a8edc89e031a
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Thu Jul 29 00:05:15 2010 -0300

    Correct number of past fixed and pitch gains and
    modify their orderings for simplicity

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 35f74af..3bd6e13 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -63,8 +63,8 @@ typedef struct {
     float      fixed_vector[AMRWB_SUBFRAME_SIZE]; ///< algebraic codebook (fixed) vector
 
     float                    prediction_error[4]; ///< quantified prediction errors {20log10(^gamma_gc)} for previous four subframes
-    float                          pitch_gain[5]; ///< quantified pitch gains for the current and previous four subframes
-    float                          fixed_gain[5]; ///< quantified fixed gains for the current and previous four subframes
+    float                          pitch_gain[6]; ///< quantified pitch gains for the current and previous five subframes
+    float                          fixed_gain[2]; ///< quantified fixed gains for the current and previous subframes
 
     float                              tilt_coef; ///< {beta_1} related to the voicing of the previous subframe
 
@@ -729,22 +729,22 @@ static float *anti_sparseness(AMRWBContext *ctx,
     if (ctx->fr_cur_mode > MODE_8k85) // no filtering in high modes
         return fixed_vector;
 
-    if (ctx->pitch_gain[4] < 0.6) {
+    if (ctx->pitch_gain[0] < 0.6) {
         ir_filter_nr = 0;      // strong filtering
-    } else if (ctx->pitch_gain[4] < 0.9) {
+    } else if (ctx->pitch_gain[0] < 0.9) {
         ir_filter_nr = 1;      // medium filtering
     } else
         ir_filter_nr = 2;      // no filtering
 
     // detect 'onset'
-    if (ctx->fixed_gain[4] > 3.0 * ctx->fixed_gain[3]) {
+    if (ctx->fixed_gain[0] > 3.0 * ctx->fixed_gain[1]) {
         if (ir_filter_nr < 2)
             ir_filter_nr++;
     } else
     {
         int i, count = 0;
 
-        for (i = 0; i < 5; i++)
+        for (i = 0; i < 6; i++)
             if (ctx->pitch_gain[i] < 0.6)
                 count++;
         if (count > 2)
@@ -886,17 +886,17 @@ static void synthesis(AMRWBContext *ctx, float *lpc, float *excitation,
                      float *samples)
 {
     ff_weighted_vector_sumf(excitation, ctx->pitch_vector, fixed_vector,
-                            ctx->pitch_gain[4], fixed_gain, AMRWB_SUBFRAME_SIZE);
+                            ctx->pitch_gain[0], fixed_gain, AMRWB_SUBFRAME_SIZE);
 
     // emphasize pitch vector contribution in low bitrate modes
-    if (ctx->pitch_gain[4] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) {
+    if (ctx->pitch_gain[0] > 0.5 && ctx->fr_cur_mode <= MODE_8k85) {
         int i;
         float energy = ff_dot_productf(excitation, excitation,
                                        AMRWB_SUBFRAME_SIZE);
 
         // XXX: Weird part in both ref code and spec. A unknown parameter
         // {beta} seems to be identical to the current pitch gain
-        float pitch_factor = 0.25 * ctx->pitch_gain[4] * ctx->pitch_gain[4];
+        float pitch_factor = 0.25 * ctx->pitch_gain[0] * ctx->pitch_gain[0];
 
         for (i = 0; i < AMRWB_SUBFRAME_SIZE; i++)
             excitation[i] += pitch_factor * ctx->pitch_vector[i];
@@ -1093,8 +1093,8 @@ static void update_sub_state(AMRWBContext *ctx)
     memmove(&ctx->excitation_buf[0], &ctx->excitation_buf[AMRWB_SUBFRAME_SIZE],
             (AMRWB_P_DELAY_MAX + LP_ORDER + 1) * sizeof(float));
 
-    memmove(&ctx->pitch_gain[0], &ctx->pitch_gain[1], 4 * sizeof(float));
-    memmove(&ctx->fixed_gain[0], &ctx->fixed_gain[1], 4 * sizeof(float));
+    memmove(&ctx->pitch_gain[1], &ctx->pitch_gain[0], 5 * sizeof(float));
+    memmove(&ctx->fixed_gain[1], &ctx->fixed_gain[0], 1 * sizeof(float));
 
     memmove(&ctx->samples_az[0], &ctx->samples_az[AMRWB_SUBFRAME_SIZE],
             LP_ORDER * sizeof(float));
@@ -1165,11 +1165,11 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
                             cur_subframe->pul_il, ctx->fr_cur_mode);
 
         decode_gains(cur_subframe->vq_gain, ctx->fr_cur_mode,
-                     &fixed_gain_factor, &ctx->pitch_gain[4]);
+                     &fixed_gain_factor, &ctx->pitch_gain[0]);
 
         pitch_sharpening(ctx, &fixed_sparse, ctx->fixed_vector);
 
-        ctx->fixed_gain[4] =
+        ctx->fixed_gain[0] =
             ff_amr_set_fixed_gain(fixed_gain_factor,
                        ff_dot_productf(ctx->fixed_vector, ctx->fixed_vector,
                                        AMRWB_SUBFRAME_SIZE)/AMRWB_SUBFRAME_SIZE,
@@ -1177,22 +1177,22 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
                        ENERGY_MEAN, energy_pred_fac);
 
         /* Calculate voice factor and store tilt for next subframe */
-        voice_fac      = voice_factor(ctx->pitch_vector, ctx->pitch_gain[4],
-                                      ctx->fixed_vector, ctx->fixed_gain[4]);
+        voice_fac      = voice_factor(ctx->pitch_vector, ctx->pitch_gain[0],
+                                      ctx->fixed_vector, ctx->fixed_gain[0]);
         ctx->tilt_coef = voice_fac * 0.25 + 0.25;
 
         /* Construct current excitation */
         for (i = 0; i < AMRWB_SUBFRAME_SIZE; i++) {
-            ctx->excitation[i] *= ctx->pitch_gain[4];
+            ctx->excitation[i] *= ctx->pitch_gain[0];
             // XXX: Did not used ff_set_fixed_vector like AMR-NB in order
             // to retain pitch sharpening done to the fixed_vector
-            ctx->excitation[i] += ctx->fixed_gain[4] * ctx->fixed_vector[i];
+            ctx->excitation[i] += ctx->fixed_gain[0] * ctx->fixed_vector[i];
             // XXX: Should remove fractional part of excitation like NB?
             // I did not found a reference of this in the ref decoder
         }
 
         /* Post-processing of excitation elements */
-        synth_fixed_gain = noise_enhancer(ctx->fixed_gain[4], &ctx->prev_tr_gain,
+        synth_fixed_gain = noise_enhancer(ctx->fixed_gain[0], &ctx->prev_tr_gain,
                                           voice_fac, stab_fac);
 
         synth_fixed_vector = anti_sparseness(ctx, ctx->fixed_vector,

commit 33c6d2a788ee89d1340cecf89470ba1446db794c
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Wed Jul 28 23:18:35 2010 -0300

    Improve FIR interpolation table for better precision

diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index 0966e9c..acfb443 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -1626,23 +1626,23 @@ static const int16_t isf_init[LP_ORDER] = {
 /* Coefficients for FIR interpolation of excitation vector
  * at pitch lag resulting the adaptive codebook vector */
 static const float ac_inter[65] = {
-   0.940000,
-   0.856390,   0.632268,   0.337560,   0.059072,
-  -0.131059,  -0.199393,  -0.158569,  -0.056359,
-   0.047606,   0.106749,   0.103705,   0.052062,
-  -0.015182,  -0.063705,  -0.073660,  -0.046497,
-  -0.000983,   0.038227,   0.053143,   0.040059,
-   0.009308,  -0.021674,  -0.037767,  -0.033186,
-  -0.013028,   0.010702,   0.025901,   0.026318,
-   0.013821,  -0.003645,  -0.016813,  -0.019855,
-  -0.012766,  -0.000530,   0.010080,   0.014122,
-   0.010657,   0.002594,  -0.005363,  -0.009344,
-  -0.008101,  -0.003182,   0.002330,   0.005635,
-   0.005562,   0.002844,  -0.000627,  -0.002993,
-  -0.003362,  -0.002044,  -0.000116,   0.001315,
-   0.001692,   0.001151,   0.000259,  -0.000417,
-  -0.000618,  -0.000434,  -0.000133,   0.000063,
-   0.000098,   0.000048,   0.000007,   0.000000
+     9.400024e-01,
+     8.563843e-01,  6.322632e-01,  3.375854e-01,  5.908203e-02,
+    -1.310425e-01, -1.994019e-01, -1.585693e-01, -5.633545e-02,
+     4.760742e-02,  1.067505e-01,  1.036987e-01,  5.206299e-02,
+    -1.519775e-02, -6.372070e-02, -7.366943e-02, -4.650879e-02,
+    -9.765625e-04,  3.820801e-02,  5.316162e-02,  4.003906e-02,
+     9.338379e-03, -2.166748e-02, -3.778076e-02, -3.320312e-02,
+    -1.300049e-02,  1.068115e-02,  2.587891e-02,  2.630615e-02,
+     1.379395e-02, -3.662109e-03, -1.678467e-02, -1.983643e-02,
+    -1.275635e-02, -5.493164e-04,  1.007080e-02,  1.409912e-02,
+     1.068115e-02,  2.624512e-03, -5.371094e-03, -9.338379e-03,
+    -8.117676e-03, -3.173828e-03,  2.319336e-03,  5.615234e-03,
+     5.554199e-03,  2.868652e-03, -6.103516e-04, -2.990723e-03,
+    -3.356934e-03, -2.014160e-03, -1.220703e-04,  1.342773e-03,
+     1.708984e-03,  1.159668e-03,  2.441406e-04, -4.272461e-04,
+    -6.103516e-04, -4.272461e-04, -1.220703e-04,  6.103516e-05,
+     1.220703e-04,  6.103516e-05,  0.000000e+00,  0.000000e+00
 };
 
 /* [i][j] is the number of pulses present in track j at mode i */

commit 6bcfe4400dde8897b6095f076d0e71119aa14b09
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Wed Jul 28 23:17:45 2010 -0300

    Fix typos in the reordering tables for 12k65 mode

diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index 8db1617..0966e9c 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -175,40 +175,40 @@ static const uint16_t order_MODE_12k65[] = {
      9, AMR_OF(0, pul_il[3]), 112, 149, 181, 213, 245, 153, 185, 217,
                               249,
      7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
-     6,      AMR_OF(2, adap),  36,  49,  72,  77,  83,  98,
-     1,       AMR_OF(2, ltp), 106,
-     9, AMR_OF(2, pul_il[0]), 113, 126, 158, 190, 222, 130, 162, 194,
+     6,      AMR_OF(1, adap),  36,  49,  72,  77,  83,  98,
+     1,       AMR_OF(1, ltp), 106,
+     9, AMR_OF(1, pul_il[0]), 113, 126, 158, 190, 222, 130, 162, 194,
                               226,
-     9, AMR_OF(2, pul_il[1]), 114, 134, 166, 198, 230, 138, 170, 202,
+     9, AMR_OF(1, pul_il[1]), 114, 134, 166, 198, 230, 138, 170, 202,
                               234,
-     9, AMR_OF(2, pul_il[2]), 115, 142, 174, 206, 238, 146, 178, 210,
+     9, AMR_OF(1, pul_il[2]), 115, 142, 174, 206, 238, 146, 178, 210,
                               242,
-     9, AMR_OF(2, pul_il[3]), 116, 150, 182, 214, 246, 154, 186, 218,
+     9, AMR_OF(1, pul_il[3]), 116, 150, 182, 214, 246, 154, 186, 218,
                               250,
-     7,   AMR_OF(2, vq_gain),   4,  21,  43,  29,  33,  39,  25,
-     9,      AMR_OF(3, adap),  15,  16,  17,  18,  19,  51,  70,  80,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
+     9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
-     1,       AMR_OF(3, ltp), 107,
-     9, AMR_OF(3, pul_il[0]), 117, 127, 159, 191, 223, 131, 163, 195,
+     1,       AMR_OF(2, ltp), 107,
+     9, AMR_OF(2, pul_il[0]), 117, 127, 159, 191, 223, 131, 163, 195,
                               227,
-     9, AMR_OF(3, pul_il[1]), 118, 135, 167, 199, 231, 139, 171, 203,
+     9, AMR_OF(2, pul_il[1]), 118, 135, 167, 199, 231, 139, 171, 203,
                               235,
-     9, AMR_OF(3, pul_il[2]), 119, 143, 175, 207, 239, 147, 179, 211,
+     9, AMR_OF(2, pul_il[2]), 119, 143, 175, 207, 239, 147, 179, 211,
                               243,
-     9, AMR_OF(3, pul_il[3]), 120, 151, 183, 215, 247, 155, 187, 219,
+     9, AMR_OF(2, pul_il[3]), 120, 151, 183, 215, 247, 155, 187, 219,
                               251,
-     7,   AMR_OF(3, vq_gain),   5,  22,  44,  30,  34,  40,  26,
-     6,      AMR_OF(4, adap),  37,  50,  73,  78,  84,  99,
-     1,       AMR_OF(4, ltp), 108,
-     9, AMR_OF(4, pul_il[0]), 121, 128, 160, 192, 224, 132, 164, 196,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
+     6,      AMR_OF(3, adap),  37,  50,  73,  78,  84,  99,
+     1,       AMR_OF(3, ltp), 108,
+     9, AMR_OF(3, pul_il[0]), 121, 128, 160, 192, 224, 132, 164, 196,
                               228,
-     9, AMR_OF(4, pul_il[1]), 122, 136, 168, 200, 232, 140, 172, 204,
+     9, AMR_OF(3, pul_il[1]), 122, 136, 168, 200, 232, 140, 172, 204,
                               236,
-     9, AMR_OF(4, pul_il[2]), 123, 144, 176, 208, 240, 148, 180, 212,
+     9, AMR_OF(3, pul_il[2]), 123, 144, 176, 208, 240, 148, 180, 212,
                               244,
-     9, AMR_OF(4, pul_il[3]), 124, 152, 184, 216, 248, 156, 188, 220,
+     9, AMR_OF(3, pul_il[3]), 124, 152, 184, 216, 248, 156, 188, 220,
                               252,
-     7,   AMR_OF(4, vq_gain),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
 

-----------------------------------------------------------------------

Summary of changes:
 libavcodec/amrwbdata.h |   76 ++++++++++++++++++++++++------------------------
 libavcodec/amrwbdec.c  |   47 +++++++++++++++--------------
 2 files changed, 62 insertions(+), 61 deletions(-)


hooks/post-receive
-- 
AMR-WB decoder


More information about the FFmpeg-soc mailing list