Skip to content

Commit

Permalink
demos/plplay: allow controlling color space hint
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 authored and haasn committed Feb 19, 2023
1 parent 3c32b8c commit 10b23fa
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions demos/plplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ struct plplay {
bool target_override;
bool levels_override;
bool ignore_dovi;
bool colorspace_hint;

// custom shaders
const struct pl_hook **shader_hooks;
Expand Down Expand Up @@ -405,8 +406,9 @@ static void update_colorspace_hint(struct plplay *p, const struct pl_frame_mix *
if (!frame)
return;

struct pl_swapchain_colors hint;
pl_swapchain_colors_from_avframe(&hint, frame->user_data);
struct pl_swapchain_colors hint = {0};
if (p->colorspace_hint)
pl_swapchain_colors_from_avframe(&hint, frame->user_data);
pl_swapchain_colorspace_hint(p->win->swapchain, &hint);
}

Expand Down Expand Up @@ -639,12 +641,15 @@ int main(int argc, char **argv)
.title = "plplay",
.width = par->width,
.height = par->height,
.colors = {
};

if (p->colorspace_hint) {
params.colors = (struct pl_swapchain_colors) {
.primaries = pl_primaries_from_av(par->color_primaries),
.transfer = pl_transfer_from_av(par->color_trc),
// HDR metadata will come from AVFrame side data
},
};
};
}

if (desc->flags & AV_PIX_FMT_FLAG_ALPHA) {
params.alpha = true;
Expand Down Expand Up @@ -1317,6 +1322,12 @@ static void update_settings(struct plplay *p)
trepr->bits.color_depth = bits;
trepr->bits.sample_depth = bits;

nk_layout_row_dynamic(nk, 24, 1);
p->reset_colorspace = nk_checkbox_label(nk,
"Inform the swapchain about "
"the input color space",
&p->colorspace_hint);

nk_layout_row_dynamic(nk, 50, 1);
if (ui_widget_hover(nk, "Drop ICC profile here...") && dropped_file) {
uint8_t *buf;
Expand Down

0 comments on commit 10b23fa

Please sign in to comment.