summaryrefslogtreecommitdiff
path: root/src/render/renderer_libplacebo.c
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2026-09-07 15:06:14 -0400
committerAndrew Opalach <andrew@akon.city> 2026-09-07 15:06:14 -0400
commitc66c7c64ebd16287b892f8a780cffcabafba3799 (patch)
treeb2195902ef055147878b591cf1171be7e6133c97 /src/render/renderer_libplacebo.c
parent1758ae9e860bd3b65b661e3c804288c3599f4fd4 (diff)
downloadcamu-c66c7c64ebd16287b892f8a780cffcabafba3799.tar.gz
camu-c66c7c64ebd16287b892f8a780cffcabafba3799.tar.bz2
camu-c66c7c64ebd16287b892f8a780cffcabafba3799.zip
Better OSD behavior, lots of build stuff
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/render/renderer_libplacebo.c')
-rw-r--r--src/render/renderer_libplacebo.c130
1 files changed, 75 insertions, 55 deletions
diff --git a/src/render/renderer_libplacebo.c b/src/render/renderer_libplacebo.c
index 8c28162..c0a413a 100644
--- a/src/render/renderer_libplacebo.c
+++ b/src/render/renderer_libplacebo.c
@@ -117,7 +117,7 @@ static void log_callback(void *userdata, enum pl_log_level level, const char *me
// will be shot anyway so allow it.
log_info(message);
} else {
- log_info(message);
+ log_debug(message);
}
}
@@ -166,9 +166,11 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
struct camu_renderer_lp *lr = (struct camu_renderer_lp *)renderer;
#ifndef CRT_BACKGROUND
- clear_color[0] = ((global_color_palette.colors[0] >> 16) & 0xff) / 255.f;
- clear_color[1] = ((global_color_palette.colors[0] >> 8) & 0xff) / 255.f;
- clear_color[2] = ((global_color_palette.colors[0]) & 0xff) / 255.f;
+ if (global_color_palette.supplied) {
+ clear_color[0] = ((global_color_palette.colors[CAMU_COLOR_BACKGROUND] >> 16) & 0xff) / 255.f;
+ clear_color[1] = ((global_color_palette.colors[CAMU_COLOR_BACKGROUND] >> 8) & 0xff) / 255.f;
+ clear_color[2] = (global_color_palette.colors[CAMU_COLOR_BACKGROUND] & 0xff) / 255.f;
+ }
#endif
lr->logger = pl_log_create(PL_API_VER, pl_log_params(
@@ -319,7 +321,7 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
al_memset(&lr->params, 0, sizeof(struct pl_render_params));
lr->params = default_params;
- lr->params.deband_params = NULL;
+ //lr->params.deband_params = NULL;
//lr->params.frame_mixer = NULL;
// Clear manually so we can draw multiple images per frame.
@@ -331,26 +333,28 @@ static bool renderer_lp_create_renderer(struct camu_renderer *renderer, u32 *wid
lr->params.correct_subpixel_offsets = true;
lr->osd.vars[0].var = pl_var_uvec2("screen");
- lr->osd.vars[1].var = pl_var_uint("scale");
- lr->osd.vars[2].var = pl_var_float("time");
- lr->osd.vars[3].var = pl_var_uint("show_osd");
- lr->osd.vars[4].var = pl_var_uint("connecting");
- lr->osd.vars[5].var = pl_var_uint("paused");
- lr->osd.vars[6].var = pl_var_uint("bar_mode");
- lr->osd.vars[7].var = pl_var_float("bar");
- lr->osd.vars[8].var = pl_var_float("dbar");
- lr->osd.vars[9].var = pl_var_float("bbar");
- lr->osd.vars[10].var = pl_var_uint("show_hour");
- lr->osd.vars[11].var = pl_var_uint("negative");
+ lr->osd.vars[1].var = pl_var_vec4("tcolor");
+ lr->osd.vars[2].var = pl_var_vec4("bcolor");
+ lr->osd.vars[3].var = pl_var_uint("scale");
+ lr->osd.vars[4].var = pl_var_float("time");
+ lr->osd.vars[5].var = pl_var_uint("show_osd");
+ lr->osd.vars[6].var = pl_var_uint("connecting");
+ lr->osd.vars[7].var = pl_var_uint("paused");
+ lr->osd.vars[8].var = pl_var_uint("bar_mode");
+ lr->osd.vars[9].var = pl_var_float("bar");
+ lr->osd.vars[10].var = pl_var_float("dbar");
+ lr->osd.vars[11].var = pl_var_float("bbar");
+ lr->osd.vars[12].var = pl_var_uint("show_hour");
+ lr->osd.vars[13].var = pl_var_uint("negative");
static const char num_names[9][6] = {
"num1", "num2", "num3", "num4",
"num5", "num6", "num7", "num8",
"num9"
};
for (u32 i = 0; i < 9; i++) {
- lr->osd.vars[12 + i].var = pl_var_uint(num_names[i]);
+ lr->osd.vars[14 + i].var = pl_var_uint(num_names[i]);
}
- for (u32 i = 0; i < 21; i++) {
+ for (u32 i = 0; i < 23; i++) {
lr->osd.vars[i].dynamic = true;
}
@@ -491,7 +495,7 @@ static inline intptr_t float_64_hash(f64 value)
static inline bool render_osd(struct camu_renderer_lp *lr, struct camu_screen *scr)
{
f64 duration = scr->osd.duration / 1000000.0;
- f32 bar, dbar, bbar;
+ static f32 bar, dbar, bbar;
f32 progress = ((duration != 0) ? scr->osd.pts / duration : 0.f);
if (scr->osd.bar_mode != CAMU_OSD_BAR_VOLUME) {
dbar = progress;
@@ -504,68 +508,84 @@ static inline bool render_osd(struct camu_renderer_lp *lr, struct camu_screen *s
lr->osd.screen_size[0] = scr->width;
lr->osd.screen_size[1] = scr->height;
lr->osd.vars[0].data = lr->osd.screen_size;
- u32 scale = 1;
- lr->osd.vars[1].data = &scale;
+ static float tcolor[4] = { 0.89f, 0.87f, 0.87f, 1.f };
+ if (global_color_palette.supplied) {
+ tcolor[0] = ((global_color_palette.colors[CAMU_COLOR_FOREGROUND] >> 16) & 0xff) / 255.f;
+ tcolor[1] = ((global_color_palette.colors[CAMU_COLOR_FOREGROUND] >> 8) & 0xff) / 255.f;
+ tcolor[2] = (global_color_palette.colors[CAMU_COLOR_FOREGROUND] & 0xff) / 255.f;
+ }
+ lr->osd.vars[1].data = tcolor;
+ static float bcolor[4] = { 0.04f, 0.04f, 0.04f, 0.575f };
+ if (global_color_palette.supplied) {
+ bcolor[0] = ((global_color_palette.colors[CAMU_COLOR_BACKGROUND] >> 16) & 0xff) / 255.f;
+ bcolor[1] = ((global_color_palette.colors[CAMU_COLOR_BACKGROUND] >> 8) & 0xff) / 255.f;
+ bcolor[2] = (global_color_palette.colors[CAMU_COLOR_BACKGROUND] & 0xff) / 255.f;
+ }
+ lr->osd.vars[2].data = bcolor;
+ static u32 scale = 1;
+ lr->osd.vars[3].data = &scale;
f64 tick = nn_get_tick();
if (lr->osd.tick_time == -1.0) lr->osd.tick_time = tick;
lr->osd.time = (f32)(tick - lr->osd.tick_time);
- lr->osd.vars[2].data = &lr->osd.time;
- lr->osd.vars[3].data = &scr->osd.show;
- lr->osd.vars[4].data = &scr->osd.connecting;
- lr->osd.vars[5].data = &scr->osd.paused;
- lr->osd.vars[6].data = &scr->osd.bar_mode;
- lr->osd.vars[7].data = &bar;
- lr->osd.vars[8].data = &dbar;
- lr->osd.vars[9].data = &bbar;
- u32 hours1, minutes1, seconds1, hundredths;
- u32 show_hour;
+ lr->osd.vars[4].data = &lr->osd.time;
+ lr->osd.vars[5].data = &scr->osd.show;
+ lr->osd.vars[6].data = &scr->osd.connecting;
+ lr->osd.vars[7].data = &scr->osd.paused;
+ lr->osd.vars[8].data = &scr->osd.bar_mode;
+ lr->osd.vars[9].data = &bar;
+ lr->osd.vars[10].data = &dbar;
+ lr->osd.vars[11].data = &bbar;
+ static u32 hours1, minutes1, seconds1, hundredths;
+ static u32 show_hour;
show_hour = camu_split_time(scr->osd.duration, &hours1, &minutes1, &seconds1, &hundredths);
ROUND_SECONDS(hours1, minutes1, seconds1, hundredths);
- lr->osd.vars[10].data = &show_hour;
- u32 negative;
+ lr->osd.vars[12].data = &show_hour;
+ static u32 negative;
negative = scr->osd.pts < 0.0f;
- lr->osd.vars[11].data = &negative;
- lr->osd.vars[15].data = &hours1;
- lr->osd.vars[16].data = &minutes1;
- lr->osd.vars[17].data = &seconds1;
- u32 hours2, minutes2, seconds2;
- camu_split_time(fabs(scr->osd.pts) * 1000000u, &hours2, &minutes2, &seconds2, &hundredths);
+ lr->osd.vars[13].data = &negative;
+ lr->osd.vars[17].data = &hours1;
+ lr->osd.vars[18].data = &minutes1;
+ lr->osd.vars[19].data = &seconds1;
+ static u32 hours2, minutes2, seconds2;
+ u64 time = fabs(scr->osd.pts) * 1000000u;
+ time = MIN(time, scr->osd.duration);
+ camu_split_time(time, &hours2, &minutes2, &seconds2, &hundredths);
// The trade-off of rounding PTS is that if we do, second 0 will be shown for only half a second.
// If we don't, more noticeably, PTS will never equal duration if duration rounds up.
// There's also the option of not rounding either.
ROUND_SECONDS(hours2, minutes2, seconds2, hundredths);
- lr->osd.vars[12].data = &hours2;
- lr->osd.vars[13].data = &minutes2;
- lr->osd.vars[14].data = &seconds2;
- u32 zero = 0;
- lr->osd.vars[18].data = &zero;
- lr->osd.vars[19].data = &zero;
+ lr->osd.vars[14].data = &hours2;
+ lr->osd.vars[15].data = &minutes2;
+ lr->osd.vars[16].data = &seconds2;
+ static u32 zero = 0;
lr->osd.vars[20].data = &zero;
+ lr->osd.vars[21].data = &zero;
+ lr->osd.vars[22].data = &zero;
if (scr->osd.bar_mode == CAMU_OSD_BAR_SEEK) {
- u32 hours3, minutes3, seconds3;
+ static u32 hours3, minutes3, seconds3;
camu_split_time(fabs(duration * bar) * 1000000u, &hours3, &minutes3, &seconds3, &hundredths);
ROUND_SECONDS(hours3, minutes3, seconds3, hundredths);
- lr->osd.vars[18].data = &hours3;
- lr->osd.vars[19].data = &minutes3;
- lr->osd.vars[20].data = &seconds3;
+ lr->osd.vars[20].data = &hours3;
+ lr->osd.vars[21].data = &minutes3;
+ lr->osd.vars[22].data = &seconds3;
} else {
f64 whole = floor(bar);
f64 frac = (bar - whole) * 100.0;
- u32 num1, num2;
+ static u32 num1, num2;
num1 = (u32)whole;
num2 = (u32)round(frac);
- lr->osd.vars[19].data = &num1;
- lr->osd.vars[20].data = &num2;
+ lr->osd.vars[21].data = &num1;
+ lr->osd.vars[22].data = &num2;
}
lr->osd.sh = pl_dispatch_begin(lr->dispatch);
pl_shader_custom(lr->osd.sh, &(struct pl_custom_shader){
.description = "osd",
.prelude = lr->osd.prelude,
- .header = scr->osd.show_binds ? lr->osd.binds : lr->osd.header,
+ .header = scr->osd.alt ? lr->osd.binds : lr->osd.header,
.body = "color = (show_osd == 0u) ? vec4(0.) : draw_osd();",
.output = PL_SHADER_SIG_COLOR,
- .num_variables = 21,
+ .num_variables = 23,
.variables = lr->osd.vars
});
@@ -703,7 +723,7 @@ static bool renderer_lp_render(struct camu_renderer *renderer, struct camu_scree
target->rotation = mix.frames[0]->rotation - video->view.rotation;
//lr->params.color_map_params = pl_color_map_params(.inverse_tone_mapping = true);
/*
- if () {
+ if (1) {
target->color = pl_color_space_srgb;
target->color.hdr.max_luma = PL_COLOR_SDR_WHITE - 50.f;
target->color.hdr.min_luma = (PL_COLOR_SDR_WHITE - 50.f) / PL_COLOR_SDR_CONTRAST;