Skip to content

Commit 3b112bb

Browse files
committed
add MLT_PLACEBO_CACHE_PATH and replace atext()
1 parent 11bf94d commit 3b112bb

7 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/modules/placebo/factory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* factory.c -- module registration for libplacebo filters
3-
* Copyright (C) 2025 D-Ogi
3+
* Copyright (C) 2025-2026 D-Ogi
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/modules/placebo/filter_placebo_render.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* filter_placebo_render.c -- GPU-accelerated renderer via libplacebo
3-
* Copyright (C) 2025 D-Ogi
3+
* Copyright (C) 2025-2026 D-Ogi
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/modules/placebo/filter_placebo_render.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type: filter
33
identifier: placebo.render
44
title: GPU Render (libplacebo)
55
version: 1
6-
copyright: Copyright (C) 2025 D-Ogi
6+
copyright: Copyright (C) 2025-2026 D-Ogi
77
creator: D-Ogi
88
license: LGPLv2.1
99
language: en
@@ -13,6 +13,9 @@ description: >
1313
GPU-accelerated scaling, debanding, dithering and tonemapping via libplacebo.
1414
Uses D3D11 on Windows, Vulkan elsewhere. Processes every frame through
1515
pl_renderer with configurable quality presets and scaling algorithms.
16+
The compiled shader cache is stored in a platform-specific location and can
17+
be overridden by setting the MLT_PLACEBO_CACHE_PATH environment variable to
18+
an absolute path for the cache file.
1619
1720
parameters:
1821
- identifier: preset

src/modules/placebo/filter_placebo_shader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* filter_placebo_shader.c -- custom .hook shader loader via libplacebo
3-
* Copyright (C) 2025 D-Ogi
3+
* Copyright (C) 2025-2026 D-Ogi
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

src/modules/placebo/filter_placebo_shader.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type: filter
33
identifier: placebo.shader
44
title: GPU Shader (libplacebo)
55
version: 1
6-
copyright: Copyright (C) 2025 D-Ogi
6+
copyright: Copyright (C) 2025-2026 D-Ogi
77
creator: D-Ogi
88
license: LGPLv2.1
99
language: en
@@ -13,6 +13,9 @@ description: >
1313
Load and apply a custom mpv/libplacebo .hook shader file for GPU-accelerated
1414
video processing. Supports Anime4K, FSRCNNX, film grain, and other
1515
mpv-compatible user shaders. The shader file is hot-reloaded when modified.
16+
The compiled shader cache is stored in a platform-specific location and can
17+
be overridden by setting the MLT_PLACEBO_CACHE_PATH environment variable to
18+
an absolute path for the cache file.
1619
1720
parameters:
1821
- identifier: shader_path

src/modules/placebo/gpu_context.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* gpu_context.c -- shared libplacebo GPU lifecycle (singleton)
3-
* Copyright (C) 2025 D-Ogi
3+
* Copyright (C) 2025-2026 D-Ogi
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public
@@ -19,6 +19,7 @@
1919

2020
#include "gpu_context.h"
2121

22+
#include <framework/mlt_factory.h>
2223
#include <framework/mlt_frame.h>
2324
#include <libplacebo/cache.h>
2425
#include <libplacebo/dispatch.h>
@@ -103,6 +104,11 @@ static pthread_mutex_t s_render_mutex = PTHREAD_MUTEX_INITIALIZER;
103104

104105
static void get_cache_path(char *buf, size_t len)
105106
{
107+
const char *override = getenv("MLT_PLACEBO_CACHE_PATH");
108+
if (override && override[0] != '\0') {
109+
snprintf(buf, len, "%s", override);
110+
return;
111+
}
106112
#ifdef _WIN32
107113
char appdata[MAX_PATH] = {0};
108114
if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, appdata))) {
@@ -305,7 +311,7 @@ static int init_gpu(void)
305311

306312
load_cache();
307313

308-
atexit(placebo_gpu_release);
314+
mlt_factory_register_for_clean_up(NULL, (mlt_destructor) placebo_gpu_release);
309315

310316
return 1;
311317
}

src/modules/placebo/gpu_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* gpu_context.h -- shared libplacebo GPU lifecycle
3-
* Copyright (C) 2025 D-Ogi
3+
* Copyright (C) 2025-2026 D-Ogi
44
*
55
* This library is free software; you can redistribute it and/or
66
* modify it under the terms of the GNU Lesser General Public

0 commit comments

Comments
 (0)