[FFmpeg-soc] [soc]AMR-WB decoder branch, master, updated.
Marcelo Póvoa
marspeoplester at gmail.com
Fri Jul 2 22:49:27 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 ae42363624c0c0379bd2dc754801bdec55eb216e (commit)
from 18bd5b400745788b6f7bc40dafc0c2c1d9ebdc28 (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 ae42363624c0c0379bd2dc754801bdec55eb216e
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date: Fri Jul 2 17:45:40 2010 -0300
Calculate first adaptive codebook vector (v1)
diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index 35e3060..5e4f62e 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -24,9 +24,12 @@
#include <stdint.h>
-#define LP_ORDER 16 ///< linear predictive coding filter order
-#define MIN_ISF_SPACING 50.0 /* Taken from fixed-point 26.173, not sure */
-#define PRED_FACTOR (1.0/3.0)
+#define LP_ORDER 16 ///< linear predictive coding filter order
+#define MIN_ISF_SPACING 50.0 /* Taken from fixed-point 26.173, not sure */
+#define PRED_FACTOR (1.0/3.0)
+
+#define AMRWB_SUBFRAME_SIZE 64 ///< samples per subframe
+#define PITCH_MAX 231 ///< maximum received pitch delay value
/* Mode ordering is sensitive, do not change */
enum Mode {
@@ -1597,6 +1600,28 @@ static const int16_t isp_init[LP_ORDER] = {
-6393, -12540, -18205, -23170, -27246, -30274, -32138, 1475
};
+/* 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
+};
+
/* Core frame sizes in each mode */
static const uint16_t cf_sizes_wb[] = {
132, 177, 253, 285, 317, 365, 397, 461, 477,
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 68a5d91..827b0d5 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -22,24 +22,30 @@
#include "avcodec.h"
#include "get_bits.h"
#include "lsp.h"
+#include "acelp_filters.h"
#include "amrwbdata.h"
typedef struct {
- AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
- enum Mode fr_cur_mode; ///< mode index of current frame
- uint8_t fr_quality; ///< frame quality index (FQI)
- uint8_t fr_mode_ind; ///< mode indication field
- uint8_t fr_mode_req; ///< mode request field
- uint8_t fr_crc; ///< crc for class A bits
- float isf_quant[LP_ORDER]; ///< quantized ISF vector from current frame
- float isf_q_past[LP_ORDER]; ///< quantized ISF vector of the previous frame
- double isp[4][LP_ORDER]; ///< ISP vectors from current frame
- double isp_sub4_past[LP_ORDER]; ///< ISP vector for the 4th subframe of the previous frame
+ AMRWBFrame frame; ///< AMRWB parameters decoded from bitstream
+ enum Mode fr_cur_mode; ///< mode index of current frame
+ uint8_t fr_quality; ///< frame quality index (FQI)
+ uint8_t fr_mode_ind; ///< mode indication field
+ uint8_t fr_mode_req; ///< mode request field
+ uint8_t fr_crc; ///< crc for class A bits
+ float isf_quant[LP_ORDER]; ///< quantized ISF vector from current frame
+ float isf_q_past[LP_ORDER]; ///< quantized ISF vector of the previous frame
+ double isp[4][LP_ORDER]; ///< ISP vectors from current frame
+ double isp_sub4_past[LP_ORDER]; ///< ISP vector for the 4th subframe of the previous frame
- float lp_coef[4][LP_ORDER]; ///< Linear Prediction Coefficients from ISP vector
+ float lp_coef[4][LP_ORDER]; ///< Linear Prediction Coefficients from ISP vector
- uint8_t base_pitch_lag; ///< integer part of pitch lag for next relative subframe
+ uint8_t base_pitch_lag; ///< integer part of pitch lag for next relative subframe
+
+ float excitation_buf[PITCH_MAX + LP_ORDER + 1 + AMRWB_SUBFRAME_SIZE]; ///< current excitation and all necessary excitation history
+ float *excitation; ///< points to current excitation in excitation_buf[]
+
+ float pitch_vector[AMRWB_SUBFRAME_SIZE]; ///< adaptive codebook (pitch) vector for current subframe
} AMRWBContext;
static int amrwb_decode_init(AVCodecContext *avctx)
@@ -288,7 +294,7 @@ static void isp2lp(double isp[LP_ORDER], float *lp, int lp_half_order) {
/**
* Decode a adaptive codebook index into pitch lag (except 6k60, 8k85 modes)
- * Calculate (nearest) integer lag and fractional lag using 1/4 resolution
+ * Calculate (nearest) integer lag and fractional lag always using 1/4 resolution
* In 1st and 3rd subframes index is relative to last subframe integer lag
*
* @param lag_int [out] Decoded integer pitch lag
@@ -384,6 +390,17 @@ static void decode_pitch_vector(AMRWBContext *ctx,
} else
decode_pitch_lag_high(&pitch_lag_int, &pitch_lag_frac, amr_subframe->adap,
&ctx->base_pitch_lag, subframe);
+
+ pitch_lag_int += pitch_lag_frac > 0;
+
+ /* Calculate the pitch vector by interpolating the past excitation at the
+ pitch lag using a hamming windowed sinc function. */
+ ff_acelp_interpolatef(ctx->excitation, ctx->excitation + 1 - pitch_lag_int,
+ ac_inter, 4,
+ pitch_lag_frac + 4 - 4*(pitch_lag_frac > 0),
+ LP_ORDER, AMRWB_SUBFRAME_SIZE);
+
+ memcpy(ctx->pitch_vector, ctx->excitation, AMRWB_SUBFRAME_SIZE * sizeof(float));
}
static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
-----------------------------------------------------------------------
Summary of changes:
libavcodec/amrwbdata.h | 31 ++++++++++++++++++++++++++++---
libavcodec/amrwbdec.c | 43 ++++++++++++++++++++++++++++++-------------
2 files changed, 58 insertions(+), 16 deletions(-)
hooks/post-receive
--
AMR-WB decoder
More information about the FFmpeg-soc
mailing list