From 524077caa6a5e5508af40cf2012d45087ed9e7f3 Mon Sep 17 00:00:00 2001 From: Lajos Molnar Date: Fri, 25 Jul 2014 07:53:56 -0700 Subject: [PATCH] OMX: add supporting methods for flexible YUV Bug: 10706245 Change-Id: I2427930a34c468e49d3db7ba2865344f1fba2960 --- include/media/hardware/HardwareAPI.h | 57 ++++++++++++++++++++++++++++ include/media/openmax/OMX_IVCommon.h | 7 ++++ 2 files changed, 64 insertions(+) diff --git a/include/media/hardware/HardwareAPI.h b/include/media/hardware/HardwareAPI.h index de3aeb154..88e7ad33e 100644 --- a/include/media/hardware/HardwareAPI.h +++ b/include/media/hardware/HardwareAPI.h @@ -157,6 +157,63 @@ struct PrependSPSPPSToIDRFramesParams { OMX_BOOL bEnable; }; +// Structure describing a media image (frame) +// Currently only supporting YUV +struct MediaImage { + enum Type { + MEDIA_IMAGE_TYPE_UNKNOWN = 0, + MEDIA_IMAGE_TYPE_YUV, + }; + + enum PlaneIndex { + Y = 0, + U, + V, + MAX_NUM_PLANES + }; + + Type mType; + size_t mNumPlanes; // number of planes + size_t mWidth; // width of largest plane + size_t mHeight; // height of largest plane + size_t mBitDepth; // useable bit depth + struct PlaneInfo { + size_t mOffset; // offset of first pixel of the plane in bytes + // from buffer offset + size_t mColInc; // column increment in bytes + size_t mRowInc; // row increment in bytes + size_t mHorizSubsampling; // subsampling compared to the largest plane + size_t mVertSubsampling; // subsampling compared to the largest plane + }; + PlaneInfo mPlane[MAX_NUM_PLANES]; +}; + +// A pointer to this struct is passed to OMX_GetParameter when the extension +// index for the 'OMX.google.android.index.describeColorFormat' +// extension is given. This method can be called from any component state +// other than invalid. The color-format, frame width/height, and stride/ +// slice-height parameters are ones that are associated with a raw video +// port (input or output), but the stride/slice height parameters may be +// incorrect. The component shall fill out the MediaImage structure that +// corresponds to the described raw video format, and the potentially corrected +// stride and slice-height info. +// +// For non-YUV packed planar/semiplanar image formats, the component shall set +// mNumPlanes to 0, and mType to MEDIA_IMAGE_TYPE_UNKNOWN. +struct DescribeColorFormatParams { + OMX_U32 nSize; + OMX_VERSIONTYPE nVersion; + // input: parameters from OMX_VIDEO_PORTDEFINITIONTYPE + OMX_COLOR_FORMATTYPE eColorFormat; + OMX_U32 nFrameWidth; + OMX_U32 nFrameHeight; + OMX_U32 nStride; + OMX_U32 nSliceHeight; + + // output: fill out the MediaImage fields + MediaImage sMediaImage; +}; + } // namespace android extern android::OMXPluginBase *createOMXPlugin(); diff --git a/include/media/openmax/OMX_IVCommon.h b/include/media/openmax/OMX_IVCommon.h index 96a4396e2..5f9e9b6ac 100644 --- a/include/media/openmax/OMX_IVCommon.h +++ b/include/media/openmax/OMX_IVCommon.h @@ -157,6 +157,13 @@ typedef enum OMX_COLOR_FORMATTYPE { * an acceptable range once that is done. * */ OMX_COLOR_FormatAndroidOpaque = 0x7F000789, + /** Flexible 8-bit YUV format. Codec should report this format + * as being supported if it supports any YUV420 packed planar + * or semiplanar formats. When port is set to use this format, + * codec can substitute any YUV420 packed planar or semiplanar + * format for it. */ + OMX_COLOR_FormatYUV420Flexible = 0x7F420888, + OMX_TI_COLOR_FormatYUV420PackedSemiPlanar = 0x7F000100, OMX_QCOM_COLOR_FormatYVU420SemiPlanar = 0x7FA30C00, OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7FA30C03,