Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/ppc
diff options
context:
space:
mode:
authorHenrik Gramner <gramner@twoorioles.com>2022-07-06 15:43:44 +0300
committerHenrik Gramner <henrik@gramner.com>2022-07-06 16:05:47 +0300
commitbd0466350d20e2c6aab4c47668cd5486dc7a3d94 (patch)
treea49202fdff9fe3f560aa4eadde6f54f4d033ed21 /src/ppc
parent820bf5156322ea6f9d1fc180ac579743347b9c5b (diff)
Eliminate unused C DSP functions at compile time
When compiling with asm enabled there's no point in compiling C versions of DSP functions that have asm implementations using instruction sets that the compiler can unconditionally use. E.g. when compiling with -mssse3 we can remove the C version of all functions with SSSE3 implementations. This is accomplished using the compiler's dead code elimination functionality. Can be configured using the new 'trim_dsp' meson option, which by default is enabled when compiling in release mode.
Diffstat (limited to 'src/ppc')
-rw-r--r--src/ppc/cdef.h61
-rw-r--r--src/ppc/cdef_tmpl.c (renamed from src/ppc/cdef_init_tmpl.c)43
-rw-r--r--src/ppc/looprestoration.h48
-rw-r--r--src/ppc/looprestoration_tmpl.c (renamed from src/ppc/looprestoration_init_tmpl.c)30
4 files changed, 127 insertions, 55 deletions
diff --git a/src/ppc/cdef.h b/src/ppc/cdef.h
new file mode 100644
index 0000000..b794ba5
--- /dev/null
+++ b/src/ppc/cdef.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright © 2019, Luca Barbato
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+
+#include "common/bitdepth.h"
+#include "common/intops.h"
+
+#include "src/cdef.h"
+#include "src/cpu.h"
+
+#define cdef_vsx_fn(w, h) \
+void dav1d_cdef_filter_##w##x##h##_vsx(pixel *const dst, \
+ const ptrdiff_t dst_stride, \
+ const pixel (*left)[2], \
+ const pixel *const top, \
+ const pixel *const bottom, \
+ const int pri_strength, \
+ const int sec_strength, \
+ const int dir, \
+ const int damping, \
+ const enum CdefEdgeFlags edges)
+
+cdef_vsx_fn(4, 4);
+cdef_vsx_fn(4, 8);
+cdef_vsx_fn(8, 8);
+
+static ALWAYS_INLINE void cdef_dsp_init_ppc(Dav1dCdefDSPContext *const c) {
+ const unsigned flags = dav1d_get_cpu_flags();
+
+ if (!(flags & DAV1D_PPC_CPU_FLAG_VSX)) return;
+
+#if BITDEPTH == 8
+ c->fb[0] = dav1d_cdef_filter_8x8_vsx;
+ c->fb[1] = dav1d_cdef_filter_4x8_vsx;
+ c->fb[2] = dav1d_cdef_filter_4x4_vsx;
+#endif
+}
diff --git a/src/ppc/cdef_init_tmpl.c b/src/ppc/cdef_tmpl.c
index 12e4a66..020e17b 100644
--- a/src/ppc/cdef_init_tmpl.c
+++ b/src/ppc/cdef_tmpl.c
@@ -24,15 +24,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <stdlib.h>
-
-#include "common/bitdepth.h"
-#include "common/intops.h"
-
-#include "src/cdef.h"
-#include "src/cpu.h"
-
#include "src/ppc/dav1d_types.h"
+#include "src/ppc/cdef.h"
#if BITDEPTH == 8
static inline i16x8 vconstrain(const i16x8 diff, const int16_t threshold,
@@ -451,18 +444,17 @@ filter_8xN(pixel *dst, const ptrdiff_t dst_stride,
}
-
#define cdef_fn(w, h, tmp_stride) \
-static void cdef_filter_##w##x##h##_vsx(pixel *const dst, \
- const ptrdiff_t dst_stride, \
- const pixel (*left)[2], \
- const pixel *const top, \
- const pixel *const bottom, \
- const int pri_strength, \
- const int sec_strength, \
- const int dir, \
- const int damping, \
- const enum CdefEdgeFlags edges) \
+void dav1d_cdef_filter_##w##x##h##_vsx(pixel *const dst, \
+ const ptrdiff_t dst_stride, \
+ const pixel (*left)[2], \
+ const pixel *const top, \
+ const pixel *const bottom, \
+ const int pri_strength, \
+ const int sec_strength, \
+ const int dir, \
+ const int damping, \
+ const enum CdefEdgeFlags edges) \
{ \
ALIGN_STK_16(uint16_t, tmp_buf, 12 * tmp_stride,); \
uint16_t *tmp = tmp_buf + 2 * tmp_stride + 2; \
@@ -474,16 +466,3 @@ cdef_fn(4, 4, 8);
cdef_fn(4, 8, 8);
cdef_fn(8, 8, 16);
#endif
-
-COLD void bitfn(dav1d_cdef_dsp_init_ppc)(Dav1dCdefDSPContext *const c) {
- const unsigned flags = dav1d_get_cpu_flags();
-
- if (!(flags & DAV1D_PPC_CPU_FLAG_VSX)) return;
-
-#if BITDEPTH == 8
- // c->dir = dav1d_cdef_find_dir_vsx;
- c->fb[0] = cdef_filter_8x8_vsx;
- c->fb[1] = cdef_filter_4x8_vsx;
- c->fb[2] = cdef_filter_4x4_vsx;
-#endif
-}
diff --git a/src/ppc/looprestoration.h b/src/ppc/looprestoration.h
new file mode 100644
index 0000000..3fe1631
--- /dev/null
+++ b/src/ppc/looprestoration.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright © 2019, VideoLAN and dav1d authors
+ * Copyright © 2019, Michail Alvanos
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "common/intops.h"
+
+#include "src/cpu.h"
+#include "src/looprestoration.h"
+
+void dav1d_wiener_filter_vsx(uint8_t *p, const ptrdiff_t stride,
+ const uint8_t (*const left)[4],
+ const uint8_t *lpf,
+ const int w, const int h,
+ const LooprestorationParams *const params,
+ const enum LrEdgeFlags edges HIGHBD_DECL_SUFFIX);
+
+static ALWAYS_INLINE void loop_restoration_dsp_init_ppc(Dav1dLoopRestorationDSPContext *const c, const int bpc) {
+ const unsigned flags = dav1d_get_cpu_flags();
+
+ if (!(flags & DAV1D_PPC_CPU_FLAG_VSX)) return;
+
+#if BITDEPTH == 8
+ c->wiener[0] = c->wiener[1] = dav1d_wiener_filter_vsx;
+#endif
+}
diff --git a/src/ppc/looprestoration_init_tmpl.c b/src/ppc/looprestoration_tmpl.c
index e9bc622..f64a963 100644
--- a/src/ppc/looprestoration_init_tmpl.c
+++ b/src/ppc/looprestoration_tmpl.c
@@ -25,10 +25,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "common/intops.h"
#include "src/ppc/dav1d_types.h"
-#include "src/cpu.h"
-#include "src/looprestoration.h"
+#include "src/ppc/looprestoration.h"
#if BITDEPTH == 8
@@ -302,12 +300,12 @@ static inline void padding(uint8_t *dst, const uint8_t *p,
// (since first and last tops are always 0 for chroma)
// FIXME Could implement a version that requires less temporary memory
// (should be possible to implement with only 6 rows of temp storage)
-static void wiener_filter_vsx(uint8_t *p, const ptrdiff_t stride,
- const uint8_t (*const left)[4],
- const uint8_t *lpf,
- const int w, const int h,
- const LooprestorationParams *const params,
- const enum LrEdgeFlags edges HIGHBD_DECL_SUFFIX)
+void dav1d_wiener_filter_vsx(uint8_t *p, const ptrdiff_t stride,
+ const uint8_t (*const left)[4],
+ const uint8_t *lpf,
+ const int w, const int h,
+ const LooprestorationParams *const params,
+ const enum LrEdgeFlags edges HIGHBD_DECL_SUFFIX)
{
const int16_t (*const filter)[8] = params->filter;
@@ -321,17 +319,3 @@ static void wiener_filter_vsx(uint8_t *p, const ptrdiff_t stride,
wiener_filter_v_vsx(p, stride, hor, filter[1], w, h);
}
#endif
-
-COLD void bitfn(dav1d_loop_restoration_dsp_init_ppc)(Dav1dLoopRestorationDSPContext *const c,
- const int bpc)
-{
- const unsigned flags = dav1d_get_cpu_flags();
-
- if (!(flags & DAV1D_PPC_CPU_FLAG_VSX)) return;
-
-#if BITDEPTH == 8
- c->wiener[0] = c->wiener[1] = wiener_filter_vsx;
-#endif
-}
-
-