mode: Add a function to get padding bytes per line (MR 13)
Add a function to get extra padding bytes needed to make bytes per width a multiple of 8.
This commit is contained in:

committed by
Martijn Braam

parent
7dbc2288d0
commit
ba57d91da4
13
src/mode.c
13
src/mode.c
@@ -208,6 +208,19 @@ mp_pixel_format_width_to_bytes(MPPixelFormat pixel_format, uint32_t width)
|
||||
return (bits_per_width + 8 - remainder) / 8;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
mp_pixel_format_width_to_padding(MPPixelFormat pixel_format, uint32_t width)
|
||||
{
|
||||
uint64_t bytes_per_width =
|
||||
mp_pixel_format_width_to_bytes(pixel_format, width);
|
||||
|
||||
uint64_t remainder = bytes_per_width % 8;
|
||||
if (remainder == 0)
|
||||
return remainder;
|
||||
|
||||
return 8 - remainder;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
mp_pixel_format_width_to_colors(MPPixelFormat pixel_format, uint32_t width)
|
||||
{
|
||||
|
@@ -33,6 +33,8 @@ uint32_t mp_pixel_format_pixel_depth(MPPixelFormat pixel_format);
|
||||
const char *mp_pixel_format_cfa(MPPixelFormat pixel_format);
|
||||
const char *mp_pixel_format_cfa_pattern(MPPixelFormat pixel_format);
|
||||
uint32_t mp_pixel_format_width_to_bytes(MPPixelFormat pixel_format, uint32_t width);
|
||||
uint32_t mp_pixel_format_width_to_padding(MPPixelFormat pixel_format,
|
||||
uint32_t width);
|
||||
uint32_t mp_pixel_format_width_to_colors(MPPixelFormat pixel_format, uint32_t width);
|
||||
uint32_t mp_pixel_format_height_to_colors(MPPixelFormat pixel_format,
|
||||
uint32_t height);
|
||||
|
Reference in New Issue
Block a user