|
| 1 | +/* |
| 2 | + * Copyright (c) 2025 tinyVision.ai Inc. |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +#ifndef ZEPHYR_INCLUDE_PIXEL_BAYER_H_ |
| 8 | +#define ZEPHYR_INCLUDE_PIXEL_BAYER_H_ |
| 9 | + |
| 10 | +#include <stdint.h> |
| 11 | +#include <stdlib.h> |
| 12 | + |
| 13 | +#include <zephyr/pixel/stream.h> |
| 14 | + |
| 15 | +/** |
| 16 | + * @brief Convert a line from RGGB8 to RGB24 with 3x3 method |
| 17 | + * |
| 18 | + * @param i0 Buffer of the input row number 0 in bayer format (1 byte per pixel). |
| 19 | + * @param i1 Buffer of the input row number 1 in bayer format (1 byte per pixel). |
| 20 | + * @param i2 Buffer of the input row number 2 in bayer format (1 byte per pixel). |
| 21 | + * @param rgb24 Buffer of the output row in RGB24 format (3 bytes per pixel). |
| 22 | + * @param width Width of the lines in number of pixels. |
| 23 | + */ |
| 24 | +void pixel_rggb8line_to_rgb24line_3x3(const uint8_t *i0, const uint8_t *i1, const uint8_t *i2, |
| 25 | + uint8_t *rgb24, uint16_t width); |
| 26 | +/** |
| 27 | + * @brief Convert a line from GRBG8 to RGB24 with 3x3 method |
| 28 | + * @copydetails pixel_rggb8line_to_rgb24line_3x3() |
| 29 | + */ |
| 30 | +void pixel_grbg8line_to_rgb24line_3x3(const uint8_t *i0, const uint8_t *i1, const uint8_t *i2, |
| 31 | + uint8_t *rgb24, uint16_t width); |
| 32 | +/** |
| 33 | + * @brief Convert a line from BGGR8 to RGB24 with 3x3 method |
| 34 | + * @copydetails pixel_rggb8line_to_rgb24line_3x3() |
| 35 | + */ |
| 36 | +void pixel_bggr8line_to_rgb24line_3x3(const uint8_t *i0, const uint8_t *i1, const uint8_t *i2, |
| 37 | + uint8_t *rgb24, uint16_t width); |
| 38 | +/** |
| 39 | + * @brief Convert a line from GBRG8 to RGB24 with 3x3 method |
| 40 | + * @copydetails pixel_rggb8line_to_rgb24line_3x3() |
| 41 | + */ |
| 42 | +void pixel_gbrg8line_to_rgb24line_3x3(const uint8_t *i0, const uint8_t *i1, const uint8_t *i2, |
| 43 | + uint8_t *rgb24, uint16_t width); |
| 44 | + |
| 45 | +/** |
| 46 | + * @brief Convert a line from RGGB8 to RGB24 with 2x2 method |
| 47 | + * |
| 48 | + * @param i0 Buffer of the input row number 0 in bayer format (1 byte per pixel). |
| 49 | + * @param i1 Buffer of the input row number 1 in bayer format (1 byte per pixel). |
| 50 | + * @param rgb24 Buffer of the output row in RGB24 format (3 bytes per pixel). |
| 51 | + * @param width Width of the lines in number of pixels. |
| 52 | + */ |
| 53 | +void pixel_rggb8line_to_rgb24line_2x2(const uint8_t *i0, const uint8_t *i1, uint8_t *rgb24, |
| 54 | + uint16_t width); |
| 55 | +/** |
| 56 | + * @brief Convert a line from GBRG8 to RGB24 with 2x2 method |
| 57 | + * @copydetails pixel_rggb8line_to_rgb24line_2x2() |
| 58 | + */ |
| 59 | +void pixel_gbrg8line_to_rgb24line_2x2(const uint8_t *i0, const uint8_t *i1, uint8_t *rgb24, |
| 60 | + uint16_t width); |
| 61 | +/** |
| 62 | + * @brief Convert a line from BGGR8 to RGB24 with 2x2 method |
| 63 | + * @copydetails pixel_rggb8line_to_rgb24line_2x2() |
| 64 | + */ |
| 65 | +void pixel_bggr8line_to_rgb24line_2x2(const uint8_t *i0, const uint8_t *i1, uint8_t *rgb24, |
| 66 | + uint16_t width); |
| 67 | +/** |
| 68 | + * @brief Convert a line from GRBG8 to RGB24 with 2x2 method |
| 69 | + * @copydetails pixel_rggb8line_to_rgb24line_2x2() |
| 70 | + */ |
| 71 | +void pixel_grbg8line_to_rgb24line_2x2(const uint8_t *i0, const uint8_t *i1, uint8_t *rgb24, |
| 72 | + uint16_t width); |
| 73 | + |
| 74 | +/** |
| 75 | + * @brief Define a stream converter from RGGB8 to RGB24 with the 3x3 method |
| 76 | + * |
| 77 | + * @param name The symbol of the @ref pixel_stream that will be defined. |
| 78 | + * @param width The total width of the input frame in number of pixels. |
| 79 | + * @param height The total height of the input frame in number of pixels. |
| 80 | + */ |
| 81 | +#define PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3(name, width, height) \ |
| 82 | + PIXEL_BAYER_DEFINE(name, pixel_rggb8stream_to_rgb24stream_3x3, (width), (height), 3) |
| 83 | +/** |
| 84 | + * @brief Define a stream converter from GRBG8 to RGB24 with the 3x3 method |
| 85 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 86 | + */ |
| 87 | +#define PIXEL_GRBG8STREAM_TO_RGB24STREAM_3X3(name, width, height) \ |
| 88 | + PIXEL_BAYER_DEFINE(name, pixel_grbg8stream_to_rgb24stream_3x3, (width), (height), 3) |
| 89 | +/** |
| 90 | + * @brief Define a stream converter from BGGR8 to RGB24 with the 3x3 method |
| 91 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 92 | + */ |
| 93 | +#define PIXEL_BGGR8STREAM_TO_RGB24STREAM_3X3(name, width, height) \ |
| 94 | + PIXEL_BAYER_DEFINE(name, pixel_bggr8stream_to_rgb24stream_3x3, (width), (height), 3) |
| 95 | +/** |
| 96 | + * @brief Define a stream converter from GBRG8 to RGB24 with the 3x3 method |
| 97 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 98 | + */ |
| 99 | +#define PIXEL_GBRG8STREAM_TO_RGB24STREAM_3X3(name, width, height) \ |
| 100 | + PIXEL_BAYER_DEFINE(name, pixel_gbrg8stream_to_rgb24stream_3x3, (width), (height), 3) |
| 101 | +/** |
| 102 | + * @brief Define a stream converter from RGGB8 to RGB24 with the 2x2 method |
| 103 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 104 | + */ |
| 105 | +#define PIXEL_RGGB8STREAM_TO_RGB24STREAM_2X2(name, width, height) \ |
| 106 | + PIXEL_BAYER_DEFINE(name, pixel_rggb8stream_to_rgb24stream_2x2, (width), (height), 2) |
| 107 | +/** |
| 108 | + * @brief Define a stream converter from GBRG8 to RGB24 with the 2x2 method |
| 109 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 110 | + */ |
| 111 | +#define PIXEL_GBRG8STREAM_TO_RGB24STREAM_2X2(name, width, height) \ |
| 112 | + PIXEL_BAYER_DEFINE(name, pixel_gbrg8stream_to_rgb24stream_2x2, (width), (height), 2) |
| 113 | +/** |
| 114 | + * @brief Define a stream converter from BGGR8 to RGB24 with the 2x2 method |
| 115 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 116 | + */ |
| 117 | +#define PIXEL_BGGR8STREAM_TO_RGB24STREAM_2X2(name, width, height) \ |
| 118 | + PIXEL_BAYER_DEFINE(name, pixel_bggr8stream_to_rgb24stream_2x2, (width), (height), 2) |
| 119 | +/** |
| 120 | + * @brief Define a stream converter from GRBG8 to RGB24 with the 2x2 method |
| 121 | + * @copydetails PIXEL_RGGB8STREAM_TO_RGB24STREAM_3X3() |
| 122 | + */ |
| 123 | +#define PIXEL_GRBG8STREAM_TO_RGB24STREAM_2X2(name, width, height) \ |
| 124 | + PIXEL_BAYER_DEFINE(name, pixel_grbg8stream_to_rgb24stream_2x2, (width), (height), 2) |
| 125 | + |
| 126 | +/** @cond INTERNAL_HIDDEN */ |
| 127 | +#define PIXEL_BAYER_DEFINE(name, fn, width, height, window_height) \ |
| 128 | + PIXEL_STREAM_DEFINE((name), (fn), (width), (height), (width), (window_height) * (width)) |
| 129 | +void pixel_rggb8stream_to_rgb24stream_3x3(struct pixel_stream *strm); |
| 130 | +void pixel_grbg8stream_to_rgb24stream_3x3(struct pixel_stream *strm); |
| 131 | +void pixel_bggr8stream_to_rgb24stream_3x3(struct pixel_stream *strm); |
| 132 | +void pixel_gbrg8stream_to_rgb24stream_3x3(struct pixel_stream *strm); |
| 133 | +void pixel_rggb8stream_to_rgb24stream_2x2(struct pixel_stream *strm); |
| 134 | +void pixel_gbrg8stream_to_rgb24stream_2x2(struct pixel_stream *strm); |
| 135 | +void pixel_bggr8stream_to_rgb24stream_2x2(struct pixel_stream *strm); |
| 136 | +void pixel_grbg8stream_to_rgb24stream_2x2(struct pixel_stream *strm); |
| 137 | +/** @endcond */ |
| 138 | + |
| 139 | +#endif /* ZEPHYR_INCLUDE_PIXEL_BAYER_H_ */ |
0 commit comments