mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Merge branch 'ML-cplx_red_ICIP'
This commit is contained in:
commit
57e8c3ebc2
|
@ -138,6 +138,7 @@
|
|||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\constraint.c" />
|
||||
<ClCompile Include="..\..\src\extras\crypto.cpp" />
|
||||
<ClCompile Include="..\..\src\extras\libmd5.c" />
|
||||
<ClCompile Include="..\..\src\input_frame_buffer.c" />
|
||||
|
@ -159,6 +160,7 @@
|
|||
<ClCompile Include="..\..\src\imagelist.c" />
|
||||
<ClCompile Include="..\..\src\inter.c" />
|
||||
<ClCompile Include="..\..\src\intra.c" />
|
||||
<ClCompile Include="..\..\src\ml_intra_cu_depth_pred.c" />
|
||||
<ClCompile Include="..\..\src\nal.c" />
|
||||
<ClCompile Include="..\..\src\rate_control.c" />
|
||||
<ClCompile Include="..\..\src\rdo.c" />
|
||||
|
@ -199,6 +201,7 @@
|
|||
<ClCompile Include="..\..\src\strategies\strategies-intra.c" />
|
||||
<ClCompile Include="..\..\src\strategies\strategies-quant.c" />
|
||||
<ClInclude Include="..\..\src\checkpoint.h" />
|
||||
<ClInclude Include="..\..\src\constraint.h" />
|
||||
<ClInclude Include="..\..\src\cu.h" />
|
||||
<ClInclude Include="..\..\src\extras\crypto.h" />
|
||||
<ClInclude Include="..\..\src\extras\libmd5.h" />
|
||||
|
@ -259,6 +262,7 @@
|
|||
<ClInclude Include="..\..\src\input_frame_buffer.h" />
|
||||
<ClInclude Include="..\..\src\kvazaar_internal.h" />
|
||||
<ClInclude Include="..\..\src\kvz_math.h" />
|
||||
<ClInclude Include="..\..\src\ml_intra_cu_depth_pred.h" />
|
||||
<ClInclude Include="..\..\src\search_inter.h" />
|
||||
<ClInclude Include="..\..\src\search_intra.h" />
|
||||
<ClInclude Include="..\..\src\strategies\avx2\avx2_common_functions.h" />
|
||||
|
|
|
@ -52,6 +52,9 @@
|
|||
<Filter Include="Threadwrapper">
|
||||
<UniqueIdentifier>{f4abece9-e209-4817-a57e-c64ca7c5e05c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Constraint">
|
||||
<UniqueIdentifier>{895fc8cc-6f08-49a7-b377-b5c38a44d1b1}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\src\strategies\strategies-nal.c">
|
||||
|
@ -239,6 +242,12 @@
|
|||
<ClCompile Include="..\..\src\threadwrapper\src\semaphore.cpp">
|
||||
<Filter>Threadwrapper</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\constraint.c">
|
||||
<Filter>Constraint</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\ml_intra_cu_depth_pred.c">
|
||||
<Filter>Constraint</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\src\bitstream.h">
|
||||
|
@ -453,6 +462,12 @@
|
|||
<ClInclude Include="..\..\src\threadwrapper\include\semaphore.h">
|
||||
<Filter>Threadwrapper</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\constraint.h">
|
||||
<Filter>Constraint</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\src\ml_intra_cu_depth_pred.h">
|
||||
<Filter>Constraint</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<YASM Include="..\..\src\extras\x86inc.asm">
|
||||
|
|
|
@ -53,6 +53,8 @@ libkvazaar_la_SOURCES = \
|
|||
checkpoint.h \
|
||||
cfg.c \
|
||||
cfg.h \
|
||||
constraint.c \
|
||||
constraint.h \
|
||||
context.c \
|
||||
context.h \
|
||||
cu.c \
|
||||
|
@ -85,6 +87,8 @@ libkvazaar_la_SOURCES = \
|
|||
kvazaar.c \
|
||||
kvazaar_internal.h \
|
||||
kvz_math.h \
|
||||
ml_intra_cu_depth_pred.c \
|
||||
ml_intra_cu_depth_pred.h \
|
||||
nal.c \
|
||||
nal.h \
|
||||
rate_control.c \
|
||||
|
|
|
@ -141,6 +141,8 @@ int kvz_config_init(kvz_config *cfg)
|
|||
cfg->max_merge = 5;
|
||||
cfg->early_skip = true;
|
||||
|
||||
cfg->ml_pu_depth_intra = false;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -1260,6 +1262,9 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
|
|||
else if OPT("early-skip") {
|
||||
cfg->early_skip = (bool)atobool(value);
|
||||
}
|
||||
else if OPT("ml-pu-depth-intra") {
|
||||
cfg->ml_pu_depth_intra = (bool)atobool(value);
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -137,7 +137,8 @@ static const struct option long_options[] = {
|
|||
{ "max-merge", required_argument, NULL, 0 },
|
||||
{ "early-skip", no_argument, NULL, 0 },
|
||||
{ "no-early-skip", no_argument, NULL, 0 },
|
||||
{0, 0, 0, 0}
|
||||
{ "ml-pu-depth-intra", no_argument, NULL, 0 },
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -478,6 +479,9 @@ void print_help(void)
|
|||
" - 0, 1, 2, 3: from 64x64 to 8x8\n"
|
||||
" --pu-depth-intra <int>-<int> : Intra prediction units sizes [1-4]\n"
|
||||
" - 0, 1, 2, 3, 4: from 64x64 to 4x4\n"
|
||||
" --ml-pu-depth-intra : Predict the pu-depth-intra using machine\n"
|
||||
" learning trees, overrides the\n"
|
||||
" --pu-depth-intra parameter. [disabled]\n"
|
||||
" --tr-depth-intra <int> : Transform split depth for intra blocks [0]\n"
|
||||
" --(no-)bipred : Bi-prediction [disabled]\n"
|
||||
" --cu-split-termination <string> : CU split search termination [zero]\n"
|
||||
|
|
59
src/constraint.c
Normal file
59
src/constraint.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*****************************************************************************
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include "constraint.h"
|
||||
|
||||
/**
|
||||
* \brief Allocate the constraint_t structure.
|
||||
*
|
||||
* \param state encoder state
|
||||
* \return the pointer of constraint_t structure
|
||||
*/
|
||||
void * kvz_init_constraint(encoder_state_t* state, const encoder_control_t * const encoder) {
|
||||
constraint_t* constr = NULL;
|
||||
// Allocate the constraint_t strucutre
|
||||
constr = MALLOC(constraint_t, 1);
|
||||
if (!constr) {
|
||||
fprintf(stderr, "Memory allocation failed!\n");
|
||||
assert(0);
|
||||
}
|
||||
|
||||
// Allocate the ml_intra_ctu_pred_t structure
|
||||
constr->ml_intra_depth_ctu = NULL;
|
||||
if (encoder->cfg.ml_pu_depth_intra) // TODO: Change this by a new param !!
|
||||
{
|
||||
constr->ml_intra_depth_ctu = kvz_init_ml_intra_depth_const();
|
||||
}
|
||||
return constr;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Deallocate the constraint_t structure.
|
||||
*
|
||||
* \param state encoder state
|
||||
*/
|
||||
void kvz_constraint_free(encoder_state_t* state) {
|
||||
constraint_t* constr = state->constraint;
|
||||
if (constr->ml_intra_depth_ctu)
|
||||
{
|
||||
kvz_end_ml_intra_depth_const(constr->ml_intra_depth_ctu);
|
||||
}
|
||||
FREE_POINTER(constr);
|
||||
}
|
40
src/constraint.h
Normal file
40
src/constraint.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
#ifndef CONSTRAINT_H_
|
||||
#define CONSTRAINT_H_
|
||||
/*****************************************************************************
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ml_intra_cu_depth_pred.h"
|
||||
#include "encoderstate.h"
|
||||
|
||||
|
||||
/* Constraint structure:
|
||||
* Each field corresponds to a constraint technique. The encoder tests if the constraint
|
||||
* pointer is allocated to apply the technique.
|
||||
*/
|
||||
typedef struct {
|
||||
// Structure used for the CTU depth prediction using Machine Learning in All Intra
|
||||
ml_intra_ctu_pred_t * ml_intra_depth_ctu;
|
||||
} constraint_t;
|
||||
|
||||
|
||||
void * kvz_init_constraint(encoder_state_t* state, const encoder_control_t * const);
|
||||
void kvz_constraint_free(encoder_state_t* state);
|
||||
|
||||
#endif
|
|
@ -348,7 +348,9 @@ int kvz_encoder_state_init(encoder_state_t * const child_state, encoder_state_t
|
|||
if (!child_state->slice) child_state->slice = parent_state->slice;
|
||||
if (!child_state->wfrow) child_state->wfrow = parent_state->wfrow;
|
||||
}
|
||||
|
||||
// Intialization of the constraint structure
|
||||
child_state->constraint = kvz_init_constraint(child_state->constraint, child_state->encoder_control);
|
||||
|
||||
kvz_bitstream_init(&child_state->stream);
|
||||
|
||||
// Set CABAC output bitstream
|
||||
|
@ -681,7 +683,7 @@ void kvz_encoder_state_finalize(encoder_state_t * const state) {
|
|||
for (i = 0; state->children[i].encoder_control; ++i) {
|
||||
kvz_encoder_state_finalize(&state->children[i]);
|
||||
}
|
||||
|
||||
|
||||
FREE_POINTER(state->children);
|
||||
}
|
||||
|
||||
|
@ -706,6 +708,11 @@ void kvz_encoder_state_finalize(encoder_state_t * const state) {
|
|||
FREE_POINTER(state->frame);
|
||||
}
|
||||
|
||||
if (state->constraint) {
|
||||
// End of the constraint structure
|
||||
kvz_constraint_free(state);
|
||||
}
|
||||
|
||||
kvz_bitstream_finalize(&state->stream);
|
||||
|
||||
kvz_threadqueue_free_job(&state->tqj_recon_done);
|
||||
|
|
|
@ -27,7 +27,8 @@
|
|||
*/
|
||||
|
||||
#include "global.h" // IWYU pragma: keep
|
||||
|
||||
#include "ml_intra_cu_depth_pred.h"
|
||||
#include "constraint.h"
|
||||
|
||||
// Forward declare because including the header would lead to a cyclic
|
||||
// dependency.
|
||||
|
|
|
@ -1163,6 +1163,12 @@ static void encoder_state_init_children(encoder_state_t * const state) {
|
|||
kvz_threadqueue_free_job(&state->tqj_bitstream_written);
|
||||
kvz_threadqueue_free_job(&state->tqj_recon_done);
|
||||
|
||||
//Copy the constraint pointer
|
||||
// TODO: Try to do it in the if (state->is_leaf)
|
||||
//if (state->parent != NULL) {
|
||||
// state->constraint = state->parent->constraint;
|
||||
//}
|
||||
|
||||
for (int i = 0; state->children[i].encoder_control; ++i) {
|
||||
encoder_state_init_children(&state->children[i]);
|
||||
}
|
||||
|
@ -1345,6 +1351,7 @@ void kvz_encoder_prepare(encoder_state_t *state)
|
|||
assert(!state->tile->frame->rec);
|
||||
assert(!state->tile->frame->cu_array);
|
||||
state->frame->prepared = 1;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1395,6 +1402,8 @@ void kvz_encoder_prepare(encoder_state_t *state)
|
|||
state->frame->irap_poc = prev_state->frame->irap_poc;
|
||||
|
||||
state->frame->prepared = 1;
|
||||
|
||||
|
||||
}
|
||||
|
||||
coeff_scan_order_t kvz_get_scan_order(int8_t cu_type, int intra_mode, int depth)
|
||||
|
|
|
@ -288,6 +288,11 @@ typedef struct encoder_state_t {
|
|||
//Jobs to wait for
|
||||
threadqueue_job_t * tqj_recon_done; //Reconstruction is done
|
||||
threadqueue_job_t * tqj_bitstream_written; //Bitstream is written
|
||||
|
||||
//Constraint structure
|
||||
void * constraint;
|
||||
|
||||
|
||||
} encoder_state_t;
|
||||
|
||||
void kvz_encode_one_frame(encoder_state_t * const state, kvz_picture* frame);
|
||||
|
|
|
@ -390,6 +390,9 @@ typedef struct kvz_config
|
|||
/** \brief Enable Early Skip Mode Decision */
|
||||
uint8_t early_skip;
|
||||
|
||||
/** \brief Enable Machine learning CU depth prediction for Intra encoding. */
|
||||
uint8_t ml_pu_depth_intra;
|
||||
|
||||
} kvz_config;
|
||||
|
||||
/**
|
||||
|
|
808
src/ml_classifier_intra_depth_pred.c
Normal file
808
src/ml_classifier_intra_depth_pred.c
Normal file
|
@ -0,0 +1,808 @@
|
|||
/*****************************************************************************
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ml_classifier_intra_depth_pred.h"
|
||||
|
||||
|
||||
int tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->merge_variance <= 140.3129)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 569.6553)
|
||||
{
|
||||
if (p_features->merge_variance <= 20.8854)
|
||||
{
|
||||
*p_nb_iter = 19428.0;
|
||||
*p_nb_bad = 1740.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->sub_variance_0 <= 9.1015)
|
||||
{
|
||||
if (p_features->merge_variance <= 39.132)
|
||||
{
|
||||
*p_nb_iter = 1166.0;
|
||||
*p_nb_bad = 358.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1049.0;
|
||||
*p_nb_bad = 392.0;
|
||||
return 1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 9371.0;
|
||||
*p_nb_bad = 1805.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->sub_variance_2 <= 23.3193)
|
||||
{
|
||||
*p_nb_iter = 1059.0;
|
||||
*p_nb_bad = 329.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else if (p_features->sub_variance_1 <= 30.7348)
|
||||
{
|
||||
*p_nb_iter = 1042.0;
|
||||
*p_nb_bad = 395.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1756.0;
|
||||
*p_nb_bad = 588.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->merge_variance <= 857.8047)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 66593.5553)
|
||||
{
|
||||
if (p_features->sub_variance_0 <= 12.1697)
|
||||
{
|
||||
*p_nb_iter = 2006.0;
|
||||
*p_nb_bad = 374.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_C <= 646.8204)
|
||||
{
|
||||
if (p_features->neigh_variance_A <= 664.7609)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 571.2004)
|
||||
{
|
||||
if (p_features->var_of_sub_mean <= 4.1069)
|
||||
{
|
||||
*p_nb_iter = 1208.0;
|
||||
*p_nb_bad = 399.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 11832.6635)
|
||||
{
|
||||
*p_nb_iter = 8701.0;
|
||||
*p_nb_bad = 3037.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_A <= 142.298)
|
||||
{
|
||||
*p_nb_iter = 1025.0;
|
||||
*p_nb_bad = 290.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else if (p_features->variance <= 394.4839)
|
||||
{
|
||||
*p_nb_iter = 1156.0;
|
||||
*p_nb_bad = 489.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1150.0;
|
||||
*p_nb_bad = 503.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1777.0;
|
||||
*p_nb_bad = 558.0;
|
||||
return 1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1587.0;
|
||||
*p_nb_bad = 411.0;
|
||||
return 1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1980.0;
|
||||
*p_nb_bad = 474.0;
|
||||
return 1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 3613.0;
|
||||
*p_nb_bad = 475.0;
|
||||
return 1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 20926.0;
|
||||
*p_nb_bad = 1873.0;
|
||||
return 1.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->merge_variance <= 119.4611)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 1078.0638)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 70.2189)
|
||||
{
|
||||
*p_nb_iter = 29253.0;
|
||||
*p_nb_bad = 3837.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->variance <= 20.8711)
|
||||
{
|
||||
*p_nb_iter = 1292.0;
|
||||
*p_nb_bad = 458.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1707.0;
|
||||
*p_nb_bad = 399.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 3300.4034)
|
||||
{
|
||||
*p_nb_iter = 1554.0;
|
||||
*p_nb_bad = 675.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1540.0;
|
||||
*p_nb_bad = 429.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->merge_variance <= 696.1989)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 31803.3242)
|
||||
{
|
||||
if (p_features->sub_variance_2 <= 10.3845)
|
||||
{
|
||||
*p_nb_iter = 3473.0;
|
||||
*p_nb_bad = 768.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_C <= 571.5329)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 492.8159)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 38.9672)
|
||||
{
|
||||
*p_nb_iter = 1887.0;
|
||||
*p_nb_bad = 588.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_A <= 380.5927)
|
||||
{
|
||||
if (p_features->sub_variance_1 <= 19.9678)
|
||||
{
|
||||
*p_nb_iter = 1686.0;
|
||||
*p_nb_bad = 721.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_A <= 66.6749)
|
||||
{
|
||||
*p_nb_iter = 1440.0;
|
||||
*p_nb_bad = 631.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 5772.0;
|
||||
*p_nb_bad = 2031.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1791.0;
|
||||
*p_nb_bad = 619.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1624.0;
|
||||
*p_nb_bad = 494.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1298.0;
|
||||
*p_nb_bad = 312.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 4577.0;
|
||||
*p_nb_bad = 892.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 21106.0;
|
||||
*p_nb_bad = 2744.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tree_predict_merge_depth_3(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->merge_variance <= 80.1487)
|
||||
{
|
||||
if (p_features->neigh_variance_C <= 83.7148)
|
||||
{
|
||||
*p_nb_iter = 29806.0;
|
||||
*p_nb_bad = 3603.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1003.0;
|
||||
*p_nb_bad = 421.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->merge_variance <= 351.8138)
|
||||
{
|
||||
if (p_features->neigh_variance_C <= 255.4236)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 260.5349)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 6381.513)
|
||||
{
|
||||
if (p_features->neigh_variance_A <= 244.2556)
|
||||
{
|
||||
if (p_features->sub_variance_0 <= 4.75)
|
||||
{
|
||||
*p_nb_iter = 1290.0;
|
||||
*p_nb_bad = 525.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_B <= 16.9287)
|
||||
{
|
||||
*p_nb_iter = 1045.0;
|
||||
*p_nb_bad = 499.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 6901.0;
|
||||
*p_nb_bad = 2494.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1332.0;
|
||||
*p_nb_bad = 408.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2929.0;
|
||||
*p_nb_bad = 842.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2239.0;
|
||||
*p_nb_bad = 572.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2777.0;
|
||||
*p_nb_bad = 714.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 30678.0;
|
||||
*p_nb_bad = 5409.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tree_predict_merge_depth_4(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->neigh_variance_C <= 240.2773)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 227.5898)
|
||||
{
|
||||
if (p_features->neigh_variance_A <= 195.4844)
|
||||
{
|
||||
if (p_features->variance <= 203.3086)
|
||||
{
|
||||
if (p_features->qp <= 32)
|
||||
{
|
||||
if (p_features->neigh_variance_C <= 102.2344)
|
||||
{
|
||||
if (p_features->neigh_variance_B <= 116.4961)
|
||||
{
|
||||
if (p_features->variance <= 89.4023)
|
||||
{
|
||||
*p_nb_iter = 27398.0;
|
||||
*p_nb_bad = 4665.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1676.0;
|
||||
*p_nb_bad = 795.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1405.0;
|
||||
*p_nb_bad = 566.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2827.0;
|
||||
*p_nb_bad = 1173.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 8871.0;
|
||||
*p_nb_bad = 822.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 3162.0;
|
||||
*p_nb_bad = 718.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 6154.0;
|
||||
*p_nb_bad = 1397.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 9385.0;
|
||||
*p_nb_bad = 1609.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 19122.0;
|
||||
*p_nb_bad = 2960.0;
|
||||
return 4.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 12754.7856)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 137.9034)
|
||||
{
|
||||
*p_nb_iter = 25155.0;
|
||||
*p_nb_bad = 2959.0;
|
||||
return 0.0000;
|
||||
}
|
||||
else if (p_features->sub_variance_2 <= 13.2892)
|
||||
{
|
||||
*p_nb_iter = 1080.0;
|
||||
*p_nb_bad = 383.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->variance <= 564.1738)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 1185.4728)
|
||||
{
|
||||
*p_nb_iter = 6067.0;
|
||||
*p_nb_bad = 1699.0;
|
||||
return 0.0000;
|
||||
}
|
||||
else if (p_features->var_of_sub_mean <= 46.2388)
|
||||
{
|
||||
if (p_features->sub_variance_0 <= 46.8708)
|
||||
{
|
||||
*p_nb_iter = 1088.0;
|
||||
*p_nb_bad = 377.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->sub_variance_3 <= 61.4213)
|
||||
{
|
||||
*p_nb_iter = 1183.0;
|
||||
*p_nb_bad = 498.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 3416.0;
|
||||
*p_nb_bad = 1373.0;
|
||||
return 0.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 3769.0;
|
||||
*p_nb_bad = 1093.0;
|
||||
return 0.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1036.0;
|
||||
*p_nb_bad = 434.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 98333.8279)
|
||||
{
|
||||
if (p_features->variance <= 987.2333)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 37261.2896)
|
||||
{
|
||||
if (p_features->variance <= 238.2248)
|
||||
{
|
||||
*p_nb_iter = 1323.0;
|
||||
*p_nb_bad = 301.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 17347.3971)
|
||||
{
|
||||
*p_nb_iter = 1215.0;
|
||||
*p_nb_bad = 550.0;
|
||||
return 0.0000;
|
||||
}
|
||||
else if (p_features->qp <= 22)
|
||||
{
|
||||
*p_nb_iter = 1000.0;
|
||||
*p_nb_bad = 493.0;
|
||||
return 0.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2640.0;
|
||||
*p_nb_bad = 1121.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 5188.0;
|
||||
*p_nb_bad = 1248.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2323.0;
|
||||
*p_nb_bad = 274.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 21357.0;
|
||||
*p_nb_bad = 1829.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 1138.9473)
|
||||
{
|
||||
*p_nb_iter = 32445.0;
|
||||
*p_nb_bad = 4580.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 27289.2117)
|
||||
{
|
||||
if (p_features->sub_variance_1 <= 12.0603)
|
||||
{
|
||||
*p_nb_iter = 1900.0;
|
||||
*p_nb_bad = 401.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 5841.4773)
|
||||
{
|
||||
if (p_features->variance <= 72.4175)
|
||||
{
|
||||
*p_nb_iter = 1000.0;
|
||||
*p_nb_bad = 356.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_A <= 633.8163)
|
||||
{
|
||||
*p_nb_iter = 5279.0;
|
||||
*p_nb_bad = 1961.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1176.0;
|
||||
*p_nb_bad = 527.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->sub_variance_0 <= 38.3035)
|
||||
{
|
||||
*p_nb_iter = 1251.0;
|
||||
*p_nb_bad = 293.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_B <= 664.9494)
|
||||
{
|
||||
if (p_features->sub_variance_3 <= 45.8181)
|
||||
{
|
||||
*p_nb_iter = 1276.0;
|
||||
*p_nb_bad = 471.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->sub_variance_3 <= 404.3086)
|
||||
{
|
||||
if (p_features->sub_variance_1 <= 99.8715)
|
||||
{
|
||||
*p_nb_iter = 1005.0;
|
||||
*p_nb_bad = 435.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->sub_variance_0 <= 282.3064)
|
||||
{
|
||||
*p_nb_iter = 1370.0;
|
||||
*p_nb_bad = 539.0;
|
||||
return 1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1013.0;
|
||||
*p_nb_bad = 495.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1000.0;
|
||||
*p_nb_bad = 379.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2270.0;
|
||||
*p_nb_bad = 679.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 29015.0;
|
||||
*p_nb_bad = 3950.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 2597.4529)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 146.7734)
|
||||
{
|
||||
*p_nb_iter = 23216.0;
|
||||
*p_nb_bad = 1560.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else if (p_features->merge_variance <= 259.6952)
|
||||
{
|
||||
*p_nb_iter = 7470.0;
|
||||
*p_nb_bad = 1902.0;
|
||||
return 2.0000;
|
||||
}
|
||||
else if (p_features->qp <= 27)
|
||||
{
|
||||
if (p_features->variance <= 73.9929)
|
||||
{
|
||||
*p_nb_iter = 1138.0;
|
||||
*p_nb_bad = 486.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1619.0;
|
||||
*p_nb_bad = 716.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2425.0;
|
||||
*p_nb_bad = 861.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 60850.5208)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 10144.602)
|
||||
{
|
||||
if (p_features->neigh_variance_C <= 926.8972)
|
||||
{
|
||||
if (p_features->sub_variance_0 <= 26.6006)
|
||||
{
|
||||
*p_nb_iter = 1796.0;
|
||||
*p_nb_bad = 586.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_A <= 493.5849)
|
||||
{
|
||||
if (p_features->neigh_variance_A <= 72.9516)
|
||||
{
|
||||
*p_nb_iter = 1326.0;
|
||||
*p_nb_bad = 557.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->variance <= 156.4014)
|
||||
{
|
||||
*p_nb_iter = 1210.0;
|
||||
*p_nb_bad = 563.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1920.0;
|
||||
*p_nb_bad = 817.0;
|
||||
return 2.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1106.0;
|
||||
*p_nb_bad = 437.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1001.0;
|
||||
*p_nb_bad = 278.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 13068.0;
|
||||
*p_nb_bad = 3612.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 22705.0;
|
||||
*p_nb_bad = 2687.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, double* p_nb_bad)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 818.5173)
|
||||
{
|
||||
if (p_features->merge_variance <= 62.7641)
|
||||
{
|
||||
*p_nb_iter = 20568.0;
|
||||
*p_nb_bad = 767.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else if (p_features->qp <= 27)
|
||||
{
|
||||
if (p_features->variance <= 9.4219)
|
||||
{
|
||||
*p_nb_iter = 1255.0;
|
||||
*p_nb_bad = 206.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else if (p_features->merge_variance <= 375.2185)
|
||||
{
|
||||
*p_nb_iter = 3999.0;
|
||||
*p_nb_bad = 1321.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1786.0;
|
||||
*p_nb_bad = 817.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 5286.0;
|
||||
*p_nb_bad = 737.0;
|
||||
return 3.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->var_of_sub_var <= 37332.3018)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 7585.0282)
|
||||
{
|
||||
if (p_features->qp <= 32)
|
||||
{
|
||||
if (p_features->neigh_variance_C <= 330.2178)
|
||||
{
|
||||
if (p_features->sub_variance_0 <= 8.5273)
|
||||
{
|
||||
*p_nb_iter = 1114.0;
|
||||
*p_nb_bad = 346.0;
|
||||
return -1.0000;
|
||||
}
|
||||
else if (p_features->neigh_variance_B <= 221.5469)
|
||||
{
|
||||
if (p_features->var_of_sub_var <= 1989.7928)
|
||||
{
|
||||
*p_nb_iter = 1539.0;
|
||||
*p_nb_bad = 606.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else if (p_features->variance <= 155.5974)
|
||||
{
|
||||
*p_nb_iter = 1298.0;
|
||||
*p_nb_bad = 634.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1076.0;
|
||||
*p_nb_bad = 456.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1644.0;
|
||||
*p_nb_bad = 639.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 2401.0;
|
||||
*p_nb_bad = 713.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else if (p_features->merge_variance <= 281.9509)
|
||||
{
|
||||
*p_nb_iter = 1020.0;
|
||||
*p_nb_bad = 262.0;
|
||||
return 3.0000;
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 1278.0;
|
||||
*p_nb_bad = 594.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 10507.0;
|
||||
*p_nb_bad = 2943.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
||||
else {
|
||||
*p_nb_iter = 25229.0;
|
||||
*p_nb_bad = 3060.0;
|
||||
return -1.0000;
|
||||
}
|
||||
}
|
38
src/ml_classifier_intra_depth_pred.h
Normal file
38
src/ml_classifier_intra_depth_pred.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
#ifndef ML_CLASSIFIER_INTRA_DEPTH_PRED
|
||||
#define ML_CLASSIFIER_INTRA_DEPTH_PRED
|
||||
|
||||
/*****************************************************************************
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ml_intra_cu_depth_pred.h"
|
||||
|
||||
|
||||
int tree_predict_merge_depth_1(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
int tree_predict_merge_depth_2(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
int tree_predict_merge_depth_3(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
int tree_predict_merge_depth_4(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
|
||||
|
||||
int tree_predict_split_depth_0(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
int tree_predict_split_depth_1(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
int tree_predict_split_depth_2(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
int tree_predict_split_depth_3(features_s* p_features, double* p_nb_iter, double* p_nb_bad);
|
||||
|
||||
#endif
|
1744
src/ml_intra_cu_depth_pred.c
Normal file
1744
src/ml_intra_cu_depth_pred.c
Normal file
File diff suppressed because it is too large
Load diff
90
src/ml_intra_cu_depth_pred.h
Normal file
90
src/ml_intra_cu_depth_pred.h
Normal file
|
@ -0,0 +1,90 @@
|
|||
#ifndef ML_INTRA_CU_DEPTH_PRED_H_
|
||||
#define ML_INTRA_CU_DEPTH_PRED_H_
|
||||
/*****************************************************************************
|
||||
* 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/>.
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "global.h" // IWYU pragma: keep
|
||||
|
||||
|
||||
|
||||
|
||||
#define LCU_DEPTH_MAT_SIZE 64
|
||||
#define RESTRAINED_FLAG 1
|
||||
|
||||
#define pow2(x) ((x)*(x))
|
||||
#define CR_XMAX(x_px, block_size, width) (MIN((x_px) + (block_size), (width)) - (x_px))
|
||||
#define CR_YMAX(y_px, block_size, height) (MIN((y_px) + (block_size), (height)) - (y_px))
|
||||
#define CR_GET_X_LCU(lcu_id, nb_lcu_width) (((lcu_id) % (nb_lcu_width)) << 6)
|
||||
#define CR_GET_Y_LCU(lcu_id, nb_lcu_width) (((lcu_id) / (nb_lcu_width)) << 6)
|
||||
#define CR_GET_CU_D3(x, y, depth) ((x)*(1 << (3-depth)) + ((y) << (6 - depth)))
|
||||
#define CR_GET_CU_D4(x, y, depth) ((x)*(1 << (4-depth)) + ((y) << (8 - depth)))
|
||||
#define CR_GET_DEPTH_MIN(x, y, depth_min_mat) *(depth_min_mat + (x >> 3) + ((y >> 3) << 3))
|
||||
#define CR_GET_DEPTH_MAX(x, y, depth_max_mat) *(depth_max_mat + (x >> 3) + ((y >> 3) << 3))
|
||||
|
||||
typedef struct {
|
||||
int32_t x;
|
||||
int32_t y;
|
||||
}vect_2D;
|
||||
|
||||
|
||||
// Structure used for the CTU depth prediction using Machine Learning
|
||||
// in All Intra
|
||||
typedef struct {
|
||||
/*!< Number of depth to add to the QT prediction in ''one-shot'' */
|
||||
int8_t i_nb_addDepth;
|
||||
/*!< Apply an extra Upper Expansion in the upper_depth */
|
||||
bool b_extra_up_exp;
|
||||
/*!< Matrix used to store the upper and lower QT prediction*/
|
||||
uint8_t* _mat_upper_depth;
|
||||
uint8_t* _mat_lower_depth;
|
||||
} ml_intra_ctu_pred_t;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* brief generic structure used for the features
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
double variance;
|
||||
double merge_variance;
|
||||
double sub_variance_0;
|
||||
double sub_variance_1;
|
||||
double sub_variance_2;
|
||||
double sub_variance_3;
|
||||
double neigh_variance_A;
|
||||
double neigh_variance_B;
|
||||
double neigh_variance_C;
|
||||
double var_of_sub_mean;
|
||||
int qp;
|
||||
//int NB_pixels;
|
||||
double var_of_sub_var;
|
||||
}features_s;
|
||||
|
||||
|
||||
typedef int (*tree_predict)(features_s*, double*, double*);
|
||||
|
||||
ml_intra_ctu_pred_t* kvz_init_ml_intra_depth_const(void);
|
||||
void kvz_end_ml_intra_depth_const(ml_intra_ctu_pred_t * ml_intra_depth_ctu);
|
||||
|
||||
void kvz_lcu_luma_depth_pred(ml_intra_ctu_pred_t* ml_intra_depth_ctu, uint8_t* luma_px, int8_t qp);
|
||||
|
||||
#endif
|
38
src/search.c
38
src/search.c
|
@ -455,6 +455,11 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
uint32_t inter_bitcost = MAX_INT;
|
||||
cu_info_t *cur_cu;
|
||||
|
||||
struct {
|
||||
int32_t min;
|
||||
int32_t max;
|
||||
} pu_depth_inter, pu_depth_intra;
|
||||
|
||||
lcu_t *const lcu = &work_tree[depth];
|
||||
|
||||
int x_local = SUB_SCU(x);
|
||||
|
@ -466,6 +471,19 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Assign correct depth limit
|
||||
constraint_t* constr = state->constraint;
|
||||
if(constr->ml_intra_depth_ctu) {
|
||||
pu_depth_intra.min = constr->ml_intra_depth_ctu->_mat_upper_depth[(x_local >> 3) + (y_local >> 3) * 8];
|
||||
pu_depth_intra.max = constr->ml_intra_depth_ctu->_mat_lower_depth[(x_local >> 3) + (y_local >> 3) * 8];
|
||||
}
|
||||
else {
|
||||
pu_depth_intra.min = ctrl->cfg.pu_depth_intra.min;
|
||||
pu_depth_intra.max = ctrl->cfg.pu_depth_intra.max;
|
||||
}
|
||||
pu_depth_inter.min = ctrl->cfg.pu_depth_inter.min;
|
||||
pu_depth_inter.max = ctrl->cfg.pu_depth_inter.max;
|
||||
|
||||
cur_cu = LCU_GET_CU_AT_PX(lcu, x_local, y_local);
|
||||
// Assign correct depth
|
||||
cur_cu->depth = depth > MAX_DEPTH ? MAX_DEPTH : depth;
|
||||
|
@ -479,12 +497,12 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
if (x + cu_width <= frame->width &&
|
||||
y + cu_width <= frame->height)
|
||||
{
|
||||
int cu_width_inter_min = LCU_WIDTH >> ctrl->cfg.pu_depth_inter.max;
|
||||
int cu_width_inter_min = LCU_WIDTH >> pu_depth_inter.max;
|
||||
bool can_use_inter =
|
||||
state->frame->slicetype != KVZ_SLICE_I &&
|
||||
depth <= MAX_DEPTH &&
|
||||
(
|
||||
WITHIN(depth, ctrl->cfg.pu_depth_inter.min, ctrl->cfg.pu_depth_inter.max) ||
|
||||
WITHIN(depth, pu_depth_inter.min, pu_depth_inter.max) ||
|
||||
// When the split was forced because the CTU is partially outside the
|
||||
// frame, we permit inter coding even if pu_depth_inter would
|
||||
// otherwise forbid it.
|
||||
|
@ -543,9 +561,9 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
&& cost / (cu_width * cu_width) < INTRA_THRESHOLD)
|
||||
|| (ctrl->cfg.early_skip && cur_cu->skipped);
|
||||
|
||||
int32_t cu_width_intra_min = LCU_WIDTH >> ctrl->cfg.pu_depth_intra.max;
|
||||
int32_t cu_width_intra_min = LCU_WIDTH >> pu_depth_intra.max;
|
||||
bool can_use_intra =
|
||||
WITHIN(depth, ctrl->cfg.pu_depth_intra.min, ctrl->cfg.pu_depth_intra.max) ||
|
||||
WITHIN(depth, pu_depth_intra.min, pu_depth_intra.max) ||
|
||||
// When the split was forced because the CTU is partially outside
|
||||
// the frame, we permit intra coding even if pu_depth_intra would
|
||||
// otherwise forbid it.
|
||||
|
@ -677,9 +695,9 @@ static double search_cu(encoder_state_t * const state, int x, int y, int depth,
|
|||
// If the CU is partially outside the frame, we need to split it even
|
||||
// if pu_depth_intra and pu_depth_inter would not permit it.
|
||||
cur_cu->type == CU_NOTSET ||
|
||||
depth < ctrl->cfg.pu_depth_intra.max ||
|
||||
depth < pu_depth_intra.max ||
|
||||
(state->frame->slicetype != KVZ_SLICE_I &&
|
||||
depth < ctrl->cfg.pu_depth_inter.max);
|
||||
depth < pu_depth_inter.max);
|
||||
|
||||
// Recursively split all the way to max search depth.
|
||||
if (can_split_cu) {
|
||||
|
@ -937,6 +955,14 @@ void kvz_search_lcu(encoder_state_t * const state, const int x, const int y, con
|
|||
work_tree[depth] = work_tree[0];
|
||||
}
|
||||
|
||||
// If the ML depth prediction is enabled,
|
||||
// generate the depth prediction interval
|
||||
// for the current lcu
|
||||
constraint_t* constr = state->constraint;
|
||||
if (constr->ml_intra_depth_ctu) {
|
||||
kvz_lcu_luma_depth_pred(constr->ml_intra_depth_ctu, work_tree[0].ref.y, state->qp);
|
||||
}
|
||||
|
||||
// Start search from depth 0.
|
||||
double cost = search_cu(state, x, y, 0, work_tree);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "encoderstate.h"
|
||||
#include "global.h" // IWYU pragma: keep
|
||||
#include "image.h"
|
||||
#include "constraint.h"
|
||||
|
||||
void kvz_sort_modes(int8_t *__restrict modes, double *__restrict costs, uint8_t length);
|
||||
|
||||
|
|
Loading…
Reference in a new issue