James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 HARDWARE_API_H_ |
| 18 | |
| 19 | #define HARDWARE_API_H_ |
| 20 | |
Andreas Huber | 00e595f | 2013-06-25 10:08:42 -0700 | [diff] [blame] | 21 | #include <media/hardware/OMXPluginBase.h> |
| 22 | #include <media/hardware/MetadataBufferType.h> |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 23 | #include <system/window.h> |
| 24 | #include <utils/RefBase.h> |
| 25 | |
| 26 | #include <OMX_Component.h> |
| 27 | |
| 28 | namespace android { |
| 29 | |
Lajos Molnar | d5f7935 | 2016-02-11 14:20:39 -0800 | [diff] [blame] | 30 | // This structure is used to enable Android native buffer use for either |
| 31 | // graphic buffers or secure buffers. |
| 32 | // |
| 33 | // TO CONTROL ANDROID GRAPHIC BUFFER USAGE: |
| 34 | // |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 35 | // A pointer to this struct is passed to the OMX_SetParameter when the extension |
| 36 | // index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension |
| 37 | // is given. |
| 38 | // |
| 39 | // When Android native buffer use is disabled for a port (the default state), |
| 40 | // the OMX node should operate as normal, and expect UseBuffer calls to set its |
| 41 | // buffers. This is the mode that will be used when CPU access to the buffer is |
| 42 | // required. |
| 43 | // |
| 44 | // When Android native buffer use has been enabled for a given port, the video |
| 45 | // color format for the port is to be interpreted as an Android pixel format |
Lajos Molnar | 5f39f60 | 2013-07-17 14:55:55 -0700 | [diff] [blame] | 46 | // rather than an OMX color format. Enabling Android native buffers may also |
| 47 | // change how the component receives the native buffers. If store-metadata-mode |
| 48 | // is enabled on the port, the component will receive the buffers as specified |
| 49 | // in the section below. Otherwise, unless the node supports the |
| 50 | // 'OMX.google.android.index.useAndroidNativeBuffer2' extension, it should |
| 51 | // expect to receive UseAndroidNativeBuffer calls (via OMX_SetParameter) rather |
| 52 | // than UseBuffer calls for that port. |
Lajos Molnar | d5f7935 | 2016-02-11 14:20:39 -0800 | [diff] [blame] | 53 | // |
| 54 | // TO CONTROL ANDROID SECURE BUFFER USAGE: |
| 55 | // |
| 56 | // A pointer to this struct is passed to the OMX_SetParameter when the extension |
| 57 | // index for the 'OMX.google.android.index.allocateNativeHandle' extension |
| 58 | // is given. |
| 59 | // |
| 60 | // When native handle use is disabled for a port (the default state), |
| 61 | // the OMX node should operate as normal, and expect AllocateBuffer calls to |
| 62 | // return buffer pointers. This is the mode that will be used for non-secure |
| 63 | // buffers if component requires allocate buffers instead of use buffers. |
| 64 | // |
| 65 | // When native handle use has been enabled for a given port, the component |
| 66 | // shall allocate native_buffer_t objects containing that can be passed between |
| 67 | // processes using binder. This is the mode that will be used for secure buffers. |
| 68 | // When an OMX component allocates native handle for buffers, it must close and |
| 69 | // delete that handle when it frees those buffers. Even though pBuffer will point |
| 70 | // to a native handle, nFilledLength, nAllocLength and nOffset will correspond |
| 71 | // to the data inside the opaque buffer. |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 72 | struct EnableAndroidNativeBuffersParams { |
| 73 | OMX_U32 nSize; |
| 74 | OMX_VERSIONTYPE nVersion; |
| 75 | OMX_U32 nPortIndex; |
| 76 | OMX_BOOL enable; |
| 77 | }; |
| 78 | |
Lajos Molnar | d5f7935 | 2016-02-11 14:20:39 -0800 | [diff] [blame] | 79 | typedef struct EnableAndroidNativeBuffersParams AllocateNativeHandleParams; |
| 80 | |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 81 | // A pointer to this struct is passed to OMX_SetParameter() when the extension index |
| 82 | // "OMX.google.android.index.storeMetaDataInBuffers" or |
| 83 | // "OMX.google.android.index.storeANWBufferInMetadata" is given. |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 84 | // |
| 85 | // When meta data is stored in the video buffers passed between OMX clients |
| 86 | // and OMX components, interpretation of the buffer data is up to the |
| 87 | // buffer receiver, and the data may or may not be the actual video data, but |
| 88 | // some information helpful for the receiver to locate the actual data. |
| 89 | // The buffer receiver thus needs to know how to interpret what is stored |
| 90 | // in these buffers, with mechanisms pre-determined externally. How to |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 91 | // interpret the meta data is outside of the scope of this parameter. |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 92 | // |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 93 | // Currently, this is used to pass meta data from video source (camera component, for instance) to |
| 94 | // video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output |
| 95 | // buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE. |
Lajos Molnar | 5f39f60 | 2013-07-17 14:55:55 -0700 | [diff] [blame] | 96 | // |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 97 | // If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and |
| 98 | // the output buffers contain either real YUV frame data, or are themselves native handles as |
| 99 | // directed by enable/use-android-native-buffer parameter settings. |
| 100 | // In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension |
| 101 | // index, the component should not assume that the client is not using metadata mode for the port. |
Lajos Molnar | 5f39f60 | 2013-07-17 14:55:55 -0700 | [diff] [blame] | 102 | // |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 103 | // If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata" |
| 104 | // extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata |
| 105 | // layout as defined below. Each buffer will be accompanied by a fence. The fence must signal |
| 106 | // before the buffer can be used (e.g. read from or written into). When returning such buffer to |
| 107 | // the client, component must provide a new fence that must signal before the returned buffer can |
| 108 | // be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close |
| 109 | // it when fence has signaled. The client will own and close the returned fence file descriptor. |
| 110 | // |
| 111 | // If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers" |
| 112 | // extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata |
| 113 | // (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed |
| 114 | // as "CameraSource", the layout of which is vendor dependent. |
| 115 | // |
| 116 | // Metadata buffers are registered with the component using UseBuffer calls, or can be allocated |
| 117 | // by the component for encoder-metadata-output buffers. |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 118 | struct StoreMetaDataInBuffersParams { |
| 119 | OMX_U32 nSize; |
| 120 | OMX_VERSIONTYPE nVersion; |
| 121 | OMX_U32 nPortIndex; |
| 122 | OMX_BOOL bStoreMetaData; |
| 123 | }; |
| 124 | |
Lajos Molnar | 07d93d1 | 2013-05-03 13:20:53 -0700 | [diff] [blame] | 125 | // Meta data buffer layout used to transport output frames to the decoder for |
| 126 | // dynamic buffer handling. |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 127 | struct VideoGrallocMetadata { |
| 128 | MetadataBufferType eType; // must be kMetadataBufferTypeGrallocSource |
Lajos Molnar | abaaf70 | 2015-07-20 15:29:24 -0700 | [diff] [blame] | 129 | #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS |
| 130 | OMX_PTR pHandle; |
| 131 | #else |
Lajos Molnar | d910f3c | 2015-06-02 19:43:16 -0700 | [diff] [blame] | 132 | buffer_handle_t pHandle; |
Lajos Molnar | abaaf70 | 2015-07-20 15:29:24 -0700 | [diff] [blame] | 133 | #endif |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 134 | }; |
| 135 | |
Lajos Molnar | a8c2454 | 2015-06-01 21:13:47 -0700 | [diff] [blame] | 136 | // Legacy name for VideoGrallocMetadata struct. |
Lajos Molnar | d910f3c | 2015-06-02 19:43:16 -0700 | [diff] [blame] | 137 | struct VideoDecoderOutputMetaData : public VideoGrallocMetadata {}; |
Lajos Molnar | a8c2454 | 2015-06-01 21:13:47 -0700 | [diff] [blame] | 138 | |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 139 | struct VideoNativeMetadata { |
| 140 | MetadataBufferType eType; // must be kMetadataBufferTypeANWBuffer |
Lajos Molnar | abaaf70 | 2015-07-20 15:29:24 -0700 | [diff] [blame] | 141 | #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS |
| 142 | OMX_PTR pBuffer; |
| 143 | #else |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 144 | struct ANativeWindowBuffer* pBuffer; |
Lajos Molnar | abaaf70 | 2015-07-20 15:29:24 -0700 | [diff] [blame] | 145 | #endif |
Lajos Molnar | 9f590df | 2015-05-15 20:31:57 -0700 | [diff] [blame] | 146 | int nFenceFd; // -1 if unused |
Lajos Molnar | 07d93d1 | 2013-05-03 13:20:53 -0700 | [diff] [blame] | 147 | }; |
| 148 | |
Praveen Chavan | 9990837 | 2016-01-13 01:32:25 -0800 | [diff] [blame] | 149 | // Meta data buffer layout for passing a native_handle to codec |
| 150 | struct VideoNativeHandleMetadata { |
| 151 | MetadataBufferType eType; // must be kMetadataBufferTypeNativeHandleSource |
| 152 | |
| 153 | #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS |
| 154 | OMX_PTR pHandle; |
| 155 | #else |
| 156 | native_handle_t *pHandle; |
| 157 | #endif |
| 158 | }; |
| 159 | |
Lajos Molnar | dde86f7 | 2013-05-03 13:22:13 -0700 | [diff] [blame] | 160 | // A pointer to this struct is passed to OMX_SetParameter() when the extension |
| 161 | // index "OMX.google.android.index.prepareForAdaptivePlayback" is given. |
| 162 | // |
| 163 | // This method is used to signal a video decoder, that the user has requested |
| 164 | // seamless resolution change support (if bEnable is set to OMX_TRUE). |
| 165 | // nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest |
| 166 | // anticipated frames in the video. If bEnable is OMX_FALSE, no resolution |
| 167 | // change is expected, and the nMaxFrameWidth/Height fields are unused. |
| 168 | // |
| 169 | // If the decoder supports dynamic output buffers, it may ignore this |
| 170 | // request. Otherwise, it shall request resources in such a way so that it |
| 171 | // avoids full port-reconfiguration (due to output port-definition change) |
| 172 | // during resolution changes. |
| 173 | // |
| 174 | // DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED. INSTEAD, IMPLEMENT |
| 175 | // METADATA SUPPORT FOR VIDEO DECODERS. |
| 176 | struct PrepareForAdaptivePlaybackParams { |
| 177 | OMX_U32 nSize; |
| 178 | OMX_VERSIONTYPE nVersion; |
| 179 | OMX_U32 nPortIndex; |
| 180 | OMX_BOOL bEnable; |
| 181 | OMX_U32 nMaxFrameWidth; |
| 182 | OMX_U32 nMaxFrameHeight; |
| 183 | }; |
| 184 | |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 185 | // A pointer to this struct is passed to OMX_SetParameter when the extension |
| 186 | // index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is |
| 187 | // given. This call will only be performed if a prior call was made with the |
| 188 | // 'OMX.google.android.index.enableAndroidNativeBuffers' extension index, |
| 189 | // enabling use of Android native buffers. |
| 190 | struct UseAndroidNativeBufferParams { |
| 191 | OMX_U32 nSize; |
| 192 | OMX_VERSIONTYPE nVersion; |
| 193 | OMX_U32 nPortIndex; |
| 194 | OMX_PTR pAppPrivate; |
| 195 | OMX_BUFFERHEADERTYPE **bufferHeader; |
| 196 | const sp<ANativeWindowBuffer>& nativeBuffer; |
| 197 | }; |
| 198 | |
| 199 | // A pointer to this struct is passed to OMX_GetParameter when the extension |
| 200 | // index for the 'OMX.google.android.index.getAndroidNativeBufferUsage' |
| 201 | // extension is given. The usage bits returned from this query will be used to |
| 202 | // allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer |
| 203 | // command. |
| 204 | struct GetAndroidNativeBufferUsageParams { |
| 205 | OMX_U32 nSize; // IN |
| 206 | OMX_VERSIONTYPE nVersion; // IN |
| 207 | OMX_U32 nPortIndex; // IN |
| 208 | OMX_U32 nUsage; // OUT |
| 209 | }; |
| 210 | |
| 211 | // An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat |
| 212 | // is declared in media/stagefright/openmax/OMX_IVCommon.h |
| 213 | // This will inform the encoder that the actual |
| 214 | // colorformat will be relayed by the GRalloc Buffers. |
| 215 | // OMX_COLOR_FormatAndroidOpaque = 0x7F000001, |
| 216 | |
Andreas Huber | 7682a9c | 2012-09-28 11:32:16 -0700 | [diff] [blame] | 217 | // A pointer to this struct is passed to OMX_SetParameter when the extension |
| 218 | // index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension |
| 219 | // is given. |
| 220 | // A successful result indicates that future IDR frames will be prefixed by |
| 221 | // SPS/PPS. |
| 222 | struct PrependSPSPPSToIDRFramesParams { |
| 223 | OMX_U32 nSize; |
| 224 | OMX_VERSIONTYPE nVersion; |
| 225 | OMX_BOOL bEnable; |
| 226 | }; |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 227 | |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 228 | // Structure describing a media image (frame) |
| 229 | // Currently only supporting YUV |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 230 | // @deprecated. Use MediaImage2 instead |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 231 | struct MediaImage { |
| 232 | enum Type { |
| 233 | MEDIA_IMAGE_TYPE_UNKNOWN = 0, |
| 234 | MEDIA_IMAGE_TYPE_YUV, |
| 235 | }; |
| 236 | |
| 237 | enum PlaneIndex { |
| 238 | Y = 0, |
| 239 | U, |
| 240 | V, |
| 241 | MAX_NUM_PLANES |
| 242 | }; |
| 243 | |
| 244 | Type mType; |
Lajos Molnar | abaaf70 | 2015-07-20 15:29:24 -0700 | [diff] [blame] | 245 | uint32_t mNumPlanes; // number of planes |
| 246 | uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) |
| 247 | uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) |
| 248 | uint32_t mBitDepth; // useable bit depth |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 249 | struct PlaneInfo { |
Lajos Molnar | abaaf70 | 2015-07-20 15:29:24 -0700 | [diff] [blame] | 250 | uint32_t mOffset; // offset of first pixel of the plane in bytes |
| 251 | // from buffer offset |
| 252 | uint32_t mColInc; // column increment in bytes |
| 253 | uint32_t mRowInc; // row increment in bytes |
| 254 | uint32_t mHorizSubsampling; // subsampling compared to the largest plane |
| 255 | uint32_t mVertSubsampling; // subsampling compared to the largest plane |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 256 | }; |
| 257 | PlaneInfo mPlane[MAX_NUM_PLANES]; |
| 258 | }; |
| 259 | |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 260 | struct MediaImage2 { |
Lajos Molnar | 212e916 | 2016-02-24 18:01:10 -0800 | [diff] [blame] | 261 | enum Type : uint32_t { |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 262 | MEDIA_IMAGE_TYPE_UNKNOWN = 0, |
| 263 | MEDIA_IMAGE_TYPE_YUV, |
| 264 | MEDIA_IMAGE_TYPE_YUVA, |
| 265 | MEDIA_IMAGE_TYPE_RGB, |
| 266 | MEDIA_IMAGE_TYPE_RGBA, |
| 267 | MEDIA_IMAGE_TYPE_Y, |
| 268 | }; |
| 269 | |
Lajos Molnar | 212e916 | 2016-02-24 18:01:10 -0800 | [diff] [blame] | 270 | enum PlaneIndex : uint32_t { |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 271 | Y = 0, |
| 272 | U = 1, |
| 273 | V = 2, |
| 274 | R = 0, |
| 275 | G = 1, |
| 276 | B = 2, |
| 277 | A = 3, |
| 278 | MAX_NUM_PLANES = 4, |
| 279 | }; |
| 280 | |
| 281 | Type mType; |
| 282 | uint32_t mNumPlanes; // number of planes |
| 283 | uint32_t mWidth; // width of largest plane (unpadded, as in nFrameWidth) |
| 284 | uint32_t mHeight; // height of largest plane (unpadded, as in nFrameHeight) |
| 285 | uint32_t mBitDepth; // useable bit depth (always MSB) |
| 286 | uint32_t mBitDepthAllocated; // bits per component (must be 8 or 16) |
| 287 | |
| 288 | struct PlaneInfo { |
| 289 | uint32_t mOffset; // offset of first pixel of the plane in bytes |
| 290 | // from buffer offset |
| 291 | int32_t mColInc; // column increment in bytes |
| 292 | int32_t mRowInc; // row increment in bytes |
| 293 | uint32_t mHorizSubsampling; // subsampling compared to the largest plane |
| 294 | uint32_t mVertSubsampling; // subsampling compared to the largest plane |
| 295 | }; |
| 296 | PlaneInfo mPlane[MAX_NUM_PLANES]; |
Lajos Molnar | 212e916 | 2016-02-24 18:01:10 -0800 | [diff] [blame] | 297 | |
| 298 | void initFromV1(const MediaImage&); // for internal use only |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 299 | }; |
| 300 | |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 301 | // A pointer to this struct is passed to OMX_GetParameter when the extension |
| 302 | // index for the 'OMX.google.android.index.describeColorFormat' |
| 303 | // extension is given. This method can be called from any component state |
| 304 | // other than invalid. The color-format, frame width/height, and stride/ |
| 305 | // slice-height parameters are ones that are associated with a raw video |
| 306 | // port (input or output), but the stride/slice height parameters may be |
Lajos Molnar | ea5da67 | 2015-01-30 10:36:11 -0800 | [diff] [blame] | 307 | // incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will |
| 308 | // be used (while specifying this color format). |
| 309 | // |
| 310 | // The component shall fill out the MediaImage structure that |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 311 | // corresponds to the described raw video format, and the potentially corrected |
| 312 | // stride and slice-height info. |
| 313 | // |
Lajos Molnar | ea5da67 | 2015-01-30 10:36:11 -0800 | [diff] [blame] | 314 | // The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE, |
| 315 | // though most implementations can ignore this difference. When using native buffers, |
| 316 | // the component may change the configured color format to an optimized format. |
| 317 | // Additionally, when allocating these buffers for flexible usecase, the framework |
| 318 | // will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers |
| 319 | // is OMX_TRUE), the component shall fill out the MediaImage information for the |
| 320 | // scenario when these SW-readable/writable buffers are locked using gralloc_lock. |
| 321 | // Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must |
| 322 | // be supported for vendor-specific formats. |
| 323 | // |
| 324 | // For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers |
| 325 | // is OMX_TRUE and the component does not support this color format with native |
| 326 | // buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 327 | |
| 328 | // @deprecated: use DescribeColorFormat2Params |
Lajos Molnar | 212e916 | 2016-02-24 18:01:10 -0800 | [diff] [blame] | 329 | struct DescribeColorFormat2Params; |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 330 | struct DescribeColorFormatParams { |
| 331 | OMX_U32 nSize; |
| 332 | OMX_VERSIONTYPE nVersion; |
| 333 | // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE |
| 334 | OMX_COLOR_FORMATTYPE eColorFormat; |
| 335 | OMX_U32 nFrameWidth; |
| 336 | OMX_U32 nFrameHeight; |
| 337 | OMX_U32 nStride; |
| 338 | OMX_U32 nSliceHeight; |
Lajos Molnar | ea5da67 | 2015-01-30 10:36:11 -0800 | [diff] [blame] | 339 | OMX_BOOL bUsingNativeBuffers; |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 340 | |
| 341 | // output: fill out the MediaImage fields |
| 342 | MediaImage sMediaImage; |
Lajos Molnar | 212e916 | 2016-02-24 18:01:10 -0800 | [diff] [blame] | 343 | |
| 344 | DescribeColorFormatParams(const DescribeColorFormat2Params&); // for internal use only |
Lajos Molnar | 524077c | 2014-07-25 07:53:56 -0700 | [diff] [blame] | 345 | }; |
| 346 | |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 347 | // A pointer to this struct is passed to OMX_GetParameter when the extension |
| 348 | // index for the 'OMX.google.android.index.describeColorFormat2' |
| 349 | // extension is given. This is operationally the same as DescribeColorFormatParams |
| 350 | // but can be used for HDR and RGBA/YUVA formats. |
| 351 | struct DescribeColorFormat2Params { |
| 352 | OMX_U32 nSize; |
| 353 | OMX_VERSIONTYPE nVersion; |
| 354 | // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE |
| 355 | OMX_COLOR_FORMATTYPE eColorFormat; |
| 356 | OMX_U32 nFrameWidth; |
| 357 | OMX_U32 nFrameHeight; |
| 358 | OMX_U32 nStride; |
| 359 | OMX_U32 nSliceHeight; |
| 360 | OMX_BOOL bUsingNativeBuffers; |
| 361 | |
| 362 | // output: fill out the MediaImage2 fields |
| 363 | MediaImage2 sMediaImage; |
Lajos Molnar | 212e916 | 2016-02-24 18:01:10 -0800 | [diff] [blame] | 364 | |
| 365 | void initFromV1(const DescribeColorFormatParams&); // for internal use only |
Lajos Molnar | 8d513b2 | 2016-01-26 18:21:25 -0800 | [diff] [blame] | 366 | }; |
| 367 | |
Rachad | 7cb0d39 | 2014-07-29 17:53:53 -0700 | [diff] [blame] | 368 | // A pointer to this struct is passed to OMX_SetParameter or OMX_GetParameter |
| 369 | // when the extension index for the |
| 370 | // 'OMX.google.android.index.configureVideoTunnelMode' extension is given. |
| 371 | // If the extension is supported then tunneled playback mode should be supported |
| 372 | // by the codec. If bTunneled is set to OMX_TRUE then the video decoder should |
| 373 | // operate in "tunneled" mode and output its decoded frames directly to the |
| 374 | // sink. In this case nAudioHwSync is the HW SYNC ID of the audio HAL Output |
| 375 | // stream to sync the video with. If bTunneled is set to OMX_FALSE, "tunneled" |
| 376 | // mode should be disabled and nAudioHwSync should be ignored. |
| 377 | // OMX_GetParameter is used to query tunneling configuration. bTunneled should |
| 378 | // return whether decoder is operating in tunneled mode, and if it is, |
| 379 | // pSidebandWindow should contain the codec allocated sideband window handle. |
| 380 | struct ConfigureVideoTunnelModeParams { |
| 381 | OMX_U32 nSize; // IN |
| 382 | OMX_VERSIONTYPE nVersion; // IN |
| 383 | OMX_U32 nPortIndex; // IN |
| 384 | OMX_BOOL bTunneled; // IN/OUT |
| 385 | OMX_U32 nAudioHwSync; // IN |
| 386 | OMX_PTR pSidebandWindow; // OUT |
| 387 | }; |
| 388 | |
Lajos Molnar | 51de0ba | 2016-01-15 16:12:33 -0800 | [diff] [blame] | 389 | // Color description parameters. This is passed via OMX_SetConfig or OMX_GetConfig |
| 390 | // to video encoders and decoders when the |
| 391 | // 'OMX.google.android.index.describeColorAspects' extension is given. |
| 392 | // |
| 393 | // Video encoders: the framework uses OMX_SetConfig to specify color aspects |
| 394 | // of the coded video before the component transitions to idle state. |
| 395 | // |
| 396 | // Video decoders: the framework uses OMX_SetConfig to specify color aspects |
| 397 | // of the coded video parsed from the container before the component transitions |
| 398 | // to idle state. If the bitstream contains color information, the component should |
| 399 | // update the appropriate color aspects - unless the bitstream contains the |
| 400 | // "unspecified" value. For "reserved" values, the component should set the aspect |
| 401 | // to "Other". |
| 402 | // |
| 403 | // The framework subsequently uses OMX_GetConfig to get any updates of the |
| 404 | // color aspects from the decoder. If the color aspects change at any time |
| 405 | // during the processing of the stream, the component shall signal a |
| 406 | // OMX_EventPortSettingsChanged event with data2 set to the extension index |
| 407 | // (or OMX_IndexConfigCommonOutputCrop, as it is handled identically). Component |
| 408 | // shall not signal a separate event purely for color aspect change, if it occurs |
| 409 | // together with a port definition (e.g. size) or crop change. |
| 410 | // |
| 411 | // NOTE: this structure is expected to grow in the future if new color aspects are |
| 412 | // added to codec bitstreams. OMX component should not require a specific nSize |
| 413 | // though could verify that nSize is at least the size of the structure at the |
| 414 | // time of implementation. All new fields will be added at the end of the structure |
| 415 | // ensuring backward compatibility. |
| 416 | |
| 417 | struct DescribeColorAspectsParams { |
| 418 | OMX_U32 nSize; // IN |
| 419 | OMX_VERSIONTYPE nVersion; // IN |
| 420 | OMX_U32 nPortIndex; // IN |
| 421 | OMX_U32 nRange; // IN/OUT (one of the ColorAspects.Range enums) |
| 422 | OMX_U32 nPrimaries; // IN/OUT (one of the ColorAspects.Primaries enums) |
| 423 | OMX_U32 nTransfer; // IN/OUT (one of the ColorAspects.Transfer enums) |
| 424 | OMX_U32 nMatrixCoeffs; // IN/OUT (one of the ColorAspects.MatrixCoeffs enums) |
| 425 | }; |
| 426 | |
| 427 | struct ColorAspects { |
| 428 | // this is in sync with the range values in graphics.h |
| 429 | enum Range : uint32_t { |
| 430 | RangeUnspecified, |
| 431 | RangeFull, |
| 432 | RangeLimited, |
| 433 | RangeOther = 0xff, |
| 434 | }; |
| 435 | |
| 436 | enum Primaries : uint32_t { |
| 437 | PrimariesUnspecified, |
| 438 | PrimariesBT709_5, // Rec.ITU-R BT.709-5 or equivalent |
| 439 | PrimariesBT470_6M, // Rec.ITU-R BT.470-6 System M or equivalent |
| 440 | PrimariesBT601_6_625, // Rec.ITU-R BT.601-6 625 or equivalent |
| 441 | PrimariesBT601_6_525, // Rec.ITU-R BT.601-6 525 or equivalent |
| 442 | PrimariesGenericFilm, // Generic Film |
| 443 | PrimariesBT2020, // Rec.ITU-R BT.2020 or equivalent |
| 444 | PrimariesOther = 0xff, |
| 445 | }; |
| 446 | |
| 447 | // this partially in sync with the transfer values in graphics.h prior to the transfers |
| 448 | // unlikely to be required by Android section |
| 449 | enum Transfer : uint32_t { |
| 450 | TransferUnspecified, |
| 451 | TransferLinear, // Linear transfer characteristics |
| 452 | TransferSRGB, // sRGB or equivalent |
| 453 | TransferSMPTE170M, // SMPTE 170M or equivalent (e.g. BT.601/709/2020) |
| 454 | TransferGamma22, // Assumed display gamma 2.2 |
| 455 | TransferGamma28, // Assumed display gamma 2.8 |
| 456 | TransferST2084, // SMPTE ST 2084 for 10/12/14/16 bit systems |
| 457 | TransferHLG, // ARIB STD-B67 hybrid-log-gamma |
| 458 | |
| 459 | // transfers unlikely to be required by Android |
| 460 | TransferSMPTE240M = 0x40, // SMPTE 240M |
| 461 | TransferXvYCC, // IEC 61966-2-4 |
| 462 | TransferBT1361, // Rec.ITU-R BT.1361 extended gamut |
| 463 | TransferST428, // SMPTE ST 428-1 |
| 464 | TransferOther = 0xff, |
| 465 | }; |
| 466 | |
| 467 | enum MatrixCoeffs : uint32_t { |
| 468 | MatrixUnspecified, |
| 469 | MatrixBT709_5, // Rec.ITU-R BT.709-5 or equivalent |
| 470 | MatrixBT470_6M, // KR=0.30, KB=0.11 or equivalent |
| 471 | MatrixBT601_6, // Rec.ITU-R BT.601-6 625 or equivalent |
| 472 | MatrixSMPTE240M, // SMPTE 240M or equivalent |
| 473 | MatrixBT2020, // Rec.ITU-R BT.2020 non-constant luminance |
| 474 | MatrixBT2020Constant, // Rec.ITU-R BT.2020 constant luminance |
| 475 | MatrixOther = 0xff, |
| 476 | }; |
| 477 | |
| 478 | // this is in sync with the standard values in graphics.h |
| 479 | enum Standard : uint32_t { |
| 480 | StandardUnspecified, |
| 481 | StandardBT709, // PrimariesBT709_5 and MatrixBT709_5 |
| 482 | StandardBT601_625, // PrimariesBT601_6_625 and MatrixBT601_6 |
| 483 | StandardBT601_625_Unadjusted, // PrimariesBT601_6_625 and KR=0.222, KB=0.071 |
| 484 | StandardBT601_525, // PrimariesBT601_6_525 and MatrixBT601_6 |
| 485 | StandardBT601_525_Unadjusted, // PrimariesBT601_6_525 and MatrixSMPTE240M |
| 486 | StandardBT2020, // PrimariesBT2020 and MatrixBT2020 |
| 487 | StandardBT2020Constant, // PrimariesBT2020 and MatrixBT2020Constant |
| 488 | StandardBT470M, // PrimariesBT470_6M and MatrixBT470_6M |
| 489 | StandardFilm, // PrimariesGenericFilm and KR=0.253, KB=0.068 |
| 490 | StandardOther = 0xff, |
| 491 | }; |
| 492 | }; |
| 493 | |
James Dong | 334de52 | 2012-03-12 12:47:14 -0700 | [diff] [blame] | 494 | } // namespace android |
| 495 | |
| 496 | extern android::OMXPluginBase *createOMXPlugin(); |
| 497 | |
| 498 | #endif // HARDWARE_API_H_ |