blob: 83ed74b7b07f70e7f1a80920a14346c0a94c0143 [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>
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010021
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010022#include "system/graphics.h"
23
24namespace android {
25namespace companion {
26namespace virtualcamera {
27
28// Jpeg-compress image into the output buffer.
Jan Sebechlebsky4ce32082024-02-14 16:02:11 +010029// * width - width of the image
30// * heigh - height of the image
31// * quality - 0-100, higher number corresponds to higher quality.
32// * ycbr - android_ycbr structure describing layout of input YUV420 image.
33// * app1ExifData - vector containing data to be included in APP1
34// segment. Can be empty.
35// * outBufferSize - capacity of the output buffer.
36// * outBuffer - output buffer to write compressed data into.
37// Returns size of compressed data if the compression was successful,
38// empty optional otherwise.
39std::optional<size_t> compressJpeg(int width, int height, int quality,
40 const android_ycbcr& ycbcr,
41 const std::vector<uint8_t>& app1ExifData,
42 size_t outBufferSize, void* outBuffer);
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010043
Jan Sebechlebsky5cb39962023-11-22 17:33:07 +010044} // namespace virtualcamera
45} // namespace companion
46} // namespace android
47
48#endif // ANDROID_COMPANION_VIRTUALCAMERA_JPEGUTIL_H