mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-16 17:05:08 +03:00
android: Modify Encoder interface
In Encoder::encode(), the |source| argument doesn't have to be a pointer. This replaces its type, const pointer, with const reference as the latter is preferred to the former. libcamera::Span is cheap to construct/copy/move. We should deal with the type as pass-by-value parameter. Therefore this also drops the const reference in the |destination| argument. Signed-off-by: Hirokazu Honda <hiroh@chromium.org> Reviewed-by: Umang Jain <email@uajain.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
parent
b8dd5ce944
commit
90c193f2a7
4 changed files with 8 additions and 8 deletions
|
@ -17,8 +17,8 @@ public:
|
||||||
virtual ~Encoder() {}
|
virtual ~Encoder() {}
|
||||||
|
|
||||||
virtual int configure(const libcamera::StreamConfiguration &cfg) = 0;
|
virtual int configure(const libcamera::StreamConfiguration &cfg) = 0;
|
||||||
virtual int encode(const libcamera::FrameBuffer *source,
|
virtual int encode(const libcamera::FrameBuffer &source,
|
||||||
const libcamera::Span<uint8_t> &destination,
|
libcamera::Span<uint8_t> destination,
|
||||||
const libcamera::Span<const uint8_t> &exifData) = 0;
|
const libcamera::Span<const uint8_t> &exifData) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -179,11 +179,11 @@ void EncoderLibJpeg::compressNV(const libcamera::MappedBuffer *frame)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int EncoderLibJpeg::encode(const FrameBuffer *source,
|
int EncoderLibJpeg::encode(const FrameBuffer &source,
|
||||||
const libcamera::Span<uint8_t> &dest,
|
libcamera::Span<uint8_t> dest,
|
||||||
const libcamera::Span<const uint8_t> &exifData)
|
const libcamera::Span<const uint8_t> &exifData)
|
||||||
{
|
{
|
||||||
MappedFrameBuffer frame(source, PROT_READ);
|
MappedFrameBuffer frame(&source, PROT_READ);
|
||||||
if (!frame.isValid()) {
|
if (!frame.isValid()) {
|
||||||
LOG(JPEG, Error) << "Failed to map FrameBuffer : "
|
LOG(JPEG, Error) << "Failed to map FrameBuffer : "
|
||||||
<< strerror(frame.error());
|
<< strerror(frame.error());
|
||||||
|
|
|
@ -21,8 +21,8 @@ public:
|
||||||
~EncoderLibJpeg();
|
~EncoderLibJpeg();
|
||||||
|
|
||||||
int configure(const libcamera::StreamConfiguration &cfg) override;
|
int configure(const libcamera::StreamConfiguration &cfg) override;
|
||||||
int encode(const libcamera::FrameBuffer *source,
|
int encode(const libcamera::FrameBuffer &source,
|
||||||
const libcamera::Span<uint8_t> &destination,
|
libcamera::Span<uint8_t> destination,
|
||||||
const libcamera::Span<const uint8_t> &exifData) override;
|
const libcamera::Span<const uint8_t> &exifData) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -67,7 +67,7 @@ int PostProcessorJpeg::process(const libcamera::FrameBuffer &source,
|
||||||
if (exif.generate() != 0)
|
if (exif.generate() != 0)
|
||||||
LOG(JPEG, Error) << "Failed to generate valid EXIF data";
|
LOG(JPEG, Error) << "Failed to generate valid EXIF data";
|
||||||
|
|
||||||
int jpeg_size = encoder_->encode(&source, destination, exif.data());
|
int jpeg_size = encoder_->encode(source, destination, exif.data());
|
||||||
if (jpeg_size < 0) {
|
if (jpeg_size < 0) {
|
||||||
LOG(JPEG, Error) << "Failed to encode stream image";
|
LOG(JPEG, Error) << "Failed to encode stream image";
|
||||||
return jpeg_size;
|
return jpeg_size;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue