diff options
author | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-09-06 01:43:36 +0300 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-09-07 19:18:54 +0300 |
commit | a339d055cc7ebd92b89adadd3044f69f8f9653b8 (patch) | |
tree | 82015eaf6aa67ac9d4e542a1ee7bc91af4b6f609 /src/qcam/format_converter.cpp | |
parent | c20ad98c2a96d31847b0ef4b500e1e7a221b67c0 (diff) |
qcam: viewfinder_qt: Support multi-planar buffers
Now that the ViewFinderQt receives an Image, move the Converter API to
take an Image as well, and enable multi-planar buffer support.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/qcam/format_converter.cpp')
-rw-r--r-- | src/qcam/format_converter.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/qcam/format_converter.cpp b/src/qcam/format_converter.cpp index 973966f6..673ad33e 100644 --- a/src/qcam/format_converter.cpp +++ b/src/qcam/format_converter.cpp @@ -13,6 +13,8 @@ #include <libcamera/formats.h> +#include "../cam/image.h" + #define RGBSHIFT 8 #ifndef MAX #define MAX(a,b) ((a)>(b)?(a):(b)) @@ -154,12 +156,11 @@ int FormatConverter::configure(const libcamera::PixelFormat &format, return 0; } -void FormatConverter::convert(const unsigned char *src, size_t size, - QImage *dst) +void FormatConverter::convert(const Image *src, size_t size, QImage *dst) { switch (formatFamily_) { case MJPEG: - dst->loadFromData(src, size, "JPEG"); + dst->loadFromData(src->data(0).data(), size, "JPEG"); break; case YUV: convertYUV(src, dst->bits()); @@ -183,13 +184,14 @@ static void yuv_to_rgb(int y, int u, int v, int *r, int *g, int *b) *b = CLIP(( 298 * c + 516 * d + 128) >> RGBSHIFT); } -void FormatConverter::convertNV(const unsigned char *src, unsigned char *dst) +void FormatConverter::convertNV(const Image *srcImage, unsigned char *dst) { unsigned int c_stride = width_ * (2 / horzSubSample_); unsigned int c_inc = horzSubSample_ == 1 ? 2 : 0; unsigned int cb_pos = nvSwap_ ? 1 : 0; unsigned int cr_pos = nvSwap_ ? 0 : 1; - const unsigned char *src_c = src + width_ * height_; + const unsigned char *src = srcImage->data(0).data(); + const unsigned char *src_c = srcImage->data(1).data(); int r, g, b; for (unsigned int y = 0; y < height_; y++) { @@ -223,8 +225,9 @@ void FormatConverter::convertNV(const unsigned char *src, unsigned char *dst) } } -void FormatConverter::convertRGB(const unsigned char *src, unsigned char *dst) +void FormatConverter::convertRGB(const Image *srcImage, unsigned char *dst) { + const unsigned char *src = srcImage->data(0).data(); unsigned int x, y; int r, g, b; @@ -245,8 +248,9 @@ void FormatConverter::convertRGB(const unsigned char *src, unsigned char *dst) } } -void FormatConverter::convertYUV(const unsigned char *src, unsigned char *dst) +void FormatConverter::convertYUV(const Image *srcImage, unsigned char *dst) { + const unsigned char *src = srcImage->data(0).data(); unsigned int src_x, src_y, dst_x, dst_y; unsigned int src_stride; unsigned int dst_stride; |