lib: split calculating thread count to its own function
diff --git a/src/lib.c b/src/lib.c
index b21a735..210b4f3 100644
--- a/src/lib.c
+++ b/src/lib.c
@@ -97,6 +97,25 @@
     return 0;
 }
 
+static COLD void get_num_threads(Dav1dContext *const c, const Dav1dSettings *const s,
+                                 unsigned *n_tc, unsigned *n_fc)
+{
+    /* ceil(sqrt(n)) */
+    static const uint8_t fc_lut[49] = {
+        1,                                     /*     1 */
+        2, 2, 2,                               /*  2- 4 */
+        3, 3, 3, 3, 3,                         /*  5- 9 */
+        4, 4, 4, 4, 4, 4, 4,                   /* 10-16 */
+        5, 5, 5, 5, 5, 5, 5, 5, 5,             /* 17-25 */
+        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,       /* 26-36 */
+        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 37-49 */
+    };
+    *n_tc = s->n_threads ? s->n_threads :
+        iclip(dav1d_num_logical_processors(c), 1, DAV1D_MAX_THREADS);
+    *n_fc = s->max_frame_delay ? umin(s->max_frame_delay, *n_tc) :
+            *n_tc < 50 ? fc_lut[*n_tc - 1] : 8; // min(8, ceil(sqrt(n)))
+}
+
 COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) {
     static pthread_once_t initted = PTHREAD_ONCE_INIT;
     pthread_once(&initted, init_internal);
@@ -171,20 +190,7 @@
     c->flush = &c->flush_mem;
     atomic_init(c->flush, 0);
 
-    c->n_tc = s->n_threads ? s->n_threads :
-        iclip(dav1d_num_logical_processors(c), 1, DAV1D_MAX_THREADS);
-    /* ceil(sqrt(n)) */
-    static const uint8_t fc_lut[49] = {
-        1,                                     /*     1 */
-        2, 2, 2,                               /*  2- 4 */
-        3, 3, 3, 3, 3,                         /*  5- 9 */
-        4, 4, 4, 4, 4, 4, 4,                   /* 10-16 */
-        5, 5, 5, 5, 5, 5, 5, 5, 5,             /* 17-25 */
-        6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,       /* 26-36 */
-        7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, /* 37-49 */
-    };
-    c->n_fc = s->max_frame_delay ? umin(s->max_frame_delay, c->n_tc) :
-              c->n_tc < 50 ? fc_lut[c->n_tc - 1] : 8; // min(8, ceil(sqrt(n)))
+    get_num_threads(c, s, &c->n_tc, &c->n_fc);
 
     c->fc = dav1d_alloc_aligned(sizeof(*c->fc) * c->n_fc, 32);
     if (!c->fc) goto error;