James Dong | 79f407c | 2011-05-05 12:50:04 -0700 | [diff] [blame] | 1 | /* |
| 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 Chung | 6e08d2b | 2016-02-25 15:04:56 +0900 | [diff] [blame] | 20 | #include <gui/CpuConsumer.h> |
James Dong | 79f407c | 2011-05-05 12:50:04 -0700 | [diff] [blame] | 21 | |
| 22 | namespace android { |
| 23 | |
Zhijun He | 0ab4162 | 2016-02-25 16:00:38 -0800 | [diff] [blame] | 24 | // -----------Utility functions used by ImageReader/Writer JNI----------------- |
| 25 | |
| 26 | typedef CpuConsumer::LockedBuffer LockedImage; |
| 27 | |
| 28 | bool usingRGBAToJpegOverride(int32_t imageFormat, int32_t containerFormat); |
| 29 | |
| 30 | int32_t applyFormatOverrides(int32_t imageFormat, int32_t containerFormat); |
| 31 | |
Shuzhen Wang | f655b1c | 2018-12-28 15:40:36 -0800 | [diff] [blame] | 32 | uint32_t Image_getBlobSize(LockedImage* buffer, bool usingRGBAOverride); |
Zhijun He | 0ab4162 | 2016-02-25 16:00:38 -0800 | [diff] [blame] | 33 | |
| 34 | bool isFormatOpaque(int format); |
| 35 | |
| 36 | bool isPossiblyYUV(PixelFormat format); |
| 37 | |
| 38 | status_t getLockedImageInfo(LockedImage* buffer, int idx, int32_t containerFormat, |
| 39 | uint8_t **base, uint32_t *size, int *pixelStride, int *rowStride); |
| 40 | |
| 41 | status_t lockImageFromBuffer(sp<GraphicBuffer> buffer, uint32_t inUsage, |
| 42 | const Rect& rect, int fenceFd, LockedImage* outputImage); |
| 43 | |
| 44 | status_t lockImageFromBuffer(BufferItem* bufferItem, uint32_t inUsage, |
| 45 | int fenceFd, LockedImage* outputImage); |
| 46 | |
| 47 | int getBufferWidth(BufferItem *buffer); |
| 48 | |
| 49 | int getBufferHeight(BufferItem *buffer); |
| 50 | |
James Dong | 79f407c | 2011-05-05 12:50:04 -0700 | [diff] [blame] | 51 | }; // namespace android |
| 52 | |
| 53 | #endif // _ANDROID_MEDIA_UTILS_H_ |