2014-04-29 08:14:42 +00:00
|
|
|
#ifndef STRATEGYSELECTOR_H_
|
|
|
|
#define STRATEGYSELECTOR_H_
|
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
|
2014-04-29 08:14:42 +00:00
|
|
|
* COPYING file).
|
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* Kvazaar 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.
|
2014-04-29 08:14:42 +00:00
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* Kvazaar 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.
|
2014-04-29 08:14:42 +00:00
|
|
|
*
|
2015-02-23 11:18:48 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
2014-04-29 08:14:42 +00:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-10-14 09:01:56 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
2014-06-16 09:15:19 +00:00
|
|
|
#if defined(_DEBUG) && !defined(DEBUG_STRATEGYSELECTOR)
|
|
|
|
# define DEBUG_STRATEGYSELECTOR
|
|
|
|
#endif
|
|
|
|
|
2014-04-29 08:14:42 +00:00
|
|
|
//Hardware data (abstraction of defines). Extend for other compilers
|
|
|
|
|
|
|
|
#if defined(_M_IX86) || defined(__i586__) || defined(__i686__) || defined(_M_X64) || defined(_M_AMD64) || defined(__amd64__) || defined(__x86_64__)
|
2014-07-09 13:16:52 +00:00
|
|
|
# define COMPILE_INTEL 1
|
|
|
|
#else
|
|
|
|
# define COMPILE_INTEL 0
|
2014-04-29 08:14:42 +00:00
|
|
|
#endif
|
|
|
|
|
2014-07-09 13:16:52 +00:00
|
|
|
// Visual Studio note:
|
|
|
|
// Because these macros are only used to guard code that is guarded by CPUID
|
|
|
|
// at runtime, use /arch parameter to disable them, but enable all intrinsics
|
|
|
|
// supported by VisualStudio if SSE2 (highest) is enabled.
|
|
|
|
// AVX and AVX2 are handled by /arch directly and sse intrinsics will use VEX
|
|
|
|
// versions if they are defined.
|
|
|
|
#define MSC_X86_SIMD(level) (_M_X64 || (_M_IX86_FP >= (level)))
|
|
|
|
|
|
|
|
#if COMPILE_INTEL
|
|
|
|
# if defined(__MMX__) || MSC_X86_SIMD(1)
|
|
|
|
# define COMPILE_INTEL_MMX 1
|
|
|
|
# endif
|
|
|
|
# if defined(__SSE__) || MSC_X86_SIMD(1)
|
|
|
|
# define COMPILE_INTEL_SSE 1
|
|
|
|
# endif
|
|
|
|
# if defined(__SSE2__) || MSC_X86_SIMD(2)
|
|
|
|
# define COMPILE_INTEL_SSE2 1
|
|
|
|
# endif
|
|
|
|
# if defined(__SSE3__)
|
|
|
|
# define COMPILE_INTEL_SSE3 1
|
|
|
|
# endif
|
|
|
|
# if defined(__SSSE3__) || MSC_X86_SIMD(2)
|
|
|
|
# define COMPILE_INTEL_SSSE3 1
|
|
|
|
# endif
|
|
|
|
# if defined(__SSE4_1__) || MSC_X86_SIMD(2)
|
|
|
|
# define COMPILE_INTEL_SSE41 1
|
|
|
|
# endif
|
|
|
|
# if defined(__SSE4_2__) || MSC_X86_SIMD(2)
|
|
|
|
# define COMPILE_INTEL_SSE42 1
|
|
|
|
# endif
|
|
|
|
# if defined(__AVX__)
|
|
|
|
# define COMPILE_INTEL_AVX 1
|
|
|
|
# endif
|
|
|
|
# if defined(__AVX2__)
|
|
|
|
# define COMPILE_INTEL_AVX2 1
|
|
|
|
# endif
|
2014-04-29 08:14:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined (_M_PPC) || defined(__powerpc64__) || defined(__powerpc__)
|
2014-07-09 13:16:52 +00:00
|
|
|
# define COMPILE_POWERPC 1
|
|
|
|
# ifdef __ALTIVEC__
|
|
|
|
# define COMPILE_POWERPC_ALTIVEC 1
|
|
|
|
# else
|
|
|
|
# define COMPILE_POWERPC_ALTIVEC 0
|
|
|
|
# endif
|
2014-04-29 08:14:42 +00:00
|
|
|
#else
|
2014-07-09 13:16:52 +00:00
|
|
|
# define COMPILE_POWERPC 0
|
2014-04-29 08:14:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined (_M_ARM) || defined(__arm__) || defined(__thumb__)
|
2014-07-09 13:16:52 +00:00
|
|
|
# define COMPILE_ARM 1
|
2014-04-29 08:14:42 +00:00
|
|
|
#else
|
2014-07-09 13:16:52 +00:00
|
|
|
# define COMPILE_ARM 0
|
2014-04-29 08:14:42 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char *type; //Type of the function, usually its name
|
|
|
|
const char *strategy_name; //Name of the strategy (e.g. sse2)
|
|
|
|
unsigned int priority; //Priority. 0 = lowest (default strategy)
|
|
|
|
void *fptr; //Pointer to the function
|
2015-03-04 14:17:45 +00:00
|
|
|
} strategy_t;
|
2014-04-29 08:14:42 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
unsigned int count;
|
|
|
|
unsigned int allocated;
|
2015-03-04 14:17:45 +00:00
|
|
|
strategy_t* strategies;
|
2015-03-04 14:23:04 +00:00
|
|
|
} strategy_list_t;
|
2014-04-29 08:14:42 +00:00
|
|
|
|
|
|
|
#define STRATEGY_LIST_ALLOC_SIZE 16
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
const char *strategy_type;
|
|
|
|
void **fptr;
|
2015-03-04 14:24:06 +00:00
|
|
|
} strategy_to_select_t;
|
2014-04-29 08:14:42 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int intel;
|
|
|
|
struct {
|
|
|
|
int mmx;
|
|
|
|
int sse;
|
|
|
|
int sse2;
|
|
|
|
int sse3;
|
|
|
|
int ssse3;
|
|
|
|
int sse41;
|
|
|
|
int sse42;
|
|
|
|
int avx;
|
2014-06-12 15:16:03 +00:00
|
|
|
int avx2;
|
2014-04-29 08:14:42 +00:00
|
|
|
} intel_flags;
|
|
|
|
|
|
|
|
int powerpc;
|
|
|
|
struct {
|
|
|
|
int altivec;
|
|
|
|
} powerpc_flags;
|
|
|
|
|
|
|
|
int arm;
|
|
|
|
struct {
|
|
|
|
int neon;
|
|
|
|
} arm_flags;
|
2015-03-04 14:24:59 +00:00
|
|
|
} hardware_flags_t;
|
2014-04-29 08:14:42 +00:00
|
|
|
|
2015-03-04 14:24:59 +00:00
|
|
|
extern hardware_flags_t g_hardware_flags;
|
2014-04-29 08:14:42 +00:00
|
|
|
|
|
|
|
|
2014-10-14 09:01:56 +00:00
|
|
|
int strategyselector_init(int32_t cpuid);
|
2014-04-29 08:14:42 +00:00
|
|
|
int strategyselector_register(void *opaque, const char *type, const char *strategy_name, int priority, void *fptr);
|
|
|
|
|
|
|
|
|
|
|
|
//Strategy to include
|
2014-06-13 07:20:02 +00:00
|
|
|
#include "strategies/strategies-nal.h"
|
|
|
|
#include "strategies/strategies-picture.h"
|
2014-07-29 15:10:47 +00:00
|
|
|
#include "strategies/strategies-dct.h"
|
2014-11-20 16:38:54 +00:00
|
|
|
#include "strategies/strategies-ipol.h"
|
2014-04-29 08:14:42 +00:00
|
|
|
|
2015-03-04 14:24:06 +00:00
|
|
|
static const strategy_to_select_t strategies_to_select[] = {
|
2014-06-16 09:13:41 +00:00
|
|
|
STRATEGIES_NAL_EXPORTS
|
|
|
|
STRATEGIES_PICTURE_EXPORTS
|
2014-07-29 15:10:47 +00:00
|
|
|
STRATEGIES_DCT_EXPORTS
|
2014-11-20 16:38:54 +00:00
|
|
|
STRATEGIES_IPOL_EXPORTS
|
2014-07-23 12:15:09 +00:00
|
|
|
{ NULL, NULL },
|
2014-04-29 08:14:42 +00:00
|
|
|
};
|
|
|
|
|
2015-03-04 14:35:17 +00:00
|
|
|
unsigned satd_8bit_8x8_generic(const pixel_t * const block1, const pixel_t * const block2);
|
2014-04-29 08:14:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
#endif //STRATEGYSELECTOR_H_
|