Skip to content

Commit

Permalink
vo_gpu_next: add chroma location and HDR metadata to shader parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 committed Nov 2, 2024
1 parent 89e608e commit 42ff6f9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 4 deletions.
1 change: 1 addition & 0 deletions DOCS/interface-changes/glsl-shader-opts.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``glsl-shader-opts`` now has predefined parameters that can be used. See the documentation for available values.
42 changes: 42 additions & 0 deletions DOCS/man/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6327,6 +6327,48 @@ them.
The shader name is the base part of the shader filename, without the
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``
Enable the debanding algorithm. This greatly reduces the amount of visible
banding, blocking and other quantization artifacts, at the expense of
Expand Down
26 changes: 22 additions & 4 deletions video/out/vo_gpu_next.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
const struct mp_image *mpi)
{
const struct { const char *name; double value; } opts[] = {
{ "PTS", mpi->pts },
float chroma_offset_x, chroma_offset_y;
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++) {
Expand All @@ -2092,8 +2110,8 @@ static void update_hook_opts_dynamic(struct priv *p, const struct pl_hook *hook,

switch (hp->type) {
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_UINT: hp->data->u = round(opts[n].value); break;
case PL_VAR_SINT: hp->data->i = lrint(opts[n].value); break;
case PL_VAR_UINT: hp->data->u = lrint(opts[n].value); break;
}
}
}
Expand Down

0 comments on commit 42ff6f9

Please sign in to comment.