| /*-------------------------------------------------------------------------- |
| Copyright (c) 2017, The Linux Foundation. All rights reserved. |
| |
| Redistribution and use in source and binary forms, with or without |
| modification, are permitted provided that the following conditions are |
| met: |
| * Redistributions of source code must retain the above copyright |
| notice, this list of conditions and the following disclaimer. |
| * Redistributions in binary form must reproduce the above |
| copyright notice, this list of conditions and the following |
| disclaimer in the documentation and/or other materials provided |
| with the distribution. |
| * Neither the name of The Linux Foundation nor the names of its |
| contributors may be used to endorse or promote products derived |
| from this software without specific prior written permission. |
| |
| THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| --------------------------------------------------------------------------*/ |
| |
| void omx_vdec::init_vendor_extensions (VendorExtensionStore &store) { |
| |
| //TODO: add extensions based on Codec, m_platform and/or other capability queries |
| |
| ADD_EXTENSION("qti-ext-dec-picture-order", OMX_QcomIndexParamVideoDecoderPictureOrder, OMX_DirOutput) |
| ADD_PARAM_END("enable", OMX_AndroidVendorValueInt32) |
| |
| ADD_EXTENSION("qti-ext-dec-low-latency", OMX_QTIIndexParamLowLatencyMode, OMX_DirOutput) |
| ADD_PARAM_END("enable", OMX_AndroidVendorValueInt32) |
| |
| ADD_EXTENSION("qti-ext-extradata-enable", OMX_QcomIndexParamIndexExtraDataType, OMX_DirOutput) |
| ADD_PARAM_END("types", OMX_AndroidVendorValueString) |
| |
| ADD_EXTENSION("qti-ext-dec-caps-vt-driver-version", OMX_QTIIndexParamCapabilitiesVTDriverVersion, OMX_DirOutput) |
| ADD_PARAM_END("number", OMX_AndroidVendorValueInt32) |
| } |
| |
| |
| OMX_ERRORTYPE omx_vdec::get_vendor_extension_config( |
| OMX_CONFIG_ANDROID_VENDOR_EXTENSIONTYPE *ext) { |
| if (ext->nIndex >= mVendorExtensionStore.size()) { |
| return OMX_ErrorNoMore; |
| } |
| |
| const VendorExtension& vExt = mVendorExtensionStore[ext->nIndex]; |
| DEBUG_PRINT_LOW("VendorExt: getConfig: index=%u (%s)", ext->nIndex, vExt.name()); |
| |
| vExt.copyInfoTo(ext); |
| if (ext->nParamSizeUsed < vExt.paramCount()) { |
| // this happens during initial getConfig to query only extension-name and param-count |
| return OMX_ErrorNone; |
| } |
| |
| // We now have sufficient params allocated in extension data passed. |
| // Following code is to set the extension-specific data |
| |
| bool setStatus = true; |
| |
| switch ((OMX_U32)vExt.extensionIndex()) { |
| case OMX_QcomIndexParamVideoDecoderPictureOrder: |
| { |
| setStatus &= vExt.setParamInt32(ext, "enable", m_decode_order_mode); |
| break; |
| } |
| case OMX_QTIIndexParamLowLatencyMode: |
| { |
| setStatus &= vExt.setParamInt32(ext, "enable", m_sParamLowLatency.bEnableLowLatencyMode); |
| break; |
| } |
| case OMX_QcomIndexParamIndexExtraDataType: |
| { |
| char exType[OMX_MAX_STRINGVALUE_SIZE + 1]; |
| memset (exType, 0, (sizeof(char)*OMX_MAX_STRINGVALUE_SIZE)); |
| if ((OMX_BOOL)(client_extradata & OMX_OUTPUTCROP_EXTRADATA)){ |
| const char * outputCropInfo = getStringForExtradataType(OMX_ExtraDataOutputCropInfo); |
| if (outputCropInfo != NULL && |
| (strlcat(exType, outputCropInfo, |
| OMX_MAX_STRINGVALUE_SIZE)) >= OMX_MAX_STRINGVALUE_SIZE) { |
| DEBUG_PRINT_LOW("extradata string size exceeds size %d",OMX_MAX_STRINGVALUE_SIZE); |
| } |
| } |
| |
| setStatus &= vExt.setParamString(ext, "types", exType); |
| DEBUG_PRINT_LOW("VendorExt: getparam: Extradata %s", exType); |
| break; |
| } |
| case OMX_QTIIndexParamCapabilitiesVTDriverVersion: |
| { |
| setStatus &= vExt.setParamInt32(ext, "number", 65536); |
| break; |
| } |
| default: |
| { |
| return OMX_ErrorNotImplemented; |
| } |
| } |
| return setStatus ? OMX_ErrorNone : OMX_ErrorUndefined; |
| } |
| |
| OMX_ERRORTYPE omx_vdec::set_vendor_extension_config( |
| OMX_CONFIG_ANDROID_VENDOR_EXTENSIONTYPE *ext) { |
| |
| DEBUG_PRINT_LOW("set_vendor_extension_config"); |
| if (ext->nIndex >= mVendorExtensionStore.size()) { |
| DEBUG_PRINT_ERROR("unrecognized vendor extension index (%u) max(%u)", |
| ext->nIndex, mVendorExtensionStore.size()); |
| return OMX_ErrorBadParameter; |
| } |
| |
| const VendorExtension& vExt = mVendorExtensionStore[ext->nIndex]; |
| DEBUG_PRINT_LOW("VendorExt: setConfig: index=%u (%s)", ext->nIndex, vExt.name()); |
| |
| OMX_ERRORTYPE err = OMX_ErrorNone; |
| err = vExt.isConfigValid(ext); |
| if (err != OMX_ErrorNone) { |
| return err; |
| } |
| |
| // mark this as set, regardless of set_config succeeding/failing. |
| // App will know by inconsistent values in output-format |
| vExt.set(); |
| |
| bool valueSet = false; |
| switch ((OMX_U32)vExt.extensionIndex()) { |
| case OMX_QcomIndexParamVideoDecoderPictureOrder: |
| { |
| OMX_S32 pic_order_enable = 0; |
| valueSet |= vExt.readParamInt32(ext, "enable", &pic_order_enable); |
| if (!valueSet) { |
| break; |
| } |
| |
| DEBUG_PRINT_HIGH("VENDOR-EXT: set_config: OMX_QcomIndexParamVideoDecoderPictureOrder : %d", |
| pic_order_enable); |
| |
| QOMX_VIDEO_DECODER_PICTURE_ORDER decParam; |
| OMX_INIT_STRUCT(&decParam, QOMX_VIDEO_DECODER_PICTURE_ORDER); |
| decParam.eOutputPictureOrder = |
| pic_order_enable ? QOMX_VIDEO_DECODE_ORDER : QOMX_VIDEO_DISPLAY_ORDER; |
| decParam.nPortIndex = OMX_DirOutput; |
| |
| err = set_parameter( |
| NULL, (OMX_INDEXTYPE)OMX_QcomIndexParamVideoDecoderPictureOrder, &decParam); |
| if (err != OMX_ErrorNone) { |
| DEBUG_PRINT_ERROR("set_config: OMX_QcomIndexParamVideoDecoderPictureOrder failed !"); |
| } |
| break; |
| } |
| case OMX_QTIIndexParamLowLatencyMode: |
| { |
| QOMX_EXTNINDEX_VIDEO_LOW_LATENCY_MODE lowLatency; |
| memcpy(&lowLatency, &m_sParamLowLatency, sizeof(QOMX_EXTNINDEX_VIDEO_LOW_LATENCY_MODE)); |
| valueSet |= vExt.readParamInt32(ext, "enable", (OMX_S32 *)&(lowLatency.bEnableLowLatencyMode)); |
| if (!valueSet) { |
| break; |
| } |
| |
| DEBUG_PRINT_HIGH("VENDOR-EXT: set_param: low latency mode =%u", lowLatency.bEnableLowLatencyMode); |
| err = set_parameter( |
| NULL, (OMX_INDEXTYPE)OMX_QTIIndexParamLowLatencyMode, &lowLatency); |
| if (err != OMX_ErrorNone) { |
| DEBUG_PRINT_ERROR("set_param: OMX_QTIIndexParamLowLatencyMode failed !"); |
| } |
| |
| break; |
| } |
| case OMX_QcomIndexParamIndexExtraDataType: |
| { |
| QOMX_INDEXEXTRADATATYPE extraDataParam; |
| char exType[OMX_MAX_STRINGVALUE_SIZE]; |
| OMX_INIT_STRUCT(&extraDataParam, QOMX_INDEXEXTRADATATYPE); |
| valueSet |= vExt.readParamString(ext, "types", exType); |
| if (!valueSet) { |
| break; |
| } |
| char *rest = exType; |
| char *token = strtok_r(exType, "|", &rest); |
| do { |
| extraDataParam.bEnabled = OMX_TRUE; |
| extraDataParam.nIndex = (OMX_INDEXTYPE)getIndexForExtradataType(token); |
| if (extraDataParam.nIndex < 0) { |
| DEBUG_PRINT_HIGH(" extradata %s not supported ", token); |
| continue; |
| } |
| if (extraDataParam.nIndex == (OMX_INDEXTYPE)OMX_ExtraDataOutputCropInfo) { |
| extraDataParam.nPortIndex = OMX_CORE_OUTPUT_PORT_INDEX; |
| } |
| DEBUG_PRINT_HIGH("VENDOR-EXT: set_config: extradata: enable for index = %x", |
| extraDataParam.nIndex); |
| err = set_parameter( |
| NULL, (OMX_INDEXTYPE)OMX_QcomIndexParamIndexExtraDataType, &extraDataParam); |
| if (err != OMX_ErrorNone) { |
| DEBUG_PRINT_ERROR("set_config: OMX_QcomIndexParamIndexExtraDataType failed !"); |
| } |
| } while ((token = strtok_r(NULL, "|", &rest))); |
| break; |
| } |
| case OMX_QTIIndexParamCapabilitiesVTDriverVersion: |
| { |
| break; |
| } |
| default: |
| { |
| return OMX_ErrorNotImplemented; |
| } |
| } |
| |
| return err; |
| } |