mirror of
https://code.videolan.org/videolan/dav1d
synced 2026-06-11 04:03:05 +00:00
Set default framedelay to min(8, ceil(sqrt(n_threads)))
This reduces memory usage significantly. Fixes #375.
This commit is contained in:
@@ -169,8 +169,18 @@ COLD int dav1d_open(Dav1dContext **const c_out, const Dav1dSettings *const s) {
|
||||
|
||||
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) :
|
||||
umin(c->n_tc, 8);
|
||||
c->n_tc < 50 ? fc_lut[c->n_tc - 1] : 8; // min(8, ceil(sqrt(n)))
|
||||
|
||||
c->fc = dav1d_alloc_aligned(sizeof(*c->fc) * c->n_fc, 32);
|
||||
if (!c->fc) goto error;
|
||||
|
||||
Reference in New Issue
Block a user