[FFmpeg-devel] [PATCH 2/2] Add SIPR decoder for 5k0, 6k5 and 8k5 modes

Michael Niedermayer michaelni
Sat Dec 19 06:21:41 CET 2009


On Fri, Dec 18, 2009 at 06:07:45PM +0100, Vitor Sessak wrote:
> Diego Biurrun wrote:
>> On Fri, Dec 18, 2009 at 05:52:13PM +0100, Vitor Sessak wrote:
>>> --- libavcodec/sipr.c	(revision 0)
>>> +++ libavcodec/sipr.c	(revision 0)
>>> @@ -0,0 +1,611 @@
>>> +typedef struct
>>> +{
>> { on the same line
>
> fixed
>
>>> +            ff_celp_lp_synthesis_filterf(
>>> +                ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i*subsize,
>>> +                pAz, excitation, L_SUBFR_SIPR, LP_FILTER_ORDER);
>> ugly formatting
>
> What do you suggest? Splitting the sum in two lines or passing the 80-char 
> limit?
>
>>> +            float energy = ff_dot_productf(
>>> +                ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * subsize,
>>> +                ctx->postfilter_syn5k0 + LP_FILTER_ORDER + i * subsize,
>>> +                L_SUBFR_SIPR);
>> again
>
> same
>
>>> +    ff_acelp_apply_order_2_transfer_function(
>>> +        synth,
>>> +        (const float[2])  {-1.99997   , 1.},
>>> +        (const float[2])  {-1.93307352, 0.935891986},
>>> +        0.939805806, ctx->ymem, frame_size);
>> ditto
>
> Gave a try to a different formatting.
>
> Here is a new patch with these and a few other minor cosmetics fixed.

[...]
> +typedef struct {
> +    const char *mode_name;
> +    uint16_t bits_per_frame;

> +    uint8_t subframe_size;

constant?


> +    uint8_t subframe_count;
> +    uint8_t frames_per_packet;

> +    float treshpit;

treshpit ?


> +
> +    /* bitstream parameters */
> +    uint8_t number_of_fc_indexes;
> +
> +    /** size in bits of the i-th stage vector of quantizer */
> +    uint8_t vq_indexes_bits[5];
> +
> +    /** size in bits of the adaptive-codebook index for every subframe */
> +    uint8_t pitch_delay_bits[5];
> +
> +    uint8_t gp_index_bits;
> +    uint8_t fc_index_bits[10]; ///< size in bits of the fixed codebook indexes

> +    uint8_t gc_index_bits; ///< size in bits of the gain codebook indexes

always 7 ?


[...]
> +static void dequant(float *out, const int *idx, const float *cbs[])
> +{
> +    int i;
> +
> +    int stride  = 2;
> +    int num_vec = 5;
> +
> +    for (i = 0; i < num_vec; i++)
> +        memcpy(out + stride*i, cbs[i] + stride*idx[i], stride*sizeof(float));

you dont need local vars for constants

[...]
> +static void sipr_decode_lp(float *lsfnew, const float *lsfold, float *Az,
> +                           int num_subfr, int filter_order)
> +{
> +    float *pAz = Az;
> +    double lsfint[filter_order];
> +    int i,j;
> +    float t, t0 = 1.0 / num_subfr;
> +

> +    t = t0/2;

*0.5 divide is slow and gcc not trustworthy

filter_order seems constant so why pass it into the func?


> +    for (i = 0; i < num_subfr; i++) {
> +        for (j = 0; j < filter_order; j++)
> +            lsfint[j] = lsfold[j] * (1 - t) + t * lsfnew[j];
> +
> +        lsp2lpc_sipr(lsfint, pAz, filter_order);
> +        pAz += filter_order;
> +        t += t0;
> +    }
> +}
> +
> +/**
> + * Evaluate the adaptative impulse response
> + */

> +static void eval_ir(const float *Az, int pitch_lag, float *freq,
> +                    float treshpit, int length)
> +{
> +    float tmp1[L_SUBFR_SIPR+1], tmp2[LP_FILTER_ORDER+1];
> +    int i;
> +
> +    tmp1[0] = 1.;
> +    for (i = 0; i < LP_FILTER_ORDER; i++) {
> +        tmp1[i+1] = Az[i] * ff_pow_0_55[i];
> +        tmp2[i  ] = Az[i] * ff_pow_0_7 [i];
> +    }
> +    memset(tmp1 + 11, 0, 37*sizeof(float));
> +
> +    ff_celp_lp_synthesis_filterf(freq, tmp2, tmp1, L_SUBFR_SIPR,
> +                                 LP_FILTER_ORDER);
> +
> +    pitch_sharpening(length, pitch_lag, treshpit, freq);
[...]
> +    for (i = 0; i < LP_FILTER_ORDER; i++) {
> +        lpc_d[i] = lpc[i] * ff_pow_0_75[i];
> +        lpc_n[i] = lpc[i] *    pow_0_5 [i];
> +    };
> +
> +    memcpy(pole_out - LP_FILTER_ORDER, ctx->postfilter_mem,
> +           LP_FILTER_ORDER*sizeof(float));
> +
> +    ff_celp_lp_synthesis_filterf(pole_out, lpc_d, samples, L_SUBFR_SIPR,
> +                                 LP_FILTER_ORDER);

looks somewhat similar, dunno if it can be factorized ...


[...]
> +static float lsf_cb5[32][2] = {

const

[...]
> +static float pred[4] = {

const

and i assume you checked that these tables are not duplicates from other
similar codecs?

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Incandescent light bulbs waste a lot of energy as heat so the EU forbids them.
Their replacement, compact fluorescent lamps, much more expensive, dont fit in
many old lamps, flicker, contain toxic mercury, produce a fraction of the light
that is claimed and in a unnatural spectrum rendering colors different than
in natural light. Ah and we now need to turn the heaters up more in winter to
compensate the lower wasted heat. Who wins? Not the environment, thats for sure
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20091219/c91fd0b6/attachment.pgp>



More information about the ffmpeg-devel mailing list