blob: 4feb4f516f1ecb84c260b856ce00be600e0cd7b5 [file] [log] [blame]
James Dong79f407c2011-05-05 12:50:04 -07001/*
2 * Copyright 2011, 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_MEDIA_UTILS_H_
18#define _ANDROID_MEDIA_UTILS_H_
19
Jaesung Chung6e08d2b2016-02-25 15:04:56 +090020#include <gui/CpuConsumer.h>
James Dong79f407c2011-05-05 12:50:04 -070021
22namespace android {
23
Zhijun He0ab41622016-02-25 16:00:38 -080024// -----------Utility functions used by ImageReader/Writer JNI-----------------
25
26typedef CpuConsumer::LockedBuffer LockedImage;
27
28bool usingRGBAToJpegOverride(int32_t imageFormat, int32_t containerFormat);
29
30int32_t applyFormatOverrides(int32_t imageFormat, int32_t containerFormat);
31
Shuzhen Wangf655b1c2018-12-28 15:40:36 -080032uint32_t Image_getBlobSize(LockedImage* buffer, bool usingRGBAOverride);
Zhijun He0ab41622016-02-25 16:00:38 -080033
34bool isFormatOpaque(int format);
35
36bool isPossiblyYUV(PixelFormat format);
37
Wonsik Kim584cde22022-04-07 16:51:46 -070038bool isPossibly10BitYUV(PixelFormat format);
39
Zhijun He0ab41622016-02-25 16:00:38 -080040status_t getLockedImageInfo(LockedImage* buffer, int idx, int32_t containerFormat,
41 uint8_t **base, uint32_t *size, int *pixelStride, int *rowStride);
42
43status_t lockImageFromBuffer(sp<GraphicBuffer> buffer, uint32_t inUsage,
44 const Rect& rect, int fenceFd, LockedImage* outputImage);
45
46status_t lockImageFromBuffer(BufferItem* bufferItem, uint32_t inUsage,
47 int fenceFd, LockedImage* outputImage);
48
49int getBufferWidth(BufferItem *buffer);
50
51int getBufferHeight(BufferItem *buffer);
52
James Dong79f407c2011-05-05 12:50:04 -070053}; // namespace android
54
55#endif // _ANDROID_MEDIA_UTILS_H_