libcamera/src/android/jpeg/encoder_libjpeg.h
Kieran Bingham f3629363c4 libcamera: Give MappedFrameBuffer its own implementation
The MappedFrameBuffer is a convenience feature which sits on top of the
FrameBuffer and facilitates mapping it to CPU accessible memory with
mmap.

This implementation is internal and currently sits in the same internal
files as the internal FrameBuffer, thus exposing those internals to
users of the MappedFramebuffer implementation.

Move the MappedFrameBuffer and MappedBuffer implementation to its own
implementation files, and fix the sources throughout to use that
accordingly.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
2021-08-10 10:53:57 +01:00

45 lines
1.1 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-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/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,
libcamera::Span<uint8_t> destination,
libcamera::Span<const uint8_t> exifData,
unsigned int quality) override;
int encode(libcamera::Span<const uint8_t> source,
libcamera::Span<uint8_t> destination,
libcamera::Span<const uint8_t> exifData,
unsigned int quality);
private:
void compressRGB(libcamera::Span<const uint8_t> frame);
void compressNV(libcamera::Span<const uint8_t> frame);
struct jpeg_compress_struct compress_;
struct jpeg_error_mgr jerr_;
const libcamera::PixelFormatInfo *pixelFormatInfo_;
bool nv_;
bool nvSwap_;
};
#endif /* __ANDROID_JPEG_ENCODER_LIBJPEG_H__ */