summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2023-08-31 16:52:28 +0200
committerJan Ekström <jeebjp@gmail.com>2024-03-07 21:12:12 +0200
commitd471f2902eb4f824fb5b62c3a30b26581d1e22b9 (patch)
tree3db807047fa7190882a73bfccac1bbbaae45f66d /player
parent0d33394955cb9d90905e8ade8776a3574d694544 (diff)
downloadmpv-d471f2902eb4f824fb5b62c3a30b26581d1e22b9.tar.bz2
mpv-d471f2902eb4f824fb5b62c3a30b26581d1e22b9.tar.xz
mp_image: add imgfmt_name to mp_image_params
Convenience to override name if imgfmt is not set. Allows to create mp_image_params without setting imgfmt. Will be useful for the next change where mp_imgfmt is not available. This is workaround that will be remved once all codebase switches to pl_fmt.
Diffstat (limited to 'player')
-rw-r--r--player/command.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/player/command.c b/player/command.c
index 5b61ae3498..75debf781d 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2321,22 +2321,24 @@ static const char *get_aspect_ratio_name(double ratio)
static int property_imgparams(const struct mp_image_params *p, int action, void *arg)
{
- if (!p->imgfmt)
+ if (!p->imgfmt && !p->imgfmt_name)
return M_PROPERTY_UNAVAILABLE;
int d_w, d_h;
mp_image_params_get_dsize(p, &d_w, &d_h);
- struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p->imgfmt);
int bpp = 0;
- for (int i = 0; i < desc.num_planes; i++)
- bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]);
-
enum pl_alpha_mode alpha = p->repr.alpha;
- // Alpha type is not supported by FFmpeg, so PL_ALPHA_UNKNOWN may mean alpha
- // is of an unknown type, or simply not present. Normalize to AUTO=no alpha.
- if (!!(desc.flags & MP_IMGFLAG_ALPHA) != (alpha != PL_ALPHA_UNKNOWN))
- alpha = (desc.flags & MP_IMGFLAG_ALPHA) ? PL_ALPHA_INDEPENDENT : PL_ALPHA_UNKNOWN;
+ if (p->imgfmt) {
+ struct mp_imgfmt_desc desc = mp_imgfmt_get_desc(p->imgfmt);
+ for (int i = 0; i < desc.num_planes; i++)
+ bpp += desc.bpp[i] >> (desc.xs[i] + desc.ys[i]);
+
+ // Alpha type is not supported by FFmpeg, so PL_ALPHA_UNKNOWN may mean alpha
+ // is of an unknown type, or simply not present. Normalize to AUTO=no alpha.
+ if (!!(desc.flags & MP_IMGFLAG_ALPHA) != (alpha != PL_ALPHA_UNKNOWN))
+ alpha = (desc.flags & MP_IMGFLAG_ALPHA) ? PL_ALPHA_INDEPENDENT : PL_ALPHA_UNKNOWN;
+ }
const struct pl_hdr_metadata *hdr = &p->color.hdr;
bool has_cie_y = pl_hdr_metadata_contains(hdr, PL_HDR_METADATA_CIE_Y);
@@ -2346,8 +2348,10 @@ static int property_imgparams(const struct mp_image_params *p, int action, void
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);
+ const char *pixelformat_name = p->imgfmt_name ? p->imgfmt_name :
+ mp_imgfmt_to_name(p->imgfmt);
struct m_sub_property props[] = {
- {"pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p->imgfmt))},
+ {"pixelformat", SUB_PROP_STR(pixelformat_name)},
{"hw-pixelformat", SUB_PROP_STR(mp_imgfmt_to_name(p->hw_subfmt)),
.unavailable = !p->hw_subfmt},
{"average-bpp", SUB_PROP_INT(bpp),