Skip to content

Commit

Permalink
tone_mapping: make HDR metadata available to tone-mappers
Browse files Browse the repository at this point in the history
By just sticking it inside `pl_hdr_metadata`, happen what may.

We don't need access to the output metadata, so omit it. (This will
probably never change, because this HDR metadata contains scene-derived
values)
  • Loading branch information
haasn committed Feb 13, 2023
1 parent 85847a8 commit 812586a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ project('libplacebo', ['c', 'cpp'],
5,
# API version
{
'245': 'add `pl_tone_map_params.hdr`',
'244': 'add `pl_map_hdr_metadata`',
'243': 'add `pl_color_space.nominal_min/max`',
'242': 'add `pl_hdr_metadata.scene_max/avg` and `pl_hdr_metadata.ootf`',
Expand Down
5 changes: 5 additions & 0 deletions src/include/libplacebo/tone_mapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdbool.h>

#include <libplacebo/common.h>
#include <libplacebo/colorspace.h>

PL_API_BEGIN

Expand Down Expand Up @@ -93,6 +94,10 @@ struct pl_tone_map_params {
// The desired characteristics of the output, in `output_scaling` units.
float output_min;
float output_max;

// The input HDR metadata. Only used by a select few tone-mapping
// functions. (Optional)
struct pl_hdr_metadata hdr;
};

#define pl_tone_map_params(...) (&(struct pl_tone_map_params) { __VA_ARGS__ });
Expand Down
1 change: 1 addition & 0 deletions src/shaders/colorspace.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,6 +1285,7 @@ static void tone_map(pl_shader sh,
.input_max = pl_hdr_rescale(PL_HDR_NORM, PL_HDR_SQRT, src_max),
.output_min = dst_min,
.output_max = dst_max,
.hdr = src->hdr,
};

enum pl_tone_map_mode mode = params->tone_mapping_mode;
Expand Down
3 changes: 2 additions & 1 deletion src/tone_mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ bool pl_tone_map_params_equal(const struct pl_tone_map_params *a,
a->input_min == b->input_min &&
a->input_max == b->input_max &&
a->output_min == b->output_min &&
a->output_max == b->output_max;
a->output_max == b->output_max &&
pl_hdr_metadata_equal(&a->hdr, &b->hdr);
}

bool pl_tone_map_params_noop(const struct pl_tone_map_params *p)
Expand Down

0 comments on commit 812586a

Please sign in to comment.