[FFmpeg-devel] [PATCH] ARMv6 optimised VP3 loop filter

Måns Rullgård mans
Wed Jun 30 15:17:24 CEST 2010


David Conrad <lessen42 at gmail.com> writes:

> 10% faster overall on a 1g ipod touch
> ---
>  libavcodec/Makefile                 |    3 +
>  libavcodec/arm/dsputil_init_armv6.c |    8 ++
>  libavcodec/arm/vp3dsp_armv6.S       |  126 +++++++++++++++++++++++++++++++++++
>  3 files changed, 137 insertions(+), 0 deletions(-)
>  create mode 100644 libavcodec/arm/vp3dsp_armv6.S
>
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index 0b58459..6108d30 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -610,9 +610,12 @@ OBJS-$(HAVE_ARMV5TE)                   += arm/dsputil_init_armv5te.o    \
>                                            arm/mpegvideo_armv5te_s.o     \
>                                            arm/simple_idct_armv5te.o     \
>
> +ARMV6-OBJS-$(CONFIG_VP3_DECODER)       += arm/vp3dsp_armv6.o
> +
>  OBJS-$(HAVE_ARMV6)                     += arm/dsputil_init_armv6.o      \
>                                            arm/dsputil_armv6.o           \
>                                            arm/simple_idct_armv6.o       \
> +                                          $(ARMV6-OBJS-yes)
>
>  OBJS-$(HAVE_ARMVFP)                    += arm/dsputil_vfp.o             \
>                                            arm/dsputil_init_vfp.o        \

OK

> diff --git a/libavcodec/arm/dsputil_init_armv6.c b/libavcodec/arm/dsputil_init_armv6.c
> index 3209062..2d7a354 100644
> --- a/libavcodec/arm/dsputil_init_armv6.c
> +++ b/libavcodec/arm/dsputil_init_armv6.c
> @@ -70,6 +70,9 @@ int ff_sse16_armv6(void *s, uint8_t *blk1, uint8_t *blk2,
>  int ff_pix_norm1_armv6(uint8_t *pix, int line_size);
>  int ff_pix_sum_armv6(uint8_t *pix, int line_size);
>
> +void ff_vp3_v_loop_filter_armv6(uint8_t *, int, int *);
> +void ff_vp3_h_loop_filter_armv6(uint8_t *, int, int *);
> +
>  void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
>  {
>      if (!avctx->lowres && (avctx->idct_algo == FF_IDCT_AUTO ||
> @@ -118,4 +121,9 @@ void av_cold ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx)
>
>      c->pix_norm1 = ff_pix_norm1_armv6;
>      c->pix_sum   = ff_pix_sum_armv6;
> +
> +    if (CONFIG_VP3_DECODER) {
> +        c->vp3_v_loop_filter = ff_vp3_v_loop_filter_armv6;
> +        c->vp3_h_loop_filter = ff_vp3_h_loop_filter_armv6;
> +    }
>  }

OK

> diff --git a/libavcodec/arm/vp3dsp_armv6.S b/libavcodec/arm/vp3dsp_armv6.S
> new file mode 100644
> index 0000000..3d751e6
> --- /dev/null
> +++ b/libavcodec/arm/vp3dsp_armv6.S
> @@ -0,0 +1,126 @@
> +/*
> + * Copyright (c) 2010 David Conrad
> + *
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "asm.S"
> +
> +.text
> +
> +// ((p0 - p3) + 3*(p2 - p1) + 4) >> 3 has range -127, 128
> +// so we instead calculate the negative, so it fits in signed 8 bits
> +
> +function ff_vp3_v_loop_filter_armv6, export=1
> +    push    {r4-r10,lr}
> +    sub     r0,  r0,  r1
> +    ldr     r2,  [r2, #129*4]
> +    ldr     r3,  =0x030003
> +    ldr     ip,  =0xff00ff

MOV immediate and shift is probably faster.

Looks OK otherwise.

-- 
M?ns Rullg?rd
mans at mansr.com



More information about the ffmpeg-devel mailing list