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/>.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-07-29 15:10:47 +00:00
|
|
|
#include "strategies/strategies-dct.h"
|
2016-04-01 14:14:23 +00:00
|
|
|
|
|
|
|
#include "avx2/dct-avx2.h"
|
|
|
|
#include "generic/dct-generic.h"
|
2014-07-29 15:10:47 +00:00
|
|
|
#include "strategyselector.h"
|
|
|
|
|
2016-04-01 14:14:23 +00:00
|
|
|
|
2014-07-29 15:10:47 +00:00
|
|
|
// Define function pointers.
|
2015-08-26 08:50:27 +00:00
|
|
|
dct_func * kvz_fast_forward_dst_4x4 = 0;
|
2014-07-29 15:10:47 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
dct_func * kvz_dct_4x4 = 0;
|
|
|
|
dct_func * kvz_dct_8x8 = 0;
|
|
|
|
dct_func * kvz_dct_16x16 = 0;
|
|
|
|
dct_func * kvz_dct_32x32 = 0;
|
2014-07-29 15:10:47 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
dct_func * kvz_fast_inverse_dst_4x4 = 0;
|
2014-07-29 15:10:47 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
dct_func * kvz_idct_4x4 = 0;
|
|
|
|
dct_func * kvz_idct_8x8= 0;
|
|
|
|
dct_func * kvz_idct_16x16 = 0;
|
|
|
|
dct_func * kvz_idct_32x32 = 0;
|
2014-07-29 15:10:47 +00:00
|
|
|
|
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
int kvz_strategy_register_dct(void* opaque, uint8_t bitdepth) {
|
2014-07-29 15:10:47 +00:00
|
|
|
bool success = true;
|
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
success &= kvz_strategy_register_dct_generic(opaque, bitdepth);
|
2014-07-29 15:10:47 +00:00
|
|
|
|
2015-08-26 08:50:27 +00:00
|
|
|
if (kvz_g_hardware_flags.intel_flags.avx2) {
|
|
|
|
success &= kvz_strategy_register_dct_avx2(opaque, bitdepth);
|
2014-07-29 15:10:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-01-12 09:16:01 +00:00
|
|
|
* \brief Get a function that performs the transform for a block.
|
|
|
|
*
|
|
|
|
* \param width Width of the region
|
|
|
|
* \param color Color plane
|
|
|
|
* \param type Prediction type
|
|
|
|
*
|
|
|
|
* \returns Pointer to the function.
|
|
|
|
*/
|
|
|
|
dct_func * kvz_get_dct_func(int8_t width, color_t color, cu_type_t type)
|
2014-07-29 15:10:47 +00:00
|
|
|
{
|
|
|
|
switch (width) {
|
|
|
|
case 4:
|
2018-01-12 09:16:01 +00:00
|
|
|
if (color == COLOR_Y && type == CU_INTRA) {
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_fast_forward_dst_4x4;
|
2018-01-12 09:16:01 +00:00
|
|
|
} else {
|
|
|
|
return kvz_dct_4x4;
|
|
|
|
}
|
2014-07-29 15:10:47 +00:00
|
|
|
case 8:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_dct_8x8;
|
2014-07-29 15:10:47 +00:00
|
|
|
case 16:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_dct_16x16;
|
2014-07-29 15:10:47 +00:00
|
|
|
case 32:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_dct_32x32;
|
2014-07-29 15:10:47 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-01-12 09:16:01 +00:00
|
|
|
* \brief Get a function that performs the inverse transform for a block.
|
|
|
|
*
|
|
|
|
* \param width Width of the region
|
|
|
|
* \param color Color plane
|
|
|
|
* \param type Prediction type
|
|
|
|
*
|
|
|
|
* \returns Pointer to the function.
|
|
|
|
*/
|
|
|
|
dct_func * kvz_get_idct_func(int8_t width, color_t color, cu_type_t type)
|
2014-07-29 15:10:47 +00:00
|
|
|
{
|
|
|
|
switch (width) {
|
|
|
|
case 4:
|
2018-01-12 09:16:01 +00:00
|
|
|
if (color == COLOR_Y && type == CU_INTRA) {
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_fast_inverse_dst_4x4;
|
2018-01-12 09:16:01 +00:00
|
|
|
} else {
|
|
|
|
return kvz_idct_4x4;
|
2014-07-29 15:10:47 +00:00
|
|
|
}
|
|
|
|
case 8:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_idct_8x8;
|
2014-07-29 15:10:47 +00:00
|
|
|
case 16:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_idct_16x16;
|
2014-07-29 15:10:47 +00:00
|
|
|
case 32:
|
2015-08-26 08:50:27 +00:00
|
|
|
return kvz_idct_32x32;
|
2014-07-29 15:10:47 +00:00
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|