summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Klug <stefan.klug@ideasonboard.com>2024-06-28 12:01:45 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2024-06-29 00:18:34 +0300
commite9dc398b92cf5a15240650fbac4078fdefc41ff2 (patch)
treeb743e238cd29f194912c35caea58cc25e5375d83
parent4513db58c0f5a4e94b61bebf633277d1a3efc4eb (diff)
apps: common: dng_writer: Support RAW10 and RAW12 format
Add support for RAW10 and RAW12 to the dng_writer. This is needed on imx8mp to produce tuning images. Both formats were tested on a debix som with a imx335. Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
-rw-r--r--src/apps/common/dng_writer.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/src/apps/common/dng_writer.cpp b/src/apps/common/dng_writer.cpp
index 96bbd26b..9241f23f 100644
--- a/src/apps/common/dng_writer.cpp
+++ b/src/apps/common/dng_writer.cpp
@@ -136,6 +136,34 @@ void packScanlineRaw8(void *output, const void *input, unsigned int width)
std::copy(in, in + width, out);
}
+void packScanlineRaw10(void *output, const void *input, unsigned int width)
+{
+ const uint16_t *in = static_cast<const uint16_t *>(input);
+ uint8_t *out = static_cast<uint8_t *>(output);
+
+ for (unsigned int i = 0; i < width; i += 4) {
+ *out++ = (in[0] & 0x3fc) >> 2;
+ *out++ = (in[0] & 0x003) << 6 | (in[1] & 0x3f0) >> 4;
+ *out++ = (in[1] & 0x00f) << 4 | (in[2] & 0x3c0) >> 6;
+ *out++ = (in[2] & 0x03f) << 2 | (in[3] & 0x300) >> 8;
+ *out++ = (in[3] & 0x0ff);
+ in += 4;
+ }
+}
+
+void packScanlineRaw12(void *output, const void *input, unsigned int width)
+{
+ const uint16_t *in = static_cast<const uint16_t *>(input);
+ uint8_t *out = static_cast<uint8_t *>(output);
+
+ for (unsigned int i = 0; i < width; i += 2) {
+ *out++ = (in[0] & 0xff0) >> 4;
+ *out++ = (in[0] & 0x00f) << 4 | (in[1] & 0xf00) >> 8;
+ *out++ = (in[1] & 0x0ff);
+ in += 2;
+ }
+}
+
void packScanlineRaw16(void *output, const void *input, unsigned int width)
{
const uint16_t *in = static_cast<const uint16_t *>(input);
@@ -340,6 +368,54 @@ const std::map<PixelFormat, FormatInfo> formatInfo = {
.packScanline = packScanlineRaw8,
.thumbScanline = thumbScanlineRaw_CSI2P,
} },
+ { formats::SBGGR10, {
+ .bitsPerSample = 10,
+ .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed },
+ .packScanline = packScanlineRaw10,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SGBRG10, {
+ .bitsPerSample = 10,
+ .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen },
+ .packScanline = packScanlineRaw10,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SGRBG10, {
+ .bitsPerSample = 10,
+ .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen },
+ .packScanline = packScanlineRaw10,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SRGGB10, {
+ .bitsPerSample = 10,
+ .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue },
+ .packScanline = packScanlineRaw10,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SBGGR12, {
+ .bitsPerSample = 12,
+ .pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed },
+ .packScanline = packScanlineRaw12,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SGBRG12, {
+ .bitsPerSample = 12,
+ .pattern = { CFAPatternGreen, CFAPatternBlue, CFAPatternRed, CFAPatternGreen },
+ .packScanline = packScanlineRaw12,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SGRBG12, {
+ .bitsPerSample = 12,
+ .pattern = { CFAPatternGreen, CFAPatternRed, CFAPatternBlue, CFAPatternGreen },
+ .packScanline = packScanlineRaw12,
+ .thumbScanline = thumbScanlineRaw,
+ } },
+ { formats::SRGGB12, {
+ .bitsPerSample = 12,
+ .pattern = { CFAPatternRed, CFAPatternGreen, CFAPatternGreen, CFAPatternBlue },
+ .packScanline = packScanlineRaw12,
+ .thumbScanline = thumbScanlineRaw,
+ } },
{ formats::SBGGR16, {
.bitsPerSample = 16,
.pattern = { CFAPatternBlue, CFAPatternGreen, CFAPatternGreen, CFAPatternRed },