mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Add a step-cutoff parameter for motion estimation search
This commit is contained in:
parent
4e13608b01
commit
e8e0e7596a
|
@ -137,6 +137,9 @@ Compression tools:
|
||||||
- full: Full Search
|
- full: Full Search
|
||||||
- full8, full16, full32, full64
|
- full8, full16, full32, full64
|
||||||
- dia: Diamond Search
|
- dia: Diamond Search
|
||||||
|
--me-steps <integer> : How many search steps does the motion estimation
|
||||||
|
do before cutting off, -1 for no limits [-1]
|
||||||
|
Has effect only for 'hexbs' and 'dia'
|
||||||
--subme <integer> : Set fractional pixel motion estimation level
|
--subme <integer> : Set fractional pixel motion estimation level
|
||||||
- 0: only integer motion estimation
|
- 0: only integer motion estimation
|
||||||
- 1: + 1/2-pixel horizontal and vertical
|
- 1: + 1/2-pixel horizontal and vertical
|
||||||
|
|
|
@ -130,6 +130,8 @@ int kvz_config_init(kvz_config *cfg)
|
||||||
cfg->force_level = true; // don't care about level limits by-default
|
cfg->force_level = true; // don't care about level limits by-default
|
||||||
cfg->high_tier = false;
|
cfg->high_tier = false;
|
||||||
|
|
||||||
|
cfg->me_max_steps = (uint32_t)-1;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1153,6 +1155,9 @@ int kvz_config_parse(kvz_config *cfg, const char *name, const char *value)
|
||||||
else if (OPT("high-tier")) {
|
else if (OPT("high-tier")) {
|
||||||
cfg->high_tier = true;
|
cfg->high_tier = true;
|
||||||
}
|
}
|
||||||
|
else if (OPT("me-steps")) {
|
||||||
|
cfg->me_max_steps = (uint32_t)atoi(value); // fix
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,7 @@ static const struct option long_options[] = {
|
||||||
{ "level", required_argument, NULL, 0 },
|
{ "level", required_argument, NULL, 0 },
|
||||||
{ "force-level", required_argument, NULL, 0 },
|
{ "force-level", required_argument, NULL, 0 },
|
||||||
{ "high-tier", no_argument, NULL, 0 },
|
{ "high-tier", no_argument, NULL, 0 },
|
||||||
|
{ "me-steps", required_argument, NULL, 0 },
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -431,6 +432,9 @@ void print_help(void)
|
||||||
" - full: Full Search\n"
|
" - full: Full Search\n"
|
||||||
" - full8, full16, full32, full64\n"
|
" - full8, full16, full32, full64\n"
|
||||||
" - dia: Diamond Search\n"
|
" - dia: Diamond Search\n"
|
||||||
|
" --me-steps <integer> : How many search steps does the motion estimation\n"
|
||||||
|
" do before cutting off, -1 for no limits [-1]\n"
|
||||||
|
" Has effect only for 'hexbs' and 'dia'\n"
|
||||||
" --subme <integer> : Set fractional pixel motion estimation level\n"
|
" --subme <integer> : Set fractional pixel motion estimation level\n"
|
||||||
" - 0: only integer motion estimation\n"
|
" - 0: only integer motion estimation\n"
|
||||||
" - 1: + 1/2-pixel horizontal and vertical\n"
|
" - 1: + 1/2-pixel horizontal and vertical\n"
|
||||||
|
|
|
@ -361,6 +361,9 @@ typedef struct kvz_config
|
||||||
uint8_t high_tier;
|
uint8_t high_tier;
|
||||||
/** \brief The maximum allowed bitrate for this level and tier. */
|
/** \brief The maximum allowed bitrate for this level and tier. */
|
||||||
uint32_t max_bitrate;
|
uint32_t max_bitrate;
|
||||||
|
|
||||||
|
/** \brief Maximum steps that hexagonal and diagonal motion estimation can use. -1 to disable */
|
||||||
|
uint32_t me_max_steps;
|
||||||
} kvz_config;
|
} kvz_config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -640,7 +640,7 @@ static void tz_search(inter_search_info_t *info, vector2d_t extra_mv)
|
||||||
* the predicted motion vector is way off. In the future even more additional
|
* the predicted motion vector is way off. In the future even more additional
|
||||||
* points like 0,0 might be used, such as vectors from top or left.
|
* points like 0,0 might be used, such as vectors from top or left.
|
||||||
*/
|
*/
|
||||||
static void hexagon_search(inter_search_info_t *info, vector2d_t extra_mv)
|
static void hexagon_search(inter_search_info_t *info, vector2d_t extra_mv, uint32_t max_steps)
|
||||||
{
|
{
|
||||||
// The start of the hexagonal pattern has been repeated at the end so that
|
// The start of the hexagonal pattern has been repeated at the end so that
|
||||||
// the indices between 1-6 can be used as the start of a 3-point list of new
|
// the indices between 1-6 can be used as the start of a 3-point list of new
|
||||||
|
@ -689,9 +689,14 @@ static void hexagon_search(inter_search_info_t *info, vector2d_t extra_mv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t steps_left = max_steps;
|
||||||
|
|
||||||
// Iteratively search the 3 new points around the best match, until the best
|
// Iteratively search the 3 new points around the best match, until the best
|
||||||
// match is in the center.
|
// match is in the center.
|
||||||
while (best_index != 0) {
|
while (best_index != 0 && steps_left != 0) {
|
||||||
|
// decrement count if enabled
|
||||||
|
if (steps_left > 0 && max_steps != (uint32_t)-1) steps_left -= 1;
|
||||||
|
|
||||||
// Starting point of the 3 offsets to be searched.
|
// Starting point of the 3 offsets to be searched.
|
||||||
unsigned start;
|
unsigned start;
|
||||||
if (best_index == 1) {
|
if (best_index == 1) {
|
||||||
|
@ -727,7 +732,7 @@ static void hexagon_search(inter_search_info_t *info, vector2d_t extra_mv)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void diamond_search(inter_search_info_t *info, vector2d_t extra_mv)
|
static void diamond_search(inter_search_info_t *info, vector2d_t extra_mv, uint32_t max_steps)
|
||||||
{
|
{
|
||||||
enum diapos {
|
enum diapos {
|
||||||
DIA_UP = 0,
|
DIA_UP = 0,
|
||||||
|
@ -786,9 +791,12 @@ static void diamond_search(inter_search_info_t *info, vector2d_t extra_mv)
|
||||||
|
|
||||||
// whether we found a better candidate this iteration
|
// whether we found a better candidate this iteration
|
||||||
uint8_t better_found;
|
uint8_t better_found;
|
||||||
|
uint32_t steps_left = max_steps;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
better_found = 0;
|
better_found = 0;
|
||||||
|
// decrement count if enabled
|
||||||
|
if (steps_left > 0 && max_steps != (uint32_t) -1) steps_left -= 1;
|
||||||
|
|
||||||
// search the points of the diamond
|
// search the points of the diamond
|
||||||
for (int i = 0; i < 4; ++i) {
|
for (int i = 0; i < 4; ++i) {
|
||||||
|
@ -810,7 +818,7 @@ static void diamond_search(inter_search_info_t *info, vector2d_t extra_mv)
|
||||||
// the xor operation flips the orientation
|
// the xor operation flips the orientation
|
||||||
from_dir = best_index ^ 0x3;
|
from_dir = best_index ^ 0x3;
|
||||||
}
|
}
|
||||||
} while (better_found);
|
} while (better_found && steps_left != 0);
|
||||||
// and we're done
|
// and we're done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1250,11 +1258,11 @@ static void search_pu_inter_ref(inter_search_info_t *info,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case KVZ_IME_DIA:
|
case KVZ_IME_DIA:
|
||||||
diamond_search(info, mv);
|
diamond_search(info, mv, info->state->encoder_control->cfg.me_max_steps);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
hexagon_search(info, mv);
|
hexagon_search(info, mv, info->state->encoder_control->cfg.me_max_steps);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue