History

command: add hdr-metadata property

Kacper Michajłow committed 3 years ago

Commit 3cf71fd1 parent 38ac6733 files · +84 −0Browse files

Unified · Split

3 files
  1. DOCS/interface-changes.rst +1 −0
  2. DOCS/man/input.rst +48 −0
  3. player/command.c +35 −0
DOCS/interface-changes.rst+1−0
@@ -51,6 +51,7 @@ Interface changes · 50 unmodified lines
5151 - remove `auto-forced-only` property
5252 - rename `--sub-forced-only` to `--sub-forced-events-only`
5353 - remove `sub-forced-only-cur` property (`--sub-forced-events-only` is a replacement)
54+ - add `hdr-metadata` property
5455 --- mpv 0.36.0 ---
5556 - add `--target-contrast`
5657 - Target luminance value is now also applied when ICC profile is used.
DOCS/man/input.rst+48−0
@@ -2480,6 +2480,54 @@ Property list · 2479 unmodified lines
24802480 "average-bpp" MPV_FORMAT_INT64
24812481 "alpha" MPV_FORMAT_STRING
24822482
2483+``hdr-metadata``
2484+ Video HDR metadata per frame, including peak detection result.
2485+ This has a number of sub-properties:
2486+
2487+ ``hdr-metadata/min-luma``
2488+ Minimum luminance, as reported by HDR10 metadata (in cd/m²)
2489+
2490+ ``hdr-metadata/max-luma``
2491+ Maximum luminance, as reported by HDR10 metadata (in cd/m²)
2492+
2493+ ``hdr-metadata/max-cll``
2494+ Maximum content light level, as reported by HDR10 metadata (in cd/m²)
2495+
2496+ ``hdr-metadata/max-fall``
2497+ Maximum frame average light level, as reported by HDR10 metadata (in cd/m²)
2498+
2499+ ``hdr-metadata/scene-max-r``
2500+ MaxRGB of a scene for R component, as reported by HDR10+ metadata (in cd/m²)
2501+
2502+ ``hdr-metadata/scene-max-g``
2503+ MaxRGB of a scene for G component, as reported by HDR10+ metadata (in cd/m²)
2504+
2505+ ``hdr-metadata/scene-max-b``
2506+ MaxRGB of a scene for B component, as reported by HDR10+ metadata (in cd/m²)
2507+
2508+ ``hdr-metadata/max-pq-y``
2509+ Maximum PQ luminance of a frame, as reported by peak detection (in PQ, 0-1)
2510+
2511+ ``hdr-metadata/avg-pq-y``
2512+ Average PQ luminance of a frame, as reported by peak detection (in PQ, 0-1)
2513+
2514+ When querying the property with the client API using ``MPV_FORMAT_NODE``,
2515+ or with Lua ``mp.get_property_native``, this will return a mpv_node with
2516+ the following contents:
2517+
2518+ ::
2519+
2520+ MPV_FORMAT_NODE_MAP
2521+ "min-luma" MPV_FORMAT_DOUBLE
2522+ "max-luma" MPV_FORMAT_DOUBLE
2523+ "max-cll" MPV_FORMAT_DOUBLE
2524+ "max-fall" MPV_FORMAT_DOUBLE
2525+ "scene-max-r" MPV_FORMAT_DOUBLE
2526+ "scene-max-g" MPV_FORMAT_DOUBLE
2527+ "scene-max-b" MPV_FORMAT_DOUBLE
2528+ "max-pq-y" MPV_FORMAT_DOUBLE
2529+ "avg-pq-y" MPV_FORMAT_DOUBLE
2530+
24832531 ``dwidth``, ``dheight``
24842532 Video display size. This is the video size after filters and aspect scaling
24852533 have been applied. The actual video window size can still be different
player/command.c+35−0
@@ -2664,6 +2664,40 @@ out: · 2663 unmodified lines
26642664 return ret;
26652665 }
26662666
2667+static int mp_property_hdr_metadata(void *ctx, struct m_property *prop,
2668+ int action, void *arg)
2669+{
2670+ MPContext *mpctx = ctx;
2671+ if (!mpctx->video_out)
2672+ return M_PROPERTY_UNAVAILABLE;
2673+
2674+ struct mp_hdr_metadata data;
2675+ if (vo_control(mpctx->video_out, VOCTRL_HDR_METADATA, &data) != VO_TRUE)
2676+ return M_PROPERTY_UNAVAILABLE;
2677+
2678+ bool has_hdr10 = data.max_luma;
2679+ bool has_hdr10plus = data.scene_avg && (data.scene_max[0] ||
2680+ data.scene_max[1] ||
2681+ data.scene_max[2]);
2682+ bool has_cie_y = data.max_pq_y && data.avg_pq_y;
2683+
2684+ struct m_sub_property props[] = {
2685+ {"min-luma", SUB_PROP_FLOAT(data.min_luma), .unavailable = !has_hdr10},
2686+ {"max-luma", SUB_PROP_FLOAT(data.max_luma), .unavailable = !has_hdr10},
2687+ {"max-cll", SUB_PROP_FLOAT(data.max_cll), .unavailable = !has_hdr10},
2688+ {"max-fall", SUB_PROP_FLOAT(data.max_fall), .unavailable = !has_hdr10},
2689+ {"scene-max-r", SUB_PROP_FLOAT(data.scene_max[0]), .unavailable = !has_hdr10plus},
2690+ {"scene-max-g", SUB_PROP_FLOAT(data.scene_max[1]), .unavailable = !has_hdr10plus},
2691+ {"scene-max-b", SUB_PROP_FLOAT(data.scene_max[2]), .unavailable = !has_hdr10plus},
2692+ {"scene-avg", SUB_PROP_FLOAT(data.scene_avg), .unavailable = !has_hdr10plus},
2693+ {"max-pq-y", SUB_PROP_FLOAT(data.max_pq_y), .unavailable = !has_cie_y},
2694+ {"avg-pq-y", SUB_PROP_FLOAT(data.avg_pq_y), .unavailable = !has_cie_y},
2695+ {0}
2696+ };
2697+
2698+ return m_property_read_sub(props, action, arg);
2699+}
2700+
26672701 static int mp_property_perf_info(void *ctx, struct m_property *p, int action,
26682702 void *arg)
26692703 {
@@ -3934,6 +3968,7 @@ static const struct m_property mp_properties_base[] = { · 1264 unmodified lines
39343968 {"current-window-scale", mp_property_current_window_scale},
39353969 {"vo-configured", mp_property_vo_configured},
39363970 {"vo-passes", mp_property_vo_passes},
3971+ {"hdr-metadata", mp_property_hdr_metadata},
39373972 {"perf-info", mp_property_perf_info},
39383973 {"current-vo", mp_property_vo},
39393974 {"container-fps", mp_property_fps},

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t