vo_gpu_next: add chroma location and HDR metadata to shader parameters

This commit is contained in:
Kacper Michajłow 2024-11-01 19:49:35 +01:00
parent 89e608e169
commit 42ff6f92c3
3 changed files with 65 additions and 4 deletions

View File

@ -0,0 +1 @@
``glsl-shader-opts`` now has predefined parameters that can be used. See the documentation for available values.

View File

@ -6327,6 +6327,48 @@ them.
The shader name is the base part of the shader filename, without the The shader name is the base part of the shader filename, without the
extension. (``--vo=gpu-next`` only) extension. (``--vo=gpu-next`` only)
Some parameters are filled automatically if the shader requests them.
Currently following parameters are available:
``PTS``
PTS of the current frame in seconds.
``chroma_offset_x``
chroma offset to the reference plane in x direction.
``chroma_offset_y``
chroma offset to the reference plane in y direction.
``min_luma``
Minimum luminance value (in cd/m²).
``max_luma``
Maximum luminance value (in cd/m²).
``max_cll``
Maximum Content Light Level (in cd/m²).
``max_fall``
Maximum Frame Average Light Level (in cd/m²).
``scene_max_r``
Maximum scene light level of the red channel (in cd/m²).
``scene_max_g``
Maximum scene light level of the green channel (in cd/m²).
``scene_max_b``
Maximum scene light level of the blue channel (in cd/m²).
``scene_avg``
Average scene light level (in cd/m²).
``max_pq_y``
Maximum PQ luminance (in PQ, 0-1).
``avg_pq_y``
Average PQ luminance (in PQ, 0-1).
``--deband`` ``--deband``
Enable the debanding algorithm. This greatly reduces the amount of visible Enable the debanding algorithm. This greatly reduces the amount of visible
banding, blocking and other quantization artifacts, at the expense of banding, blocking and other quantization artifacts, at the expense of

View File

@ -2080,8 +2080,26 @@ static void update_lut(struct priv *p, struct user_lut *lut)
static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook, static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook,
const struct mp_image *mpi) const struct mp_image *mpi)
{ {
const struct { const char *name; double value; } opts[] = { float chroma_offset_x, chroma_offset_y;
{ "PTS", mpi->pts }, pl_chroma_location_offset(mpi->params.chroma_location,
&chroma_offset_x, &chroma_offset_y);
const struct {
const char *name;
double value;
} opts[] = {
{ "PTS", mpi->pts },
{ "chroma_offset_x", chroma_offset_x },
{ "chroma_offset_y", chroma_offset_y },
{ "min_luma", mpi->params.color.hdr.min_luma },
{ "max_luma", mpi->params.color.hdr.max_luma },
{ "max_cll", mpi->params.color.hdr.max_cll },
{ "max_fall", mpi->params.color.hdr.max_fall },
{ "scene_max_r", mpi->params.color.hdr.scene_max[0] },
{ "scene_max_g", mpi->params.color.hdr.scene_max[1] },
{ "scene_max_b", mpi->params.color.hdr.scene_max[2] },
{ "scene_avg", mpi->params.color.hdr.scene_avg },
{ "max_pq_y", mpi->params.color.hdr.max_pq_y },
{ "avg_pq_y", mpi->params.color.hdr.avg_pq_y },
}; };
for (int i = 0; i < hook->num_parameters; i++) { for (int i = 0; i < hook->num_parameters; i++) {
@ -2092,8 +2110,8 @@ static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook,
switch (hp->type) { switch (hp->type) {
case PL_VAR_FLOAT: hp->data->f = opts[n].value; break; case PL_VAR_FLOAT: hp->data->f = opts[n].value; break;
case PL_VAR_SINT: hp->data->i = round(opts[n].value); break; case PL_VAR_SINT: hp->data->i = lrint(opts[n].value); break;
case PL_VAR_UINT: hp->data->u = round(opts[n].value); break; case PL_VAR_UINT: hp->data->u = lrint(opts[n].value); break;
} }
} }
} }