mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-17 01:15:06 +03:00
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>
This commit is contained in:
parent
c09aee4ccb
commit
998f4de65e
5 changed files with 291 additions and 0 deletions
42
src/android/jpeg/encoder_libjpeg.h
Normal file
42
src/android/jpeg/encoder_libjpeg.h
Normal file
|
@ -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__ */
|
Loading…
Add table
Add a link
Reference in a new issue