xref: /aosp_15_r20/frameworks/native/include/media/hardware/HardwareAPI.h (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
1*38e8c45fSAndroid Build Coastguard Worker /*
2*38e8c45fSAndroid Build Coastguard Worker  * Copyright (C) 2009 The Android Open Source Project
3*38e8c45fSAndroid Build Coastguard Worker  *
4*38e8c45fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*38e8c45fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*38e8c45fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*38e8c45fSAndroid Build Coastguard Worker  *
8*38e8c45fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*38e8c45fSAndroid Build Coastguard Worker  *
10*38e8c45fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*38e8c45fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*38e8c45fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*38e8c45fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*38e8c45fSAndroid Build Coastguard Worker  * limitations under the License.
15*38e8c45fSAndroid Build Coastguard Worker  */
16*38e8c45fSAndroid Build Coastguard Worker 
17*38e8c45fSAndroid Build Coastguard Worker #ifndef HARDWARE_API_H_
18*38e8c45fSAndroid Build Coastguard Worker 
19*38e8c45fSAndroid Build Coastguard Worker #define HARDWARE_API_H_
20*38e8c45fSAndroid Build Coastguard Worker 
21*38e8c45fSAndroid Build Coastguard Worker #include <media/hardware/OMXPluginBase.h>
22*38e8c45fSAndroid Build Coastguard Worker #include <media/hardware/MetadataBufferType.h>
23*38e8c45fSAndroid Build Coastguard Worker #include <cutils/native_handle.h>
24*38e8c45fSAndroid Build Coastguard Worker #include <utils/RefBase.h>
25*38e8c45fSAndroid Build Coastguard Worker 
26*38e8c45fSAndroid Build Coastguard Worker #include "VideoAPI.h"
27*38e8c45fSAndroid Build Coastguard Worker 
28*38e8c45fSAndroid Build Coastguard Worker #include <OMX_Component.h>
29*38e8c45fSAndroid Build Coastguard Worker 
30*38e8c45fSAndroid Build Coastguard Worker struct ANativeWindowBuffer;
31*38e8c45fSAndroid Build Coastguard Worker 
32*38e8c45fSAndroid Build Coastguard Worker namespace android {
33*38e8c45fSAndroid Build Coastguard Worker 
34*38e8c45fSAndroid Build Coastguard Worker // This structure is used to enable Android native buffer use for either
35*38e8c45fSAndroid Build Coastguard Worker // graphic buffers or secure buffers.
36*38e8c45fSAndroid Build Coastguard Worker //
37*38e8c45fSAndroid Build Coastguard Worker // TO CONTROL ANDROID GRAPHIC BUFFER USAGE:
38*38e8c45fSAndroid Build Coastguard Worker //
39*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to the OMX_SetParameter when the extension
40*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension
41*38e8c45fSAndroid Build Coastguard Worker // is given.
42*38e8c45fSAndroid Build Coastguard Worker //
43*38e8c45fSAndroid Build Coastguard Worker // When Android native buffer use is disabled for a port (the default state),
44*38e8c45fSAndroid Build Coastguard Worker // the OMX node should operate as normal, and expect UseBuffer calls to set its
45*38e8c45fSAndroid Build Coastguard Worker // buffers.  This is the mode that will be used when CPU access to the buffer is
46*38e8c45fSAndroid Build Coastguard Worker // required.
47*38e8c45fSAndroid Build Coastguard Worker //
48*38e8c45fSAndroid Build Coastguard Worker // When Android native buffer use has been enabled for a given port, the video
49*38e8c45fSAndroid Build Coastguard Worker // color format for the port is to be interpreted as an Android pixel format
50*38e8c45fSAndroid Build Coastguard Worker // rather than an OMX color format.  Enabling Android native buffers may also
51*38e8c45fSAndroid Build Coastguard Worker // change how the component receives the native buffers.  If store-metadata-mode
52*38e8c45fSAndroid Build Coastguard Worker // is enabled on the port, the component will receive the buffers as specified
53*38e8c45fSAndroid Build Coastguard Worker // in the section below. Otherwise, unless the node supports the
54*38e8c45fSAndroid Build Coastguard Worker // 'OMX.google.android.index.useAndroidNativeBuffer2' extension, it should
55*38e8c45fSAndroid Build Coastguard Worker // expect to receive UseAndroidNativeBuffer calls (via OMX_SetParameter) rather
56*38e8c45fSAndroid Build Coastguard Worker // than UseBuffer calls for that port.
57*38e8c45fSAndroid Build Coastguard Worker //
58*38e8c45fSAndroid Build Coastguard Worker // TO CONTROL ANDROID SECURE BUFFER USAGE:
59*38e8c45fSAndroid Build Coastguard Worker //
60*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to the OMX_SetParameter when the extension
61*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.allocateNativeHandle' extension
62*38e8c45fSAndroid Build Coastguard Worker // is given.
63*38e8c45fSAndroid Build Coastguard Worker //
64*38e8c45fSAndroid Build Coastguard Worker // When native handle use is disabled for a port (the default state),
65*38e8c45fSAndroid Build Coastguard Worker // the OMX node should operate as normal, and expect AllocateBuffer calls to
66*38e8c45fSAndroid Build Coastguard Worker // return buffer pointers. This is the mode that will be used for non-secure
67*38e8c45fSAndroid Build Coastguard Worker // buffers if component requires allocate buffers instead of use buffers.
68*38e8c45fSAndroid Build Coastguard Worker //
69*38e8c45fSAndroid Build Coastguard Worker // When native handle use has been enabled for a given port, the component
70*38e8c45fSAndroid Build Coastguard Worker // shall allocate native_buffer_t objects containing  that can be passed between
71*38e8c45fSAndroid Build Coastguard Worker // processes using binder. This is the mode that will be used for secure buffers.
72*38e8c45fSAndroid Build Coastguard Worker // When an OMX component allocates native handle for buffers, it must close and
73*38e8c45fSAndroid Build Coastguard Worker // delete that handle when it frees those buffers. Even though pBuffer will point
74*38e8c45fSAndroid Build Coastguard Worker // to a native handle, nFilledLength, nAllocLength and nOffset will correspond
75*38e8c45fSAndroid Build Coastguard Worker // to the data inside the opaque buffer.
76*38e8c45fSAndroid Build Coastguard Worker struct EnableAndroidNativeBuffersParams {
77*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
78*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
79*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;
80*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL enable;
81*38e8c45fSAndroid Build Coastguard Worker };
82*38e8c45fSAndroid Build Coastguard Worker 
83*38e8c45fSAndroid Build Coastguard Worker typedef struct EnableAndroidNativeBuffersParams AllocateNativeHandleParams;
84*38e8c45fSAndroid Build Coastguard Worker 
85*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_SetParameter() when the extension index
86*38e8c45fSAndroid Build Coastguard Worker // "OMX.google.android.index.storeMetaDataInBuffers" or
87*38e8c45fSAndroid Build Coastguard Worker // "OMX.google.android.index.storeANWBufferInMetadata" is given.
88*38e8c45fSAndroid Build Coastguard Worker //
89*38e8c45fSAndroid Build Coastguard Worker // When meta data is stored in the video buffers passed between OMX clients
90*38e8c45fSAndroid Build Coastguard Worker // and OMX components, interpretation of the buffer data is up to the
91*38e8c45fSAndroid Build Coastguard Worker // buffer receiver, and the data may or may not be the actual video data, but
92*38e8c45fSAndroid Build Coastguard Worker // some information helpful for the receiver to locate the actual data.
93*38e8c45fSAndroid Build Coastguard Worker // The buffer receiver thus needs to know how to interpret what is stored
94*38e8c45fSAndroid Build Coastguard Worker // in these buffers, with mechanisms pre-determined externally. How to
95*38e8c45fSAndroid Build Coastguard Worker // interpret the meta data is outside of the scope of this parameter.
96*38e8c45fSAndroid Build Coastguard Worker //
97*38e8c45fSAndroid Build Coastguard Worker // Currently, this is used to pass meta data from video source (camera component, for instance) to
98*38e8c45fSAndroid Build Coastguard Worker // video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output
99*38e8c45fSAndroid Build Coastguard Worker // buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE.
100*38e8c45fSAndroid Build Coastguard Worker //
101*38e8c45fSAndroid Build Coastguard Worker // If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and
102*38e8c45fSAndroid Build Coastguard Worker // the output buffers contain either real YUV frame data, or are themselves native handles as
103*38e8c45fSAndroid Build Coastguard Worker // directed by enable/use-android-native-buffer parameter settings.
104*38e8c45fSAndroid Build Coastguard Worker // In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension
105*38e8c45fSAndroid Build Coastguard Worker // index, the component should not assume that the client is not using metadata mode for the port.
106*38e8c45fSAndroid Build Coastguard Worker //
107*38e8c45fSAndroid Build Coastguard Worker // If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata"
108*38e8c45fSAndroid Build Coastguard Worker // extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata
109*38e8c45fSAndroid Build Coastguard Worker // layout as defined below. Each buffer will be accompanied by a fence. The fence must signal
110*38e8c45fSAndroid Build Coastguard Worker // before the buffer can be used (e.g. read from or written into). When returning such buffer to
111*38e8c45fSAndroid Build Coastguard Worker // the client, component must provide a new fence that must signal before the returned buffer can
112*38e8c45fSAndroid Build Coastguard Worker // be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close
113*38e8c45fSAndroid Build Coastguard Worker // it when fence has signaled. The client will own and close the returned fence file descriptor.
114*38e8c45fSAndroid Build Coastguard Worker //
115*38e8c45fSAndroid Build Coastguard Worker // If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers"
116*38e8c45fSAndroid Build Coastguard Worker // extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata
117*38e8c45fSAndroid Build Coastguard Worker // (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed
118*38e8c45fSAndroid Build Coastguard Worker // as "CameraSource", the layout of which is vendor dependent.
119*38e8c45fSAndroid Build Coastguard Worker //
120*38e8c45fSAndroid Build Coastguard Worker // Metadata buffers are registered with the component using UseBuffer calls, or can be allocated
121*38e8c45fSAndroid Build Coastguard Worker // by the component for encoder-metadata-output buffers.
122*38e8c45fSAndroid Build Coastguard Worker struct StoreMetaDataInBuffersParams {
123*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
124*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
125*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;
126*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bStoreMetaData;
127*38e8c45fSAndroid Build Coastguard Worker };
128*38e8c45fSAndroid Build Coastguard Worker 
129*38e8c45fSAndroid Build Coastguard Worker // Meta data buffer layout used to transport output frames to the decoder for
130*38e8c45fSAndroid Build Coastguard Worker // dynamic buffer handling.
131*38e8c45fSAndroid Build Coastguard Worker struct VideoGrallocMetadata {
132*38e8c45fSAndroid Build Coastguard Worker     MetadataBufferType eType;               // must be kMetadataBufferTypeGrallocSource
133*38e8c45fSAndroid Build Coastguard Worker #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
134*38e8c45fSAndroid Build Coastguard Worker     OMX_PTR pHandle;
135*38e8c45fSAndroid Build Coastguard Worker #else
136*38e8c45fSAndroid Build Coastguard Worker     buffer_handle_t pHandle;
137*38e8c45fSAndroid Build Coastguard Worker #endif
138*38e8c45fSAndroid Build Coastguard Worker };
139*38e8c45fSAndroid Build Coastguard Worker 
140*38e8c45fSAndroid Build Coastguard Worker // Legacy name for VideoGrallocMetadata struct.
141*38e8c45fSAndroid Build Coastguard Worker struct VideoDecoderOutputMetaData : public VideoGrallocMetadata {};
142*38e8c45fSAndroid Build Coastguard Worker 
143*38e8c45fSAndroid Build Coastguard Worker struct VideoNativeMetadata {
144*38e8c45fSAndroid Build Coastguard Worker     MetadataBufferType eType;               // must be kMetadataBufferTypeANWBuffer
145*38e8c45fSAndroid Build Coastguard Worker #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
146*38e8c45fSAndroid Build Coastguard Worker     OMX_PTR pBuffer;
147*38e8c45fSAndroid Build Coastguard Worker #else
148*38e8c45fSAndroid Build Coastguard Worker     struct ANativeWindowBuffer* pBuffer;
149*38e8c45fSAndroid Build Coastguard Worker #endif
150*38e8c45fSAndroid Build Coastguard Worker     int nFenceFd;                           // -1 if unused
151*38e8c45fSAndroid Build Coastguard Worker };
152*38e8c45fSAndroid Build Coastguard Worker 
153*38e8c45fSAndroid Build Coastguard Worker // Meta data buffer layout for passing a native_handle to codec
154*38e8c45fSAndroid Build Coastguard Worker struct VideoNativeHandleMetadata {
155*38e8c45fSAndroid Build Coastguard Worker     MetadataBufferType eType;               // must be kMetadataBufferTypeNativeHandleSource
156*38e8c45fSAndroid Build Coastguard Worker 
157*38e8c45fSAndroid Build Coastguard Worker #ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
158*38e8c45fSAndroid Build Coastguard Worker     OMX_PTR pHandle;
159*38e8c45fSAndroid Build Coastguard Worker #else
160*38e8c45fSAndroid Build Coastguard Worker     native_handle_t *pHandle;
161*38e8c45fSAndroid Build Coastguard Worker #endif
162*38e8c45fSAndroid Build Coastguard Worker };
163*38e8c45fSAndroid Build Coastguard Worker 
164*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_SetParameter() when the extension
165*38e8c45fSAndroid Build Coastguard Worker // index "OMX.google.android.index.prepareForAdaptivePlayback" is given.
166*38e8c45fSAndroid Build Coastguard Worker //
167*38e8c45fSAndroid Build Coastguard Worker // This method is used to signal a video decoder, that the user has requested
168*38e8c45fSAndroid Build Coastguard Worker // seamless resolution change support (if bEnable is set to OMX_TRUE).
169*38e8c45fSAndroid Build Coastguard Worker // nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest
170*38e8c45fSAndroid Build Coastguard Worker // anticipated frames in the video.  If bEnable is OMX_FALSE, no resolution
171*38e8c45fSAndroid Build Coastguard Worker // change is expected, and the nMaxFrameWidth/Height fields are unused.
172*38e8c45fSAndroid Build Coastguard Worker //
173*38e8c45fSAndroid Build Coastguard Worker // If the decoder supports dynamic output buffers, it may ignore this
174*38e8c45fSAndroid Build Coastguard Worker // request.  Otherwise, it shall request resources in such a way so that it
175*38e8c45fSAndroid Build Coastguard Worker // avoids full port-reconfiguration (due to output port-definition change)
176*38e8c45fSAndroid Build Coastguard Worker // during resolution changes.
177*38e8c45fSAndroid Build Coastguard Worker //
178*38e8c45fSAndroid Build Coastguard Worker // DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED.  INSTEAD, IMPLEMENT
179*38e8c45fSAndroid Build Coastguard Worker // METADATA SUPPORT FOR VIDEO DECODERS.
180*38e8c45fSAndroid Build Coastguard Worker struct PrepareForAdaptivePlaybackParams {
181*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
182*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
183*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;
184*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bEnable;
185*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nMaxFrameWidth;
186*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nMaxFrameHeight;
187*38e8c45fSAndroid Build Coastguard Worker };
188*38e8c45fSAndroid Build Coastguard Worker 
189*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_SetParameter when the extension
190*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is
191*38e8c45fSAndroid Build Coastguard Worker // given.  This call will only be performed if a prior call was made with the
192*38e8c45fSAndroid Build Coastguard Worker // 'OMX.google.android.index.enableAndroidNativeBuffers' extension index,
193*38e8c45fSAndroid Build Coastguard Worker // enabling use of Android native buffers.
194*38e8c45fSAndroid Build Coastguard Worker struct UseAndroidNativeBufferParams {
195*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
196*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
197*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;
198*38e8c45fSAndroid Build Coastguard Worker     OMX_PTR pAppPrivate;
199*38e8c45fSAndroid Build Coastguard Worker     OMX_BUFFERHEADERTYPE **bufferHeader;
200*38e8c45fSAndroid Build Coastguard Worker     const sp<ANativeWindowBuffer>& nativeBuffer;
201*38e8c45fSAndroid Build Coastguard Worker };
202*38e8c45fSAndroid Build Coastguard Worker 
203*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_GetParameter when the extension
204*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.getAndroidNativeBufferUsage'
205*38e8c45fSAndroid Build Coastguard Worker // extension is given.  The usage bits returned from this query will be used to
206*38e8c45fSAndroid Build Coastguard Worker // allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer
207*38e8c45fSAndroid Build Coastguard Worker // command.
208*38e8c45fSAndroid Build Coastguard Worker struct GetAndroidNativeBufferUsageParams {
209*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;              // IN
210*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;   // IN
211*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;         // IN
212*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nUsage;             // OUT
213*38e8c45fSAndroid Build Coastguard Worker };
214*38e8c45fSAndroid Build Coastguard Worker 
215*38e8c45fSAndroid Build Coastguard Worker // An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat
216*38e8c45fSAndroid Build Coastguard Worker // is declared in media/stagefright/openmax/OMX_IVCommon.h
217*38e8c45fSAndroid Build Coastguard Worker // This will inform the encoder that the actual
218*38e8c45fSAndroid Build Coastguard Worker // colorformat will be relayed by the GRalloc Buffers.
219*38e8c45fSAndroid Build Coastguard Worker // OMX_COLOR_FormatAndroidOpaque  = 0x7F000001,
220*38e8c45fSAndroid Build Coastguard Worker 
221*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_SetParameter when the extension
222*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension
223*38e8c45fSAndroid Build Coastguard Worker // is given.
224*38e8c45fSAndroid Build Coastguard Worker // A successful result indicates that future IDR frames will be prefixed by
225*38e8c45fSAndroid Build Coastguard Worker // SPS/PPS.
226*38e8c45fSAndroid Build Coastguard Worker struct PrependSPSPPSToIDRFramesParams {
227*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
228*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
229*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bEnable;
230*38e8c45fSAndroid Build Coastguard Worker };
231*38e8c45fSAndroid Build Coastguard Worker 
232*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_GetParameter when the extension
233*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.describeColorFormat'
234*38e8c45fSAndroid Build Coastguard Worker // extension is given.  This method can be called from any component state
235*38e8c45fSAndroid Build Coastguard Worker // other than invalid.  The color-format, frame width/height, and stride/
236*38e8c45fSAndroid Build Coastguard Worker // slice-height parameters are ones that are associated with a raw video
237*38e8c45fSAndroid Build Coastguard Worker // port (input or output), but the stride/slice height parameters may be
238*38e8c45fSAndroid Build Coastguard Worker // incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will
239*38e8c45fSAndroid Build Coastguard Worker // be used (while specifying this color format).
240*38e8c45fSAndroid Build Coastguard Worker //
241*38e8c45fSAndroid Build Coastguard Worker // The component shall fill out the MediaImage structure that
242*38e8c45fSAndroid Build Coastguard Worker // corresponds to the described raw video format, and the potentially corrected
243*38e8c45fSAndroid Build Coastguard Worker // stride and slice-height info.
244*38e8c45fSAndroid Build Coastguard Worker //
245*38e8c45fSAndroid Build Coastguard Worker // The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE,
246*38e8c45fSAndroid Build Coastguard Worker // though most implementations can ignore this difference. When using native buffers,
247*38e8c45fSAndroid Build Coastguard Worker // the component may change the configured color format to an optimized format.
248*38e8c45fSAndroid Build Coastguard Worker // Additionally, when allocating these buffers for flexible usecase, the framework
249*38e8c45fSAndroid Build Coastguard Worker // will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers
250*38e8c45fSAndroid Build Coastguard Worker // is OMX_TRUE), the component shall fill out the MediaImage information for the
251*38e8c45fSAndroid Build Coastguard Worker // scenario when these SW-readable/writable buffers are locked using gralloc_lock.
252*38e8c45fSAndroid Build Coastguard Worker // Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must
253*38e8c45fSAndroid Build Coastguard Worker // be supported for vendor-specific formats.
254*38e8c45fSAndroid Build Coastguard Worker //
255*38e8c45fSAndroid Build Coastguard Worker // For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers
256*38e8c45fSAndroid Build Coastguard Worker // is OMX_TRUE and the component does not support this color format with native
257*38e8c45fSAndroid Build Coastguard Worker // buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN.
258*38e8c45fSAndroid Build Coastguard Worker 
259*38e8c45fSAndroid Build Coastguard Worker // @deprecated: use DescribeColorFormat2Params
260*38e8c45fSAndroid Build Coastguard Worker struct DescribeColorFormat2Params;
261*38e8c45fSAndroid Build Coastguard Worker struct DescribeColorFormatParams {
262*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
263*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
264*38e8c45fSAndroid Build Coastguard Worker     // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE
265*38e8c45fSAndroid Build Coastguard Worker     OMX_COLOR_FORMATTYPE eColorFormat;
266*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nFrameWidth;
267*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nFrameHeight;
268*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nStride;
269*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSliceHeight;
270*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bUsingNativeBuffers;
271*38e8c45fSAndroid Build Coastguard Worker 
272*38e8c45fSAndroid Build Coastguard Worker     // output: fill out the MediaImage fields
273*38e8c45fSAndroid Build Coastguard Worker     MediaImage sMediaImage;
274*38e8c45fSAndroid Build Coastguard Worker 
275*38e8c45fSAndroid Build Coastguard Worker     explicit DescribeColorFormatParams(const DescribeColorFormat2Params&); // for internal use only
276*38e8c45fSAndroid Build Coastguard Worker };
277*38e8c45fSAndroid Build Coastguard Worker 
278*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_GetParameter when the extension
279*38e8c45fSAndroid Build Coastguard Worker // index for the 'OMX.google.android.index.describeColorFormat2'
280*38e8c45fSAndroid Build Coastguard Worker // extension is given. This is operationally the same as DescribeColorFormatParams
281*38e8c45fSAndroid Build Coastguard Worker // but can be used for HDR and RGBA/YUVA formats.
282*38e8c45fSAndroid Build Coastguard Worker struct DescribeColorFormat2Params {
283*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;
284*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;
285*38e8c45fSAndroid Build Coastguard Worker     // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE
286*38e8c45fSAndroid Build Coastguard Worker     OMX_COLOR_FORMATTYPE eColorFormat;
287*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nFrameWidth;
288*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nFrameHeight;
289*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nStride;
290*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSliceHeight;
291*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bUsingNativeBuffers;
292*38e8c45fSAndroid Build Coastguard Worker 
293*38e8c45fSAndroid Build Coastguard Worker     // output: fill out the MediaImage2 fields
294*38e8c45fSAndroid Build Coastguard Worker     MediaImage2 sMediaImage;
295*38e8c45fSAndroid Build Coastguard Worker 
296*38e8c45fSAndroid Build Coastguard Worker     void initFromV1(const DescribeColorFormatParams&); // for internal use only
297*38e8c45fSAndroid Build Coastguard Worker };
298*38e8c45fSAndroid Build Coastguard Worker 
299*38e8c45fSAndroid Build Coastguard Worker // A pointer to this struct is passed to OMX_SetParameter or OMX_GetParameter
300*38e8c45fSAndroid Build Coastguard Worker // when the extension index for the
301*38e8c45fSAndroid Build Coastguard Worker // 'OMX.google.android.index.configureVideoTunnelMode' extension is  given.
302*38e8c45fSAndroid Build Coastguard Worker // If the extension is supported then tunneled playback mode should be supported
303*38e8c45fSAndroid Build Coastguard Worker // by the codec. If bTunneled is set to OMX_TRUE then the video decoder should
304*38e8c45fSAndroid Build Coastguard Worker // operate in "tunneled" mode and output its decoded frames directly to the
305*38e8c45fSAndroid Build Coastguard Worker // sink. In this case nAudioHwSync is the HW SYNC ID of the audio HAL Output
306*38e8c45fSAndroid Build Coastguard Worker // stream to sync the video with. If bTunneled is set to OMX_FALSE, "tunneled"
307*38e8c45fSAndroid Build Coastguard Worker // mode should be disabled and nAudioHwSync should be ignored.
308*38e8c45fSAndroid Build Coastguard Worker // OMX_GetParameter is used to query tunneling configuration. bTunneled should
309*38e8c45fSAndroid Build Coastguard Worker // return whether decoder is operating in tunneled mode, and if it is,
310*38e8c45fSAndroid Build Coastguard Worker // pSidebandWindow should contain the codec allocated sideband window handle.
311*38e8c45fSAndroid Build Coastguard Worker struct ConfigureVideoTunnelModeParams {
312*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;              // IN
313*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;   // IN
314*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;         // IN
315*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bTunneled;         // IN/OUT
316*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nAudioHwSync;       // IN
317*38e8c45fSAndroid Build Coastguard Worker     OMX_PTR pSidebandWindow;    // OUT
318*38e8c45fSAndroid Build Coastguard Worker };
319*38e8c45fSAndroid Build Coastguard Worker 
320*38e8c45fSAndroid Build Coastguard Worker // Color space description (aspects) parameters.
321*38e8c45fSAndroid Build Coastguard Worker // This is passed via OMX_SetConfig or OMX_GetConfig to video encoders and decoders when the
322*38e8c45fSAndroid Build Coastguard Worker // 'OMX.google.android.index.describeColorAspects' extension is given. Component SHALL behave
323*38e8c45fSAndroid Build Coastguard Worker // as described below if it supports this extension.
324*38e8c45fSAndroid Build Coastguard Worker //
325*38e8c45fSAndroid Build Coastguard Worker // bDataSpaceChanged and bRequestingDataSpace is assumed to be OMX_FALSE unless noted otherwise.
326*38e8c45fSAndroid Build Coastguard Worker //
327*38e8c45fSAndroid Build Coastguard Worker // VIDEO ENCODERS: the framework uses OMX_SetConfig to specify color aspects of the coded video.
328*38e8c45fSAndroid Build Coastguard Worker // This may happen:
329*38e8c45fSAndroid Build Coastguard Worker //   a) before the component transitions to idle state
330*38e8c45fSAndroid Build Coastguard Worker //   b) before the input frame is sent via OMX_EmptyThisBuffer in executing state
331*38e8c45fSAndroid Build Coastguard Worker //   c) during execution, just before an input frame with a different color aspect information
332*38e8c45fSAndroid Build Coastguard Worker //      is sent.
333*38e8c45fSAndroid Build Coastguard Worker //
334*38e8c45fSAndroid Build Coastguard Worker // The framework also uses OMX_GetConfig to
335*38e8c45fSAndroid Build Coastguard Worker //   d) verify the color aspects that will be written to the stream
336*38e8c45fSAndroid Build Coastguard Worker //   e) (optional) verify the color aspects that should be reported to the container for a
337*38e8c45fSAndroid Build Coastguard Worker //      given dataspace/pixelformat received
338*38e8c45fSAndroid Build Coastguard Worker //
339*38e8c45fSAndroid Build Coastguard Worker // 1. Encoders SHOULD maintain an internal color aspect state, initialized to Unspecified values.
340*38e8c45fSAndroid Build Coastguard Worker //    This represents the values that will be written into the bitstream.
341*38e8c45fSAndroid Build Coastguard Worker // 2. Upon OMX_SetConfig, they SHOULD update their internal state to the aspects received
342*38e8c45fSAndroid Build Coastguard Worker //    (including Unspecified values). For specific aspect values that are not supported by the
343*38e8c45fSAndroid Build Coastguard Worker //    codec standard, encoders SHOULD substitute Unspecified values; or they MAY use a suitable
344*38e8c45fSAndroid Build Coastguard Worker //    alternative (e.g. to suggest the use of BT.709 EOTF instead of SMPTE 240M.)
345*38e8c45fSAndroid Build Coastguard Worker // 3. OMX_GetConfig SHALL return the internal state (values that will be written).
346*38e8c45fSAndroid Build Coastguard Worker // 4. OMX_SetConfig SHALL always succeed before receiving the first frame. It MAY fail afterwards,
347*38e8c45fSAndroid Build Coastguard Worker //    but only if the configured values would change AND the component does not support updating the
348*38e8c45fSAndroid Build Coastguard Worker //    color information to those values mid-stream. If component supports updating a portion of
349*38e8c45fSAndroid Build Coastguard Worker //    the color information, those values should be updated in the internal state, and OMX_SetConfig
350*38e8c45fSAndroid Build Coastguard Worker //    SHALL succeed. Otherwise, the internal state SHALL remain intact and OMX_SetConfig SHALL fail
351*38e8c45fSAndroid Build Coastguard Worker //    with OMX_ErrorUnsupportedSettings.
352*38e8c45fSAndroid Build Coastguard Worker // 5. When the framework receives an input frame with an unexpected dataspace, it will query
353*38e8c45fSAndroid Build Coastguard Worker //    encoders for the color aspects that should be reported to the container using OMX_GetConfig
354*38e8c45fSAndroid Build Coastguard Worker //    with bDataSpaceChanged set to OMX_TRUE, and nPixelFormat/nDataSpace containing the new
355*38e8c45fSAndroid Build Coastguard Worker //    format/dataspace values. This allows vendors to use extended dataspace during capture and
356*38e8c45fSAndroid Build Coastguard Worker //    composition (e.g. screenrecord) - while performing color-space conversion inside the encoder -
357*38e8c45fSAndroid Build Coastguard Worker //    and encode and report a different color-space information in the bitstream/container.
358*38e8c45fSAndroid Build Coastguard Worker //    sColorAspects contains the requested color aspects by the client for reference, which may
359*38e8c45fSAndroid Build Coastguard Worker //    include aspects not supported by the encoding. This is used together with guidance for
360*38e8c45fSAndroid Build Coastguard Worker //    dataspace selection; see 6. below.
361*38e8c45fSAndroid Build Coastguard Worker //
362*38e8c45fSAndroid Build Coastguard Worker // VIDEO DECODERS: the framework uses OMX_SetConfig to specify the default color aspects to use
363*38e8c45fSAndroid Build Coastguard Worker // for the video.
364*38e8c45fSAndroid Build Coastguard Worker // This may happen:
365*38e8c45fSAndroid Build Coastguard Worker //   a) before the component transitions to idle state
366*38e8c45fSAndroid Build Coastguard Worker //   b) during execution, when the resolution or the default color aspects change.
367*38e8c45fSAndroid Build Coastguard Worker //
368*38e8c45fSAndroid Build Coastguard Worker // The framework also uses OMX_GetConfig to
369*38e8c45fSAndroid Build Coastguard Worker //   c) get the final color aspects reported by the coded bitstream after taking the default values
370*38e8c45fSAndroid Build Coastguard Worker //      into account.
371*38e8c45fSAndroid Build Coastguard Worker //
372*38e8c45fSAndroid Build Coastguard Worker // 1. Decoders should maintain two color aspect states - the default state as reported by the
373*38e8c45fSAndroid Build Coastguard Worker //    framework, and the coded state as reported by the bitstream - as each state can change
374*38e8c45fSAndroid Build Coastguard Worker //    independently from the other.
375*38e8c45fSAndroid Build Coastguard Worker // 2. Upon OMX_SetConfig, it SHALL update its default state regardless of whether such aspects
376*38e8c45fSAndroid Build Coastguard Worker //    could be supplied by the component bitstream. (E.g. it should blindly support all enumeration
377*38e8c45fSAndroid Build Coastguard Worker //    values, even unknown ones, and the Other value). This SHALL always succeed.
378*38e8c45fSAndroid Build Coastguard Worker // 3. Upon OMX_GetConfig, the component SHALL return the final color aspects by replacing
379*38e8c45fSAndroid Build Coastguard Worker //    Unspecified coded values with the default values. This SHALL always succeed.
380*38e8c45fSAndroid Build Coastguard Worker // 4. Whenever the component processes color aspect information in the bitstream even with an
381*38e8c45fSAndroid Build Coastguard Worker //    Unspecified value, it SHOULD update its internal coded state with that information just before
382*38e8c45fSAndroid Build Coastguard Worker //    the frame with the new information would be outputted, and the component SHALL signal an
383*38e8c45fSAndroid Build Coastguard Worker //    OMX_EventPortSettingsChanged event with data2 set to the extension index.
384*38e8c45fSAndroid Build Coastguard Worker // NOTE: Component SHOULD NOT signal a separate event purely for color aspect change, if it occurs
385*38e8c45fSAndroid Build Coastguard Worker //    together with a port definition (e.g. size) or crop change.
386*38e8c45fSAndroid Build Coastguard Worker // 5. If the aspects a component encounters in the bitstream cannot be represented with enumeration
387*38e8c45fSAndroid Build Coastguard Worker //    values as defined below, the component SHALL set those aspects to Other. Restricted values in
388*38e8c45fSAndroid Build Coastguard Worker //    the bitstream SHALL be treated as defined by the relevant bitstream specifications/standards,
389*38e8c45fSAndroid Build Coastguard Worker //    or as Unspecified, if not defined.
390*38e8c45fSAndroid Build Coastguard Worker //
391*38e8c45fSAndroid Build Coastguard Worker // BOTH DECODERS AND ENCODERS: the framework uses OMX_GetConfig during idle and executing state to
392*38e8c45fSAndroid Build Coastguard Worker //   f) (optional) get guidance for the dataspace to set for given color aspects, by setting
393*38e8c45fSAndroid Build Coastguard Worker //      bRequestingDataSpace to OMX_TRUE. The component SHALL return OMX_ErrorUnsupportedSettings
394*38e8c45fSAndroid Build Coastguard Worker //      IF it does not support this request.
395*38e8c45fSAndroid Build Coastguard Worker //
396*38e8c45fSAndroid Build Coastguard Worker // 6. This is an information request that can happen at any time, independent of the normal
397*38e8c45fSAndroid Build Coastguard Worker //    configuration process. This allows vendors to use extended dataspace during capture, playback
398*38e8c45fSAndroid Build Coastguard Worker //    and composition - while performing color-space conversion inside the component. Component
399*38e8c45fSAndroid Build Coastguard Worker //    SHALL set the desired dataspace into nDataSpace. Otherwise, it SHALL return
400*38e8c45fSAndroid Build Coastguard Worker //    OMX_ErrorUnsupportedSettings to let the framework choose a nearby standard dataspace.
401*38e8c45fSAndroid Build Coastguard Worker //
402*38e8c45fSAndroid Build Coastguard Worker // 6.a. For encoders, this query happens before the first frame is received using surface encoding.
403*38e8c45fSAndroid Build Coastguard Worker //    This allows the encoder to use a specific dataspace for the color aspects (e.g. because the
404*38e8c45fSAndroid Build Coastguard Worker //    device supports additional dataspaces, or because it wants to perform color-space extension
405*38e8c45fSAndroid Build Coastguard Worker //    to facilitate a more optimal rendering/capture pipeline.).
406*38e8c45fSAndroid Build Coastguard Worker //
407*38e8c45fSAndroid Build Coastguard Worker // 6.b. For decoders, this query happens before the first frame, and every time the color aspects
408*38e8c45fSAndroid Build Coastguard Worker //    change, while using surface buffers. This allows the decoder to use a specific dataspace for
409*38e8c45fSAndroid Build Coastguard Worker //    the color aspects (e.g. because the device supports additional dataspaces, or because it wants
410*38e8c45fSAndroid Build Coastguard Worker //    to perform color-space extension by inline color-space conversion to facilitate a more optimal
411*38e8c45fSAndroid Build Coastguard Worker //    rendering pipeline.).
412*38e8c45fSAndroid Build Coastguard Worker //
413*38e8c45fSAndroid Build Coastguard Worker // Note: the size of sAspects may increase in the future by additional fields.
414*38e8c45fSAndroid Build Coastguard Worker // Implementations SHOULD NOT require a certain size.
415*38e8c45fSAndroid Build Coastguard Worker struct DescribeColorAspectsParams {
416*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;                 // IN
417*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;      // IN
418*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;            // IN
419*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bRequestingDataSpace; // IN
420*38e8c45fSAndroid Build Coastguard Worker     OMX_BOOL bDataSpaceChanged;    // IN
421*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPixelFormat;          // IN
422*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nDataSpace;            // OUT
423*38e8c45fSAndroid Build Coastguard Worker     ColorAspects sAspects;         // IN/OUT
424*38e8c45fSAndroid Build Coastguard Worker };
425*38e8c45fSAndroid Build Coastguard Worker 
426*38e8c45fSAndroid Build Coastguard Worker // HDR color description parameters.
427*38e8c45fSAndroid Build Coastguard Worker // This is passed via OMX_SetConfig or OMX_GetConfig to video encoders and decoders when the
428*38e8c45fSAndroid Build Coastguard Worker // 'OMX.google.android.index.describeHDRStaticInfo' extension is given and an HDR stream
429*38e8c45fSAndroid Build Coastguard Worker // is detected.  Component SHALL behave as described below if it supports this extension.
430*38e8c45fSAndroid Build Coastguard Worker //
431*38e8c45fSAndroid Build Coastguard Worker // Currently, only Static Metadata Descriptor Type 1 support is required.
432*38e8c45fSAndroid Build Coastguard Worker //
433*38e8c45fSAndroid Build Coastguard Worker // VIDEO ENCODERS: the framework uses OMX_SetConfig to specify the HDR static information of the
434*38e8c45fSAndroid Build Coastguard Worker // coded video.
435*38e8c45fSAndroid Build Coastguard Worker // This may happen:
436*38e8c45fSAndroid Build Coastguard Worker //   a) before the component transitions to idle state
437*38e8c45fSAndroid Build Coastguard Worker //   b) before the input frame is sent via OMX_EmptyThisBuffer in executing state
438*38e8c45fSAndroid Build Coastguard Worker //   c) during execution, just before an input frame with a different HDR static
439*38e8c45fSAndroid Build Coastguard Worker //      information is sent.
440*38e8c45fSAndroid Build Coastguard Worker //
441*38e8c45fSAndroid Build Coastguard Worker // The framework also uses OMX_GetConfig to
442*38e8c45fSAndroid Build Coastguard Worker //   d) verify the HDR static information that will be written to the stream.
443*38e8c45fSAndroid Build Coastguard Worker //
444*38e8c45fSAndroid Build Coastguard Worker // 1. Encoders SHOULD maintain an internal HDR static info data, initialized to Unspecified values.
445*38e8c45fSAndroid Build Coastguard Worker //    This represents the values that will be written into the bitstream.
446*38e8c45fSAndroid Build Coastguard Worker // 2. Upon OMX_SetConfig, they SHOULD update their internal state to the info received
447*38e8c45fSAndroid Build Coastguard Worker //    (including Unspecified values). For specific parameters that are not supported by the
448*38e8c45fSAndroid Build Coastguard Worker //    codec standard, encoders SHOULD substitute Unspecified values. NOTE: no other substitution
449*38e8c45fSAndroid Build Coastguard Worker //    is allowed.
450*38e8c45fSAndroid Build Coastguard Worker // 3. OMX_GetConfig SHALL return the internal state (values that will be written).
451*38e8c45fSAndroid Build Coastguard Worker // 4. OMX_SetConfig SHALL always succeed before receiving the first frame if the encoder is
452*38e8c45fSAndroid Build Coastguard Worker //    configured into an HDR compatible profile. It MAY fail with OMX_ErrorUnsupportedSettings error
453*38e8c45fSAndroid Build Coastguard Worker //    code if it is not configured into such a profile, OR if the configured values would change
454*38e8c45fSAndroid Build Coastguard Worker //    AND the component does not support updating the HDR static information mid-stream. If the
455*38e8c45fSAndroid Build Coastguard Worker //    component supports updating a portion of the information, those values should be updated in
456*38e8c45fSAndroid Build Coastguard Worker //    the internal state, and OMX_SetConfig SHALL succeed. Otherwise, the internal state SHALL
457*38e8c45fSAndroid Build Coastguard Worker //    remain intact.
458*38e8c45fSAndroid Build Coastguard Worker //
459*38e8c45fSAndroid Build Coastguard Worker // VIDEO DECODERS: the framework uses OMX_SetConfig to specify the default HDR static information
460*38e8c45fSAndroid Build Coastguard Worker // to use for the video.
461*38e8c45fSAndroid Build Coastguard Worker //   a) This only happens if the client supplies this information, in which case it occurs before
462*38e8c45fSAndroid Build Coastguard Worker //      the component transitions to idle state.
463*38e8c45fSAndroid Build Coastguard Worker //   b) This may also happen subsequently if the default HDR static information changes.
464*38e8c45fSAndroid Build Coastguard Worker //
465*38e8c45fSAndroid Build Coastguard Worker // The framework also uses OMX_GetConfig to
466*38e8c45fSAndroid Build Coastguard Worker //   c) get the final HDR static information reported by the coded bitstream after taking the
467*38e8c45fSAndroid Build Coastguard Worker //      default values into account.
468*38e8c45fSAndroid Build Coastguard Worker //
469*38e8c45fSAndroid Build Coastguard Worker // 1. Decoders should maintain two HDR static information structures - the default values as
470*38e8c45fSAndroid Build Coastguard Worker //    reported by the framework, and the coded values as reported by the bitstream - as each
471*38e8c45fSAndroid Build Coastguard Worker //    structure can change independently from the other.
472*38e8c45fSAndroid Build Coastguard Worker // 2. Upon OMX_SetConfig, it SHALL update its default structure regardless of whether such static
473*38e8c45fSAndroid Build Coastguard Worker //    parameters could be supplied by the component bitstream. (E.g. it should blindly support all
474*38e8c45fSAndroid Build Coastguard Worker //    parameter values, even seemingly illegal ones). This SHALL always succeed.
475*38e8c45fSAndroid Build Coastguard Worker //  Note: The descriptor ID used in sInfo may change in subsequent calls. (although for now only
476*38e8c45fSAndroid Build Coastguard Worker //    Type 1 support is required.)
477*38e8c45fSAndroid Build Coastguard Worker // 3. Upon OMX_GetConfig, the component SHALL return the final HDR static information by replacing
478*38e8c45fSAndroid Build Coastguard Worker //    Unspecified coded values with the default values. This SHALL always succeed. This may be
479*38e8c45fSAndroid Build Coastguard Worker //    provided using any supported descriptor ID (currently only Type 1) with the goal of expressing
480*38e8c45fSAndroid Build Coastguard Worker //    the most of the available static information.
481*38e8c45fSAndroid Build Coastguard Worker // 4. Whenever the component processes HDR static information in the bitstream even ones with
482*38e8c45fSAndroid Build Coastguard Worker //    Unspecified parameters, it SHOULD update its internal coded structure with that information
483*38e8c45fSAndroid Build Coastguard Worker //    just before the frame with the new information would be outputted, and the component SHALL
484*38e8c45fSAndroid Build Coastguard Worker //    signal an OMX_EventPortSettingsChanged event with data2 set to the extension index.
485*38e8c45fSAndroid Build Coastguard Worker // NOTE: Component SHOULD NOT signal a separate event purely for HDR static info change, if it
486*38e8c45fSAndroid Build Coastguard Worker //    occurs together with a port definition (e.g. size), color aspect or crop change.
487*38e8c45fSAndroid Build Coastguard Worker // 5. If certain parameters of the HDR static information encountered in the bitstream cannot be
488*38e8c45fSAndroid Build Coastguard Worker //    represented using sInfo, the component SHALL use the closest representation.
489*38e8c45fSAndroid Build Coastguard Worker //
490*38e8c45fSAndroid Build Coastguard Worker // Note: the size of sInfo may increase in the future by supporting additional descriptor types.
491*38e8c45fSAndroid Build Coastguard Worker // Implementations SHOULD NOT require a certain size.
492*38e8c45fSAndroid Build Coastguard Worker struct DescribeHDRStaticInfoParams {
493*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;                 // IN
494*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;      // IN
495*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;            // IN
496*38e8c45fSAndroid Build Coastguard Worker     HDRStaticInfo sInfo;           // IN/OUT
497*38e8c45fSAndroid Build Coastguard Worker };
498*38e8c45fSAndroid Build Coastguard Worker 
499*38e8c45fSAndroid Build Coastguard Worker // HDR10+ metadata configuration.
500*38e8c45fSAndroid Build Coastguard Worker //
501*38e8c45fSAndroid Build Coastguard Worker // nParamSize: size of the storage starting at nValue (must be at least 1 and at most
502*38e8c45fSAndroid Build Coastguard Worker //             MAX_HDR10PLUSINFO_SIZE). This field must not be modified by the component.
503*38e8c45fSAndroid Build Coastguard Worker // nParamSizeUsed: size of the actual HDR10+ metadata starting at nValue. For OMX_SetConfig,
504*38e8c45fSAndroid Build Coastguard Worker //                 it must not be modified by the component. For OMX_GetConfig, the component
505*38e8c45fSAndroid Build Coastguard Worker //                 should put the actual size of the retrieved config in this field (and in
506*38e8c45fSAndroid Build Coastguard Worker //                 case where nParamSize is smaller than nParamSizeUsed, the component should
507*38e8c45fSAndroid Build Coastguard Worker //                 still update nParamSizeUsed without actually copying the metadata to nValue).
508*38e8c45fSAndroid Build Coastguard Worker // nValue: storage of the HDR10+ metadata conforming to the user_data_registered_itu_t_t35()
509*38e8c45fSAndroid Build Coastguard Worker //         syntax of SEI message for ST 2094-40.
510*38e8c45fSAndroid Build Coastguard Worker //
511*38e8c45fSAndroid Build Coastguard Worker // This is passed via OMX_SetConfig or OMX_GetConfig to video encoders and decoders when the
512*38e8c45fSAndroid Build Coastguard Worker // 'OMX.google.android.index.describeHDR10PlusInfo' extension is given. In general, this config
513*38e8c45fSAndroid Build Coastguard Worker // is associated with a particular frame. A typical sequence of usage is as follows:
514*38e8c45fSAndroid Build Coastguard Worker //
515*38e8c45fSAndroid Build Coastguard Worker // a) OMX_SetConfig associates the config with the next input buffer sent in OMX_EmptyThisBuffer
516*38e8c45fSAndroid Build Coastguard Worker //    (input A);
517*38e8c45fSAndroid Build Coastguard Worker // b) The component sends OMX_EventConfigUpdate to notify the client that there is a config
518*38e8c45fSAndroid Build Coastguard Worker //    update  on the output port that is associated with the next output buffer that's about to
519*38e8c45fSAndroid Build Coastguard Worker //    be sent via FillBufferDone callback (output A);
520*38e8c45fSAndroid Build Coastguard Worker // c) The client, upon receiving the OMX_EventConfigUpdate, calls OMX_GetConfig to retrieve
521*38e8c45fSAndroid Build Coastguard Worker //    the config and associates it with output A.
522*38e8c45fSAndroid Build Coastguard Worker //
523*38e8c45fSAndroid Build Coastguard Worker // All config updates will be retrieved in the order reported, and the client is required to
524*38e8c45fSAndroid Build Coastguard Worker // call OMX_GetConfig for each OMX_EventConfigUpdate for this config. Note that the order of
525*38e8c45fSAndroid Build Coastguard Worker // OMX_EventConfigUpdate relative to FillBufferDone callback determines which output frame
526*38e8c45fSAndroid Build Coastguard Worker // the config should be associated with, the actual OMX_GetConfig for the config could happen
527*38e8c45fSAndroid Build Coastguard Worker // before or after the component calls the FillBufferDone callback.
528*38e8c45fSAndroid Build Coastguard Worker //
529*38e8c45fSAndroid Build Coastguard Worker // Depending on the video codec type (in particular, whether the codec uses in-band or out-of-
530*38e8c45fSAndroid Build Coastguard Worker // band HDR10+ metadata), the component shall behave as detailed below:
531*38e8c45fSAndroid Build Coastguard Worker //
532*38e8c45fSAndroid Build Coastguard Worker // VIDEO DECODERS:
533*38e8c45fSAndroid Build Coastguard Worker // 1) If the codec utilizes out-of-band HDR10+ metadata, the decoder must support the sequence
534*38e8c45fSAndroid Build Coastguard Worker //    a) ~ c) outlined above;
535*38e8c45fSAndroid Build Coastguard Worker // 2) If the codec utilizes in-band HDR10+ metadata, OMX_SetConfig for this config should be
536*38e8c45fSAndroid Build Coastguard Worker //    ignored (as the metadata is embedded in the input buffer), while the notification and
537*38e8c45fSAndroid Build Coastguard Worker //    retrieval of the config on the output as outlined in b) & c) must be supported.
538*38e8c45fSAndroid Build Coastguard Worker //
539*38e8c45fSAndroid Build Coastguard Worker // VIDEO ENCODERS:
540*38e8c45fSAndroid Build Coastguard Worker // 1) If the codec utilizes out-of-band HDR10+ metadata, the decoder must support the sequence
541*38e8c45fSAndroid Build Coastguard Worker //    a) ~ c) outlined above;
542*38e8c45fSAndroid Build Coastguard Worker // 2) If the codec utilizes in-band HDR10+ metadata, OMX_SetConfig for this config outlined in
543*38e8c45fSAndroid Build Coastguard Worker //    a) must be supported. The notification as outlined in b) must not be sent, and the
544*38e8c45fSAndroid Build Coastguard Worker //    retrieval of the config via OMX_GetConfig should be ignored (as the metadata is embedded
545*38e8c45fSAndroid Build Coastguard Worker //    in the output buffer).
546*38e8c45fSAndroid Build Coastguard Worker 
547*38e8c45fSAndroid Build Coastguard Worker #define MAX_HDR10PLUSINFO_SIZE 1024
548*38e8c45fSAndroid Build Coastguard Worker struct DescribeHDR10PlusInfoParams {
549*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nSize;                 // IN
550*38e8c45fSAndroid Build Coastguard Worker     OMX_VERSIONTYPE nVersion;      // IN
551*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nPortIndex;            // IN
552*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nParamSize;            // IN
553*38e8c45fSAndroid Build Coastguard Worker     OMX_U32 nParamSizeUsed;        // IN/OUT
554*38e8c45fSAndroid Build Coastguard Worker     OMX_U8 nValue[1];              // IN/OUT
555*38e8c45fSAndroid Build Coastguard Worker };
556*38e8c45fSAndroid Build Coastguard Worker 
557*38e8c45fSAndroid Build Coastguard Worker }  // namespace android
558*38e8c45fSAndroid Build Coastguard Worker 
559*38e8c45fSAndroid Build Coastguard Worker extern android::OMXPluginBase *createOMXPlugin();
560*38e8c45fSAndroid Build Coastguard Worker 
561*38e8c45fSAndroid Build Coastguard Worker #endif  // HARDWARE_API_H_
562