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

Marcelo Póvoa marspeoplester at gmail.com
Wed Jul 28 05:32:34 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  9af5752cd7ed98e7bfbc0f6bd2d17b345f22278a (commit)
       via  f38e5de8f3cf8bb0f83c9440cbb7bd1f74184cdb (commit)
      from  4e9169a62e5fdb901d0f1a0a4a85613b575e7b2f (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 9af5752cd7ed98e7bfbc0f6bd2d17b345f22278a
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Wed Jul 28 00:28:42 2010 -0300

    Correct past synthesized samples memory, separating between
    filtered and not filtered (directly from synthesis)

diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index 46a97ff..8db1617 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -27,7 +27,8 @@
 #define LP_ORDER              16               ///< linear predictive coding filter order
 #define LP_ORDER_16k          20               ///< lpc filter order at 16kHz
 #define UPS_FIR_SIZE          12               ///< upsampling filter size
-#define SAMPLE_MEM            24               ///< number of stored past samples given by
+#define UPS_MEM_SIZE          2 * UPS_FIR_SIZE
+//#define SAMPLE_MEM            24               ///< number of stored past samples given by
                                                ///< max(LP_ORDER, UPS_FIR_SIZE * 2)
 #define MIN_ISF_SPACING       (128 / 32768.0)  ///< minimum isf gap
 #define PRED_FACTOR           (1.0 / 3.0)
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index c7787af..3f3faf4 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -72,10 +72,11 @@ typedef struct {
     uint8_t                    prev_ir_filter_nr; ///< previous impulse response filter "impNr": 0 - strong, 1 - medium, 2 - none
     float                           prev_tr_gain; ///< previous initial gain used by noise enhancer for thresold
 
-    float samples_in[SAMPLE_MEM + AMRWB_SUBFRAME_SIZE]; ///< lower band floating point samples at 12.8kHz
+    float samples_az[LP_ORDER + AMRWB_SUBFRAME_SIZE]; ///< lower band samples from synthesis at 12.8kHz
+    float samples_up[UPS_MEM_SIZE + AMRWB_SUBFRAME_SIZE]; ///< lower band samples processed for upsampling at 12.8kHz
 
-    float                           demph_mem[1]; ///< previous value in the de-emphasis filter
     float          hpf_31_mem[4], hpf_400_mem[4]; ///< previous values in the high-pass filters
+    float                           demph_mem[1]; ///< previous value in the de-emphasis filter
 
     AVLFG                                   prng; ///< random number generator for white noise excitation
     uint8_t                          first_frame; ///< flag active during decoding of the first frame
@@ -912,20 +913,21 @@ static void synthesis(AMRWBContext *ctx, float *lpc, float *excitation,
  * Apply to synthesis a de-emphasis filter of the form:
  * H(z) = 1 / (1 - m * z^-1)
  *
- * @param synth               [in/out] synthesized speech array
+ * @param out                 [out] output buffer
+ * @param in                  [in] input samples array with in[-1]
  * @param m                   [in] filter coefficient
- * @param mem                 [in] state from last filtering
+ * @param mem                 [in/out] state from last filtering
  */
-static void de_emphasis(float *synth, float m, float mem[1])
+static void de_emphasis(float *out, float *in, float m, float mem[1])
 {
     int i;
 
-    synth[0] += m * mem[0];
+    out[0] = in[0] + m * mem[0];
 
-    for (i = 0; i < AMRWB_SUBFRAME_SIZE; i++)
-        synth[i] += synth[i - 1] * m;
+    for (i = 1; i < AMRWB_SUBFRAME_SIZE; i++)
+         out[i] = in[i] + out[i - 1] * m;
 
-    mem[0] = synth[AMRWB_SUBFRAME_SIZE - 1];
+    mem[0] = out[AMRWB_SUBFRAME_SIZE - 1];
 }
 
 /**
@@ -981,7 +983,7 @@ static void upsample_5_4(float *out, const float *in, int o_size)
             out[i] = in[i];
         } else
             out[i] = ff_dot_productf(in0 + int_part, upsample_fir[4 - frac_part],
-                                     UPS_FIR_SIZE << 1);
+                                     UPS_MEM_SIZE);
 
         out[i] *= 2.0; // upscale output
     }
@@ -1094,8 +1096,10 @@ static void update_sub_state(AMRWBContext *ctx)
     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->samples_in[0], &ctx->samples_in[AMRWB_SUBFRAME_SIZE],
-            SAMPLE_MEM * sizeof(float));
+    memmove(&ctx->samples_az[0], &ctx->samples_az[AMRWB_SUBFRAME_SIZE],
+            LP_ORDER * sizeof(float));
+    memmove(&ctx->samples_up[0], &ctx->samples_up[AMRWB_SUBFRAME_SIZE],
+            UPS_MEM_SIZE * sizeof(float));
 }
 
 static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
@@ -1200,22 +1204,23 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
         pitch_enhancer(synth_fixed_vector, voice_fac);
 
         synthesis(ctx, ctx->lp_coef[sub], synth_exc, synth_fixed_gain,
-                  synth_fixed_vector, &ctx->samples_in[SAMPLE_MEM]);
+                  synth_fixed_vector, &ctx->samples_az[LP_ORDER]);
 
         /* Synthesis speech post-processing */
-        de_emphasis(&ctx->samples_in[SAMPLE_MEM], PREEMPH_FAC, ctx->demph_mem);
+        de_emphasis(&ctx->samples_up[UPS_MEM_SIZE],
+                    &ctx->samples_az[LP_ORDER], PREEMPH_FAC, ctx->demph_mem);
 
-        high_pass_filter(&ctx->samples_in[SAMPLE_MEM], hpf_31_coef,
-                         ctx->hpf_31_mem, &ctx->samples_in[SAMPLE_MEM]);
+        high_pass_filter(&ctx->samples_up[UPS_MEM_SIZE], hpf_31_coef,
+                         ctx->hpf_31_mem, &ctx->samples_up[UPS_MEM_SIZE]);
 
         upsample_5_4(buf_out + sub * AMRWB_SFR_SIZE_OUT,
-                     &ctx->samples_in[UPS_FIR_SIZE], AMRWB_SFR_SIZE_OUT);
+                     &ctx->samples_up[UPS_FIR_SIZE], AMRWB_SFR_SIZE_OUT);
 
         /* High frequency band generation */
-        high_pass_filter(&ctx->samples_in[SAMPLE_MEM], hpf_400_coef,
-                         ctx->hpf_400_mem, &ctx->samples_in[SAMPLE_MEM]);
+        high_pass_filter(&ctx->samples_up[UPS_MEM_SIZE], hpf_400_coef,
+                         ctx->hpf_400_mem, &ctx->samples_up[UPS_MEM_SIZE]);
 
-        hb_gain = find_hb_gain(ctx, &ctx->samples_in[SAMPLE_MEM],
+        hb_gain = find_hb_gain(ctx, &ctx->samples_up[UPS_MEM_SIZE],
                                cur_subframe->hb_gain, cf->vad);
 
         scaled_hb_excitation(ctx, hb_exc, synth_exc, hb_gain);

commit f38e5de8f3cf8bb0f83c9440cbb7bd1f74184cdb
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Wed Jul 28 00:26:04 2010 -0300

    Fix a bug in the sign of the decoded pulse index
    when its position was 0

diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index d7deb39..c7787af 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -584,7 +584,7 @@ static void decode_6p_track(int *out, int code, int m, int off)
 static void decode_fixed_sparse(AMRFixed *fixed_sparse, const uint16_t *pulse_hi,
                                 const uint16_t *pulse_lo, const enum Mode mode)
 {
-    /* sig_pos stores for each track the decoded pulse position
+    /* sig_pos stores for each track the decoded pulse position (1-based)
      * indexes multiplied by its corresponding amplitude (+1 or -1) */
     int sig_pos[4][6];
     int pulses_nb = 0;
@@ -594,51 +594,51 @@ static void decode_fixed_sparse(AMRFixed *fixed_sparse, const uint16_t *pulse_hi
     switch (mode) {
         case MODE_6k60:
             for (i = 0; i < 2; i++)
-                decode_1p_track(sig_pos[i], pulse_lo[i], 5, 0);
+                decode_1p_track(sig_pos[i], pulse_lo[i], 5, 1);
             break;
         case MODE_8k85:
             for (i = 0; i < 4; i++)
-                decode_1p_track(sig_pos[i], pulse_lo[i], 4, 0);
+                decode_1p_track(sig_pos[i], pulse_lo[i], 4, 1);
             break;
         case MODE_12k65:
             for (i = 0; i < 4; i++)
-                decode_2p_track(sig_pos[i], pulse_lo[i], 4, 0);
+                decode_2p_track(sig_pos[i], pulse_lo[i], 4, 1);
             break;
         case MODE_14k25:
             for (i = 0; i < 2; i++)
-                decode_3p_track(sig_pos[i], pulse_lo[i], 4, 0);
+                decode_3p_track(sig_pos[i], pulse_lo[i], 4, 1);
             for (i = 2; i < 4; i++)
-                decode_2p_track(sig_pos[i], pulse_lo[i], 4, 0);
+                decode_2p_track(sig_pos[i], pulse_lo[i], 4, 1);
             break;
         case MODE_15k85:
             for (i = 0; i < 4; i++)
-                decode_3p_track(sig_pos[i], pulse_lo[i], 4, 0);
+                decode_3p_track(sig_pos[i], pulse_lo[i], 4, 1);
             break;
         case MODE_18k25:
             for (i = 0; i < 4; i++)
                 decode_4p_track(sig_pos[i], (int) pulse_lo[i] +
-                               ((int) pulse_hi[i] << 14), 4, 0);
+                               ((int) pulse_hi[i] << 14), 4, 1);
             break;
         case MODE_19k85:
             for (i = 0; i < 2; i++)
                 decode_5p_track(sig_pos[i], (int) pulse_lo[i] +
-                               ((int) pulse_hi[i] << 10), 4, 0);
+                               ((int) pulse_hi[i] << 10), 4, 1);
             for (i = 2; i < 4; i++)
                 decode_4p_track(sig_pos[i], (int) pulse_lo[i] +
-                               ((int) pulse_hi[i] << 14), 4, 0);
+                               ((int) pulse_hi[i] << 14), 4, 1);
             break;
         case MODE_23k05:
         case MODE_23k85:
             for (i = 0; i < 4; i++)
                 decode_6p_track(sig_pos[i], (int) pulse_lo[i] +
-                               ((int) pulse_hi[i] << 11), 4, 0);
+                               ((int) pulse_hi[i] << 11), 4, 1);
             break;
     }
 
     for (i = 0; i < 4; i++)
         for (j = 0; j < pulses_nb_per_mode_tr[mode][i]; j++) {
             int pos = sig_pos[i][j];
-            fixed_sparse->x[pulses_nb] = FFABS(pos) * spacing + i;
+            fixed_sparse->x[pulses_nb] = (FFABS(pos) - 1) * spacing + i;
             fixed_sparse->y[pulses_nb] = pos < 0 ? -1.0 : 1.0;
             pulses_nb++;
         }

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

Summary of changes:
 libavcodec/amrwbdata.h |    3 +-
 libavcodec/amrwbdec.c  |   69 +++++++++++++++++++++++++----------------------
 2 files changed, 39 insertions(+), 33 deletions(-)


hooks/post-receive
-- 
AMR-WB decoder


More information about the FFmpeg-soc mailing list