summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2023-11-19 14:24:34 +0100
committersfan5 <sfan5@live.de>2023-11-20 17:32:40 +0100
commit70db887553a140b1b58778044e2085c4ea0f8432 (patch)
tree56517db77d5ce3cb0b7a9e4b3cffd23648e07246 /video
parente62dac8338a7b1a96cae95b6b733dda29cf1a499 (diff)
downloadmpv-70db887553a140b1b58778044e2085c4ea0f8432.tar.bz2
mpv-70db887553a140b1b58778044e2085c4ea0f8432.tar.xz
vo_gpu_next: don't re-save unmodified cache
Backwards compatibility wrapper can be bumped once sufficient libplacebo version is a minimum dependency. See-Also: https://github.com/mpv-player/mpv/pull/12902
Diffstat (limited to 'video')
-rw-r--r--video/out/vo_gpu_next.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/video/out/vo_gpu_next.c b/video/out/vo_gpu_next.c
index 0e22d0173c..5a09f2ac7f 100644
--- a/video/out/vo_gpu_next.c
+++ b/video/out/vo_gpu_next.c
@@ -92,6 +92,7 @@ struct frame_info {
struct cache {
char *path;
pl_cache cache;
+ uint64_t sig;
};
struct priv {
@@ -1512,6 +1513,20 @@ static void wait_events(struct vo *vo, int64_t until_time_ns)
}
}
+#if PL_API_VER < 342
+static inline void xor_hash(void *hash, pl_cache_obj obj)
+{
+ *((uint64_t *) hash) ^= obj.key;
+}
+
+static inline uint64_t pl_cache_signature(pl_cache cache)
+{
+ uint64_t hash = 0;
+ pl_cache_iterate(cache, xor_hash, &hash);
+ return hash;
+}
+#endif
+
static void cache_init(struct vo *vo, struct cache *cache, size_t max_size,
const char *dir_opt)
{
@@ -1542,6 +1557,7 @@ static void cache_init(struct vo *vo, struct cache *cache, size_t max_size,
MP_WARN(p, "Failed loading cache from %s\n", cache->path);
}
+ cache->sig = pl_cache_signature(cache->cache);
done:
talloc_free(dir);
}
@@ -1550,6 +1566,8 @@ static void cache_uninit(struct priv *p, struct cache *cache)
{
if (!cache->cache)
goto done;
+ if (pl_cache_signature(cache->cache) == cache->sig)
+ goto done; // skip re-saving identical cache
assert(cache->path);
char *tmp = talloc_asprintf(cache->path, "%sXXXXXX", cache->path);