[FFmpeg-devel] [PATCH 2/2] ac3enc: add SIMD-optimized shifting functions for use with the fixed-point AC3 encoder.

Michael Niedermayer michaelni
Sat Mar 12 13:25:50 CET 2011


On Sat, Mar 12, 2011 at 11:40:04AM +0000, M?ns Rullg?rd wrote:
> Ivan Kalvachev <ikalvachev at gmail.com> writes:
> 
> > On 3/12/11, M?ns Rullg?rd <mans at mansr.com> wrote:
> >> Justin Ruggles <justin.ruggles at gmail.com> writes:
> >>
> >>> ---
> >>>  libavcodec/ac3dsp.c         |   24 +++++++++++++++++++++
> >>>  libavcodec/ac3dsp.h         |   22 +++++++++++++++++++
> >>>  libavcodec/ac3enc_fixed.c   |   40 ++---------------------------------
> >>>  libavcodec/x86/ac3dsp.asm   |   48
> >>> +++++++++++++++++++++++++++++++++++++++++++
> >>>  libavcodec/x86/ac3dsp_mmx.c |   12 ++++++++++
> >>>  5 files changed, 109 insertions(+), 37 deletions(-)
> >>>
> >>>
> >>> diff --git a/libavcodec/ac3dsp.c b/libavcodec/ac3dsp.c
> >>> index da3a123..83f48a6 100644
> >>> --- a/libavcodec/ac3dsp.c
> >>> +++ b/libavcodec/ac3dsp.c
> >>> @@ -50,10 +50,34 @@ static int ac3_max_msb_abs_int16_c(const int16_t *src,
> >>> int len)
> >>>      return v;
> >>>  }
> >>>
> >>> +static void ac3_lshift_int16_c(int16_t *src, unsigned int len,
> >>> +                               unsigned int shift)
> >>> +{
> >>> +    int i;
> >>> +
> >>> +    if (shift > 0) {
> >>> +        for (i = 0; i < len; i++)
> >>> +            src[i] <<= shift;
> >>> +    }
> >>> +}
> >
> > You can shift 2 values at once if you read them as int32_t, shift and
> > then mask (masking could even be skipped if you are sure they will
> > never overflow).

These are signed values, you cannot skip the mask sadly


> 
> There's no point optimising the C version beyond comprehension.  We have
> the asm hooks for that.

We can keep the simple & understandable variant though i see no need for it.
Still if we can make the
C code 2x as fast we should, we dont have asm for every C function and every
cpu architecture.

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

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20110312/6d17e1a2/attachment.pgp>



More information about the ffmpeg-devel mailing list