blob: 1b3ac067a1c004d235d78ce3747b0aeb3831c3e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2020, Google Inc.
*
* encoder_libjpeg.h - JPEG encoding using libjpeg
*/
#pragma once
#include "encoder.h"
#include <vector>
#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(const std::vector<libcamera::Span<uint8_t>> &planes,
libcamera::Span<uint8_t> destination,
libcamera::Span<const uint8_t> exifData,
unsigned int quality);
private:
void compressRGB(const std::vector<libcamera::Span<uint8_t>> &planes);
void compressNV(const std::vector<libcamera::Span<uint8_t>> &planes);
struct jpeg_compress_struct compress_;
struct jpeg_error_mgr jerr_;
const libcamera::PixelFormatInfo *pixelFormatInfo_;
bool nv_;
bool nvSwap_;
};
|