| /*-------------------------------------------------------------------------- |
| 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) |
| } |
| |
| |
| 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; |
| } |
| default: |
| { |
| return OMX_ErrorNotImplemented; |
| } |
| } |
| return setStatus ? OMX_ErrorNone : OMX_ErrorUndefined; |
| } |
| |
| OMX_ERRORTYPE omx_vdec::set_vendor_extension_config( |
| OMX_CONFIG_ANDROID_VENDOR_EXTENSIONTYPE *ext) { |
| |
| ALOGI("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; |
| } |
| default: |
| { |
| return OMX_ErrorNotImplemented; |
| } |
| } |
| |
| return err; |
| } |