From 8506ff97c9ea4a1f52983497ecf8d4ef193403a9 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sat, 6 Oct 2012 20:28:56 +0200 Subject: vp56: Mark VP6-only optimizations as such. Most of our VP56 optimizations are VP6-only and will stay that way. So avoid compiling them for VP5-only builds. --- libavcodec/arm/Makefile | 6 +- libavcodec/arm/vp56dsp_init_arm.c | 39 --------- libavcodec/arm/vp56dsp_neon.S | 121 --------------------------- libavcodec/arm/vp6dsp_init_arm.c | 39 +++++++++ libavcodec/arm/vp6dsp_neon.S | 121 +++++++++++++++++++++++++++ libavcodec/vp56dsp.c | 8 +- libavcodec/vp56dsp.h | 4 +- libavcodec/x86/Makefile | 5 +- libavcodec/x86/vp56dsp.asm | 170 -------------------------------------- libavcodec/x86/vp56dsp_init.c | 48 ----------- libavcodec/x86/vp6dsp.asm | 170 ++++++++++++++++++++++++++++++++++++++ libavcodec/x86/vp6dsp_init.c | 45 ++++++++++ 12 files changed, 386 insertions(+), 390 deletions(-) delete mode 100644 libavcodec/arm/vp56dsp_init_arm.c delete mode 100644 libavcodec/arm/vp56dsp_neon.S create mode 100644 libavcodec/arm/vp6dsp_init_arm.c create mode 100644 libavcodec/arm/vp6dsp_neon.S delete mode 100644 libavcodec/x86/vp56dsp.asm delete mode 100644 libavcodec/x86/vp56dsp_init.c create mode 100644 libavcodec/x86/vp6dsp.asm create mode 100644 libavcodec/x86/vp6dsp_init.c diff --git a/libavcodec/arm/Makefile b/libavcodec/arm/Makefile index 9c64b361f1..0e5e53a16a 100644 --- a/libavcodec/arm/Makefile +++ b/libavcodec/arm/Makefile @@ -25,8 +25,7 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += arm/mpegaudiodsp_init_arm.o OBJS-$(CONFIG_MPEGVIDEO) += arm/mpegvideo_arm.o OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_init_arm.o OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_init_arm.o -OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_init_arm.o -OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_init_arm.o +OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_init_arm.o OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_arm.o OBJS-$(CONFIG_RV30_DECODER) += arm/rv34dsp_init_arm.o OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_init_arm.o \ @@ -89,7 +88,6 @@ NEON-OBJS-$(CONFIG_RV40_DECODER) += arm/rv34dsp_neon.o \ arm/rv40dsp_neon.o NEON-OBJS-$(CONFIG_VORBIS_DECODER) += arm/vorbisdsp_neon.o NEON-OBJS-$(CONFIG_VP3DSP) += arm/vp3dsp_neon.o -NEON-OBJS-$(CONFIG_VP5_DECODER) += arm/vp56dsp_neon.o -NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp56dsp_neon.o +NEON-OBJS-$(CONFIG_VP6_DECODER) += arm/vp6dsp_neon.o NEON-OBJS-$(CONFIG_VP8_DECODER) += arm/vp8dsp_init_neon.o \ arm/vp8dsp_neon.o diff --git a/libavcodec/arm/vp56dsp_init_arm.c b/libavcodec/arm/vp56dsp_init_arm.c deleted file mode 100644 index 65e892dafa..0000000000 --- a/libavcodec/arm/vp56dsp_init_arm.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2010 Mans Rullgard - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include - -#include "libavutil/attributes.h" -#include "libavutil/arm/cpu.h" -#include "libavcodec/avcodec.h" -#include "libavcodec/vp56dsp.h" - -void ff_vp6_edge_filter_hor_neon(uint8_t *yuv, int stride, int t); -void ff_vp6_edge_filter_ver_neon(uint8_t *yuv, int stride, int t); - -av_cold void ff_vp56dsp_init_arm(VP56DSPContext *s, enum AVCodecID codec) -{ - int cpu_flags = av_get_cpu_flags(); - - if (codec != AV_CODEC_ID_VP5 && have_neon(cpu_flags)) { - s->edge_filter_hor = ff_vp6_edge_filter_hor_neon; - s->edge_filter_ver = ff_vp6_edge_filter_ver_neon; - } -} diff --git a/libavcodec/arm/vp56dsp_neon.S b/libavcodec/arm/vp56dsp_neon.S deleted file mode 100644 index 10b4d0f14c..0000000000 --- a/libavcodec/arm/vp56dsp_neon.S +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) 2010 Mans Rullgard - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/arm/asm.S" - -.macro vp6_edge_filter - vdup.16 q3, r2 @ t - vmov.i16 q13, #1 - vsubl.u8 q0, d20, d18 @ p[ 0] - p[-s] - vsubl.u8 q1, d16, d22 @ p[-2*s] - p[ s] - vsubl.u8 q14, d21, d19 - vsubl.u8 q15, d17, d23 - vadd.i16 q2, q0, q0 @ 2*(p[0]-p[-s]) - vadd.i16 d29, d28, d28 - vadd.i16 q0, q0, q1 @ p[0]-p[-s] + p[-2*s]-p[s] - vadd.i16 d28, d28, d30 - vadd.i16 q0, q0, q2 @ 3*(p[0]-p[-s]) + p[-2*s]-p[s] - vadd.i16 d28, d28, d29 - vrshr.s16 q0, q0, #3 @ v - vrshr.s16 d28, d28, #3 - vsub.i16 q8, q3, q13 @ t-1 - vabs.s16 q1, q0 @ V - vshr.s16 q2, q0, #15 @ s - vabs.s16 d30, d28 - vshr.s16 d29, d28, #15 - vsub.i16 q12, q1, q3 @ V-t - vsub.i16 d31, d30, d6 - vsub.i16 q12, q12, q13 @ V-t-1 - vsub.i16 d31, d31, d26 - vcge.u16 q12, q12, q8 @ V-t-1 >= t-1 - vcge.u16 d31, d31, d16 - vadd.i16 q13, q3, q3 @ 2*t - vadd.i16 d16, d6, d6 - vsub.i16 q13, q13, q1 @ 2*t - V - vsub.i16 d16, d16, d30 - vadd.i16 q13, q13, q2 @ += s - vadd.i16 d16, d16, d29 - veor q13, q13, q2 @ ^= s - veor d16, d16, d29 - vbif q0, q13, q12 - vbif d28, d16, d31 - vmovl.u8 q1, d20 - vmovl.u8 q15, d21 - vaddw.u8 q2, q0, d18 - vaddw.u8 q3, q14, d19 - vsub.i16 q1, q1, q0 - vsub.i16 d30, d30, d28 - vqmovun.s16 d18, q2 - vqmovun.s16 d19, q3 - vqmovun.s16 d20, q1 - vqmovun.s16 d21, q15 -.endm - -function ff_vp6_edge_filter_ver_neon, export=1 - sub r0, r0, r1, lsl #1 - vld1.8 {q8}, [r0], r1 @ p[-2*s] - vld1.8 {q9}, [r0], r1 @ p[-s] - vld1.8 {q10}, [r0], r1 @ p[0] - vld1.8 {q11}, [r0] @ p[s] - vp6_edge_filter - sub r0, r0, r1, lsl #1 - sub r1, r1, #8 - vst1.8 {d18}, [r0]! - vst1.32 {d19[0]}, [r0], r1 - vst1.8 {d20}, [r0]! - vst1.32 {d21[0]}, [r0] - bx lr -endfunc - -function ff_vp6_edge_filter_hor_neon, export=1 - sub r3, r0, #1 - sub r0, r0, #2 - vld1.32 {d16[0]}, [r0], r1 - vld1.32 {d18[0]}, [r0], r1 - vld1.32 {d20[0]}, [r0], r1 - vld1.32 {d22[0]}, [r0], r1 - vld1.32 {d16[1]}, [r0], r1 - vld1.32 {d18[1]}, [r0], r1 - vld1.32 {d20[1]}, [r0], r1 - vld1.32 {d22[1]}, [r0], r1 - vld1.32 {d17[0]}, [r0], r1 - vld1.32 {d19[0]}, [r0], r1 - vld1.32 {d21[0]}, [r0], r1 - vld1.32 {d23[0]}, [r0], r1 - vtrn.8 q8, q9 - vtrn.8 q10, q11 - vtrn.16 q8, q10 - vtrn.16 q9, q11 - vp6_edge_filter - vtrn.8 q9, q10 - vst1.16 {d18[0]}, [r3], r1 - vst1.16 {d20[0]}, [r3], r1 - vst1.16 {d18[1]}, [r3], r1 - vst1.16 {d20[1]}, [r3], r1 - vst1.16 {d18[2]}, [r3], r1 - vst1.16 {d20[2]}, [r3], r1 - vst1.16 {d18[3]}, [r3], r1 - vst1.16 {d20[3]}, [r3], r1 - vst1.16 {d19[0]}, [r3], r1 - vst1.16 {d21[0]}, [r3], r1 - vst1.16 {d19[1]}, [r3], r1 - vst1.16 {d21[1]}, [r3], r1 - bx lr -endfunc diff --git a/libavcodec/arm/vp6dsp_init_arm.c b/libavcodec/arm/vp6dsp_init_arm.c new file mode 100644 index 0000000000..4ec41ed9f1 --- /dev/null +++ b/libavcodec/arm/vp6dsp_init_arm.c @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2010 Mans Rullgard + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +#include "libavutil/attributes.h" +#include "libavutil/arm/cpu.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/vp56dsp.h" + +void ff_vp6_edge_filter_hor_neon(uint8_t *yuv, int stride, int t); +void ff_vp6_edge_filter_ver_neon(uint8_t *yuv, int stride, int t); + +av_cold void ff_vp6dsp_init_arm(VP56DSPContext *s, enum AVCodecID codec) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_neon(cpu_flags)) { + s->edge_filter_hor = ff_vp6_edge_filter_hor_neon; + s->edge_filter_ver = ff_vp6_edge_filter_ver_neon; + } +} diff --git a/libavcodec/arm/vp6dsp_neon.S b/libavcodec/arm/vp6dsp_neon.S new file mode 100644 index 0000000000..10b4d0f14c --- /dev/null +++ b/libavcodec/arm/vp6dsp_neon.S @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2010 Mans Rullgard + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/arm/asm.S" + +.macro vp6_edge_filter + vdup.16 q3, r2 @ t + vmov.i16 q13, #1 + vsubl.u8 q0, d20, d18 @ p[ 0] - p[-s] + vsubl.u8 q1, d16, d22 @ p[-2*s] - p[ s] + vsubl.u8 q14, d21, d19 + vsubl.u8 q15, d17, d23 + vadd.i16 q2, q0, q0 @ 2*(p[0]-p[-s]) + vadd.i16 d29, d28, d28 + vadd.i16 q0, q0, q1 @ p[0]-p[-s] + p[-2*s]-p[s] + vadd.i16 d28, d28, d30 + vadd.i16 q0, q0, q2 @ 3*(p[0]-p[-s]) + p[-2*s]-p[s] + vadd.i16 d28, d28, d29 + vrshr.s16 q0, q0, #3 @ v + vrshr.s16 d28, d28, #3 + vsub.i16 q8, q3, q13 @ t-1 + vabs.s16 q1, q0 @ V + vshr.s16 q2, q0, #15 @ s + vabs.s16 d30, d28 + vshr.s16 d29, d28, #15 + vsub.i16 q12, q1, q3 @ V-t + vsub.i16 d31, d30, d6 + vsub.i16 q12, q12, q13 @ V-t-1 + vsub.i16 d31, d31, d26 + vcge.u16 q12, q12, q8 @ V-t-1 >= t-1 + vcge.u16 d31, d31, d16 + vadd.i16 q13, q3, q3 @ 2*t + vadd.i16 d16, d6, d6 + vsub.i16 q13, q13, q1 @ 2*t - V + vsub.i16 d16, d16, d30 + vadd.i16 q13, q13, q2 @ += s + vadd.i16 d16, d16, d29 + veor q13, q13, q2 @ ^= s + veor d16, d16, d29 + vbif q0, q13, q12 + vbif d28, d16, d31 + vmovl.u8 q1, d20 + vmovl.u8 q15, d21 + vaddw.u8 q2, q0, d18 + vaddw.u8 q3, q14, d19 + vsub.i16 q1, q1, q0 + vsub.i16 d30, d30, d28 + vqmovun.s16 d18, q2 + vqmovun.s16 d19, q3 + vqmovun.s16 d20, q1 + vqmovun.s16 d21, q15 +.endm + +function ff_vp6_edge_filter_ver_neon, export=1 + sub r0, r0, r1, lsl #1 + vld1.8 {q8}, [r0], r1 @ p[-2*s] + vld1.8 {q9}, [r0], r1 @ p[-s] + vld1.8 {q10}, [r0], r1 @ p[0] + vld1.8 {q11}, [r0] @ p[s] + vp6_edge_filter + sub r0, r0, r1, lsl #1 + sub r1, r1, #8 + vst1.8 {d18}, [r0]! + vst1.32 {d19[0]}, [r0], r1 + vst1.8 {d20}, [r0]! + vst1.32 {d21[0]}, [r0] + bx lr +endfunc + +function ff_vp6_edge_filter_hor_neon, export=1 + sub r3, r0, #1 + sub r0, r0, #2 + vld1.32 {d16[0]}, [r0], r1 + vld1.32 {d18[0]}, [r0], r1 + vld1.32 {d20[0]}, [r0], r1 + vld1.32 {d22[0]}, [r0], r1 + vld1.32 {d16[1]}, [r0], r1 + vld1.32 {d18[1]}, [r0], r1 + vld1.32 {d20[1]}, [r0], r1 + vld1.32 {d22[1]}, [r0], r1 + vld1.32 {d17[0]}, [r0], r1 + vld1.32 {d19[0]}, [r0], r1 + vld1.32 {d21[0]}, [r0], r1 + vld1.32 {d23[0]}, [r0], r1 + vtrn.8 q8, q9 + vtrn.8 q10, q11 + vtrn.16 q8, q10 + vtrn.16 q9, q11 + vp6_edge_filter + vtrn.8 q9, q10 + vst1.16 {d18[0]}, [r3], r1 + vst1.16 {d20[0]}, [r3], r1 + vst1.16 {d18[1]}, [r3], r1 + vst1.16 {d20[1]}, [r3], r1 + vst1.16 {d18[2]}, [r3], r1 + vst1.16 {d20[2]}, [r3], r1 + vst1.16 {d18[3]}, [r3], r1 + vst1.16 {d20[3]}, [r3], r1 + vst1.16 {d19[0]}, [r3], r1 + vst1.16 {d21[0]}, [r3], r1 + vst1.16 {d19[1]}, [r3], r1 + vst1.16 {d21[1]}, [r3], r1 + bx lr +endfunc diff --git a/libavcodec/vp56dsp.c b/libavcodec/vp56dsp.c index 9929530221..5e09d2414e 100644 --- a/libavcodec/vp56dsp.c +++ b/libavcodec/vp56dsp.c @@ -88,9 +88,11 @@ av_cold void ff_vp56dsp_init(VP56DSPContext *s, enum AVCodecID codec) if (CONFIG_VP6_DECODER) { s->vp6_filter_diag4 = ff_vp6_filter_diag4_c; + + if (ARCH_ARM) + ff_vp6dsp_init_arm(s, codec); + if (ARCH_X86) + ff_vp6dsp_init_x86(s, codec); } } - - if (ARCH_ARM) ff_vp56dsp_init_arm(s, codec); - if (ARCH_X86) ff_vp56dsp_init_x86(s, codec); } diff --git a/libavcodec/vp56dsp.h b/libavcodec/vp56dsp.h index 034e2e9c5b..389d35901c 100644 --- a/libavcodec/vp56dsp.h +++ b/libavcodec/vp56dsp.h @@ -36,7 +36,7 @@ void ff_vp6_filter_diag4_c(uint8_t *dst, uint8_t *src, int stride, const int16_t *h_weights, const int16_t *v_weights); void ff_vp56dsp_init(VP56DSPContext *s, enum AVCodecID codec); -void ff_vp56dsp_init_arm(VP56DSPContext *s, enum AVCodecID codec); -void ff_vp56dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec); +void ff_vp6dsp_init_arm(VP56DSPContext *s, enum AVCodecID codec); +void ff_vp6dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec); #endif /* AVCODEC_VP56DSP_H */ diff --git a/libavcodec/x86/Makefile b/libavcodec/x86/Makefile index e3b533d2d1..9a0c0971c6 100644 --- a/libavcodec/x86/Makefile +++ b/libavcodec/x86/Makefile @@ -27,8 +27,7 @@ OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp_init.o OBJS-$(CONFIG_VIDEODSP) += x86/videodsp_init.o OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp_init.o OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp_init.o -OBJS-$(CONFIG_VP5_DECODER) += x86/vp56dsp_init.o -OBJS-$(CONFIG_VP6_DECODER) += x86/vp56dsp_init.o +OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp_init.o OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp_init.o OBJS-$(CONFIG_XMM_CLOBBER_TEST) += x86/w64xmmtest.o @@ -88,5 +87,5 @@ YASM-OBJS-$(CONFIG_VC1_DECODER) += x86/vc1dsp.o YASM-OBJS-$(CONFIG_VIDEODSP) += x86/videodsp.o YASM-OBJS-$(CONFIG_VORBIS_DECODER) += x86/vorbisdsp.o YASM-OBJS-$(CONFIG_VP3DSP) += x86/vp3dsp.o -YASM-OBJS-$(CONFIG_VP6_DECODER) += x86/vp56dsp.o +YASM-OBJS-$(CONFIG_VP6_DECODER) += x86/vp6dsp.o YASM-OBJS-$(CONFIG_VP8_DECODER) += x86/vp8dsp.o diff --git a/libavcodec/x86/vp56dsp.asm b/libavcodec/x86/vp56dsp.asm deleted file mode 100644 index 80f8ca5f38..0000000000 --- a/libavcodec/x86/vp56dsp.asm +++ /dev/null @@ -1,170 +0,0 @@ -;****************************************************************************** -;* MMX/SSE2-optimized functions for the VP6 decoder -;* Copyright (C) 2009 Sebastien Lucas -;* Copyright (C) 2009 Zuxy Meng -;* -;* This file is part of Libav. -;* -;* Libav 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. -;* -;* Libav 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 Libav; if not, write to the Free Software -;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -;****************************************************************************** - -%include "libavutil/x86/x86util.asm" - -cextern pw_64 - -SECTION .text - -%macro DIAG4 6 -%if mmsize == 8 - movq m0, [%1+%2] - movq m1, [%1+%3] - movq m3, m0 - movq m4, m1 - punpcklbw m0, m7 - punpcklbw m1, m7 - punpckhbw m3, m7 - punpckhbw m4, m7 - pmullw m0, [rsp+8*11] ; src[x-8 ] * biweight [0] - pmullw m1, [rsp+8*12] ; src[x ] * biweight [1] - pmullw m3, [rsp+8*11] ; src[x-8 ] * biweight [0] - pmullw m4, [rsp+8*12] ; src[x ] * biweight [1] - paddw m0, m1 - paddw m3, m4 - movq m1, [%1+%4] - movq m2, [%1+%5] - movq m4, m1 - movq m5, m2 - punpcklbw m1, m7 - punpcklbw m2, m7 - punpckhbw m4, m7 - punpckhbw m5, m7 - pmullw m1, [rsp+8*13] ; src[x+8 ] * biweight [2] - pmullw m2, [rsp+8*14] ; src[x+16] * biweight [3] - pmullw m4, [rsp+8*13] ; src[x+8 ] * biweight [2] - pmullw m5, [rsp+8*14] ; src[x+16] * biweight [3] - paddw m1, m2 - paddw m4, m5 - paddsw m0, m1 - paddsw m3, m4 - paddsw m0, m6 ; Add 64 - paddsw m3, m6 ; Add 64 - psraw m0, 7 - psraw m3, 7 - packuswb m0, m3 - movq [%6], m0 -%else ; mmsize == 16 - movq m0, [%1+%2] - movq m1, [%1+%3] - punpcklbw m0, m7 - punpcklbw m1, m7 - pmullw m0, m4 ; src[x-8 ] * biweight [0] - pmullw m1, m5 ; src[x ] * biweight [1] - paddw m0, m1 - movq m1, [%1+%4] - movq m2, [%1+%5] - punpcklbw m1, m7 - punpcklbw m2, m7 - pmullw m1, m6 ; src[x+8 ] * biweight [2] - pmullw m2, m3 ; src[x+16] * biweight [3] - paddw m1, m2 - paddsw m0, m1 - paddsw m0, [pw_64] ; Add 64 - psraw m0, 7 - packuswb m0, m0 - movq [%6], m0 -%endif ; mmsize == 8/16 -%endmacro - -%macro SPLAT4REGS 0 -%if mmsize == 8 - movq m5, m3 - punpcklwd m3, m3 - movq m4, m3 - punpckldq m3, m3 - punpckhdq m4, m4 - punpckhwd m5, m5 - movq m2, m5 - punpckhdq m2, m2 - punpckldq m5, m5 - movq [rsp+8*11], m3 - movq [rsp+8*12], m4 - movq [rsp+8*13], m5 - movq [rsp+8*14], m2 -%else ; mmsize == 16 - pshuflw m4, m3, 0x0 - pshuflw m5, m3, 0x55 - pshuflw m6, m3, 0xAA - pshuflw m3, m3, 0xFF - punpcklqdq m4, m4 - punpcklqdq m5, m5 - punpcklqdq m6, m6 - punpcklqdq m3, m3 -%endif ; mmsize == 8/16 -%endmacro - -%macro vp6_filter_diag4 0 -; void ff_vp6_filter_diag4_(uint8_t *dst, uint8_t *src, int stride, -; const int16_t h_weight[4], const int16_t v_weights[4]) -cglobal vp6_filter_diag4, 5, 7, 8 - mov r5, rsp ; backup stack pointer - and rsp, ~(mmsize-1) ; align stack -%if mmsize == 16 - sub rsp, 8*11 -%else - sub rsp, 8*15 - movq m6, [pw_64] -%endif -%if ARCH_X86_64 - movsxd r2, r2d -%endif - - sub r1, r2 - - pxor m7, m7 - movq m3, [r3] - SPLAT4REGS - - mov r3, rsp - mov r6, 11 -.nextrow: - DIAG4 r1, -1, 0, 1, 2, r3 - add r3, 8 - add r1, r2 - dec r6 - jnz .nextrow - - movq m3, [r4] - SPLAT4REGS - - lea r3, [rsp+8] - mov r6, 8 -.nextcol: - DIAG4 r3, -8, 0, 8, 16, r0 - add r3, 8 - add r0, r2 - dec r6 - jnz .nextcol - - mov rsp, r5 ; restore stack pointer - RET -%endmacro - -%if ARCH_X86_32 -INIT_MMX mmx -vp6_filter_diag4 -%endif - -INIT_XMM sse2 -vp6_filter_diag4 diff --git a/libavcodec/x86/vp56dsp_init.c b/libavcodec/x86/vp56dsp_init.c deleted file mode 100644 index 1596273fdd..0000000000 --- a/libavcodec/x86/vp56dsp_init.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * VP6 MMX/SSE2 optimizations - * Copyright (C) 2009 Sebastien Lucas - * Copyright (C) 2009 Zuxy Meng - * - * This file is part of Libav. - * - * Libav 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. - * - * Libav 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 Libav; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libavutil/cpu.h" -#include "libavutil/x86/asm.h" -#include "libavutil/x86/cpu.h" -#include "libavcodec/vp56dsp.h" - -void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride, - const int16_t *h_weights,const int16_t *v_weights); -void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride, - const int16_t *h_weights,const int16_t *v_weights); - -av_cold void ff_vp56dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec) -{ - int cpu_flags = av_get_cpu_flags(); - - if (CONFIG_VP6_DECODER && codec == AV_CODEC_ID_VP6) { -#if ARCH_X86_32 - if (EXTERNAL_MMX(cpu_flags)) { - c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx; - } -#endif - - if (EXTERNAL_SSE2(cpu_flags)) { - c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2; - } - } -} diff --git a/libavcodec/x86/vp6dsp.asm b/libavcodec/x86/vp6dsp.asm new file mode 100644 index 0000000000..80f8ca5f38 --- /dev/null +++ b/libavcodec/x86/vp6dsp.asm @@ -0,0 +1,170 @@ +;****************************************************************************** +;* MMX/SSE2-optimized functions for the VP6 decoder +;* Copyright (C) 2009 Sebastien Lucas +;* Copyright (C) 2009 Zuxy Meng +;* +;* This file is part of Libav. +;* +;* Libav 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. +;* +;* Libav 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 Libav; if not, write to the Free Software +;* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +;****************************************************************************** + +%include "libavutil/x86/x86util.asm" + +cextern pw_64 + +SECTION .text + +%macro DIAG4 6 +%if mmsize == 8 + movq m0, [%1+%2] + movq m1, [%1+%3] + movq m3, m0 + movq m4, m1 + punpcklbw m0, m7 + punpcklbw m1, m7 + punpckhbw m3, m7 + punpckhbw m4, m7 + pmullw m0, [rsp+8*11] ; src[x-8 ] * biweight [0] + pmullw m1, [rsp+8*12] ; src[x ] * biweight [1] + pmullw m3, [rsp+8*11] ; src[x-8 ] * biweight [0] + pmullw m4, [rsp+8*12] ; src[x ] * biweight [1] + paddw m0, m1 + paddw m3, m4 + movq m1, [%1+%4] + movq m2, [%1+%5] + movq m4, m1 + movq m5, m2 + punpcklbw m1, m7 + punpcklbw m2, m7 + punpckhbw m4, m7 + punpckhbw m5, m7 + pmullw m1, [rsp+8*13] ; src[x+8 ] * biweight [2] + pmullw m2, [rsp+8*14] ; src[x+16] * biweight [3] + pmullw m4, [rsp+8*13] ; src[x+8 ] * biweight [2] + pmullw m5, [rsp+8*14] ; src[x+16] * biweight [3] + paddw m1, m2 + paddw m4, m5 + paddsw m0, m1 + paddsw m3, m4 + paddsw m0, m6 ; Add 64 + paddsw m3, m6 ; Add 64 + psraw m0, 7 + psraw m3, 7 + packuswb m0, m3 + movq [%6], m0 +%else ; mmsize == 16 + movq m0, [%1+%2] + movq m1, [%1+%3] + punpcklbw m0, m7 + punpcklbw m1, m7 + pmullw m0, m4 ; src[x-8 ] * biweight [0] + pmullw m1, m5 ; src[x ] * biweight [1] + paddw m0, m1 + movq m1, [%1+%4] + movq m2, [%1+%5] + punpcklbw m1, m7 + punpcklbw m2, m7 + pmullw m1, m6 ; src[x+8 ] * biweight [2] + pmullw m2, m3 ; src[x+16] * biweight [3] + paddw m1, m2 + paddsw m0, m1 + paddsw m0, [pw_64] ; Add 64 + psraw m0, 7 + packuswb m0, m0 + movq [%6], m0 +%endif ; mmsize == 8/16 +%endmacro + +%macro SPLAT4REGS 0 +%if mmsize == 8 + movq m5, m3 + punpcklwd m3, m3 + movq m4, m3 + punpckldq m3, m3 + punpckhdq m4, m4 + punpckhwd m5, m5 + movq m2, m5 + punpckhdq m2, m2 + punpckldq m5, m5 + movq [rsp+8*11], m3 + movq [rsp+8*12], m4 + movq [rsp+8*13], m5 + movq [rsp+8*14], m2 +%else ; mmsize == 16 + pshuflw m4, m3, 0x0 + pshuflw m5, m3, 0x55 + pshuflw m6, m3, 0xAA + pshuflw m3, m3, 0xFF + punpcklqdq m4, m4 + punpcklqdq m5, m5 + punpcklqdq m6, m6 + punpcklqdq m3, m3 +%endif ; mmsize == 8/16 +%endmacro + +%macro vp6_filter_diag4 0 +; void ff_vp6_filter_diag4_(uint8_t *dst, uint8_t *src, int stride, +; const int16_t h_weight[4], const int16_t v_weights[4]) +cglobal vp6_filter_diag4, 5, 7, 8 + mov r5, rsp ; backup stack pointer + and rsp, ~(mmsize-1) ; align stack +%if mmsize == 16 + sub rsp, 8*11 +%else + sub rsp, 8*15 + movq m6, [pw_64] +%endif +%if ARCH_X86_64 + movsxd r2, r2d +%endif + + sub r1, r2 + + pxor m7, m7 + movq m3, [r3] + SPLAT4REGS + + mov r3, rsp + mov r6, 11 +.nextrow: + DIAG4 r1, -1, 0, 1, 2, r3 + add r3, 8 + add r1, r2 + dec r6 + jnz .nextrow + + movq m3, [r4] + SPLAT4REGS + + lea r3, [rsp+8] + mov r6, 8 +.nextcol: + DIAG4 r3, -8, 0, 8, 16, r0 + add r3, 8 + add r0, r2 + dec r6 + jnz .nextcol + + mov rsp, r5 ; restore stack pointer + RET +%endmacro + +%if ARCH_X86_32 +INIT_MMX mmx +vp6_filter_diag4 +%endif + +INIT_XMM sse2 +vp6_filter_diag4 diff --git a/libavcodec/x86/vp6dsp_init.c b/libavcodec/x86/vp6dsp_init.c new file mode 100644 index 0000000000..c4a500b28a --- /dev/null +++ b/libavcodec/x86/vp6dsp_init.c @@ -0,0 +1,45 @@ +/* + * VP6 MMX/SSE2 optimizations + * Copyright (C) 2009 Sebastien Lucas + * Copyright (C) 2009 Zuxy Meng + * + * This file is part of Libav. + * + * Libav 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. + * + * Libav 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 Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "libavutil/cpu.h" +#include "libavutil/x86/asm.h" +#include "libavutil/x86/cpu.h" +#include "libavcodec/vp56dsp.h" + +void ff_vp6_filter_diag4_mmx(uint8_t *dst, uint8_t *src, int stride, + const int16_t *h_weights,const int16_t *v_weights); +void ff_vp6_filter_diag4_sse2(uint8_t *dst, uint8_t *src, int stride, + const int16_t *h_weights,const int16_t *v_weights); + +av_cold void ff_vp6dsp_init_x86(VP56DSPContext* c, enum AVCodecID codec) +{ + int cpu_flags = av_get_cpu_flags(); + +#if ARCH_X86_32 + if (EXTERNAL_MMX(cpu_flags)) { + c->vp6_filter_diag4 = ff_vp6_filter_diag4_mmx; + } +#endif + if (EXTERNAL_SSE2(cpu_flags)) { + c->vp6_filter_diag4 = ff_vp6_filter_diag4_sse2; + } +} -- cgit v1.2.3