[FFmpeg-soc] [PATCH] AMR-WB Decoder

Vitor Sessak vitor1001 at gmail.com
Sat Sep 11 17:37:01 CEST 2010


On 09/11/2010 04:47 PM, Marcelo Galvão Póvoa wrote:
> On 9 September 2010 16:11, Vitor Sessak<vitor1001 at gmail.com>  wrote:
>> On 09/07/2010 02:05 AM, Marcelo Galvão Póvoa wrote:
>>>
>>> On 6 September 2010 11:31, Vitor Sessak<vitor1001 at gmail.com>    wrote:
>>>>
>>>> On 09/06/2010 02:46 AM, Marcelo Galvăo Póvoa wrote:
>>>>>

[...]

>>>> Can celp_filters.c:ff_celp_circ_addf() simplify this?
>>>>
>>>
>>> I already gave some thought to that but I couldn't figure out how to
>>> use ff_celp_circ_addf() there. I wrote the algorithm the simplest way
>>> I could think of.
>>
>> Try
>>
>>         for (i = 0; i<  AMRWB_SFR_SIZE; i++)
>>             if (fixed_vector[i])
>>                 ff_celp_circ_addf(buf, buf, coef, i, fixed_vector[i],
>>                                   AMRWB_SFR_SIZE);
>>
>>
>
> That's right indeed, thanks!

> /*
>  * AMR wideband decoder
>  * Copyright (c) 2010 Marcelo Galvao Povoa
>  *
>  * This file is part of FFmpeg.
>  *
>  * FFmpeg is free software; you can redistribute it and/or
>  * modify it under the terms of the GNU Lesser General Public
>  * License as published by the Free Software Foundation; either
>  * version 2.1 of the License, or (at your option) any later version.
>  *
>  * FFmpeg is distributed in the hope that it will be useful,
>  * but WITHOUT ANY WARRANTY; without even the implied warranty of
>  * MERCHANTABILITY or FITNESS FOR A particular PURPOSE.  See the GNU
>  * Lesser General Public License for more details.
>  *
>  * You should have received a copy of the GNU Lesser General Public
>  * License along with FFmpeg; if not, write to the Free Software
>  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>  */
>
> #include "libavutil/lfg.h"
>
> #include "avcodec.h"
> #include "get_bits.h"
> #include "lsp.h"
> #include "celp_math.h"
> #include "celp_filters.h"
> #include "acelp_filters.h"
> #include "acelp_vectors.h"
> #include "acelp_pitch_delay.h"
>
> #include "amrwbdata.h"

No need to include amr.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)
>     float                      isf_cur[LP_ORDER]; ///< working ISF vector from current frame
>     float                   isf_q_past[LP_ORDER]; ///< quantized ISF vector of the previous frame
>     float               isf_past_final[LP_ORDER]; ///< final processed 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
>
>     uint8_t                       base_pitch_lag; ///< integer part of pitch lag for the next relative subframe
>     uint8_t                        pitch_lag_int; ///< integer part of pitch lag of the previous subframe
>
>     float excitation_buf[AMRWB_P_DELAY_MAX + LP_ORDER + 2 + AMRWB_SFR_SIZE]; ///< current excitation and all necessary excitation history
>     float                            *excitation; ///< points to current excitation in excitation_buf[]
>
>     float           pitch_vector[AMRWB_SFR_SIZE]; ///< adaptive codebook (pitch) vector for current subframe
>     float           fixed_vector[AMRWB_SFR_SIZE]; ///< algebraic codebook (fixed) vector for current subframe
>
>     float                    prediction_error[4]; ///< quantified prediction errors {20log10(^gamma_gc)} for 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
>
>     float                 prev_sparse_fixed_gain; ///< previous fixed gain; used by anti-sparseness to determine "onset"
>     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 threshold
>
>     float samples_az[LP_ORDER + AMRWB_SFR_SIZE];         ///< low-band samples and memory from synthesis at 12.8kHz
>     float samples_up[UPS_MEM_SIZE + AMRWB_SFR_SIZE];     ///< low-band samples and memory processed for upsampling
>     float samples_hb[LP_ORDER_16k + AMRWB_SFR_SIZE_16k]; ///< high-band samples and memory from synthesis at 16kHz
>

>     float          hpf_31_mem[4], hpf_400_mem[4]; ///< previous values in the high pass filters

I think now just two elements for the filter memory should be enough.

> diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
> new file mode 100644
> index 0000000..6344763
> --- /dev/null
> +++ b/libavcodec/amrwbdata.h

> /** [i][j] is the number of pulses present in track j at mode i */
> static const int pulses_nb_per_mode_tr[][4] = {
>     {1, 1, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2},
>     {3, 3, 2, 2}, {3, 3, 3, 3}, {4, 4, 4, 4},
>     {5, 5, 4, 4}, {6, 6, 6, 6}, {6, 6, 6, 6}
> };

uint8_t?

And I have no further comments :D

-Vitor


More information about the FFmpeg-soc mailing list