From 4ab4a888892192caeab64b7efbddce2c8881e095 Mon Sep 17 00:00:00 2001 From: nanahi <130121847+na-na-hi@users.noreply.github.com> Date: Fri, 10 Nov 2023 23:53:10 -0500 Subject: [PATCH] command: export storage aspect ratio (sar) properties Display aspect ratio (aspect) and pixel aspect ratio (par) are already exported, but storage aspect ratio (sar) isn't. This value is needed to display the storage aspect ratio for non-square pixel sources in stats.lua. This exports two new properties: video-params/sar and video-params/sar-name. Docmentation is updated accordingly. --- DOCS/man/input.rst | 6 ++++++ player/command.c | 3 +++ 2 files changed, 9 insertions(+) diff --git a/DOCS/man/input.rst b/DOCS/man/input.rst index bd0a9f7294..8dbf58b973 100644 --- a/DOCS/man/input.rst +++ b/DOCS/man/input.rst @@ -2457,6 +2457,12 @@ Property list ``video-params/par`` Pixel aspect ratio. + ``video-params/sar`` + Storage aspect ratio. + + ``video-params/sar-name`` + Storage aspect ratio name as string. + ``video-params/colormatrix`` The colormatrix in use as string. (Exact values subject to change.) diff --git a/player/command.c b/player/command.c index bf4b029b3e..937831107f 100644 --- a/player/command.c +++ b/player/command.c @@ -2299,6 +2299,7 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg) bool has_crop = mp_rect_w(p.crop) > 0 && mp_rect_h(p.crop) > 0; const char *aspect_name = get_aspect_ratio_name(d_w / (double)d_h); + const char *sar_name = get_aspect_ratio_name(p.w / (double)p.h); struct m_sub_property props[] = { {"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.imgfmt))}, {"hw-pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p.hw_subfmt)), @@ -2316,6 +2317,8 @@ static int property_imgparams(struct mp_image_params p, int action, void *arg) {"aspect", SUB_PROP_FLOAT(d_w / (double)d_h)}, {"aspect-name", SUB_PROP_STR(aspect_name), .unavailable = !aspect_name}, {"par", SUB_PROP_FLOAT(p.p_w / (double)p.p_h)}, + {"sar", SUB_PROP_FLOAT(p.w / (double)p.h)}, + {"sar-name", SUB_PROP_STR(sar_name), .unavailable = !sar_name}, {"colormatrix", SUB_PROP_STR(m_opt_choice_str(mp_csp_names, p.color.space))}, {"colorlevels",