diff options
Diffstat (limited to 'mg2d.c')
-rw-r--r-- | mg2d.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -535,8 +535,16 @@ static int mg_levels_alloc(MG2DContext *ctx, size_t domain_size) if (!priv->root) return -ENOMEM; - cur = priv->root; + // choose the domain size for the first child + // the children all have sizes 2**n + 1 + // but we skip the closest lower one if it is too close + if (domain_size <= 2) + return 0; domain_size = (1 << log2i(domain_size - 2)) + 1; + if ((double)priv->root->solver->domain_size[0] / domain_size < 1.5) + domain_size = (domain_size >> 1) + 1; + + cur = priv->root; for (int i = 0; i < LEVELS_MAX && domain_size > 4; i++) { cur->child = mg_level_alloc(domain_size); if (!cur->child) |