[host] all: make the downsample rule matching common

This commit is contained in:
Geoffrey McRae
2023-11-07 10:19:24 +11:00
parent 6c7f3c4197
commit 30c577beeb
6 changed files with 37 additions and 120 deletions

View File

@@ -84,3 +84,22 @@ bool downsampleParser(struct Option * opt, const char * str)
return true;
}
DownsampleRule * downsampleRule_match(int x, int y)
{
DownsampleRule * rule, * match = NULL;
vector_forEachRef(rule, &downsampleRules)
{
if (
( rule->greater && (x > rule->x || y > rule->y)) ||
(!rule->greater && (x == rule->x && y == rule->y)))
{
match = rule;
}
}
if (match)
DEBUG_INFO("Matched downsample rule %d", rule->id);
return match;
}