libcamera: software_isp: Use common code to store debayered pixels
The debayering macros use the same pattern, let's extract it to a common macro. This reduces code duplication a bit now and it'll make changes of debayering easier when color correction matrix is introduced. Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Milan Zamazal <mzamazal@redhat.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
148ac13043
commit
f1955a0058
1 changed files with 28 additions and 28 deletions
|
@ -62,57 +62,57 @@ DebayerCpu::~DebayerCpu() = default;
|
||||||
const pixel_t *curr = (const pixel_t *)src[1] + xShift_; \
|
const pixel_t *curr = (const pixel_t *)src[1] + xShift_; \
|
||||||
const pixel_t *next = (const pixel_t *)src[2] + xShift_;
|
const pixel_t *next = (const pixel_t *)src[2] + xShift_;
|
||||||
|
|
||||||
|
#define STORE_PIXEL(b, g, r) \
|
||||||
|
*dst++ = blue_[b]; \
|
||||||
|
*dst++ = green_[g]; \
|
||||||
|
*dst++ = red_[r]; \
|
||||||
|
if constexpr (addAlphaByte) \
|
||||||
|
*dst++ = 255; \
|
||||||
|
x++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* RGR
|
* RGR
|
||||||
* GBG
|
* GBG
|
||||||
* RGR
|
* RGR
|
||||||
*/
|
*/
|
||||||
#define BGGR_BGR888(p, n, div) \
|
#define BGGR_BGR888(p, n, div) \
|
||||||
*dst++ = blue_[curr[x] / (div)]; \
|
STORE_PIXEL( \
|
||||||
*dst++ = green_[(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div))]; \
|
curr[x] / (div), \
|
||||||
*dst++ = red_[(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div))]; \
|
(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div)), \
|
||||||
if constexpr (addAlphaByte) \
|
(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div)))
|
||||||
*dst++ = 255; \
|
|
||||||
x++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GBG
|
* GBG
|
||||||
* RGR
|
* RGR
|
||||||
* GBG
|
* GBG
|
||||||
*/
|
*/
|
||||||
#define GRBG_BGR888(p, n, div) \
|
#define GRBG_BGR888(p, n, div) \
|
||||||
*dst++ = blue_[(prev[x] + next[x]) / (2 * (div))]; \
|
STORE_PIXEL( \
|
||||||
*dst++ = green_[curr[x] / (div)]; \
|
(prev[x] + next[x]) / (2 * (div)), \
|
||||||
*dst++ = red_[(curr[x - p] + curr[x + n]) / (2 * (div))]; \
|
curr[x] / (div), \
|
||||||
if constexpr (addAlphaByte) \
|
(curr[x - p] + curr[x + n]) / (2 * (div)))
|
||||||
*dst++ = 255; \
|
|
||||||
x++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GRG
|
* GRG
|
||||||
* BGB
|
* BGB
|
||||||
* GRG
|
* GRG
|
||||||
*/
|
*/
|
||||||
#define GBRG_BGR888(p, n, div) \
|
#define GBRG_BGR888(p, n, div) \
|
||||||
*dst++ = blue_[(curr[x - p] + curr[x + n]) / (2 * (div))]; \
|
STORE_PIXEL( \
|
||||||
*dst++ = green_[curr[x] / (div)]; \
|
(curr[x - p] + curr[x + n]) / (2 * (div)), \
|
||||||
*dst++ = red_[(prev[x] + next[x]) / (2 * (div))]; \
|
curr[x] / (div), \
|
||||||
if constexpr (addAlphaByte) \
|
(prev[x] + next[x]) / (2 * (div)))
|
||||||
*dst++ = 255; \
|
|
||||||
x++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BGB
|
* BGB
|
||||||
* GRG
|
* GRG
|
||||||
* BGB
|
* BGB
|
||||||
*/
|
*/
|
||||||
#define RGGB_BGR888(p, n, div) \
|
#define RGGB_BGR888(p, n, div) \
|
||||||
*dst++ = blue_[(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div))]; \
|
STORE_PIXEL( \
|
||||||
*dst++ = green_[(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div))]; \
|
(prev[x - p] + prev[x + n] + next[x - p] + next[x + n]) / (4 * (div)), \
|
||||||
*dst++ = red_[curr[x] / (div)]; \
|
(prev[x] + curr[x - p] + curr[x + n] + next[x]) / (4 * (div)), \
|
||||||
if constexpr (addAlphaByte) \
|
curr[x] / (div))
|
||||||
*dst++ = 255; \
|
|
||||||
x++;
|
|
||||||
|
|
||||||
template<bool addAlphaByte>
|
template<bool addAlphaByte>
|
||||||
void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])
|
void DebayerCpu::debayer8_BGBG_BGR888(uint8_t *dst, const uint8_t *src[])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue