[FFmpeg-devel] [PATCH] Add prefetch for mips

Michael Niedermayer michael at niedermayer.cc
Wed Jul 12 05:19:44 EEST 2017


On Tue, Jul 11, 2017 at 12:18:59PM +0530, kaustubh.raste at imgtec.com wrote:
> From: Kaustubh Raste <kaustubh.raste at imgtec.com>
> 
> Signed-off-by: Kaustubh Raste <kaustubh.raste at imgtec.com>
> ---
>  libavcodec/mips/Makefile        |    1 +
>  libavcodec/mips/videodsp_mips.c |   42 +++++++++++++++++++++++++++++++++++++++
>  libavcodec/videodsp.c           |    2 ++
>  libavcodec/videodsp.h           |    1 +
>  4 files changed, 46 insertions(+)
>  create mode 100644 libavcodec/mips/videodsp_mips.c
> 
> diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile
> index 797df09..e2a779c 100644
> --- a/libavcodec/mips/Makefile
> +++ b/libavcodec/mips/Makefile
> @@ -38,6 +38,7 @@ OBJS-$(CONFIG_ME_CMP)                     += mips/me_cmp_init_mips.o
>  OBJS-$(CONFIG_MPEG4_DECODER)              += mips/xvididct_init_mips.o
>  OBJS-$(CONFIG_VC1DSP)                     += mips/vc1dsp_init_mips.o
>  OBJS-$(CONFIG_WMV2DSP)                    += mips/wmv2dsp_init_mips.o
> +OBJS-$(CONFIG_VIDEODSP)                   += mips/videodsp_mips.o
>  MSA-OBJS-$(CONFIG_HEVC_DECODER)           += mips/hevcdsp_msa.o            \
>                                               mips/hevc_mc_uni_msa.o        \
>                                               mips/hevc_mc_uniw_msa.o       \
> diff --git a/libavcodec/mips/videodsp_mips.c b/libavcodec/mips/videodsp_mips.c
> new file mode 100644
> index 0000000..c2c8282
> --- /dev/null
> +++ b/libavcodec/mips/videodsp_mips.c
> @@ -0,0 +1,42 @@
> +/*
> + * Copyright (c) 2017 Kaustubh Raste (kaustubh.raste at imgtec.com)
> + *
> + * 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 "config.h"
> +#include "libavutil/attributes.h"
> +#include "libavcodec/videodsp.h"
> +
> +#if HAVE_MSA
> +static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h)
> +{
> +    register const uint8_t *p = mem;

> +    do {
> +        __asm__ volatile ("pref 4, 0(%[p])" : : [p] "r" (p));
> +        __asm__ volatile ("pref 4, 32(%[p])" : : [p] "r" (p));
> +        p += stride;
> +    } while(--h);

generally doing a loop in C with asm in it is worse than the whole
loop in asm, speedwise that is


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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20170712/9f3b32f5/attachment.sig>


More information about the ffmpeg-devel mailing list