pixel-formats: Add hsub and vsub helpers
We already had these with effective width and height, but they're useful externally as well. Pull them out to a helper. Signed-off-by: Daniel Stone <daniels@collabora.com>
This commit is contained in:
committed by
Pekka Paalanen
parent
e08df66bd3
commit
4161948da9
+24
-10
@@ -654,16 +654,34 @@ pixel_format_get_info_by_opaque_substitute(uint32_t format)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT unsigned int
|
||||||
|
pixel_format_hsub(const struct pixel_format_info *info,
|
||||||
|
unsigned int plane)
|
||||||
|
{
|
||||||
|
/* We don't support any formats where the first plane is subsampled. */
|
||||||
|
if (plane == 0 || info->hsub == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return info->hsub;
|
||||||
|
}
|
||||||
|
|
||||||
|
WL_EXPORT unsigned int
|
||||||
|
pixel_format_vsub(const struct pixel_format_info *info,
|
||||||
|
unsigned int plane)
|
||||||
|
{
|
||||||
|
/* We don't support any formats where the first plane is subsampled. */
|
||||||
|
if (plane == 0 || info->vsub == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
return info->vsub;
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT unsigned int
|
WL_EXPORT unsigned int
|
||||||
pixel_format_width_for_plane(const struct pixel_format_info *info,
|
pixel_format_width_for_plane(const struct pixel_format_info *info,
|
||||||
unsigned int plane,
|
unsigned int plane,
|
||||||
unsigned int width)
|
unsigned int width)
|
||||||
{
|
{
|
||||||
/* We don't support any formats where the first plane is subsampled. */
|
return width / pixel_format_hsub(info, plane);
|
||||||
if (plane == 0 || !info->hsub)
|
|
||||||
return width;
|
|
||||||
|
|
||||||
return width / info->hsub;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WL_EXPORT unsigned int
|
WL_EXPORT unsigned int
|
||||||
@@ -671,11 +689,7 @@ pixel_format_height_for_plane(const struct pixel_format_info *info,
|
|||||||
unsigned int plane,
|
unsigned int plane,
|
||||||
unsigned int height)
|
unsigned int height)
|
||||||
{
|
{
|
||||||
/* We don't support any formats where the first plane is subsampled. */
|
return height / pixel_format_vsub(info, plane);
|
||||||
if (plane == 0 || !info->vsub)
|
|
||||||
return height;
|
|
||||||
|
|
||||||
return height / info->vsub;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_HUMAN_FORMAT_MODIFIER
|
#ifdef HAVE_HUMAN_FORMAT_MODIFIER
|
||||||
|
|||||||
@@ -248,6 +248,36 @@ pixel_format_get_opaque_substitute(const struct pixel_format_info *format);
|
|||||||
const struct pixel_format_info *
|
const struct pixel_format_info *
|
||||||
pixel_format_get_info_by_opaque_substitute(uint32_t format);
|
pixel_format_get_info_by_opaque_substitute(uint32_t format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the horizontal subsampling factor for a given plane
|
||||||
|
*
|
||||||
|
* When horizontal subsampling is effective, a sampler bound to a secondary
|
||||||
|
* plane must bind the sampler with a smaller effective width. This function
|
||||||
|
* returns the subsampling factor to use for the given plane.
|
||||||
|
*
|
||||||
|
* @param format Pixel format info structure
|
||||||
|
* @param plane Zero-indexed plane number
|
||||||
|
* @returns Horizontal subsampling factor for the given plane
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
pixel_format_hsub(const struct pixel_format_info *format,
|
||||||
|
unsigned int plane);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the vertical subsampling factor for a given plane
|
||||||
|
*
|
||||||
|
* When vertical subsampling is effective, a sampler bound to a secondary
|
||||||
|
* plane must bind the sampler with a smaller effective height. This function
|
||||||
|
* returns the subsampling factor to use for the given plane.
|
||||||
|
*
|
||||||
|
* @param format Pixel format info structure
|
||||||
|
* @param plane Zero-indexed plane number
|
||||||
|
* @returns Vertical subsampling factor for the given plane
|
||||||
|
*/
|
||||||
|
unsigned int
|
||||||
|
pixel_format_vsub(const struct pixel_format_info *format,
|
||||||
|
unsigned int plane);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the effective sampling width for a given plane
|
* Return the effective sampling width for a given plane
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user