[FFmpeg-devel] [PATCH] audio conversion clipping/overflows

Michael Niedermayer michaelni
Tue Mar 30 01:07:03 CEST 2010


On Sat, Mar 27, 2010 at 12:19:56PM -0400, Ronald S. Bultje wrote:
> Hi,
> 
> On Tue, Mar 16, 2010 at 12:02 PM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Tue, Mar 16, 2010 at 11:35:27AM -0400, Ronald S. Bultje wrote:
> >> Fixed in attached. Output is same. I'm still not sure if the
> >> interleaving-loops or history-related memcpy()s can be prevented, but
> >> am open to suggestions on how to achieve the same result without
> >> memcpy()s/loops.
> >
> > AVFrame get_buffer/release_buffer like we do for video can surely prevent
> > the copies in severak ways.
> > return pointer to internal buffer or require get_buffer to allocate suffiient
> > space prior to [0]
> 
> Yeah, I think this is a bad idea so (as you might've noticed from my
> patches) I'm trying to change this for the better and directly write
> into the output buffer.
> 
> My only problem case right now is atrac1 and wmaprodec, which do
> in-place interleaving. I'm not qualified to improve that, someone with
> actual DSP knowledge should do that.

add a FIXME comment to them


[...]
> @@ -226,14 +226,20 @@
>          else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32,  *(const int32_t*)pi)
>          else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_S32,  *(const int32_t*)pi*(1.0 / (1<<31)))
>          else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32,  *(const int32_t*)pi*(1.0 / (1<<31)))
> -        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<7)) + 0x80)
> -        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<15)))
> -        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<31)))
> +        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT,
> +                  av_clip_uint8(lrintf(*(const float*)pi * (1<<7)) + 0x80))
> +        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT,
> +                  av_clip_int16(lrintf(*(const float*)pi * (1<<15))))
> +        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT,
> +                  av_clipl_int32(llrintf(*(const float*)pi * (1<<31))))

i prefer keeping the linebreaking consistemt, aka none.

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

Many things microsoft did are stupid, but not doing something just because
microsoft did it is even more stupid. If everything ms did were stupid they
would be bankrupt already.
-------------- 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/20100330/3aec97e2/attachment.pgp>



More information about the ffmpeg-devel mailing list