[FFmpeg-devel] Nellymoser encoder

Bartlomiej Wolowiec bartek.wolowiec
Fri Aug 29 15:11:59 CEST 2008


Friday 29 August 2008 00:02:36 Michael Niedermayer napisa?(a):
> > +#define LUT_init_add -3134
> > +#define LUT_init_size 31355 + LUT_init_add
> > +static int LUT_init_table[LUT_init_size];
>
> i do not belive that the table needs to be that large
>
> > +
> > +#define LUT_delta_add 11725
> > +#define LUT_delta_size 12975 + LUT_delta_add
> > +static int LUT_delta_table[LUT_delta_size];
> > +
> > +#define LUT_dequantization_mul 128.0
> > +#define LUT_dequantization_add LUT_dequantization_mul * 2.7
> > +#define LUT_dequantization_size (int)(LUT_dequantization_mul * 2.5 +
> > LUT_dequantization_add) +#define LUT_dequantization_maxbits 6
> > +static int
> > LUT_dequantization_table[LUT_dequantization_maxbits][LUT_dequantization_s
> >ize];
>
> neither do i belive that this one needs to be that large
> besides they both can be uint8_t instead of int
>
> and the tables for fewer bits dont need to be as large as the largest

Ok, I've tried to change sizes of these arrays. Unfortunately, now I have a 
problem, because I don't know how I can simply allocate memory for 
LUT_dequantization_table so that the whole is thread-safety.

> > +
> > +void apply_mdct(NellyMoserEncodeContext *s, float *in, float *coefs)
> > +{
> > +    DECLARE_ALIGNED_16(float, in_buff[NELLY_SAMPLES]);
> > +
> > +    memcpy(&in_buff[0], &in[0], NELLY_SAMPLES * sizeof(float));
> > +    s->dsp.vector_fmul(in_buff, ff_sine_128, NELLY_BUF_LEN);
> > +    s->dsp.vector_fmul_reverse(in_buff + NELLY_BUF_LEN, in_buff +
> > NELLY_BUF_LEN, ff_sine_128, NELLY_BUF_LEN); +   
> > ff_mdct_calc(&s->mdct_ctx, coefs, in_buff);
> > +}
>
> The data is copied once in encode_frame and twice here
> There is no need to copy the data 3 times.
> vector_fmul can be used with a singl memcpy to get the data into any
> destination, and vector_fmul_reverse doesnt even need 1 memcpy, so
> overall a single memcpy is enough
>
>

Hope that you meant something similar to my solution.

> [...]
>
> > +#define find_best(val, table, LUT, LUT_add, LUT_mul, LUT_size) \
> > +    best_idx = \
> > +        LUT[av_clip (lrintf(val * LUT_mul + LUT_add), 0, LUT_size - 1)];
> > \ +    if (fabs(val - table[best_idx]) > fabs(val - table[best_idx + 1]))
> > \ +        best_idx++;
>
> this can be an inline function which would be cleaner
>
>
> [...]

it's possible, but I don't know how to do it, because table may have float 
type, uint16_t or int16_t

-- 
Bartlomiej Wolowiec
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nellymoser3.patch
Type: text/x-diff
Size: 12793 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20080829/a2aecf50/attachment.patch>



More information about the ffmpeg-devel mailing list