summaryrefslogtreecommitdiff
path: root/src/android/jpeg/encoder_libjpeg.h
diff options
context:
space:
mode:
authorKieran Bingham <kieran.bingham@ideasonboard.com>2020-06-24 14:15:15 +0100
committerKieran Bingham <kieran.bingham@ideasonboard.com>2020-08-06 15:46:02 +0100
commit998f4de65ebccf638b19a90172db74b2dc469c78 (patch)
treee4fc1bb0369963e31674c7ce708f078b9e62e93a /src/android/jpeg/encoder_libjpeg.h
parentc09aee4ccb7043484047d060f7f8bc1e0192ea23 (diff)
android: Introduce JPEG encoding
Provide an encoder interface and implement a JPEG encoder using libjpeg. Reviewed-by: Jacopo Mondi <jacopo@jmondi.org> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/android/jpeg/encoder_libjpeg.h')
-rw-r--r--src/android/jpeg/encoder_libjpeg.h42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/android/jpeg/encoder_libjpeg.h b/src/android/jpeg/encoder_libjpeg.h
new file mode 100644
index 00000000..aed081a4
--- /dev/null
+++ b/src/android/jpeg/encoder_libjpeg.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2020, Google Inc.
+ *
+ * encoder_libjpeg.h - JPEG encoding using libjpeg
+ */
+#ifndef __ANDROID_JPEG_ENCODER_LIBJPEG_H__
+#define __ANDROID_JPEG_ENCODER_LIBJPEG_H__
+
+#include "encoder.h"
+
+#include "libcamera/internal/buffer.h"
+#include "libcamera/internal/formats.h"
+
+#include <jpeglib.h>
+
+class EncoderLibJpeg : public Encoder
+{
+public:
+ EncoderLibJpeg();
+ ~EncoderLibJpeg();
+
+ int configure(const libcamera::StreamConfiguration &cfg) override;
+ int encode(const libcamera::FrameBuffer *source,
+ const libcamera::Span<uint8_t> &destination) override;
+
+private:
+ void compressRGB(const libcamera::MappedBuffer *frame);
+ void compressNV(const libcamera::MappedBuffer *frame);
+
+ struct jpeg_compress_struct compress_;
+ struct jpeg_error_mgr jerr_;
+
+ unsigned int quality_;
+
+ const libcamera::PixelFormatInfo *pixelFormatInfo_;
+
+ bool nv_;
+ bool nvSwap_;
+};
+
+#endif /* __ANDROID_JPEG_ENCODER_LIBJPEG_H__ */