2015-02-23 11:18:48 +00:00
|
|
|
/*****************************************************************************
|
|
|
|
* This file is part of Kvazaar HEVC encoder.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013-2015 Tampere University of Technology and others (see
|
|
|
|
* COPYING file).
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with Kvazaar. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2016-03-31 10:34:32 +00:00
|
|
|
#include "strategies/strategies-picture.h"
|
2016-04-01 14:14:23 +00:00
|
|
|
|
|
|
|
#include "strategies/altivec/picture-altivec.h"
|
|
|
|
#include "strategies/avx2/picture-avx2.h"
|
|
|
|
#include "strategies/generic/picture-generic.h"
|
|
|
|
#include "strategies/sse2/picture-sse2.h"
|
|
|
|
#include "strategies/sse41/picture-sse41.h"
|
|
|
|
#include "strategies/x86_asm/picture-x86-asm.h"
|
2014-07-11 14:16:32 +00:00
|
|
|
#include "strategyselector.h"
|
2014-06-13 07:20:02 +00:00
|
|
|
|
2016-04-01 14:14:23 +00:00
|
|
|
|
2014-06-16 09:13:41 +00:00
|
|
|
// Define function pointers.
|
2015-08-26 08:50:27 +00:00
|
|
|
reg_sad_func * kvz_reg_sad = 0;
|
2014-06-16 09:13:41 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
cost_pixel_nxn_func * kvz_sad_4x4 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_sad_8x8 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_sad_16x16 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_sad_32x32 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_sad_64x64 = 0;
|
2014-06-16 09:13:41 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
cost_pixel_nxn_func * kvz_satd_4x4 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_satd_8x8 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_satd_16x16 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_satd_32x32 = 0;
|
|
|
|
cost_pixel_nxn_func * kvz_satd_64x64 = 0;
|
2014-06-16 09:13:41 +00:00
|
|
|
|
2015-11-13 12:41:53 +00:00
|
|
|
cost_pixel_nxn_multi_func * kvz_sad_4x4_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_sad_8x8_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_sad_16x16_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_sad_32x32_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_sad_64x64_dual = 0;
|
|
|
|
|
|
|
|
cost_pixel_nxn_multi_func * kvz_satd_4x4_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_satd_8x8_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_satd_16x16_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_satd_32x32_dual = 0;
|
|
|
|
cost_pixel_nxn_multi_func * kvz_satd_64x64_dual = 0;
|
|
|
|
|
2015-12-08 10:43:10 +00:00
|
|
|
cost_pixel_any_size_func * kvz_satd_any_size = 0;
|
|
|
|
|
2014-06-16 09:13:41 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
int kvz_strategy_register_picture(void* opaque, uint8_t bitdepth) {
|
2014-07-11 14:16:32 +00:00
|
|
|
bool success = true;
|
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
success &= kvz_strategy_register_picture_generic(opaque, bitdepth);
|
2014-07-11 14:16:32 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
if (kvz_g_hardware_flags.intel_flags.sse2) {
|
|
|
|
success &= kvz_strategy_register_picture_sse2(opaque, bitdepth);
|
2014-07-11 14:16:32 +00:00
|
|
|
}
|
2015-08-26 08:50:27 +00:00
|
|
|
if (kvz_g_hardware_flags.intel_flags.sse41) {
|
|
|
|
success &= kvz_strategy_register_picture_sse41(opaque, bitdepth);
|
2014-04-29 08:14:42 +00:00
|
|
|
}
|
2015-08-26 08:50:27 +00:00
|
|
|
if (kvz_g_hardware_flags.intel_flags.avx) {
|
|
|
|
success &= kvz_strategy_register_picture_x86_asm_avx(opaque, bitdepth);
|
2014-07-21 07:54:33 +00:00
|
|
|
}
|
2015-08-26 08:50:27 +00:00
|
|
|
if (kvz_g_hardware_flags.intel_flags.avx2) {
|
|
|
|
success &= kvz_strategy_register_picture_avx2(opaque, bitdepth);
|
2014-07-14 13:08:19 +00:00
|
|
|
}
|
2015-08-26 08:50:27 +00:00
|
|
|
if (kvz_g_hardware_flags.powerpc_flags.altivec) {
|
|
|
|
success &= kvz_strategy_register_picture_altivec(opaque, bitdepth);
|
2014-06-04 06:19:57 +00:00
|
|
|
}
|
2014-07-11 14:16:32 +00:00
|
|
|
|
|
|
|
return success;
|
2014-04-29 08:14:42 +00:00
|
|
|
}
|
2014-06-16 09:13:41 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get a function that calculates SATD for NxN block.
|
|
|
|
*
|
|
|
|
* \param n Width of the region for which SATD is calculated.
|
|
|
|
*
|
|
|
|
* \returns Pointer to cost_16bit_nxn_func.
|
|
|
|
*/
|
2015-08-26 08:50:27 +00:00
|
|
|
cost_pixel_nxn_func * kvz_pixels_get_satd_func(unsigned n)
|
2014-06-16 09:13:41 +00:00
|
|
|
{
|
|
|
|
switch (n) {
|
|
|
|
case 4:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_satd_4x4;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 8:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_satd_8x8;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 16:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_satd_16x16;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 32:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_satd_32x32;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 64:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_satd_64x64;
|
2014-06-16 09:13:41 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get a function that calculates SAD for NxN block.
|
|
|
|
*
|
|
|
|
* \param n Width of the region for which SAD is calculated.
|
|
|
|
*
|
|
|
|
* \returns Pointer to cost_16bit_nxn_func.
|
|
|
|
*/
|
2015-08-26 08:50:27 +00:00
|
|
|
cost_pixel_nxn_func * kvz_pixels_get_sad_func(unsigned n)
|
2014-06-16 09:13:41 +00:00
|
|
|
{
|
|
|
|
switch (n) {
|
|
|
|
case 4:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_sad_4x4;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 8:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_sad_8x8;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 16:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_sad_16x16;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 32:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_sad_32x32;
|
2014-06-16 09:13:41 +00:00
|
|
|
case 64:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_sad_64x64;
|
2014-06-16 09:13:41 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
2015-11-13 12:41:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get a function that calculates SATDs for 2 NxN blocks.
|
|
|
|
*
|
|
|
|
* \param n Width of the region for which SATD is calculated.
|
|
|
|
*
|
|
|
|
* \returns Pointer to cost_pixel_nxn_multi_func.
|
|
|
|
*/
|
|
|
|
cost_pixel_nxn_multi_func * kvz_pixels_get_satd_dual_func(unsigned n)
|
|
|
|
{
|
|
|
|
switch (n) {
|
|
|
|
case 4:
|
|
|
|
return kvz_satd_4x4_dual;
|
|
|
|
case 8:
|
|
|
|
return kvz_satd_8x8_dual;
|
|
|
|
case 16:
|
|
|
|
return kvz_satd_16x16_dual;
|
|
|
|
case 32:
|
|
|
|
return kvz_satd_32x32_dual;
|
|
|
|
case 64:
|
|
|
|
return kvz_satd_64x64_dual;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \brief Get a function that calculates SADs for 2 NxN blocks.
|
|
|
|
*
|
|
|
|
* \param n Width of the region for which SAD is calculated.
|
|
|
|
*
|
|
|
|
* \returns Pointer to cost_pixel_nxn_multi_func.
|
|
|
|
*/
|
|
|
|
cost_pixel_nxn_multi_func * kvz_pixels_get_sad_dual_func(unsigned n)
|
|
|
|
{
|
|
|
|
switch (n) {
|
|
|
|
case 4:
|
|
|
|
return kvz_sad_4x4_dual;
|
|
|
|
case 8:
|
|
|
|
return kvz_sad_8x8_dual;
|
|
|
|
case 16:
|
|
|
|
return kvz_sad_16x16_dual;
|
|
|
|
case 32:
|
|
|
|
return kvz_sad_32x32_dual;
|
|
|
|
case 64:
|
|
|
|
return kvz_sad_64x64_dual;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|