[FFmpeg-devel] [PATCH] NellyMoser audio decoder v2
Michael Niedermayer
michaelni
Thu Sep 13 18:38:04 CEST 2007
Hi
On Thu, Sep 13, 2007 at 05:49:28PM +0200, Lo?c Minier wrote:
> On Thu, Sep 13, 2007, Michael Niedermayer wrote:
> > > > > +void nelly_util_floats2shorts(float audio[256], short shorts[256])
> > > > duplicate of the respective code in dsputil
> > > Hmm replacing nelly_util_floats2shorts() with ff_float_to_int16_c()
> > > ended in some garbage.
> > read the fine manual (
> > /* C version: convert floats from the range [384.0,386.0] to ints in [-32768,32767]
> > * simd versions: convert floats from [-32768.0,32767.0] without rescaling and arrays are 16byte aligned */
> > void (*float_to_int16)(int16_t *dst, const float *src, int len);
> > )
> > it clearly says [384.0,386.0] -> [-32768,32767] for C
>
> I tried replacing:
> nelly_util_floats2shorts(s->float_buf, data);
>
> with:
> dsputil_init(&s->dsp, avctx);
> if (s->dsp.float_to_int16 == ff_float_to_int16_c) {
> s->add_bias = 385.0f;
> s->div_bias = 32767.0f;
> } else {
> s->add_bias = 0.0f;
> s->div_bias = 1.0f;
> }
> [...]
> for (i=0; i<NELLY_SAMPLE_SIZE; i++) {
> s->float_buf[i] /= s->div_bias;
> s->float_buf[i] += s->add_bias;
> }
> s->dsp.float_to_int16(data, s->float_buf, NELLY_SAMPLE_SIZE);
>
> but this distorted some samples; I guess there are small rounding
+-1 doesnt matter even less so as the original code does not round
correctly
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Breaking DRM is a little like attempting to break through a door even
though the window is wide open and the only thing in the house is a bunch
of things you dont want and which you would get tomorrow for free anyway
-------------- 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/20070913/24a5500c/attachment.pgp>
More information about the ffmpeg-devel
mailing list