|
@@ -113,6 +113,38 @@ static struct libmegapixels_modename mode_lut[] = {
|
|
|
.bpp = 10,
|
|
|
.cfa = LIBMEGAPIXELS_CFA_RGGB,
|
|
|
},
|
|
|
+ {
|
|
|
+ .name = "BGGR12",
|
|
|
+ .v4l_pixel_format = V4L2_PIX_FMT_SBGGR12,
|
|
|
+ .media_bus_format = MEDIA_BUS_FMT_SBGGR12_1X12,
|
|
|
+ .bpc = 12,
|
|
|
+ .bpp = 12,
|
|
|
+ .cfa = LIBMEGAPIXELS_CFA_BGGR,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .name = "GBRG12",
|
|
|
+ .v4l_pixel_format = V4L2_PIX_FMT_SGBRG12,
|
|
|
+ .media_bus_format = MEDIA_BUS_FMT_SGBRG12_1X12,
|
|
|
+ .bpc = 12,
|
|
|
+ .bpp = 12,
|
|
|
+ .cfa = LIBMEGAPIXELS_CFA_GBRG,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .name = "GRBG12",
|
|
|
+ .v4l_pixel_format = V4L2_PIX_FMT_SGRBG12,
|
|
|
+ .media_bus_format = MEDIA_BUS_FMT_SGRBG12_1X12,
|
|
|
+ .bpc = 12,
|
|
|
+ .bpp = 12,
|
|
|
+ .cfa = LIBMEGAPIXELS_CFA_GRBG,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ .name = "RGGB12",
|
|
|
+ .v4l_pixel_format = V4L2_PIX_FMT_SRGGB12,
|
|
|
+ .media_bus_format = MEDIA_BUS_FMT_SRGGB12_1X12,
|
|
|
+ .bpc = 12,
|
|
|
+ .bpp = 12,
|
|
|
+ .cfa = LIBMEGAPIXELS_CFA_RGGB,
|
|
|
+ },
|
|
|
{
|
|
|
.name = "BGGR16",
|
|
|
.v4l_pixel_format = V4L2_PIX_FMT_SBGGR16,
|
|
@@ -274,31 +306,33 @@ libmegapixels_format_cfa_pattern(int format)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// mp_pixel_format_width_to_bytes
|
|
|
+/* Calculates the number of bytes required to store a row of pixels for a given mode and width. */
|
|
|
uint32_t
|
|
|
libmegapixels_mode_width_to_bytes(int index, uint32_t width)
|
|
|
{
|
|
|
uint32_t bits_per_pixel = mode_lut[index].bpp;
|
|
|
uint64_t bits_per_width = width * (uint64_t) bits_per_pixel;
|
|
|
uint64_t remainder = bits_per_width % 8;
|
|
|
+ uint32_t result = 0;
|
|
|
if (remainder == 0)
|
|
|
- return bits_per_width / 8;
|
|
|
+ result = bits_per_width / 8;
|
|
|
+ else
|
|
|
+ result = (bits_per_width + 8 - remainder) / 8;
|
|
|
|
|
|
- return (bits_per_width + 8 - remainder) / 8;
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
+/* Calculates the padding (in bytes) required at the end of each row for a given mode and width. */
|
|
|
uint32_t
|
|
|
libmegapixels_mode_width_to_padding(int index, uint32_t width)
|
|
|
{
|
|
|
- if (mode_lut[index].bpp == 8) {
|
|
|
- return 0;
|
|
|
- }
|
|
|
- uint64_t bytes_per_width = libmegapixels_mode_width_to_bytes(index, width);
|
|
|
- uint64_t remainder = bytes_per_width % 8;
|
|
|
+ int remainder = mode_lut[index].bpp % 8;
|
|
|
if (remainder == 0)
|
|
|
- return remainder;
|
|
|
+ return 0;
|
|
|
+
|
|
|
+ uint32_t padding = ((uint64_t) (8 - remainder) * width) / 8;
|
|
|
|
|
|
- return 8 - remainder;
|
|
|
+ return padding;
|
|
|
}
|
|
|
|
|
|
uint32_t
|