Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 1 | /* |
| 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 Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 20 | #include <optional> |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 21 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 22 | #include "system/graphics.h" |
| 23 | |
| 24 | namespace android { |
| 25 | namespace companion { |
| 26 | namespace virtualcamera { |
| 27 | |
| 28 | // Jpeg-compress image into the output buffer. |
Jan Sebechlebsky | 4ce3208 | 2024-02-14 16:02:11 +0100 | [diff] [blame] | 29 | // * 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. |
| 39 | std::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 Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 43 | |
Jan Sebechlebsky | 5cb3996 | 2023-11-22 17:33:07 +0100 | [diff] [blame] | 44 | } // namespace virtualcamera |
| 45 | } // namespace companion |
| 46 | } // namespace android |
| 47 | |
| 48 | #endif // ANDROID_COMPANION_VIRTUALCAMERA_JPEGUTIL_H |