blob: 5d53269ee532c1acb1e4835a15de01d9573d4e9e [file] [log] [blame]
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +01001/*
2 * Copyright (C) 2023 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ANDROID_COMPANION_VIRTUALCAMERA_JPEGUTIL_H
18#define ANDROID_COMPANION_VIRTUALCAMERA_JPEGUTIL_H
19
Jan Sebechlebsky4ce32082024-02-14 16:02:11 +010020#include <optional>
Yabin Cui1a8b3f82024-07-23 12:16:23 -070021#include <vector>
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010022
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010023#include "system/graphics.h"
24
25namespace android {
26namespace companion {
27namespace virtualcamera {
28
29// Jpeg-compress image into the output buffer.
Jan Sebechlebsky4ce32082024-02-14 16:02:11 +010030// * width - width of the image
31// * heigh - height of the image
32// * quality - 0-100, higher number corresponds to higher quality.
33// * ycbr - android_ycbr structure describing layout of input YUV420 image.
34// * app1ExifData - vector containing data to be included in APP1
35// segment. Can be empty.
36// * outBufferSize - capacity of the output buffer.
37// * outBuffer - output buffer to write compressed data into.
38// Returns size of compressed data if the compression was successful,
39// empty optional otherwise.
40std::optional<size_t> compressJpeg(int width, int height, int quality,
41 const android_ycbcr& ycbcr,
42 const std::vector<uint8_t>& app1ExifData,
43 size_t outBufferSize, void* outBuffer);
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010044
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010045} // namespace virtualcamera
46} // namespace companion
47} // namespace android
48
49#endif // ANDROID_COMPANION_VIRTUALCAMERA_JPEGUTIL_H