1334de520b0369215b7931fefa424fb92d295f0ebJames Dong/*
2334de520b0369215b7931fefa424fb92d295f0ebJames Dong * Copyright (C) 2009 The Android Open Source Project
3334de520b0369215b7931fefa424fb92d295f0ebJames Dong *
4334de520b0369215b7931fefa424fb92d295f0ebJames Dong * Licensed under the Apache License, Version 2.0 (the "License");
5334de520b0369215b7931fefa424fb92d295f0ebJames Dong * you may not use this file except in compliance with the License.
6334de520b0369215b7931fefa424fb92d295f0ebJames Dong * You may obtain a copy of the License at
7334de520b0369215b7931fefa424fb92d295f0ebJames Dong *
8334de520b0369215b7931fefa424fb92d295f0ebJames Dong *      http://www.apache.org/licenses/LICENSE-2.0
9334de520b0369215b7931fefa424fb92d295f0ebJames Dong *
10334de520b0369215b7931fefa424fb92d295f0ebJames Dong * Unless required by applicable law or agreed to in writing, software
11334de520b0369215b7931fefa424fb92d295f0ebJames Dong * distributed under the License is distributed on an "AS IS" BASIS,
12334de520b0369215b7931fefa424fb92d295f0ebJames Dong * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13334de520b0369215b7931fefa424fb92d295f0ebJames Dong * See the License for the specific language governing permissions and
14334de520b0369215b7931fefa424fb92d295f0ebJames Dong * limitations under the License.
15334de520b0369215b7931fefa424fb92d295f0ebJames Dong */
16334de520b0369215b7931fefa424fb92d295f0ebJames Dong
17334de520b0369215b7931fefa424fb92d295f0ebJames Dong#ifndef HARDWARE_API_H_
18334de520b0369215b7931fefa424fb92d295f0ebJames Dong
19334de520b0369215b7931fefa424fb92d295f0ebJames Dong#define HARDWARE_API_H_
20334de520b0369215b7931fefa424fb92d295f0ebJames Dong
2100e595f10f9a3a009b55c982b4f9fab3d18e5333Andreas Huber#include <media/hardware/OMXPluginBase.h>
2200e595f10f9a3a009b55c982b4f9fab3d18e5333Andreas Huber#include <media/hardware/MetadataBufferType.h>
23334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <system/window.h>
24334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <utils/RefBase.h>
25334de520b0369215b7931fefa424fb92d295f0ebJames Dong
26334de520b0369215b7931fefa424fb92d295f0ebJames Dong#include <OMX_Component.h>
27334de520b0369215b7931fefa424fb92d295f0ebJames Dong
28334de520b0369215b7931fefa424fb92d295f0ebJames Dongnamespace android {
29334de520b0369215b7931fefa424fb92d295f0ebJames Dong
30334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to the OMX_SetParameter when the extension
31334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index for the 'OMX.google.android.index.enableAndroidNativeBuffers' extension
32334de520b0369215b7931fefa424fb92d295f0ebJames Dong// is given.
33334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
34334de520b0369215b7931fefa424fb92d295f0ebJames Dong// When Android native buffer use is disabled for a port (the default state),
35334de520b0369215b7931fefa424fb92d295f0ebJames Dong// the OMX node should operate as normal, and expect UseBuffer calls to set its
36334de520b0369215b7931fefa424fb92d295f0ebJames Dong// buffers.  This is the mode that will be used when CPU access to the buffer is
37334de520b0369215b7931fefa424fb92d295f0ebJames Dong// required.
38334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
39334de520b0369215b7931fefa424fb92d295f0ebJames Dong// When Android native buffer use has been enabled for a given port, the video
40334de520b0369215b7931fefa424fb92d295f0ebJames Dong// color format for the port is to be interpreted as an Android pixel format
415f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// rather than an OMX color format.  Enabling Android native buffers may also
425f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// change how the component receives the native buffers.  If store-metadata-mode
435f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// is enabled on the port, the component will receive the buffers as specified
445f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// in the section below. Otherwise, unless the node supports the
455f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// 'OMX.google.android.index.useAndroidNativeBuffer2' extension, it should
465f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// expect to receive UseAndroidNativeBuffer calls (via OMX_SetParameter) rather
475f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar// than UseBuffer calls for that port.
48334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct EnableAndroidNativeBuffersParams {
49334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;
50334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;
51334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;
52334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_BOOL enable;
53334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
54334de520b0369215b7931fefa424fb92d295f0ebJames Dong
559f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// A pointer to this struct is passed to OMX_SetParameter() when the extension index
569f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// "OMX.google.android.index.storeMetaDataInBuffers" or
579f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// "OMX.google.android.index.storeANWBufferInMetadata" is given.
58334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
59334de520b0369215b7931fefa424fb92d295f0ebJames Dong// When meta data is stored in the video buffers passed between OMX clients
60334de520b0369215b7931fefa424fb92d295f0ebJames Dong// and OMX components, interpretation of the buffer data is up to the
61334de520b0369215b7931fefa424fb92d295f0ebJames Dong// buffer receiver, and the data may or may not be the actual video data, but
62334de520b0369215b7931fefa424fb92d295f0ebJames Dong// some information helpful for the receiver to locate the actual data.
63334de520b0369215b7931fefa424fb92d295f0ebJames Dong// The buffer receiver thus needs to know how to interpret what is stored
64334de520b0369215b7931fefa424fb92d295f0ebJames Dong// in these buffers, with mechanisms pre-determined externally. How to
659f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// interpret the meta data is outside of the scope of this parameter.
669f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar//
679f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// Currently, this is used to pass meta data from video source (camera component, for instance) to
689f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// video encoder to avoid memcpying of input video frame data, as well as to pass dynamic output
699f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// buffer to video decoder. To do this, bStoreMetaData is set to OMX_TRUE.
70334de520b0369215b7931fefa424fb92d295f0ebJames Dong//
719f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// If bStoreMetaData is set to false, real YUV frame data will be stored in input buffers, and
729f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// the output buffers contain either real YUV frame data, or are themselves native handles as
739f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// directed by enable/use-android-native-buffer parameter settings.
749f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// In addition, if no OMX_SetParameter() call is made on a port with the corresponding extension
759f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// index, the component should not assume that the client is not using metadata mode for the port.
765f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar//
779f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// If the component supports this using the "OMX.google.android.index.storeANWBufferInMetadata"
789f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// extension and bStoreMetaData is set to OMX_TRUE, data is passed using the VideoNativeMetadata
799f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// layout as defined below. Each buffer will be accompanied by a fence. The fence must signal
809f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// before the buffer can be used (e.g. read from or written into). When returning such buffer to
819f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// the client, component must provide a new fence that must signal before the returned buffer can
829f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// be used (e.g. read from or written into). The component owns the incoming fenceFd, and must close
839f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// it when fence has signaled. The client will own and close the returned fence file descriptor.
845f39f6043da49ca7ab1f682374e055deb73b0c89Lajos Molnar//
859f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// If the component supports this using the "OMX.google.android.index.storeMetaDataInBuffers"
869f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// extension and bStoreMetaData is set to OMX_TRUE, data is passed using VideoGrallocMetadata
879f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// (the layout of which is the VideoGrallocMetadata defined below). Camera input can be also passed
889f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// as "CameraSource", the layout of which is vendor dependent.
899f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar//
909f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// Metadata buffers are registered with the component using UseBuffer calls, or can be allocated
919f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar// by the component for encoder-metadata-output buffers.
92334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct StoreMetaDataInBuffersParams {
93334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;
94334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;
95334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;
96334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_BOOL bStoreMetaData;
97334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
98334de520b0369215b7931fefa424fb92d295f0ebJames Dong
9907d93d197ab41e60f91954592f6ffcd35ed757a0Lajos Molnar// Meta data buffer layout used to transport output frames to the decoder for
10007d93d197ab41e60f91954592f6ffcd35ed757a0Lajos Molnar// dynamic buffer handling.
1019f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnarstruct VideoGrallocMetadata {
1029f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar    MetadataBufferType eType;               // must be kMetadataBufferTypeGrallocSource
103abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
104abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar    OMX_PTR pHandle;
105abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar#else
106d910f3cf78ae878b1b86ead7ca837004c3a25aaaLajos Molnar    buffer_handle_t pHandle;
107abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar#endif
1089f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar};
1099f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar
110a8c2454d52d3c23bd53b4a172eff8e5f4af30168Lajos Molnar// Legacy name for VideoGrallocMetadata struct.
111d910f3cf78ae878b1b86ead7ca837004c3a25aaaLajos Molnarstruct VideoDecoderOutputMetaData : public VideoGrallocMetadata {};
112a8c2454d52d3c23bd53b4a172eff8e5f4af30168Lajos Molnar
1139f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnarstruct VideoNativeMetadata {
1149f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar    MetadataBufferType eType;               // must be kMetadataBufferTypeANWBuffer
115abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar#ifdef OMX_ANDROID_COMPILE_AS_32BIT_ON_64BIT_PLATFORMS
116abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar    OMX_PTR pBuffer;
117abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar#else
1189f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar    struct ANativeWindowBuffer* pBuffer;
119abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar#endif
1209f590df0b73d14e0c30e970098f2369403eb2617Lajos Molnar    int nFenceFd;                           // -1 if unused
12107d93d197ab41e60f91954592f6ffcd35ed757a0Lajos Molnar};
12207d93d197ab41e60f91954592f6ffcd35ed757a0Lajos Molnar
123dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// A pointer to this struct is passed to OMX_SetParameter() when the extension
124dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// index "OMX.google.android.index.prepareForAdaptivePlayback" is given.
125dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar//
126dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// This method is used to signal a video decoder, that the user has requested
127dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// seamless resolution change support (if bEnable is set to OMX_TRUE).
128dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// nMaxFrameWidth and nMaxFrameHeight are the dimensions of the largest
129dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// anticipated frames in the video.  If bEnable is OMX_FALSE, no resolution
130dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// change is expected, and the nMaxFrameWidth/Height fields are unused.
131dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar//
132dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// If the decoder supports dynamic output buffers, it may ignore this
133dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// request.  Otherwise, it shall request resources in such a way so that it
134dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// avoids full port-reconfiguration (due to output port-definition change)
135dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// during resolution changes.
136dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar//
137dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// DO NOT USE THIS STRUCTURE AS IT WILL BE REMOVED.  INSTEAD, IMPLEMENT
138dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar// METADATA SUPPORT FOR VIDEO DECODERS.
139dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnarstruct PrepareForAdaptivePlaybackParams {
140dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar    OMX_U32 nSize;
141dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar    OMX_VERSIONTYPE nVersion;
142dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar    OMX_U32 nPortIndex;
143dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar    OMX_BOOL bEnable;
144dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar    OMX_U32 nMaxFrameWidth;
145dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar    OMX_U32 nMaxFrameHeight;
146dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar};
147dde86f7b1802668a9c0986bcf7970c0e3565a92bLajos Molnar
148334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to OMX_SetParameter when the extension
149334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index for the 'OMX.google.android.index.useAndroidNativeBuffer' extension is
150334de520b0369215b7931fefa424fb92d295f0ebJames Dong// given.  This call will only be performed if a prior call was made with the
151334de520b0369215b7931fefa424fb92d295f0ebJames Dong// 'OMX.google.android.index.enableAndroidNativeBuffers' extension index,
152334de520b0369215b7931fefa424fb92d295f0ebJames Dong// enabling use of Android native buffers.
153334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct UseAndroidNativeBufferParams {
154334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;
155334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;
156334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;
157334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_PTR pAppPrivate;
158334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_BUFFERHEADERTYPE **bufferHeader;
159334de520b0369215b7931fefa424fb92d295f0ebJames Dong    const sp<ANativeWindowBuffer>& nativeBuffer;
160334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
161334de520b0369215b7931fefa424fb92d295f0ebJames Dong
162334de520b0369215b7931fefa424fb92d295f0ebJames Dong// A pointer to this struct is passed to OMX_GetParameter when the extension
163334de520b0369215b7931fefa424fb92d295f0ebJames Dong// index for the 'OMX.google.android.index.getAndroidNativeBufferUsage'
164334de520b0369215b7931fefa424fb92d295f0ebJames Dong// extension is given.  The usage bits returned from this query will be used to
165334de520b0369215b7931fefa424fb92d295f0ebJames Dong// allocate the Gralloc buffers that get passed to the useAndroidNativeBuffer
166334de520b0369215b7931fefa424fb92d295f0ebJames Dong// command.
167334de520b0369215b7931fefa424fb92d295f0ebJames Dongstruct GetAndroidNativeBufferUsageParams {
168334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nSize;              // IN
169334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_VERSIONTYPE nVersion;   // IN
170334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nPortIndex;         // IN
171334de520b0369215b7931fefa424fb92d295f0ebJames Dong    OMX_U32 nUsage;             // OUT
172334de520b0369215b7931fefa424fb92d295f0ebJames Dong};
173334de520b0369215b7931fefa424fb92d295f0ebJames Dong
174334de520b0369215b7931fefa424fb92d295f0ebJames Dong// An enum OMX_COLOR_FormatAndroidOpaque to indicate an opaque colorformat
175334de520b0369215b7931fefa424fb92d295f0ebJames Dong// is declared in media/stagefright/openmax/OMX_IVCommon.h
176334de520b0369215b7931fefa424fb92d295f0ebJames Dong// This will inform the encoder that the actual
177334de520b0369215b7931fefa424fb92d295f0ebJames Dong// colorformat will be relayed by the GRalloc Buffers.
178334de520b0369215b7931fefa424fb92d295f0ebJames Dong// OMX_COLOR_FormatAndroidOpaque  = 0x7F000001,
179334de520b0369215b7931fefa424fb92d295f0ebJames Dong
1807682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber// A pointer to this struct is passed to OMX_SetParameter when the extension
1817682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber// index for the 'OMX.google.android.index.prependSPSPPSToIDRFrames' extension
1827682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber// is given.
1837682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber// A successful result indicates that future IDR frames will be prefixed by
1847682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber// SPS/PPS.
1857682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huberstruct PrependSPSPPSToIDRFramesParams {
1867682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber    OMX_U32 nSize;
1877682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber    OMX_VERSIONTYPE nVersion;
1887682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber    OMX_BOOL bEnable;
1897682a9c35a5e9acae738974ea3a73a4ca7796323Andreas Huber};
190334de520b0369215b7931fefa424fb92d295f0ebJames Dong
191524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// Structure describing a media image (frame)
192524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// Currently only supporting YUV
193524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnarstruct MediaImage {
194524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    enum Type {
195524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar        MEDIA_IMAGE_TYPE_UNKNOWN = 0,
196524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar        MEDIA_IMAGE_TYPE_YUV,
197524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    };
198524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar
199524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    enum PlaneIndex {
200524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar        Y = 0,
201524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar        U,
202524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar        V,
203524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar        MAX_NUM_PLANES
204524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    };
205524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar
206524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    Type mType;
207abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar    uint32_t mNumPlanes;              // number of planes
208abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar    uint32_t mWidth;                  // width of largest plane (unpadded, as in nFrameWidth)
209abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar    uint32_t mHeight;                 // height of largest plane (unpadded, as in nFrameHeight)
210abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar    uint32_t mBitDepth;               // useable bit depth
211524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    struct PlaneInfo {
212abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar        uint32_t mOffset;             // offset of first pixel of the plane in bytes
213abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar                                      // from buffer offset
214abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar        uint32_t mColInc;             // column increment in bytes
215abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar        uint32_t mRowInc;             // row increment in bytes
216abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar        uint32_t mHorizSubsampling;   // subsampling compared to the largest plane
217abaaf7012937710c31e055b74bd3e566cc121ac8Lajos Molnar        uint32_t mVertSubsampling;    // subsampling compared to the largest plane
218524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    };
219524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    PlaneInfo mPlane[MAX_NUM_PLANES];
220524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar};
221524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar
222524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// A pointer to this struct is passed to OMX_GetParameter when the extension
223524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// index for the 'OMX.google.android.index.describeColorFormat'
224524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// extension is given.  This method can be called from any component state
225524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// other than invalid.  The color-format, frame width/height, and stride/
226524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// slice-height parameters are ones that are associated with a raw video
227524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// port (input or output), but the stride/slice height parameters may be
228ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// incorrect. bUsingNativeBuffers is OMX_TRUE if native android buffers will
229ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// be used (while specifying this color format).
230ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar//
231ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// The component shall fill out the MediaImage structure that
232524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// corresponds to the described raw video format, and the potentially corrected
233524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar// stride and slice-height info.
234524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar//
235ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// The behavior is slightly different if bUsingNativeBuffers is OMX_TRUE,
236ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// though most implementations can ignore this difference. When using native buffers,
237ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// the component may change the configured color format to an optimized format.
238ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// Additionally, when allocating these buffers for flexible usecase, the framework
239ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// will set the SW_READ/WRITE_OFTEN usage flags. In this case (if bUsingNativeBuffers
240ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// is OMX_TRUE), the component shall fill out the MediaImage information for the
241ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// scenario when these SW-readable/writable buffers are locked using gralloc_lock.
242ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// Note, that these buffers may also be locked using gralloc_lock_ycbcr, which must
243ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// be supported for vendor-specific formats.
244ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar//
245ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// For non-YUV packed planar/semiplanar image formats, or if bUsingNativeBuffers
246ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// is OMX_TRUE and the component does not support this color format with native
247ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar// buffers, the component shall set mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN.
248524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnarstruct DescribeColorFormatParams {
249524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_U32 nSize;
250524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_VERSIONTYPE nVersion;
251524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE
252524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_COLOR_FORMATTYPE eColorFormat;
253524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_U32 nFrameWidth;
254524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_U32 nFrameHeight;
255524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_U32 nStride;
256524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    OMX_U32 nSliceHeight;
257ea5da67d90647a1d4b395be51bf9cec218b98b71Lajos Molnar    OMX_BOOL bUsingNativeBuffers;
258524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar
259524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    // output: fill out the MediaImage fields
260524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar    MediaImage sMediaImage;
261524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar};
262524077caa6a5e5508af40cf2012d45087ed9e7f3Lajos Molnar
2637cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// A pointer to this struct is passed to OMX_SetParameter or OMX_GetParameter
2647cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// when the extension index for the
2657cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// 'OMX.google.android.index.configureVideoTunnelMode' extension is  given.
2667cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// If the extension is supported then tunneled playback mode should be supported
2677cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// by the codec. If bTunneled is set to OMX_TRUE then the video decoder should
2687cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// operate in "tunneled" mode and output its decoded frames directly to the
2697cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// sink. In this case nAudioHwSync is the HW SYNC ID of the audio HAL Output
2707cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// stream to sync the video with. If bTunneled is set to OMX_FALSE, "tunneled"
2717cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// mode should be disabled and nAudioHwSync should be ignored.
2727cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// OMX_GetParameter is used to query tunneling configuration. bTunneled should
2737cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// return whether decoder is operating in tunneled mode, and if it is,
2747cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad// pSidebandWindow should contain the codec allocated sideband window handle.
2757cb0d39016ff8061fe9fc2967870c145a6ffa2acRachadstruct ConfigureVideoTunnelModeParams {
2767cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    OMX_U32 nSize;              // IN
2777cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    OMX_VERSIONTYPE nVersion;   // IN
2787cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    OMX_U32 nPortIndex;         // IN
2797cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    OMX_BOOL bTunneled;         // IN/OUT
2807cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    OMX_U32 nAudioHwSync;       // IN
2817cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad    OMX_PTR pSidebandWindow;    // OUT
2827cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad};
2837cb0d39016ff8061fe9fc2967870c145a6ffa2acRachad
284334de520b0369215b7931fefa424fb92d295f0ebJames Dong}  // namespace android
285334de520b0369215b7931fefa424fb92d295f0ebJames Dong
286334de520b0369215b7931fefa424fb92d295f0ebJames Dongextern android::OMXPluginBase *createOMXPlugin();
287334de520b0369215b7931fefa424fb92d295f0ebJames Dong
288334de520b0369215b7931fefa424fb92d295f0ebJames Dong#endif  // HARDWARE_API_H_
289