diff options
author | James Almer <jamrial@gmail.com> | 2022-03-31 15:42:56 +0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-31 15:42:56 +0300 |
commit | 6777dd0a61ab78cc9fab92af53558ea44c135056 (patch) | |
tree | 0c9c5ec1b803fd7ba1d5598e81965e5d0d5151af | |
parent | ac07a6653a5a0c0fee65dc4c229b8188bb726acb (diff) |
lib: add a function to query the decoder frame delay
-rw-r--r-- | include/dav1d/dav1d.h | 15 | ||||
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | src/cpu.c | 3 | ||||
-rw-r--r-- | src/lib.c | 12 |
4 files changed, 30 insertions, 2 deletions
diff --git a/include/dav1d/dav1d.h b/include/dav1d/dav1d.h index fd3b622..bd70303 100644 --- a/include/dav1d/dav1d.h +++ b/include/dav1d/dav1d.h @@ -287,6 +287,21 @@ DAV1D_API int dav1d_get_event_flags(Dav1dContext *c, enum Dav1dEventFlags *flags */ DAV1D_API int dav1d_get_decode_error_data_props(Dav1dContext *c, Dav1dDataProps *out); +/** + * Get the decoder delay, which is the number of internally buffered frames, not + * including reference frames. + * This value is guaranteed to be >= 1 and <= max_frame_delay. + * + * @param c Input settings context. + * + * @return Decoder frame delay on success, or < 0 (a negative DAV1D_ERR code) on + * error. + * + * @note The returned delay is valid only for a Dav1dContext initialized with the + * provided Dav1dSettings. + */ +DAV1D_API int dav1d_get_frame_delay(const Dav1dSettings *s); + # ifdef __cplusplus } # endif diff --git a/meson.build b/meson.build index a312ae0..372a55d 100644 --- a/meson.build +++ b/meson.build @@ -30,7 +30,7 @@ project('dav1d', ['c'], 'b_ndebug=if-release'], meson_version: '>= 0.49.0') -dav1d_soname_version = '6.6.0' +dav1d_soname_version = '6.7.0' dav1d_api_version_array = dav1d_soname_version.split('.') dav1d_api_version_major = dav1d_api_version_array[0] dav1d_api_version_minor = dav1d_api_version_array[1] @@ -99,6 +99,7 @@ COLD int dav1d_num_logical_processors(Dav1dContext *const c) { #elif defined(_SC_NPROCESSORS_ONLN) return (int)sysconf(_SC_NPROCESSORS_ONLN); #endif - dav1d_log(c, "Unable to detect thread count, defaulting to single-threaded mode\n"); + if (c) + dav1d_log(c, "Unable to detect thread count, defaulting to single-threaded mode\n"); return 1; } @@ -116,6 +116,18 @@ static COLD void get_num_threads(Dav1dContext *const c, const Dav1dSettings *con *n_tc < 50 ? fc_lut[*n_tc - 1] : 8; // min(8, ceil(sqrt(n))) } +COLD int dav1d_get_frame_delay(const Dav1dSettings *const s) { + unsigned n_tc, n_fc; + validate_input_or_ret(s != NULL, DAV1D_ERR(EINVAL)); + validate_input_or_ret(s->n_threads >= 0 && + s->n_threads <= DAV1D_MAX_THREADS, DAV1D_ERR(EINVAL)); + validate_input_or_ret(s->max_frame_delay >= 0 && + s->max_frame_delay <= DAV1D_MAX_FRAME_DELAY, DAV1D_ERR(EINVAL)); + + get_num_threads(NULL, s, &n_tc, &n_fc); + return n_fc; +} + 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); |