Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/videolan/dav1d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenrik Gramner <gramner@twoorioles.com>2022-04-28 03:53:52 +0300
committerHenrik Gramner <henrik@gramner.com>2022-04-28 03:53:52 +0300
commit8bb0655895f9457ab5157f92adf311d9bd5e2801 (patch)
treea134f5f297fb302eabe24b5a66ff73d8d088ad84
parentffb59680356fd210816cf9e46d9d023ade1f4d5a (diff)
Inline dav1d_ref_inc()
Avoids the function call overhead in non-LTO builds. Also reorder code in dav1d_ref_dec() to enable tail call elimination.
-rw-r--r--src/ref.c6
-rw-r--r--src/ref.h6
2 files changed, 5 insertions, 7 deletions
diff --git a/src/ref.c b/src/ref.c
index 3889cba..46462b4 100644
--- a/src/ref.c
+++ b/src/ref.c
@@ -88,22 +88,18 @@ Dav1dRef *dav1d_ref_wrap(const uint8_t *const ptr,
return res;
}
-void dav1d_ref_inc(Dav1dRef *const ref) {
- atomic_fetch_add(&ref->ref_cnt, 1);
-}
-
void dav1d_ref_dec(Dav1dRef **const pref) {
assert(pref != NULL);
Dav1dRef *const ref = *pref;
if (!ref) return;
+ *pref = NULL;
if (atomic_fetch_sub(&ref->ref_cnt, 1) == 1) {
const int free_ref = ref->free_ref;
ref->free_callback(ref->const_data, ref->user_data);
if (free_ref) free(ref);
}
- *pref = NULL;
}
int dav1d_ref_is_writable(Dav1dRef *const ref) {
diff --git a/src/ref.h b/src/ref.h
index 54f5f69..f6e3028 100644
--- a/src/ref.h
+++ b/src/ref.h
@@ -50,9 +50,11 @@ Dav1dRef *dav1d_ref_create_using_pool(Dav1dMemPool *pool, size_t size);
Dav1dRef *dav1d_ref_wrap(const uint8_t *ptr,
void (*free_callback)(const uint8_t *data, void *user_data),
void *user_data);
-void dav1d_ref_inc(Dav1dRef *ref);
void dav1d_ref_dec(Dav1dRef **ref);
-
int dav1d_ref_is_writable(Dav1dRef *ref);
+static inline void dav1d_ref_inc(Dav1dRef *const ref) {
+ atomic_fetch_add(&ref->ref_cnt, 1);
+}
+
#endif /* DAV1D_SRC_REF_H */