mirror of
https://github.com/opencv/opencv.git
synced 2024-12-24 00:17:59 +08:00
b1ea91d8bd
* Added MSA implementations for mips platforms. Intrinsics for MSA and build scripts for MIPS platforms are added. Signed-off-by: Fei Wu <fwu@wavecomp.com> * Removed some unused code in mips.toolchain.cmake. Signed-off-by: Fei Wu <fwu@wavecomp.com> * Added comments for mips toolchain configuration and disabled compiling warnings for libpng. Signed-off-by: Fei Wu <fwu@wavecomp.com> * Fixed the build error of unsupported opcode 'pause' when mips isa_rev is less than 2. Signed-off-by: Fei Wu <fwu@wavecomp.com> * 1. Removed FP16 related item in MSA option defines in OpenCVCompilerOptimizations.cmake. 2. Use CV_CPU_COMPILE_MSA instead of __mips_msa for MSA feature check in cv_cpu_dispatch.h. 3. Removed hasSIMD128() in intrin_msa.hpp. 4. Define CPU_MSA as 150. Signed-off-by: Fei Wu <fwu@wavecomp.com> * 1. Removed unnecessary CV_SIMD128_64F guarding in intrin_msa.hpp. 2. Removed unnecessary CV_MSA related code block in dotProd_8u(). Signed-off-by: Fei Wu <fwu@wavecomp.com> * 1. Defined CPU_MSA_FLAGS_ON as "-mmsa". 2. Removed CV_SIMD128_64F guardings in intrin_msa.hpp. Signed-off-by: Fei Wu <fwu@wavecomp.com> * Removed unused msa_mlal_u16() and msa_mlal_s16 from msa_macros.h. Signed-off-by: Fei Wu <fwu@wavecomp.com>
128 lines
4.2 KiB
C
128 lines
4.2 KiB
C
|
|
/* mips_init.c - MSA optimised filter functions
|
|
*
|
|
* Copyright (c) 2018 Cosmin Truta
|
|
* Copyright (c) 2016 Glenn Randers-Pehrson
|
|
* Written by Mandar Sahastrabuddhe, 2016.
|
|
*
|
|
* This code is released under the libpng license.
|
|
* For conditions of distribution and use, see the disclaimer
|
|
* and license in png.h
|
|
*/
|
|
|
|
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
|
* called.
|
|
*/
|
|
#define _POSIX_SOURCE 1
|
|
|
|
#include <stdio.h>
|
|
#include "../pngpriv.h"
|
|
|
|
#ifdef PNG_READ_SUPPORTED
|
|
|
|
#if PNG_MIPS_MSA_OPT > 0
|
|
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do run-time checks */
|
|
/* WARNING: it is strongly recommended that you do not build libpng with
|
|
* run-time checks for CPU features if at all possible. In the case of the MIPS
|
|
* MSA instructions there is no processor-specific way of detecting the
|
|
* presence of the required support, therefore run-time detection is extremely
|
|
* OS specific.
|
|
*
|
|
* You may set the macro PNG_MIPS_MSA_FILE to the file name of file containing
|
|
* a fragment of C source code which defines the png_have_msa function. There
|
|
* are a number of implementations in contrib/mips-msa, but the only one that
|
|
* has partial support is contrib/mips-msa/linux.c - a generic Linux
|
|
* implementation which reads /proc/cpufino.
|
|
*/
|
|
#ifndef PNG_MIPS_MSA_FILE
|
|
# ifdef __linux__
|
|
# define PNG_MIPS_MSA_FILE "contrib/mips-msa/linux.c"
|
|
# endif
|
|
#endif
|
|
|
|
#ifdef PNG_MIPS_MSA_FILE
|
|
|
|
#include <signal.h> /* for sig_atomic_t */
|
|
static int png_have_msa(png_structp png_ptr);
|
|
#include PNG_MIPS_MSA_FILE
|
|
|
|
#else /* PNG_MIPS_MSA_FILE */
|
|
# error "PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks"
|
|
#endif /* PNG_MIPS_MSA_FILE */
|
|
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
|
|
|
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
|
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
|
#endif
|
|
|
|
void
|
|
png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
|
{
|
|
/* The switch statement is compiled in for MIPS_MSA_API, the call to
|
|
* png_have_msa is compiled in for MIPS_MSA_CHECK. If both are defined
|
|
* the check is only performed if the API has not set the MSA option on
|
|
* or off explicitly. In this case the check controls what happens.
|
|
*/
|
|
|
|
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
|
switch ((pp->options >> PNG_MIPS_MSA) & 3)
|
|
{
|
|
case PNG_OPTION_UNSET:
|
|
/* Allow the run-time check to execute if it has been enabled -
|
|
* thus both API and CHECK can be turned on. If it isn't supported
|
|
* this case will fall through to the 'default' below, which just
|
|
* returns.
|
|
*/
|
|
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
|
|
{
|
|
static volatile sig_atomic_t no_msa = -1; /* not checked */
|
|
|
|
if (no_msa < 0)
|
|
no_msa = !png_have_msa(pp);
|
|
|
|
if (no_msa)
|
|
return;
|
|
}
|
|
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
|
break;
|
|
|
|
default: /* OFF or INVALID */
|
|
return;
|
|
|
|
case PNG_OPTION_ON:
|
|
/* Option turned on */
|
|
break;
|
|
}
|
|
/* IMPORTANT: any new external functions used here must be declared using
|
|
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
|
* 'prefix' option to configure works:
|
|
*
|
|
* ./configure --with-libpng-prefix=foobar_
|
|
*
|
|
* Verify you have got this right by running the above command, doing a build
|
|
* and examining pngprefix.h; it must contain a #define for every external
|
|
* function you add. (Notice that this happens automatically for the
|
|
* initialization function.)
|
|
*/
|
|
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_msa;
|
|
|
|
if (bpp == 3)
|
|
{
|
|
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_msa;
|
|
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_msa;
|
|
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_msa;
|
|
}
|
|
else if (bpp == 4)
|
|
{
|
|
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_msa;
|
|
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa;
|
|
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa;
|
|
}
|
|
#else
|
|
(void)pp;
|
|
(void)bpp;
|
|
#endif /* PNG_MIPS_MSA_API_SUPPORTED */
|
|
}
|
|
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
|
#endif /* READ */
|