History

avcodec/mips: MSA (MIPS-SIMD-Arch) optimizations for pixblock functions

This patch adds MSA (MIPS-SIMD-Arch) optimizations for pixblock functions in new file pixblockdsp_msa.c Adds new generic macros (needed for this patch) in libavutil/mips/generic_macros_msa.h

Shivraj Patil committed 11 years ago

Commit d9deae01 parent 21cede97 files · +243 −0Browse files

Unified · Split

7 files
  1. libavcodec/mips/Makefile +2 −0
  2. libavcodec/mips/pixblockdsp_init_mips.c +53 −0
  3. libavcodec/mips/pixblockdsp_mips.h +33 −0
  4. libavcodec/mips/pixblockdsp_msa.c +143 −0
  5. libavcodec/pixblockdsp.c +2 −0
  6. libavcodec/pixblockdsp.h +2 −0
  7. libavutil/mips/generic_macros_msa.h +8 −0
libavcodec/mips/Makefile+2−0
@@ -28,6 +28,7 @@ OBJS-$(CONFIG_H263DSP) += mips/h263dsp_init_mips.o · 27 unmodified lines
2828 OBJS-$(CONFIG_QPELDSP) += mips/qpeldsp_init_mips.o
2929 OBJS-$(CONFIG_HPELDSP) += mips/hpeldsp_init_mips.o
3030 OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_init_mips.o
31+OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_init_mips.o
3132 MSA-OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_msa.o \
3233 mips/hevc_mc_uni_msa.o \
3334 mips/hevc_mc_uniw_msa.o \
@@ -45,5 +46,6 @@ MSA-OBJS-$(CONFIG_H263DSP) += mips/h263dsp_msa.o · 11 unmodified lines
4546 MSA-OBJS-$(CONFIG_QPELDSP) += mips/qpeldsp_msa.o
4647 MSA-OBJS-$(CONFIG_HPELDSP) += mips/hpeldsp_msa.o
4748 MSA-OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_msa.o
49+MSA-OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_msa.o
4850 LOONGSON3-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o
4951 LOONGSON3-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_mmi.o
libavcodec/mips/pixblockdsp_init_mips.c+53−0
@@ -0,0 +1,53 @@
1+/*
2+ * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include "pixblockdsp_mips.h"
22+
23+#if HAVE_MSA
24+static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c,
25+ AVCodecContext *avctx,
26+ unsigned high_bit_depth)
27+{
28+ c->diff_pixels = ff_diff_pixels_msa;
29+
30+ switch (avctx->bits_per_raw_sample) {
31+ case 9:
32+ case 10:
33+ case 12:
34+ case 14:
35+ c->get_pixels = ff_get_pixels_16_msa;
36+ break;
37+ default:
38+ if (avctx->bits_per_raw_sample <= 8 || avctx->codec_type !=
39+ AVMEDIA_TYPE_VIDEO) {
40+ c->get_pixels = ff_get_pixels_8_msa;
41+ }
42+ break;
43+ }
44+}
45+#endif // #if HAVE_MSA
46+
47+void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
48+ unsigned high_bit_depth)
49+{
50+#if HAVE_MSA
51+ pixblockdsp_init_msa(c, avctx, high_bit_depth);
52+#endif // #if HAVE_MSA
53+}
libavcodec/mips/pixblockdsp_mips.h+33−0
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#ifndef AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H
22+#define AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H
23+
24+#include "../mpegvideo.h"
25+
26+void ff_diff_pixels_msa(int16_t *av_restrict block, const uint8_t *src1,
27+ const uint8_t *src2, int stride);
28+void ff_get_pixels_16_msa(int16_t *restrict dst, const uint8_t *src,
29+ ptrdiff_t stride);
30+void ff_get_pixels_8_msa(int16_t *restrict dst, const uint8_t *src,
31+ ptrdiff_t stride);
32+
33+#endif // #ifndef AVCODEC_MIPS_PIXBLOCKDSP_MIPS_H
libavcodec/mips/pixblockdsp_msa.c+143−0
@@ -0,0 +1,143 @@
1+/*
2+ * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
3+ *
4+ * This file is part of FFmpeg.
5+ *
6+ * FFmpeg is free software; you can redistribute it and/or
7+ * modify it under the terms of the GNU Lesser General Public
8+ * License as published by the Free Software Foundation; either
9+ * version 2.1 of the License, or (at your option) any later version.
10+ *
11+ * FFmpeg is distributed in the hope that it will be useful,
12+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
13+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14+ * Lesser General Public License for more details.
15+ *
16+ * You should have received a copy of the GNU Lesser General Public
17+ * License along with FFmpeg; if not, write to the Free Software
18+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+ */
20+
21+#include "libavutil/mips/generic_macros_msa.h"
22+#include "pixblockdsp_mips.h"
23+
24+static void diff_pixels_msa(int16_t *block, const uint8_t *src1,
25+ const uint8_t *src2, int32_t stride)
26+{
27+ v16u8 in10, in11, in12, in13, in14, in15, in16, in17;
28+ v16u8 in20, in21, in22, in23, in24, in25, in26, in27;
29+ v8i16 out0, out1, out2, out3, out4, out5, out6, out7;
30+
31+ LD_UB8(src1, stride, in10, in11, in12, in13, in14, in15, in16, in17);
32+ LD_UB8(src2, stride, in20, in21, in22, in23, in24, in25, in26, in27);
33+ ILVR_B4_SH(in10, in20, in11, in21, in12, in22, in13, in23,
34+ out0, out1, out2, out3);
35+ ILVR_B4_SH(in14, in24, in15, in25, in16, in26, in17, in27,
36+ out4, out5, out6, out7);
37+ HSUB_UB4_SH(out0, out1, out2, out3, out0, out1, out2, out3);
38+ HSUB_UB4_SH(out4, out5, out6, out7, out4, out5, out6, out7);
39+ ST_SH8(out0, out1, out2, out3, out4, out5, out6, out7, block, 8);
40+}
41+
42+static void copy_8bit_to_16bit_width8_msa(const uint8_t *src, int32_t src_stride,
43+ int16_t *dst, int32_t dst_stride,
44+ int32_t height)
45+{
46+ uint8_t *dst_ptr;
47+ int32_t cnt;
48+ v16u8 src0, src1, src2, src3;
49+ v16i8 zero = { 0 };
50+
51+ dst_ptr = (uint8_t *) dst;
52+
53+ for (cnt = (height >> 2); cnt--;) {
54+ LD_UB4(src, src_stride, src0, src1, src2, src3);
55+ src += (4 * src_stride);
56+
57+ ILVR_B4_UB(zero, src0, zero, src1, zero, src2, zero, src3,
58+ src0, src1, src2, src3);
59+
60+ ST_UB4(src0, src1, src2, src3, dst_ptr, (dst_stride * 2));
61+ dst_ptr += (4 * 2 * dst_stride);
62+ }
63+}
64+
65+static void copy_16multx8mult_msa(const uint8_t *src, int32_t src_stride,
66+ uint8_t *dst, int32_t dst_stride,
67+ int32_t height, int32_t width)
68+{
69+ int32_t cnt, loop_cnt;
70+ const uint8_t *src_tmp;
71+ uint8_t *dst_tmp;
72+ v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
73+
74+ for (cnt = (width >> 4); cnt--;) {
75+ src_tmp = src;
76+ dst_tmp = dst;
77+
78+ for (loop_cnt = (height >> 3); loop_cnt--;) {
79+ LD_UB8(src_tmp, src_stride,
80+ src0, src1, src2, src3, src4, src5, src6, src7);
81+ src_tmp += (8 * src_stride);
82+
83+ ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7,
84+ dst_tmp, dst_stride);
85+ dst_tmp += (8 * dst_stride);
86+ }
87+
88+ src += 16;
89+ dst += 16;
90+ }
91+}
92+
93+static void copy_width16_msa(const uint8_t *src, int32_t src_stride,
94+ uint8_t *dst, int32_t dst_stride,
95+ int32_t height)
96+{
97+ int32_t cnt;
98+ v16u8 src0, src1, src2, src3, src4, src5, src6, src7;
99+
100+ if (0 == height % 12) {
101+ for (cnt = (height / 12); cnt--;) {
102+ LD_UB8(src, src_stride,
103+ src0, src1, src2, src3, src4, src5, src6, src7);
104+ src += (8 * src_stride);
105+ ST_UB8(src0, src1, src2, src3, src4, src5, src6, src7,
106+ dst, dst_stride);
107+ dst += (8 * dst_stride);
108+
109+ LD_UB4(src, src_stride, src0, src1, src2, src3);
110+ src += (4 * src_stride);
111+ ST_UB4(src0, src1, src2, src3, dst, dst_stride);
112+ dst += (4 * dst_stride);
113+ }
114+ } else if (0 == height % 8) {
115+ copy_16multx8mult_msa(src, src_stride, dst, dst_stride, height, 16);
116+ } else if (0 == height % 4) {
117+ for (cnt = (height >> 2); cnt--;) {
118+ LD_UB4(src, src_stride, src0, src1, src2, src3);
119+ src += (4 * src_stride);
120+
121+ ST_UB4(src0, src1, src2, src3, dst, dst_stride);
122+ dst += (4 * dst_stride);
123+ }
124+ }
125+}
126+
127+void ff_get_pixels_16_msa(int16_t *av_restrict dest, const uint8_t *src,
128+ ptrdiff_t stride)
129+{
130+ copy_width16_msa(src, stride, (uint8_t *) dest, 16, 8);
131+}
132+
133+void ff_get_pixels_8_msa(int16_t *av_restrict dest, const uint8_t *src,
134+ ptrdiff_t stride)
135+{
136+ copy_8bit_to_16bit_width8_msa(src, stride, dest, 8, 8);
137+}
138+
139+void ff_diff_pixels_msa(int16_t *av_restrict block, const uint8_t *src1,
140+ const uint8_t *src2, int stride)
141+{
142+ diff_pixels_msa(block, src1, src2, stride);
143+}
libavcodec/pixblockdsp.c+2−0
@@ -79,4 +79,6 @@ av_cold void ff_pixblockdsp_init(PixblockDSPContext *c, AVCodecContext *avctx) · 78 unmodified lines
7979 ff_pixblockdsp_init_ppc(c, avctx, high_bit_depth);
8080 if (ARCH_X86)
8181 ff_pixblockdsp_init_x86(c, avctx, high_bit_depth);
82+ if (ARCH_MIPS)
83+ ff_pixblockdsp_init_mips(c, avctx, high_bit_depth);
8284 }
libavcodec/pixblockdsp.h+2−0
@@ -42,5 +42,7 @@ void ff_pixblockdsp_init_ppc(PixblockDSPContext *c, AVCodecContext *avctx, · 41 unmodified lines
4242 unsigned high_bit_depth);
4343 void ff_pixblockdsp_init_x86(PixblockDSPContext *c, AVCodecContext *avctx,
4444 unsigned high_bit_depth);
45+void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx,
46+ unsigned high_bit_depth);
4547
4648 #endif /* AVCODEC_PIXBLOCKDSP_H */
libavutil/mips/generic_macros_msa.h+8−0
@@ -1206,6 +1206,14 @@ · 1205 unmodified lines
12061206 #define HSUB_UB2_UH(...) HSUB_UB2(v8u16, __VA_ARGS__)
12071207 #define HSUB_UB2_SH(...) HSUB_UB2(v8i16, __VA_ARGS__)
12081208
1209+#define HSUB_UB4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) \
1210+{ \
1211+ HSUB_UB2(RTYPE, in0, in1, out0, out1); \
1212+ HSUB_UB2(RTYPE, in2, in3, out2, out3); \
1213+}
1214+#define HSUB_UB4_UH(...) HSUB_UB4(v8u16, __VA_ARGS__)
1215+#define HSUB_UB4_SH(...) HSUB_UB4(v8i16, __VA_ARGS__)
1216+
12091217 /* Description : Insert specified word elements from input vectors to 1
12101218 destination vector
12111219 Arguments : Inputs - in0, in1, in2, in3 (4 input vectors)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t