summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-05-21 02:29:05 +0200
committerwm4 <wm4@nowhere>2020-05-21 02:29:05 +0200
commit2525aa339364c71a0952280d4b8ffc7dfa6d43a3 (patch)
treef7131f90782e88d20cb7b665b5ab762719ac95c1
parent8f22aefae1a6460297c478b6e57ff108dbdb52b5 (diff)
downloadmpv-2525aa339364c71a0952280d4b8ffc7dfa6d43a3.tar.bz2
mpv-2525aa339364c71a0952280d4b8ffc7dfa6d43a3.tar.xz
img_format: expose another helper
-rw-r--r--video/img_format.c5
-rw-r--r--video/img_format.h3
2 files changed, 6 insertions, 2 deletions
diff --git a/video/img_format.c b/video/img_format.c
index 592835fd9f..7fef60457f 100644
--- a/video/img_format.c
+++ b/video/img_format.c
@@ -528,8 +528,9 @@ static bool get_native_desc(int mpfmt, struct mp_imgfmt_desc *desc)
return true;
}
-static int num_comps(int flags)
+int mp_imgfmt_desc_get_num_comps(struct mp_imgfmt_desc *desc)
{
+ int flags = desc->flags;
if (!(flags & MP_IMGFLAG_COLOR_MASK))
return 0;
return 3 + (flags & MP_IMGFLAG_GRAY ? -2 : 0) + !!(flags & MP_IMGFLAG_ALPHA);
@@ -577,7 +578,7 @@ struct mp_imgfmt_desc mp_imgfmt_get_desc(int mpfmt)
&& (desc.flags & MP_IMGFLAG_BYTES)
&& ((desc.flags & MP_IMGFLAG_TYPE_MASK) == MP_IMGFLAG_TYPE_UINT))
{
- int cnt = num_comps(desc.flags);
+ int cnt = mp_imgfmt_desc_get_num_comps(&desc);
bool same_depth = true;
for (int p = 0; p < desc.num_planes; p++)
same_depth &= desc.bpp[p] == desc.bpp[0];
diff --git a/video/img_format.h b/video/img_format.h
index 96ac78f66e..ebdbd66e29 100644
--- a/video/img_format.h
+++ b/video/img_format.h
@@ -151,6 +151,9 @@ struct mp_imgfmt_desc {
struct mp_imgfmt_desc mp_imgfmt_get_desc(int imgfmt);
+// Return the number of component types, or 0 if unknown.
+int mp_imgfmt_desc_get_num_comps(struct mp_imgfmt_desc *desc);
+
// For MP_IMGFLAG_PACKED_SS_YUV formats (packed sub-sampled YUV): positions of
// further luma samples. luma_offsets must be an array of align_x size, and the
// function will return the offset (like in mp_imgfmt_comp_desc.offset) of each