147e37c4428509524ee576920a98381f3e4872493Nick Pelly/*-------------------------------------------------------------------------- 2dd5743ee305c8db17facba3e0176a3d07adc7499Rom LemarchandCopyright (c) 2010-2012, The Linux Foundation. All rights reserved. 347e37c4428509524ee576920a98381f3e4872493Nick Pelly 447e37c4428509524ee576920a98381f3e4872493Nick PellyRedistribution and use in source and binary forms, with or without 547e37c4428509524ee576920a98381f3e4872493Nick Pellymodification, are permitted provided that the following conditions are met: 647e37c4428509524ee576920a98381f3e4872493Nick Pelly * Redistributions of source code must retain the above copyright 747e37c4428509524ee576920a98381f3e4872493Nick Pelly notice, this list of conditions and the following disclaimer. 847e37c4428509524ee576920a98381f3e4872493Nick Pelly * Redistributions in binary form must reproduce the above copyright 947e37c4428509524ee576920a98381f3e4872493Nick Pelly notice, this list of conditions and the following disclaimer in the 1047e37c4428509524ee576920a98381f3e4872493Nick Pelly documentation and/or other materials provided with the distribution. 11dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand * Neither the name of Code Aurora nor 1247e37c4428509524ee576920a98381f3e4872493Nick Pelly the names of its contributors may be used to endorse or promote 1347e37c4428509524ee576920a98381f3e4872493Nick Pelly products derived from this software without specific prior written 1447e37c4428509524ee576920a98381f3e4872493Nick Pelly permission. 1547e37c4428509524ee576920a98381f3e4872493Nick Pelly 1647e37c4428509524ee576920a98381f3e4872493Nick PellyTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 1747e37c4428509524ee576920a98381f3e4872493Nick PellyAND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1847e37c4428509524ee576920a98381f3e4872493Nick PellyIMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 1947e37c4428509524ee576920a98381f3e4872493Nick PellyNON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 2047e37c4428509524ee576920a98381f3e4872493Nick PellyCONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 2147e37c4428509524ee576920a98381f3e4872493Nick PellyEXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 2247e37c4428509524ee576920a98381f3e4872493Nick PellyPROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 2347e37c4428509524ee576920a98381f3e4872493Nick PellyOR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 2447e37c4428509524ee576920a98381f3e4872493Nick PellyWHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 2547e37c4428509524ee576920a98381f3e4872493Nick PellyOTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 2647e37c4428509524ee576920a98381f3e4872493Nick PellyADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2747e37c4428509524ee576920a98381f3e4872493Nick Pelly--------------------------------------------------------------------------*/ 2847e37c4428509524ee576920a98381f3e4872493Nick Pelly#include "omx_video_encoder.h" 2947e37c4428509524ee576920a98381f3e4872493Nick Pelly#include <string.h> 3047e37c4428509524ee576920a98381f3e4872493Nick Pelly#include "video_encoder_device.h" 3147e37c4428509524ee576920a98381f3e4872493Nick Pelly#include <stdio.h> 32826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 33826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#include <media/hardware/HardwareAPI.h> 34826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 35826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ 36826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#include <cutils/properties.h> 37826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 38826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifndef _ANDROID_ 39826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#include <glib.h> 40826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#define strlcpy g_strlcpy 41826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 4247e37c4428509524ee576920a98381f3e4872493Nick Pelly/*---------------------------------------------------------------------------- 4347e37c4428509524ee576920a98381f3e4872493Nick Pelly* Preprocessor Definitions and Constants 4447e37c4428509524ee576920a98381f3e4872493Nick Pelly* -------------------------------------------------------------------------*/ 4547e37c4428509524ee576920a98381f3e4872493Nick Pelly 4647e37c4428509524ee576920a98381f3e4872493Nick Pelly#define OMX_SPEC_VERSION 0x00000101 4747e37c4428509524ee576920a98381f3e4872493Nick Pelly#define OMX_INIT_STRUCT(_s_, _name_) \ 4847e37c4428509524ee576920a98381f3e4872493Nick Pelly memset((_s_), 0x0, sizeof(_name_)); \ 4947e37c4428509524ee576920a98381f3e4872493Nick Pelly (_s_)->nSize = sizeof(_name_); \ 5047e37c4428509524ee576920a98381f3e4872493Nick Pelly (_s_)->nVersion.nVersion = OMX_SPEC_VERSION 5147e37c4428509524ee576920a98381f3e4872493Nick Pelly 5247e37c4428509524ee576920a98381f3e4872493Nick Pellyextern int m_pipe; 5347e37c4428509524ee576920a98381f3e4872493Nick Pelly 5447e37c4428509524ee576920a98381f3e4872493Nick Pelly// factory function executed by the core to create instances 5547e37c4428509524ee576920a98381f3e4872493Nick Pellyvoid *get_omx_component_factory_fn(void) 5647e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 5747e37c4428509524ee576920a98381f3e4872493Nick Pelly return(new omx_venc); 5847e37c4428509524ee576920a98381f3e4872493Nick Pelly} 5947e37c4428509524ee576920a98381f3e4872493Nick Pelly 6047e37c4428509524ee576920a98381f3e4872493Nick Pelly//constructor 6147e37c4428509524ee576920a98381f3e4872493Nick Pelly 6247e37c4428509524ee576920a98381f3e4872493Nick Pellyomx_venc::omx_venc() 6347e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 64826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 65826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev meta_mode_enable = false; 66826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memset(meta_buffer_hdr,0,sizeof(meta_buffer_hdr)); 67826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memset(meta_buffers,0,sizeof(meta_buffers)); 68dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand memset(opaque_buffer_hdr,0,sizeof(opaque_buffer_hdr)); 69826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev mUseProxyColorFormat = false; 70826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 7147e37c4428509524ee576920a98381f3e4872493Nick Pelly} 7247e37c4428509524ee576920a98381f3e4872493Nick Pelly 7347e37c4428509524ee576920a98381f3e4872493Nick Pellyomx_venc::~omx_venc() 7447e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 7547e37c4428509524ee576920a98381f3e4872493Nick Pelly //nothing to do 7647e37c4428509524ee576920a98381f3e4872493Nick Pelly} 7747e37c4428509524ee576920a98381f3e4872493Nick Pelly 7847e37c4428509524ee576920a98381f3e4872493Nick Pelly/* ====================================================================== 7947e37c4428509524ee576920a98381f3e4872493Nick PellyFUNCTION 8047e37c4428509524ee576920a98381f3e4872493Nick Pelly omx_venc::ComponentInit 8147e37c4428509524ee576920a98381f3e4872493Nick Pelly 8247e37c4428509524ee576920a98381f3e4872493Nick PellyDESCRIPTION 8347e37c4428509524ee576920a98381f3e4872493Nick Pelly Initialize the component. 8447e37c4428509524ee576920a98381f3e4872493Nick Pelly 8547e37c4428509524ee576920a98381f3e4872493Nick PellyPARAMETERS 8647e37c4428509524ee576920a98381f3e4872493Nick Pelly ctxt -- Context information related to the self. 8747e37c4428509524ee576920a98381f3e4872493Nick Pelly id -- Event identifier. This could be any of the following: 8847e37c4428509524ee576920a98381f3e4872493Nick Pelly 1. Command completion event 8947e37c4428509524ee576920a98381f3e4872493Nick Pelly 2. Buffer done callback event 9047e37c4428509524ee576920a98381f3e4872493Nick Pelly 3. Frame done callback event 9147e37c4428509524ee576920a98381f3e4872493Nick Pelly 9247e37c4428509524ee576920a98381f3e4872493Nick PellyRETURN VALUE 9347e37c4428509524ee576920a98381f3e4872493Nick Pelly None. 9447e37c4428509524ee576920a98381f3e4872493Nick Pelly 9547e37c4428509524ee576920a98381f3e4872493Nick Pelly========================================================================== */ 9647e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_ERRORTYPE omx_venc::component_init(OMX_STRING role) 9747e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 9847e37c4428509524ee576920a98381f3e4872493Nick Pelly 9947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_ERRORTYPE eRet = OMX_ErrorNone; 10047e37c4428509524ee576920a98381f3e4872493Nick Pelly 10147e37c4428509524ee576920a98381f3e4872493Nick Pelly int fds[2]; 10247e37c4428509524ee576920a98381f3e4872493Nick Pelly int r; 10347e37c4428509524ee576920a98381f3e4872493Nick Pelly 10447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_CODINGTYPE codec_type; 10547e37c4428509524ee576920a98381f3e4872493Nick Pelly 10647e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("\n omx_venc(): Inside component_init()"); 10747e37c4428509524ee576920a98381f3e4872493Nick Pelly // Copy the role information which provides the decoder m_nkind 108826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char *)m_nkind,role,OMX_MAX_STRINGNAME_SIZE); 10947e37c4428509524ee576920a98381f3e4872493Nick Pelly 11047e37c4428509524ee576920a98381f3e4872493Nick Pelly if(!strncmp((char *)m_nkind,"OMX.qcom.video.encoder.mpeg4",\ 11147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_MAX_STRINGNAME_SIZE)) 11247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 113826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char *)m_cRole, "video_encoder.mpeg4",\ 11447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_MAX_STRINGNAME_SIZE); 11547e37c4428509524ee576920a98381f3e4872493Nick Pelly codec_type = OMX_VIDEO_CodingMPEG4; 11647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 11747e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.h263",\ 11847e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_MAX_STRINGNAME_SIZE)) 11947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 120826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char *)m_cRole, "video_encoder.h263",OMX_MAX_STRINGNAME_SIZE); 12147e37c4428509524ee576920a98381f3e4872493Nick Pelly codec_type = OMX_VIDEO_CodingH263; 12247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 12347e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc",\ 12447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_MAX_STRINGNAME_SIZE)) 12547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 126826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char *)m_cRole, "video_encoder.avc",OMX_MAX_STRINGNAME_SIZE); 12747e37c4428509524ee576920a98381f3e4872493Nick Pelly codec_type = OMX_VIDEO_CodingAVC; 12847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 129dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc.secure",\ 1307783f07680c4e868295efbd0cf55a1622a106522Deva Ramasubramanian OMX_MAX_STRINGNAME_SIZE)) 1317783f07680c4e868295efbd0cf55a1622a106522Deva Ramasubramanian { 132dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand strlcpy((char *)m_cRole, "video_encoder.avc",OMX_MAX_STRINGNAME_SIZE); 133dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand codec_type = OMX_VIDEO_CodingAVC; 134dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand secure_session = true; 1357783f07680c4e868295efbd0cf55a1622a106522Deva Ramasubramanian } 13647e37c4428509524ee576920a98381f3e4872493Nick Pelly else 13747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 13847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: Unknown Component\n"); 13947e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorInvalidComponentName; 14047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 14147e37c4428509524ee576920a98381f3e4872493Nick Pelly 14247e37c4428509524ee576920a98381f3e4872493Nick Pelly 14347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(eRet != OMX_ErrorNone) 14447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 14547e37c4428509524ee576920a98381f3e4872493Nick Pelly return eRet; 14647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 14747e37c4428509524ee576920a98381f3e4872493Nick Pelly 148826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev handle = new venc_dev(this); 14947e37c4428509524ee576920a98381f3e4872493Nick Pelly 15047e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle == NULL) 15147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 15247e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: handle is NULL"); 15347e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorInsufficientResources; 15447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 15547e37c4428509524ee576920a98381f3e4872493Nick Pelly 15647e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_open(codec_type) != true) 15747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 15847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: venc_open failed"); 15947e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorInsufficientResources; 16047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 16147e37c4428509524ee576920a98381f3e4872493Nick Pelly 16247e37c4428509524ee576920a98381f3e4872493Nick Pelly //Intialise the OMX layer variables 16347e37c4428509524ee576920a98381f3e4872493Nick Pelly memset(&m_pCallbacks,0,sizeof(OMX_CALLBACKTYPE)); 16447e37c4428509524ee576920a98381f3e4872493Nick Pelly 16547e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sPortParam, OMX_PORT_PARAM_TYPE); 16647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPortParam.nPorts = 0x2; 16747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPortParam.nStartPortNumber = (OMX_U32) PORT_INDEX_IN; 16847e37c4428509524ee576920a98381f3e4872493Nick Pelly 16947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sPortParam_audio, OMX_PORT_PARAM_TYPE); 17047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPortParam_audio.nPorts = 0; 17147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPortParam_audio.nStartPortNumber = 0; 17247e37c4428509524ee576920a98381f3e4872493Nick Pelly 17347e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sPortParam_img, OMX_PORT_PARAM_TYPE); 17447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPortParam_img.nPorts = 0; 17547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPortParam_img.nStartPortNumber = 0; 17647e37c4428509524ee576920a98381f3e4872493Nick Pelly 17747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sParamBitrate, OMX_VIDEO_PARAM_BITRATETYPE); 17847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 17947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.eControlRate = OMX_Video_ControlRateVariableSkipFrames; 18047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.nTargetBitrate = 64000; 18147e37c4428509524ee576920a98381f3e4872493Nick Pelly 18247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sConfigBitrate, OMX_VIDEO_CONFIG_BITRATETYPE); 18347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigBitrate.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 18447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigBitrate.nEncodeBitrate = 64000; 18547e37c4428509524ee576920a98381f3e4872493Nick Pelly 18647e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sConfigFramerate, OMX_CONFIG_FRAMERATETYPE); 18747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigFramerate.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 18847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigFramerate.xEncodeFramerate = 30 << 16; 18947e37c4428509524ee576920a98381f3e4872493Nick Pelly 19047e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sConfigIntraRefreshVOP, OMX_CONFIG_INTRAREFRESHVOPTYPE); 19147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigIntraRefreshVOP.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 19247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigIntraRefreshVOP.IntraRefreshVOP = OMX_FALSE; 19347e37c4428509524ee576920a98381f3e4872493Nick Pelly 19447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sConfigFrameRotation, OMX_CONFIG_ROTATIONTYPE); 195826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sConfigFrameRotation.nPortIndex = (OMX_U32) PORT_INDEX_IN; 19647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigFrameRotation.nRotation = 0; 19747e37c4428509524ee576920a98381f3e4872493Nick Pelly 19847e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sSessionQuantization, OMX_VIDEO_PARAM_QUANTIZATIONTYPE); 19947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sSessionQuantization.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 20047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sSessionQuantization.nQpI = 9; 20147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sSessionQuantization.nQpP = 6; 20247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sSessionQuantization.nQpB = 2; 20347e37c4428509524ee576920a98381f3e4872493Nick Pelly 20447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sAVCSliceFMO, OMX_VIDEO_PARAM_AVCSLICEFMO); 20547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sAVCSliceFMO.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 20647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sAVCSliceFMO.eSliceMode = OMX_VIDEO_SLICEMODE_AVCDefault; 20747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sAVCSliceFMO.nNumSliceGroups = 0; 20847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sAVCSliceFMO.nSliceGroupMapType = 0; 20947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sParamProfileLevel, OMX_VIDEO_PARAM_PROFILELEVELTYPE); 21047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 21147e37c4428509524ee576920a98381f3e4872493Nick Pelly 212826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_INIT_STRUCT(&m_sIntraperiod, QOMX_VIDEO_INTRAPERIODTYPE); 213826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraperiod.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 214826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraperiod.nPFrames = (m_sConfigFramerate.xEncodeFramerate * 2) - 1; 215826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 216826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_INIT_STRUCT(&m_sErrorCorrection, OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE); 217826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sErrorCorrection.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 218826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sErrorCorrection.bEnableDataPartitioning = OMX_FALSE; 219826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sErrorCorrection.bEnableHEC = OMX_FALSE; 220826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sErrorCorrection.bEnableResync = OMX_FALSE; 221826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sErrorCorrection.bEnableRVLC = OMX_FALSE; 222826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sErrorCorrection.nResynchMarkerSpacing = 0; 223826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 224826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_INIT_STRUCT(&m_sIntraRefresh, OMX_VIDEO_PARAM_INTRAREFRESHTYPE); 225826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraRefresh.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 226826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraRefresh.eRefreshMode = OMX_VIDEO_IntraRefreshMax; 227826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 22847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(codec_type == OMX_VIDEO_CodingMPEG4) 22947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 23047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eProfile = (OMX_U32) OMX_VIDEO_MPEG4ProfileSimple; 23147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eLevel = (OMX_U32) OMX_VIDEO_MPEG4Level0; 23247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 23347e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(codec_type == OMX_VIDEO_CodingH263) 23447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 23547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eProfile = (OMX_U32) OMX_VIDEO_H263ProfileBaseline; 23647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eLevel = (OMX_U32) OMX_VIDEO_H263Level10; 23747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 23847e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(codec_type == OMX_VIDEO_CodingAVC) 23947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 24047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eProfile = (OMX_U32) OMX_VIDEO_AVCProfileBaseline; 24147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eLevel = (OMX_U32) OMX_VIDEO_AVCLevel1; 24247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 24347e37c4428509524ee576920a98381f3e4872493Nick Pelly 24447e37c4428509524ee576920a98381f3e4872493Nick Pelly // Initialize the video parameters for input port 24547e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sInPortDef, OMX_PARAM_PORTDEFINITIONTYPE); 24647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.nPortIndex= (OMX_U32) PORT_INDEX_IN; 24747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.bEnabled = OMX_TRUE; 24847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.bPopulated = OMX_FALSE; 24947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.eDomain = OMX_PortDomainVideo; 25047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.eDir = OMX_DirInput; 25147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.cMIMEType = "YUV420"; 25247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.nFrameWidth = OMX_CORE_QCIF_WIDTH; 25347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.nFrameHeight = OMX_CORE_QCIF_HEIGHT; 254826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nStride = OMX_CORE_QCIF_WIDTH; 255826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nSliceHeight = OMX_CORE_QCIF_HEIGHT; 25647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.nBitrate = 64000; 25747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.xFramerate = 15 << 16; 25847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; 25947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; 26047e37c4428509524ee576920a98381f3e4872493Nick Pelly 26147e37c4428509524ee576920a98381f3e4872493Nick Pelly if(dev_get_buf_req(&m_sInPortDef.nBufferCountMin, 26247e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sInPortDef.nBufferCountActual, 26347e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sInPortDef.nBufferSize, 26447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.nPortIndex) != true) 26547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 26647e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorUndefined; 26747e37c4428509524ee576920a98381f3e4872493Nick Pelly 26847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 26947e37c4428509524ee576920a98381f3e4872493Nick Pelly 27047e37c4428509524ee576920a98381f3e4872493Nick Pelly // Initialize the video parameters for output port 27147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sOutPortDef, OMX_PARAM_PORTDEFINITIONTYPE); 27247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 27347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.bEnabled = OMX_TRUE; 27447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.bPopulated = OMX_FALSE; 27547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.eDomain = OMX_PortDomainVideo; 27647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.eDir = OMX_DirOutput; 27747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.nFrameWidth = OMX_CORE_QCIF_WIDTH; 27847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.nFrameHeight = OMX_CORE_QCIF_HEIGHT; 27947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.nBitrate = 64000; 28047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.xFramerate = 15 << 16; 28147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.eColorFormat = OMX_COLOR_FormatUnused; 28247e37c4428509524ee576920a98381f3e4872493Nick Pelly if(codec_type == OMX_VIDEO_CodingMPEG4) 28347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 28447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingMPEG4; 28547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 28647e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(codec_type == OMX_VIDEO_CodingH263) 28747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 28847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingH263; 28947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 29047e37c4428509524ee576920a98381f3e4872493Nick Pelly else 29147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 29247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; 29347e37c4428509524ee576920a98381f3e4872493Nick Pelly } 29447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(dev_get_buf_req(&m_sOutPortDef.nBufferCountMin, 29547e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sOutPortDef.nBufferCountActual, 29647e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sOutPortDef.nBufferSize, 29747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.nPortIndex) != true) 29847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 29947e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorUndefined; 30047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 30147e37c4428509524ee576920a98381f3e4872493Nick Pelly 30247e37c4428509524ee576920a98381f3e4872493Nick Pelly // Initialize the video color format for input port 30347e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sInPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE); 30447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortFormat.nPortIndex = (OMX_U32) PORT_INDEX_IN; 30547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortFormat.nIndex = 0; 30647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortFormat.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; 30747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortFormat.eCompressionFormat = OMX_VIDEO_CodingUnused; 30847e37c4428509524ee576920a98381f3e4872493Nick Pelly 30947e37c4428509524ee576920a98381f3e4872493Nick Pelly 31047e37c4428509524ee576920a98381f3e4872493Nick Pelly // Initialize the compression format for output port 31147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sOutPortFormat, OMX_VIDEO_PARAM_PORTFORMATTYPE); 31247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 31347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.nIndex = 0; 31447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.eColorFormat = OMX_COLOR_FormatUnused; 31547e37c4428509524ee576920a98381f3e4872493Nick Pelly if(codec_type == OMX_VIDEO_CodingMPEG4) 31647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 31747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.eCompressionFormat = OMX_VIDEO_CodingMPEG4; 31847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 31947e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(codec_type == OMX_VIDEO_CodingH263) 32047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 32147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.eCompressionFormat = OMX_VIDEO_CodingH263; 32247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 32347e37c4428509524ee576920a98381f3e4872493Nick Pelly else 32447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 32547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.eCompressionFormat = OMX_VIDEO_CodingAVC; 32647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 32747e37c4428509524ee576920a98381f3e4872493Nick Pelly 32847e37c4428509524ee576920a98381f3e4872493Nick Pelly // mandatory Indices for kronos test suite 32947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sPriorityMgmt, OMX_PRIORITYMGMTTYPE); 33047e37c4428509524ee576920a98381f3e4872493Nick Pelly 33147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sInBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE); 33247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInBufSupplier.nPortIndex = (OMX_U32) PORT_INDEX_IN; 33347e37c4428509524ee576920a98381f3e4872493Nick Pelly 33447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sOutBufSupplier, OMX_PARAM_BUFFERSUPPLIERTYPE); 33547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutBufSupplier.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 33647e37c4428509524ee576920a98381f3e4872493Nick Pelly 33747e37c4428509524ee576920a98381f3e4872493Nick Pelly 33847e37c4428509524ee576920a98381f3e4872493Nick Pelly // mp4 specific init 33947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sParamMPEG4, OMX_VIDEO_PARAM_MPEG4TYPE); 34047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 34147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.eProfile = OMX_VIDEO_MPEG4ProfileSimple; 34247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.eLevel = OMX_VIDEO_MPEG4Level0; 34347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.nSliceHeaderSpacing = 0; 34447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.bSVH = OMX_FALSE; 34547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.bGov = OMX_FALSE; 346826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.nPFrames = (m_sOutPortFormat.xFramerate * 2 - 1); // 2 second intra period for default outport fps 34747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.bACPred = OMX_TRUE; 34847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.nTimeIncRes = 30; // delta = 2 @ 15 fps 34947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.nAllowedPictureTypes = 2; // pframe and iframe 35047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.nHeaderExtension = 1; // number of video packet headers per vop 35147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.bReversibleVLC = OMX_FALSE; 35247e37c4428509524ee576920a98381f3e4872493Nick Pelly 35347e37c4428509524ee576920a98381f3e4872493Nick Pelly // h263 specific init 35447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_INIT_STRUCT(&m_sParamH263, OMX_VIDEO_PARAM_H263TYPE); 35547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 356826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.nPFrames = (m_sOutPortFormat.xFramerate * 2 - 1); // 2 second intra period for default outport fps 35747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.nBFrames = 0; 35847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.eProfile = OMX_VIDEO_H263ProfileBaseline; 35947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.eLevel = OMX_VIDEO_H263Level10; 36047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.bPLUSPTYPEAllowed = OMX_FALSE; 36147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.nAllowedPictureTypes = 2; 362826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.bForceRoundingTypeToZero = OMX_TRUE; 3636eec4d1ea65df853450a6e158718981cba900bf6Shashank Mittal m_sParamH263.nPictureHeaderRepetition = 0; 364826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.nGOBHeaderInterval = 1; 36547e37c4428509524ee576920a98381f3e4872493Nick Pelly 36647e37c4428509524ee576920a98381f3e4872493Nick Pelly // h264 specific init 367826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_INIT_STRUCT(&m_sParamAVC, OMX_VIDEO_PARAM_AVCTYPE); 36847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.nPortIndex = (OMX_U32) PORT_INDEX_OUT; 369826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nSliceHeaderSpacing = 0; 370826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nPFrames = (m_sOutPortFormat.xFramerate * 2 - 1); // 2 second intra period for default outport fps 37147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.nBFrames = 0; 372826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bUseHadamard = OMX_FALSE; 373826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nRefFrames = 1; 3746eec4d1ea65df853450a6e158718981cba900bf6Shashank Mittal m_sParamAVC.nRefIdx10ActiveMinus1 = 1; 375826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nRefIdx11ActiveMinus1 = 0; 376826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bEnableUEP = OMX_FALSE; 377826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bEnableFMO = OMX_FALSE; 378826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bEnableASO = OMX_FALSE; 379826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bEnableRS = OMX_FALSE; 38047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.eProfile = OMX_VIDEO_AVCProfileBaseline; 38147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.eLevel = OMX_VIDEO_AVCLevel1; 38247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.nAllowedPictureTypes = 2; 383826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bFrameMBsOnly = OMX_FALSE; 384826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bMBAFF = OMX_FALSE; 385826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bEntropyCodingCABAC = OMX_FALSE; 386826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bWeightedPPrediction = OMX_FALSE; 387826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nWeightedBipredicitonMode = 0; 388826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bconstIpred = OMX_FALSE; 389826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bDirect8x8Inference = OMX_FALSE; 390826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.bDirectSpatialTemporal = OMX_FALSE; 391826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nCabacInitIdc = 0; 392826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.eLoopFilterMode = OMX_VIDEO_AVCLoopFilterEnable; 39347e37c4428509524ee576920a98381f3e4872493Nick Pelly 39447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_state = OMX_StateLoaded; 395826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sExtraData = 0; 396dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_sDebugSliceinfo = 0; 397dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 398dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand // For H264 enable some parameters in VUI by default 399dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if (codec_type == OMX_VIDEO_CodingAVC) 400dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand { 401dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand QOMX_VUI_BITSTREAM_RESTRICT parm; 402dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand OMX_INIT_STRUCT(&parm, QOMX_VUI_BITSTREAM_RESTRICT); 403dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand parm.bEnable = OMX_TRUE; 404dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if (set_parameter(NULL, (OMX_INDEXTYPE)OMX_QcomIndexParamEnableVUIStreamRestrictFlag, 405dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand (OMX_PTR)&parm)) { 406dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand // Don't treat this as a fatal error 407dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("Unable to set EnableVUIStreamRestrictFlag as default"); 408dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 409dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 410dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 411dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand#ifdef _ANDROID_ 412dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand char value[PROPERTY_VALUE_MAX] = {0}; 413dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand property_get("vidc.venc.debug.sliceinfo", value, "0"); 414dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_sDebugSliceinfo = (OMX_U32)atoi(value); 415dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_HIGH("vidc.venc.debug.sliceinfo value is %d", m_sDebugSliceinfo); 416dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand#endif 41747e37c4428509524ee576920a98381f3e4872493Nick Pelly 41847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(eRet == OMX_ErrorNone) 41947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 42047e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pipe(fds)) 42147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 42247e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: pipe creation failed\n"); 42347e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorInsufficientResources; 42447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 42547e37c4428509524ee576920a98381f3e4872493Nick Pelly else 42647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 42747e37c4428509524ee576920a98381f3e4872493Nick Pelly if(fds[0] == 0 || fds[1] == 0) 42847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 42947e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pipe(fds)) 43047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 43147e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: pipe creation failed\n"); 43247e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorInsufficientResources; 43347e37c4428509524ee576920a98381f3e4872493Nick Pelly } 43447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 43547e37c4428509524ee576920a98381f3e4872493Nick Pelly if(eRet == OMX_ErrorNone) 43647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 43747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_pipe_in = fds[0]; 43847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_pipe_out = fds[1]; 43947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 44047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 44147e37c4428509524ee576920a98381f3e4872493Nick Pelly r = pthread_create(&msg_thread_id,0,message_thread,this); 44247e37c4428509524ee576920a98381f3e4872493Nick Pelly 44347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(r < 0) 44447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 44547e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorInsufficientResources; 44647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 44747e37c4428509524ee576920a98381f3e4872493Nick Pelly else 44847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 44947e37c4428509524ee576920a98381f3e4872493Nick Pelly r = pthread_create(&async_thread_id,0,async_venc_message_thread,this); 45047e37c4428509524ee576920a98381f3e4872493Nick Pelly if(r < 0) 45147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 45247e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorInsufficientResources; 45347e37c4428509524ee576920a98381f3e4872493Nick Pelly } 45447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 45547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 45647e37c4428509524ee576920a98381f3e4872493Nick Pelly 45747e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("\n Component_init return value = 0x%x", eRet); 45847e37c4428509524ee576920a98381f3e4872493Nick Pelly return eRet; 45947e37c4428509524ee576920a98381f3e4872493Nick Pelly} 46047e37c4428509524ee576920a98381f3e4872493Nick Pelly 46147e37c4428509524ee576920a98381f3e4872493Nick Pelly 46247e37c4428509524ee576920a98381f3e4872493Nick Pelly/* ====================================================================== 46347e37c4428509524ee576920a98381f3e4872493Nick PellyFUNCTION 46447e37c4428509524ee576920a98381f3e4872493Nick Pelly omx_venc::Setparameter 46547e37c4428509524ee576920a98381f3e4872493Nick Pelly 46647e37c4428509524ee576920a98381f3e4872493Nick PellyDESCRIPTION 46747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX Set Parameter method implementation. 46847e37c4428509524ee576920a98381f3e4872493Nick Pelly 46947e37c4428509524ee576920a98381f3e4872493Nick PellyPARAMETERS 47047e37c4428509524ee576920a98381f3e4872493Nick Pelly <TBD>. 47147e37c4428509524ee576920a98381f3e4872493Nick Pelly 47247e37c4428509524ee576920a98381f3e4872493Nick PellyRETURN VALUE 47347e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX Error None if successful. 47447e37c4428509524ee576920a98381f3e4872493Nick Pelly 47547e37c4428509524ee576920a98381f3e4872493Nick Pelly========================================================================== */ 47647e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_ERRORTYPE omx_venc::set_parameter(OMX_IN OMX_HANDLETYPE hComp, 47747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_IN OMX_INDEXTYPE paramIndex, 47847e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_IN OMX_PTR paramData) 47947e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 48047e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_ERRORTYPE eRet = OMX_ErrorNone; 48147e37c4428509524ee576920a98381f3e4872493Nick Pelly 48247e37c4428509524ee576920a98381f3e4872493Nick Pelly 48347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_state == OMX_StateInvalid) 48447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 48547e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Set Param in Invalid State\n"); 48647e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorInvalidState; 48747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 48847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(paramData == NULL) 48947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 49047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Get Param in Invalid paramData \n"); 49147e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorBadParameter; 49247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 49347e37c4428509524ee576920a98381f3e4872493Nick Pelly 49447e37c4428509524ee576920a98381f3e4872493Nick Pelly /*set_parameter can be called in loaded state 49547e37c4428509524ee576920a98381f3e4872493Nick Pelly or disabled port */ 49647e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_state == OMX_StateLoaded 49747e37c4428509524ee576920a98381f3e4872493Nick Pelly || m_sInPortDef.bEnabled == OMX_FALSE 49847e37c4428509524ee576920a98381f3e4872493Nick Pelly || m_sOutPortDef.bEnabled == OMX_FALSE) 49947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 50047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("Set Parameter called in valid state"); 50147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 50247e37c4428509524ee576920a98381f3e4872493Nick Pelly else 50347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 50447e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Set Parameter called in Invalid State\n"); 50547e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorIncorrectStateOperation; 50647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 50747e37c4428509524ee576920a98381f3e4872493Nick Pelly 50847e37c4428509524ee576920a98381f3e4872493Nick Pelly switch(paramIndex) 50947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 51047e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamPortDefinition: 51147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 51247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_PARAM_PORTDEFINITIONTYPE *portDefn; 51347e37c4428509524ee576920a98381f3e4872493Nick Pelly portDefn = (OMX_PARAM_PORTDEFINITIONTYPE *) paramData; 51447e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPortDefinition H= %d, W = %d\n", 51547e37c4428509524ee576920a98381f3e4872493Nick Pelly (int)portDefn->format.video.nFrameHeight, 51647e37c4428509524ee576920a98381f3e4872493Nick Pelly (int)portDefn->format.video.nFrameWidth); 51747e37c4428509524ee576920a98381f3e4872493Nick Pelly 51847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(PORT_INDEX_IN == portDefn->nPortIndex) 51947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 52047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n i/p actual cnt requested = %d\n", portDefn->nBufferCountActual); 52147e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n i/p min cnt requested = %d\n", portDefn->nBufferCountMin); 52247e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n i/p buffersize requested = %d\n", portDefn->nBufferSize); 52347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_param(paramData,OMX_IndexParamPortDefinition) != true) 52447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 52547e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: venc_set_param input failed"); 52647e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 52747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 52847e37c4428509524ee576920a98381f3e4872493Nick Pelly 52947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n i/p previous actual cnt = %d\n", m_sInPortDef.nBufferCountActual); 53047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n i/p previous min cnt = %d\n", m_sInPortDef.nBufferCountMin); 531826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sInPortDef, portDefn,sizeof(OMX_PARAM_PORTDEFINITIONTYPE)); 532826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 533826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 534826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if (portDefn->format.video.eColorFormat == (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FormatAndroidOpaque) { 535826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.eColorFormat = 536826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_COLOR_FormatYUV420SemiPlanar; 537dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if(secure_session) { 538dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand secure_color_format = (int) QOMX_COLOR_FormatAndroidOpaque; 539dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand mUseProxyColorFormat = false; 540dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_input_msg_id = OMX_COMPONENT_GENERATE_ETB; 541dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } else if(!mUseProxyColorFormat){ 542dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if (!c2d_conv.init()) { 543dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("\n C2D init failed"); 544dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand return OMX_ErrorUnsupportedSetting; 545dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 546dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("\nC2D init is successful"); 547dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand mUseProxyColorFormat = true; 548dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_input_msg_id = OMX_COMPONENT_GENERATE_ETB_OPQ; 549dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 550dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } else 551dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand mUseProxyColorFormat = false; 552826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 55347e37c4428509524ee576920a98381f3e4872493Nick Pelly /*Query Input Buffer Requirements*/ 55447e37c4428509524ee576920a98381f3e4872493Nick Pelly dev_get_buf_req (&m_sInPortDef.nBufferCountMin, 55547e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sInPortDef.nBufferCountActual, 55647e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sInPortDef.nBufferSize, 55747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.nPortIndex); 55847e37c4428509524ee576920a98381f3e4872493Nick Pelly 55947e37c4428509524ee576920a98381f3e4872493Nick Pelly /*Query ouput Buffer Requirements*/ 56047e37c4428509524ee576920a98381f3e4872493Nick Pelly dev_get_buf_req (&m_sOutPortDef.nBufferCountMin, 56147e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sOutPortDef.nBufferCountActual, 56247e37c4428509524ee576920a98381f3e4872493Nick Pelly &m_sOutPortDef.nBufferSize, 56347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.nPortIndex); 56447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.nBufferCountActual = portDefn->nBufferCountActual; 56547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 56647e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(PORT_INDEX_OUT == portDefn->nPortIndex) 56747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 56847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n o/p actual cnt requested = %d\n", portDefn->nBufferCountActual); 56947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n o/p min cnt requested = %d\n", portDefn->nBufferCountMin); 57047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n o/p buffersize requested = %d\n", portDefn->nBufferSize); 57147e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_param(paramData,OMX_IndexParamPortDefinition) != true) 57247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 57347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: venc_set_param output failed"); 57447e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 57547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 576826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sOutPortDef,portDefn,sizeof(struct OMX_PARAM_PORTDEFINITIONTYPE)); 577826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev update_profile_level(); //framerate , bitrate 57847e37c4428509524ee576920a98381f3e4872493Nick Pelly 57947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n o/p previous actual cnt = %d\n", m_sOutPortDef.nBufferCountActual); 58047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n o/p previous min cnt = %d\n", m_sOutPortDef.nBufferCountMin); 58147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.nBufferCountActual = portDefn->nBufferCountActual; 58247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 58347e37c4428509524ee576920a98381f3e4872493Nick Pelly else 58447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 58547e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Set_parameter: Bad Port idx %d", 58647e37c4428509524ee576920a98381f3e4872493Nick Pelly (int)portDefn->nPortIndex); 58747e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorBadPortIndex; 58847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 58947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigFramerate.xEncodeFramerate = portDefn->format.video.xFramerate; 59047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigBitrate.nEncodeBitrate = portDefn->format.video.nBitrate; 59147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.nTargetBitrate = portDefn->format.video.nBitrate; 59247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 59347e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 59447e37c4428509524ee576920a98381f3e4872493Nick Pelly 59547e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoPortFormat: 59647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 59747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_PORTFORMATTYPE *portFmt = 59847e37c4428509524ee576920a98381f3e4872493Nick Pelly (OMX_VIDEO_PARAM_PORTFORMATTYPE *)paramData; 59947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoPortFormat %d\n", 60047e37c4428509524ee576920a98381f3e4872493Nick Pelly portFmt->eColorFormat); 60147e37c4428509524ee576920a98381f3e4872493Nick Pelly //set the driver with the corresponding values 60247e37c4428509524ee576920a98381f3e4872493Nick Pelly if(PORT_INDEX_IN == portFmt->nPortIndex) 60347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 60447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_param(paramData,OMX_IndexParamVideoPortFormat) != true) 60547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 60647e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 60747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 60847e37c4428509524ee576920a98381f3e4872493Nick Pelly 60947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoPortFormat %d\n", 61047e37c4428509524ee576920a98381f3e4872493Nick Pelly portFmt->eColorFormat); 611826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev update_profile_level(); //framerate 61247e37c4428509524ee576920a98381f3e4872493Nick Pelly 613826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 614826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if (portFmt->eColorFormat == 615826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (OMX_COLOR_FORMATTYPE)QOMX_COLOR_FormatAndroidOpaque) { 616826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortFormat.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; 617dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if(secure_session) { 618dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand secure_color_format = (int) QOMX_COLOR_FormatAndroidOpaque; 619dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand mUseProxyColorFormat = false; 620dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_input_msg_id = OMX_COMPONENT_GENERATE_ETB; 621dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } else if(!mUseProxyColorFormat){ 622dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if (!c2d_conv.init()) { 623dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("\n C2D init failed"); 624dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand return OMX_ErrorUnsupportedSetting; 625dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 626dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("\nC2D init is successful"); 627dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand mUseProxyColorFormat = true; 628dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_input_msg_id = OMX_COMPONENT_GENERATE_ETB_OPQ; 629dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 630826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 631826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 632826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 633826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 634826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortFormat.eColorFormat = portFmt->eColorFormat; 635dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand m_input_msg_id = OMX_COMPONENT_GENERATE_ETB; 636dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand mUseProxyColorFormat = false; 637826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 63847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortFormat.xFramerate = portFmt->xFramerate; 63947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 64047e37c4428509524ee576920a98381f3e4872493Nick Pelly //TODO if no use case for O/P port,delet m_sOutPortFormat 64147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 64247e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 64347e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoInit: 64447e37c4428509524ee576920a98381f3e4872493Nick Pelly { //TODO, do we need this index set param 64547e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_PORT_PARAM_TYPE* pParam = (OMX_PORT_PARAM_TYPE*)(paramData); 64647e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n Set OMX_IndexParamVideoInit called"); 64747e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 64847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 64947e37c4428509524ee576920a98381f3e4872493Nick Pelly 65047e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoBitrate: 65147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 65247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_BITRATETYPE* pParam = (OMX_VIDEO_PARAM_BITRATETYPE*)paramData; 65347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoBitrate"); 65447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_param(paramData,OMX_IndexParamVideoBitrate) != true) 65547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 65647e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 65747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 65847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.nTargetBitrate = pParam->nTargetBitrate; 65947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.eControlRate = pParam->eControlRate; 660826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev update_profile_level(); //bitrate 66147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigBitrate.nEncodeBitrate = pParam->nTargetBitrate; 66247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInPortDef.format.video.nBitrate = pParam->nTargetBitrate; 66347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.nBitrate = pParam->nTargetBitrate; 66447e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\nbitrate = %u", m_sOutPortDef.format.video.nBitrate); 66547e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 66647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 66747e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoMpeg4: 66847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 66947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_MPEG4TYPE* pParam = (OMX_VIDEO_PARAM_MPEG4TYPE*)paramData; 670826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_VIDEO_PARAM_MPEG4TYPE mp4_param; 671826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&mp4_param, pParam, sizeof(struct OMX_VIDEO_PARAM_MPEG4TYPE)); 67247e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoMpeg4"); 673826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->eProfile == OMX_VIDEO_MPEG4ProfileAdvancedSimple) 674826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 675826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef MAX_RES_1080P 676826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames) 677826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 678826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_HIGH("INFO: Only 1 Bframe is supported"); 679826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev mp4_param.nBFrames = 1; 680826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 681826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#else 682826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames) 683826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 684826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("Warning: B frames not supported\n"); 685826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev mp4_param.nBFrames = 0; 686826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 687826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 688826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 689826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 690826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 691826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames) 692826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 693826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("Warning: B frames not supported\n"); 694826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev mp4_param.nBFrames = 0; 695826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 696826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 697826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_param(&mp4_param,OMX_IndexParamVideoMpeg4) != true) 69847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 69947e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 70047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 701826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sParamMPEG4,pParam, sizeof(struct OMX_VIDEO_PARAM_MPEG4TYPE)); 70247e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 70347e37c4428509524ee576920a98381f3e4872493Nick Pelly } 70447e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoH263: 70547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 70647e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_H263TYPE* pParam = (OMX_VIDEO_PARAM_H263TYPE*)paramData; 70747e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoH263"); 70847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_param(paramData,OMX_IndexParamVideoH263) != true) 70947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 71047e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 71147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 712826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sParamH263,pParam, sizeof(struct OMX_VIDEO_PARAM_H263TYPE)); 71347e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 71447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 71547e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoAvc: 71647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 71747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_AVCTYPE* pParam = (OMX_VIDEO_PARAM_AVCTYPE*)paramData; 718826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_VIDEO_PARAM_AVCTYPE avc_param; 719826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&avc_param, pParam, sizeof( struct OMX_VIDEO_PARAM_AVCTYPE)); 72047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoAvc"); 721826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 722826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if((pParam->eProfile == OMX_VIDEO_AVCProfileHigh)|| 723826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (pParam->eProfile == OMX_VIDEO_AVCProfileMain)) 724826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 725826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef MAX_RES_1080P 726826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames) 727826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 728826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_HIGH("INFO: Only 1 Bframe is supported"); 729826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev avc_param.nBFrames = 1; 730826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 731826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nRefFrames != 2) 732826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 733dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("Warning: 2 RefFrames are needed, changing RefFrames from %d to 2", pParam->nRefFrames); 734826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev avc_param.nRefFrames = 2; 735826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 736826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#else 737826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames) 738826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 739826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("Warning: B frames not supported\n"); 740826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev avc_param.nBFrames = 0; 741826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 742826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nRefFrames != 1) 743826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 744dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("Warning: Only 1 RefFrame is supported, changing RefFrame from %d to 1)", pParam->nRefFrames); 745826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev avc_param.nRefFrames = 1; 746826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 747826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 748826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 749826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 750826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 751826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nRefFrames != 1) 752826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 753dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("Warning: Only 1 RefFrame is supported, changing RefFrame from %d to 1)", pParam->nRefFrames); 754826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev avc_param.nRefFrames = 1; 755826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 756826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames) 757826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 758826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("Warning: B frames not supported\n"); 759826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev avc_param.nBFrames = 0; 760826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 761826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 762826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_param(&avc_param,OMX_IndexParamVideoAvc) != true) 76347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 76447e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 76547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 766dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 767826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sParamAVC,pParam, sizeof(struct OMX_VIDEO_PARAM_AVCTYPE)); 76847e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 76947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 77047e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoProfileLevelCurrent: 77147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 77247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_PROFILELEVELTYPE* pParam = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)paramData; 77347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoProfileLevelCurrent"); 774826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_param(pParam,OMX_IndexParamVideoProfileLevelCurrent) != true) 77547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 776dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("set_parameter: OMX_IndexParamVideoProfileLevelCurrent failed for Profile: %d " 777dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand "Level :%d", pParam->eProfile, pParam->eLevel); 77847e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 77947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 78047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eProfile = pParam->eProfile; 78147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamProfileLevel.eLevel = pParam->eLevel; 78247e37c4428509524ee576920a98381f3e4872493Nick Pelly 78347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.mpeg4",\ 78447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_MAX_STRINGNAME_SIZE)) 78547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 78647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.eProfile = (OMX_VIDEO_MPEG4PROFILETYPE)m_sParamProfileLevel.eProfile; 78747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.eLevel = (OMX_VIDEO_MPEG4LEVELTYPE)m_sParamProfileLevel.eLevel; 78847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n MPEG4 profile = %d, level = %d", m_sParamMPEG4.eProfile, 78947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamMPEG4.eLevel); 79047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 79147e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.h263",\ 79247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_MAX_STRINGNAME_SIZE)) 79347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 79447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.eProfile = (OMX_VIDEO_H263PROFILETYPE)m_sParamProfileLevel.eProfile; 79547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.eLevel = (OMX_VIDEO_H263LEVELTYPE)m_sParamProfileLevel.eLevel; 79647e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n H263 profile = %d, level = %d", m_sParamH263.eProfile, 79747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamH263.eLevel); 79847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 799826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc",\ 800826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_MAX_STRINGNAME_SIZE)) 80147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 80247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.eProfile = (OMX_VIDEO_AVCPROFILETYPE)m_sParamProfileLevel.eProfile; 80347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.eLevel = (OMX_VIDEO_AVCLEVELTYPE)m_sParamProfileLevel.eLevel; 80447e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n AVC profile = %d, level = %d", m_sParamAVC.eProfile, 80547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamAVC.eLevel); 80647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 80747e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 80847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 80947e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamStandardComponentRole: 81047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 81147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_PARAM_COMPONENTROLETYPE *comp_role; 81247e37c4428509524ee576920a98381f3e4872493Nick Pelly comp_role = (OMX_PARAM_COMPONENTROLETYPE *) paramData; 81347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamStandardComponentRole %s\n", 81447e37c4428509524ee576920a98381f3e4872493Nick Pelly comp_role->cRole); 81547e37c4428509524ee576920a98381f3e4872493Nick Pelly 81647e37c4428509524ee576920a98381f3e4872493Nick Pelly if((m_state == OMX_StateLoaded)&& 81747e37c4428509524ee576920a98381f3e4872493Nick Pelly !BITMASK_PRESENT(&m_flags,OMX_COMPONENT_IDLE_PENDING)) 81847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 81947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("Set Parameter called in valid state"); 82047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 82147e37c4428509524ee576920a98381f3e4872493Nick Pelly else 82247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 82347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("Set Parameter called in Invalid State\n"); 82447e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorIncorrectStateOperation; 82547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 82647e37c4428509524ee576920a98381f3e4872493Nick Pelly 82747e37c4428509524ee576920a98381f3e4872493Nick Pelly if(!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.avc",OMX_MAX_STRINGNAME_SIZE)) 82847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 82947e37c4428509524ee576920a98381f3e4872493Nick Pelly if(!strncmp((char*)comp_role->cRole,"video_encoder.avc",OMX_MAX_STRINGNAME_SIZE)) 83047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 831826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char*)m_cRole,"video_encoder.avc",OMX_MAX_STRINGNAME_SIZE); 83247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 83347e37c4428509524ee576920a98381f3e4872493Nick Pelly else 83447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 83547e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setparameter: unknown Index %s\n", comp_role->cRole); 83647e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet =OMX_ErrorUnsupportedSetting; 83747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 83847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 83947e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.mpeg4",OMX_MAX_STRINGNAME_SIZE)) 84047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 84147e37c4428509524ee576920a98381f3e4872493Nick Pelly if(!strncmp((const char*)comp_role->cRole,"video_encoder.mpeg4",OMX_MAX_STRINGNAME_SIZE)) 84247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 843826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char*)m_cRole,"video_encoder.mpeg4",OMX_MAX_STRINGNAME_SIZE); 84447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 84547e37c4428509524ee576920a98381f3e4872493Nick Pelly else 84647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 84747e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setparameter: unknown Index %s\n", comp_role->cRole); 84847e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorUnsupportedSetting; 84947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 85047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 85147e37c4428509524ee576920a98381f3e4872493Nick Pelly else if(!strncmp((char*)m_nkind, "OMX.qcom.video.encoder.h263",OMX_MAX_STRINGNAME_SIZE)) 85247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 85347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(!strncmp((const char*)comp_role->cRole,"video_encoder.h263",OMX_MAX_STRINGNAME_SIZE)) 85447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 855826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev strlcpy((char*)m_cRole,"video_encoder.h263",OMX_MAX_STRINGNAME_SIZE); 85647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 85747e37c4428509524ee576920a98381f3e4872493Nick Pelly else 85847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 85947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setparameter: unknown Index %s\n", comp_role->cRole); 86047e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet =OMX_ErrorUnsupportedSetting; 86147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 86247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 86347e37c4428509524ee576920a98381f3e4872493Nick Pelly else 86447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 86547e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setparameter: unknown param %s\n", m_nkind); 86647e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorInvalidComponentName; 86747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 86847e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 86947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 87047e37c4428509524ee576920a98381f3e4872493Nick Pelly 87147e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamPriorityMgmt: 87247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 87347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPriorityMgmt"); 87447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_state != OMX_StateLoaded) 87547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 87647e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Set Parameter called in Invalid State\n"); 87747e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorIncorrectStateOperation; 87847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 87947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_PRIORITYMGMTTYPE *priorityMgmtype = (OMX_PRIORITYMGMTTYPE*) paramData; 88047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamPriorityMgmt %d\n", 88147e37c4428509524ee576920a98381f3e4872493Nick Pelly priorityMgmtype->nGroupID); 88247e37c4428509524ee576920a98381f3e4872493Nick Pelly 88347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: priorityMgmtype %d\n", 88447e37c4428509524ee576920a98381f3e4872493Nick Pelly priorityMgmtype->nGroupPriority); 88547e37c4428509524ee576920a98381f3e4872493Nick Pelly 88647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPriorityMgmt.nGroupID = priorityMgmtype->nGroupID; 88747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sPriorityMgmt.nGroupPriority = priorityMgmtype->nGroupPriority; 88847e37c4428509524ee576920a98381f3e4872493Nick Pelly 88947e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 89047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 89147e37c4428509524ee576920a98381f3e4872493Nick Pelly 89247e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamCompBufferSupplier: 89347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 89447e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamCompBufferSupplier"); 89547e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_PARAM_BUFFERSUPPLIERTYPE *bufferSupplierType = (OMX_PARAM_BUFFERSUPPLIERTYPE*) paramData; 89647e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamCompBufferSupplier %d\n", 89747e37c4428509524ee576920a98381f3e4872493Nick Pelly bufferSupplierType->eBufferSupplier); 89847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(bufferSupplierType->nPortIndex == 0 || bufferSupplierType->nPortIndex ==1) 89947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sInBufSupplier.eBufferSupplier = bufferSupplierType->eBufferSupplier; 90047e37c4428509524ee576920a98381f3e4872493Nick Pelly 90147e37c4428509524ee576920a98381f3e4872493Nick Pelly else 90247e37c4428509524ee576920a98381f3e4872493Nick Pelly 90347e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorBadPortIndex; 90447e37c4428509524ee576920a98381f3e4872493Nick Pelly 90547e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 90647e37c4428509524ee576920a98381f3e4872493Nick Pelly 90747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 90847e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexParamVideoQuantization: 90947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 91047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_IndexParamVideoQuantization\n"); 91147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_PARAM_QUANTIZATIONTYPE *session_qp = (OMX_VIDEO_PARAM_QUANTIZATIONTYPE*) paramData; 91247e37c4428509524ee576920a98381f3e4872493Nick Pelly if(session_qp->nPortIndex == PORT_INDEX_OUT) 91347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 91447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_param(paramData, OMX_IndexParamVideoQuantization) != true) 91547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 91647e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 91747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 91847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sSessionQuantization.nQpI = session_qp->nQpI; 91947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sSessionQuantization.nQpP = session_qp->nQpP; 92047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 92147e37c4428509524ee576920a98381f3e4872493Nick Pelly else 92247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 92347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: Unsupported port Index for Session QP setting\n"); 92447e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorBadPortIndex; 92547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 92647e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 92747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 92847e37c4428509524ee576920a98381f3e4872493Nick Pelly 92947e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_QcomIndexPortDefn: 93047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 93147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_QCOM_PARAM_PORTDEFINITIONTYPE* pParam = 93247e37c4428509524ee576920a98381f3e4872493Nick Pelly (OMX_QCOM_PARAM_PORTDEFINITIONTYPE*)paramData; 93347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("set_parameter: OMX_QcomIndexPortDefn"); 93447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pParam->nPortIndex == (OMX_U32)PORT_INDEX_IN) 93547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 93647e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pParam->nMemRegion > OMX_QCOM_MemRegionInvalid && 93747e37c4428509524ee576920a98381f3e4872493Nick Pelly pParam->nMemRegion < OMX_QCOM_MemRegionMax) 93847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 93947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_use_input_pmem = OMX_TRUE; 94047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 94147e37c4428509524ee576920a98381f3e4872493Nick Pelly else 94247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 94347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_use_input_pmem = OMX_FALSE; 94447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 94547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 94647e37c4428509524ee576920a98381f3e4872493Nick Pelly else if (pParam->nPortIndex == (OMX_U32)PORT_INDEX_OUT) 94747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 94847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pParam->nMemRegion > OMX_QCOM_MemRegionInvalid && 94947e37c4428509524ee576920a98381f3e4872493Nick Pelly pParam->nMemRegion < OMX_QCOM_MemRegionMax) 95047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 95147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_use_output_pmem = OMX_TRUE; 95247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 95347e37c4428509524ee576920a98381f3e4872493Nick Pelly else 95447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 95547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_use_output_pmem = OMX_FALSE; 95647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 95747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 95847e37c4428509524ee576920a98381f3e4872493Nick Pelly else 95947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 96047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: SetParameter called on unsupported Port Index for QcomPortDefn"); 96147e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorBadPortIndex; 96247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 96347e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 96447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 965826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 966826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_IndexParamVideoErrorCorrection: 967826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 968826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_LOW("OMX_IndexParamVideoErrorCorrection\n"); 969826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE* pParam = 970826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE*)paramData; 971826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(!handle->venc_set_param(paramData, OMX_IndexParamVideoErrorCorrection)) 972826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 973826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("\nERROR: Request for setting Error Resilience failed"); 974826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 975826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 976826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sErrorCorrection,pParam, sizeof(m_sErrorCorrection)); 977826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev break; 978826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 979826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_IndexParamVideoIntraRefresh: 98047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 981826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_LOW("set_param:OMX_IndexParamVideoIntraRefresh\n"); 982826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_VIDEO_PARAM_INTRAREFRESHTYPE* pParam = 983826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (OMX_VIDEO_PARAM_INTRAREFRESHTYPE*)paramData; 984826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(!handle->venc_set_param(paramData,OMX_IndexParamVideoIntraRefresh)) 98547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 986826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("\nERROR: Request for setting intra refresh failed"); 987826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 988826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 989826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev memcpy(&m_sIntraRefresh, pParam, sizeof(m_sIntraRefresh)); 990826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev break; 991826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 992826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 993eb8af24ae2de5fb529f36e7eb1a88648a641edefLajos Molnar case OMX_QcomIndexParamVideoMetaBufferMode: 994826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 995826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev StoreMetaDataInBuffersParams *pParam = 996826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (StoreMetaDataInBuffersParams*)paramData; 997826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nPortIndex == PORT_INDEX_IN) 998826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 999826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->bStoreMetaData != meta_mode_enable) 100047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1001826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(!handle->venc_set_meta_mode(pParam->bStoreMetaData)) 1002826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1003826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("\nERROR: set Metabuffer mode %d fail", 1004826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev pParam->bStoreMetaData); 1005826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1006826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1007826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev meta_mode_enable = pParam->bStoreMetaData; 1008826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(meta_mode_enable) { 1009b88cb6921518253c26b91aa4db1eb1a96cf80577Haynes Mathew George m_sInPortDef.nBufferCountActual = 4; 1010826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_param(&m_sInPortDef,OMX_IndexParamPortDefinition) != true) 1011826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1012826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("\nERROR: venc_set_param input failed"); 1013826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1014826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1015826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } else { 1016826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev /*TODO: reset encoder driver Meta mode*/ 1017826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev dev_get_buf_req (&m_sOutPortDef.nBufferCountMin, 1018826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev &m_sOutPortDef.nBufferCountActual, 1019826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev &m_sOutPortDef.nBufferSize, 1020826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.nPortIndex); 1021826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1022826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 102399a3bb61f97cf1cae4560bbaf2974f07595efb1aChong Zhang } else { 102499a3bb61f97cf1cae4560bbaf2974f07595efb1aChong Zhang DEBUG_PRINT_ERROR("set_parameter: metamode is " 102599a3bb61f97cf1cae4560bbaf2974f07595efb1aChong Zhang "valid for input port only"); 102699a3bb61f97cf1cae4560bbaf2974f07595efb1aChong Zhang eRet = OMX_ErrorUnsupportedSetting; 1027826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1028dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand break; 1029826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1030826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 1031826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifndef MAX_RES_720P 1032826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_QcomIndexParamIndexExtraDataType: 1033826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1034dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_LOW("set_parameter: OMX_QcomIndexParamIndexExtraDataType"); 1035826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev QOMX_INDEXEXTRADATATYPE *pParam = (QOMX_INDEXEXTRADATATYPE *)paramData; 1036826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if (pParam->nIndex == (OMX_INDEXTYPE)OMX_ExtraDataVideoEncoderSliceInfo) 1037826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1038826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if (pParam->nPortIndex == PORT_INDEX_OUT) 1039826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1040826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if (pParam->bEnabled == OMX_TRUE) 1041826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sExtraData |= VEN_EXTRADATA_SLICEINFO; 1042826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1043826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sExtraData &= ~VEN_EXTRADATA_SLICEINFO; 1044dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_HIGH("set_param: m_sExtraData=%x", m_sExtraData); 1045826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_param(&m_sExtraData, 1046826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (OMX_INDEXTYPE)OMX_ExtraDataVideoEncoderSliceInfo) != true) 1047826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1048826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: Setting " 1049dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand "OMX_QcomIndexParamIndexExtraDataType failed"); 1050826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1051826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1052826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1053826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1054826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.nPortIndex = PORT_INDEX_OUT; 1055826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev dev_get_buf_req(&m_sOutPortDef.nBufferCountMin, 1056826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev &m_sOutPortDef.nBufferCountActual, 1057826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev &m_sOutPortDef.nBufferSize, 1058826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.nPortIndex); 1059826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_HIGH("updated out_buf_req: buffer cnt=%d, " 1060826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev "count min=%d, buffer size=%d", 1061826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.nBufferCountActual, 1062826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.nBufferCountMin, 1063826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.nBufferSize); 1064826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1065826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1066826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1067826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1068dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("set_parameter: slice information is " 1069826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev "valid for output port only"); 1070826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev eRet = OMX_ErrorUnsupportedIndex; 107147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 107247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 107347e37c4428509524ee576920a98381f3e4872493Nick Pelly else 107447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1075dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("set_parameter: unsupported index (%x), " 1076dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand "only slice information extradata is supported", pParam->nIndex); 1077826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev eRet = OMX_ErrorUnsupportedIndex; 107847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 107947e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 108047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 1081826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 1082826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_QcomIndexParamVideoMaxAllowedBitrateCheck: 108347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1084826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev QOMX_EXTNINDEX_PARAMTYPE* pParam = 1085826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (QOMX_EXTNINDEX_PARAMTYPE*)paramData; 1086826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nPortIndex == PORT_INDEX_OUT) 1087826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1088826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev handle->m_max_allowed_bitrate_check = 1089826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev ((pParam->bEnable == OMX_TRUE) ? true : false); 1090826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_HIGH("set_parameter: max allowed bitrate check %s", 1091826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev ((pParam->bEnable == OMX_TRUE) ? "enabled" : "disabled")); 1092826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1093826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1094826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1095826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: OMX_QcomIndexParamVideoMaxAllowedBitrateCheck " 1096dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand " called on wrong port(%d)", pParam->nPortIndex); 1097826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorBadPortIndex; 1098826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 109947e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 110047e37c4428509524ee576920a98381f3e4872493Nick Pelly } 1101826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef MAX_RES_1080P 1102826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_QcomIndexEnableSliceDeliveryMode: 110347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1104826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev QOMX_EXTNINDEX_PARAMTYPE* pParam = 1105826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (QOMX_EXTNINDEX_PARAMTYPE*)paramData; 1106826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nPortIndex == PORT_INDEX_OUT) 1107826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1108826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(!handle->venc_set_param(paramData, 1109826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (OMX_INDEXTYPE)OMX_QcomIndexEnableSliceDeliveryMode)) 1110826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1111826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: Request for setting slice delivery mode failed"); 1112826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1113826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1114826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1115826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1116826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1117826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: OMX_QcomIndexEnableSliceDeliveryMode " 1118dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand "called on wrong port(%d)", pParam->nPortIndex); 1119826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorBadPortIndex; 1120826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 112147e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 112247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 1123826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 1124dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand case OMX_QcomIndexParamSequenceHeaderWithIDR: 11253145f89c1398e32bb7fc6cc03866388f42d2bad3Deva Ramasubramanian { 1126dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if(!handle->venc_set_param(paramData, 1127dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand (OMX_INDEXTYPE)OMX_QcomIndexParamSequenceHeaderWithIDR)) 11283145f89c1398e32bb7fc6cc03866388f42d2bad3Deva Ramasubramanian { 1129dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: Request for setting inband sps/pps failed"); 1130dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand return OMX_ErrorUnsupportedSetting; 11313145f89c1398e32bb7fc6cc03866388f42d2bad3Deva Ramasubramanian } 1132dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand break; 1133dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand } 1134dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand case OMX_QcomIndexParamEnableVUIStreamRestrictFlag: 1135dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand { 1136dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand if(!handle->venc_set_param(paramData, 1137dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand (OMX_INDEXTYPE)OMX_QcomIndexParamEnableVUIStreamRestrictFlag)) 11382d1c6fa918d6d3afcb93a25c0e6d60cac8365275Deva Ramasubramanian { 1139dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: Request for enabling bitstream_restrict " 1140dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand "flag in VUI failed"); 1141dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand return OMX_ErrorUnsupportedSetting; 11422d1c6fa918d6d3afcb93a25c0e6d60cac8365275Deva Ramasubramanian } 11432d1c6fa918d6d3afcb93a25c0e6d60cac8365275Deva Ramasubramanian break; 11442d1c6fa918d6d3afcb93a25c0e6d60cac8365275Deva Ramasubramanian } 1145826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_IndexParamVideoSliceFMO: 114647e37c4428509524ee576920a98381f3e4872493Nick Pelly default: 114747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 114847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setparameter: unknown param %d\n", paramIndex); 114947e37c4428509524ee576920a98381f3e4872493Nick Pelly eRet = OMX_ErrorUnsupportedIndex; 115047e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 115147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 115247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 115347e37c4428509524ee576920a98381f3e4872493Nick Pelly return eRet; 115447e37c4428509524ee576920a98381f3e4872493Nick Pelly} 115547e37c4428509524ee576920a98381f3e4872493Nick Pelly 1156826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::update_profile_level() 1157826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1158826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_U32 eProfile, eLevel; 1159826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1160826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(!handle->venc_get_profile_level(&eProfile,&eLevel)) 1161826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1162826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("\nFailed to update the profile_level\n"); 1163826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return false; 1164826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1165826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1166826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamProfileLevel.eProfile = (OMX_VIDEO_MPEG4PROFILETYPE)eProfile; 1167826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamProfileLevel.eLevel = (OMX_VIDEO_MPEG4LEVELTYPE)eLevel; 1168826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1169826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.mpeg4",\ 1170826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_MAX_STRINGNAME_SIZE)) 1171826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1172826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.eProfile = (OMX_VIDEO_MPEG4PROFILETYPE)eProfile; 1173826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.eLevel = (OMX_VIDEO_MPEG4LEVELTYPE)eLevel; 1174826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_LOW("\n MPEG4 profile = %d, level = %d", m_sParamMPEG4.eProfile, 1175826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.eLevel); 1176826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1177826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.h263",\ 1178826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_MAX_STRINGNAME_SIZE)) 1179826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1180826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.eProfile = (OMX_VIDEO_H263PROFILETYPE)eProfile; 1181826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.eLevel = (OMX_VIDEO_H263LEVELTYPE)eLevel; 1182826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_LOW("\n H263 profile = %d, level = %d", m_sParamH263.eProfile, 1183826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.eLevel); 1184826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1185826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else if(!strncmp((char *)m_nkind, "OMX.qcom.video.encoder.avc",\ 1186826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_MAX_STRINGNAME_SIZE)) 1187826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1188826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.eProfile = (OMX_VIDEO_AVCPROFILETYPE)eProfile; 1189826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.eLevel = (OMX_VIDEO_AVCLEVELTYPE)eLevel; 1190826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_LOW("\n AVC profile = %d, level = %d", m_sParamAVC.eProfile, 1191826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.eLevel); 1192826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1193826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return true; 1194826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 119547e37c4428509524ee576920a98381f3e4872493Nick Pelly/* ====================================================================== 119647e37c4428509524ee576920a98381f3e4872493Nick PellyFUNCTION 119747e37c4428509524ee576920a98381f3e4872493Nick Pelly omx_video::SetConfig 119847e37c4428509524ee576920a98381f3e4872493Nick Pelly 119947e37c4428509524ee576920a98381f3e4872493Nick PellyDESCRIPTION 120047e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX Set Config method implementation 120147e37c4428509524ee576920a98381f3e4872493Nick Pelly 120247e37c4428509524ee576920a98381f3e4872493Nick PellyPARAMETERS 120347e37c4428509524ee576920a98381f3e4872493Nick Pelly <TBD>. 120447e37c4428509524ee576920a98381f3e4872493Nick Pelly 120547e37c4428509524ee576920a98381f3e4872493Nick PellyRETURN VALUE 120647e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX Error None if successful. 120747e37c4428509524ee576920a98381f3e4872493Nick Pelly========================================================================== */ 120847e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_ERRORTYPE omx_venc::set_config(OMX_IN OMX_HANDLETYPE hComp, 120947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_IN OMX_INDEXTYPE configIndex, 121047e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_IN OMX_PTR configData) 121147e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 121247e37c4428509524ee576920a98381f3e4872493Nick Pelly if(configData == NULL) 121347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 121447e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: param is null"); 121547e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorBadParameter; 121647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 121747e37c4428509524ee576920a98381f3e4872493Nick Pelly 121847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_state == OMX_StateInvalid) 121947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 122047e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: config called in Invalid state"); 122147e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorIncorrectStateOperation; 122247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 122347e37c4428509524ee576920a98381f3e4872493Nick Pelly 122447e37c4428509524ee576920a98381f3e4872493Nick Pelly // params will be validated prior to venc_init 122547e37c4428509524ee576920a98381f3e4872493Nick Pelly switch(configIndex) 122647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 122747e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexConfigVideoBitrate: 122847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 122947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_VIDEO_CONFIG_BITRATETYPE* pParam = 123047e37c4428509524ee576920a98381f3e4872493Nick Pelly reinterpret_cast<OMX_VIDEO_CONFIG_BITRATETYPE*>(configData); 1231dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_LOW("\n omx_venc:: set_config(): OMX_IndexConfigVideoBitrate"); 123247e37c4428509524ee576920a98381f3e4872493Nick Pelly 123347e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pParam->nPortIndex == PORT_INDEX_OUT) 123447e37c4428509524ee576920a98381f3e4872493Nick Pelly { 123547e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_config(configData, OMX_IndexConfigVideoBitrate) != true) 123647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 123747e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setting OMX_IndexConfigVideoBitrate failed"); 123847e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 123947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 124047e37c4428509524ee576920a98381f3e4872493Nick Pelly 124147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigBitrate.nEncodeBitrate = pParam->nEncodeBitrate; 124247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sParamBitrate.nTargetBitrate = pParam->nEncodeBitrate; 124347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.nBitrate = pParam->nEncodeBitrate; 124447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 124547e37c4428509524ee576920a98381f3e4872493Nick Pelly else 124647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1247dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: Unsupported port index: %u", pParam->nPortIndex); 124847e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorBadPortIndex; 124947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 125047e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 125147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 125247e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexConfigVideoFramerate: 125347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 125447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_CONFIG_FRAMERATETYPE* pParam = 125547e37c4428509524ee576920a98381f3e4872493Nick Pelly reinterpret_cast<OMX_CONFIG_FRAMERATETYPE*>(configData); 1256dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_LOW("\n omx_venc:: set_config(): OMX_IndexConfigVideoFramerate"); 125747e37c4428509524ee576920a98381f3e4872493Nick Pelly 125847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pParam->nPortIndex == PORT_INDEX_OUT) 125947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 126047e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_config(configData, OMX_IndexConfigVideoFramerate) != true) 126147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 126247e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setting OMX_IndexConfigVideoFramerate failed"); 126347e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 126447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 126547e37c4428509524ee576920a98381f3e4872493Nick Pelly 126647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigFramerate.xEncodeFramerate = pParam->xEncodeFramerate; 126747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortDef.format.video.xFramerate = pParam->xEncodeFramerate; 126847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sOutPortFormat.xFramerate = pParam->xEncodeFramerate; 126947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 127047e37c4428509524ee576920a98381f3e4872493Nick Pelly else 127147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1272dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: Unsupported port index: %u", pParam->nPortIndex); 127347e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorBadPortIndex; 127447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 127547e37c4428509524ee576920a98381f3e4872493Nick Pelly 127647e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 127747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 1278826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case QOMX_IndexConfigVideoIntraperiod: 1279826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1280826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev QOMX_VIDEO_INTRAPERIODTYPE* pParam = 1281826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev reinterpret_cast<QOMX_VIDEO_INTRAPERIODTYPE*>(configData); 1282826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1283826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nPortIndex == PORT_INDEX_OUT) 1284826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1285826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef MAX_RES_720P 1286826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nBFrames > 0) 1287826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1288826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("B frames not supported\n"); 1289826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1290826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1291826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 1292826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_config(configData, (OMX_INDEXTYPE) QOMX_IndexConfigVideoIntraperiod) != true) 1293826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1294826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: Setting QOMX_IndexConfigVideoIntraperiod failed"); 1295826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1296826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1297826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraperiod.nPFrames = pParam->nPFrames; 1298826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraperiod.nBFrames = pParam->nBFrames; 1299826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sIntraperiod.nIDRPeriod = pParam->nIDRPeriod; 1300826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1301826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(m_sOutPortFormat.eCompressionFormat == OMX_VIDEO_CodingMPEG4) 1302826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1303826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.nPFrames = pParam->nPFrames; 1304826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(m_sParamMPEG4.eProfile != OMX_VIDEO_MPEG4ProfileSimple) 1305826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.nBFrames = pParam->nBFrames; 1306826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1307826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamMPEG4.nBFrames = 0; 1308826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1309826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else if(m_sOutPortFormat.eCompressionFormat == OMX_VIDEO_CodingH263) 1310826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1311826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamH263.nPFrames = pParam->nPFrames; 1312826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1313826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1314826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1315826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nPFrames = pParam->nPFrames; 1316826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(m_sParamAVC.eProfile != OMX_VIDEO_AVCProfileBaseline) 1317826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nBFrames = pParam->nBFrames; 1318826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1319826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sParamAVC.nBFrames = 0; 1320826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1321826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1322826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1323826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1324dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: (QOMX_IndexConfigVideoIntraperiod) Unsupported port index: %u", pParam->nPortIndex); 1325826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorBadPortIndex; 1326826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1327826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1328826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev break; 1329826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1330826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 133147e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexConfigVideoIntraVOPRefresh: 133247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 133347e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_CONFIG_INTRAREFRESHVOPTYPE* pParam = 133447e37c4428509524ee576920a98381f3e4872493Nick Pelly reinterpret_cast<OMX_CONFIG_INTRAREFRESHVOPTYPE*>(configData); 133547e37c4428509524ee576920a98381f3e4872493Nick Pelly 133647e37c4428509524ee576920a98381f3e4872493Nick Pelly if(pParam->nPortIndex == PORT_INDEX_OUT) 133747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 133847e37c4428509524ee576920a98381f3e4872493Nick Pelly if(handle->venc_set_config(configData, 133947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_IndexConfigVideoIntraVOPRefresh) != true) 134047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 134147e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: Setting OMX_IndexConfigVideoIntraVOPRefresh failed"); 134247e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorUnsupportedSetting; 134347e37c4428509524ee576920a98381f3e4872493Nick Pelly } 134447e37c4428509524ee576920a98381f3e4872493Nick Pelly 134547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sConfigIntraRefreshVOP.IntraRefreshVOP = pParam->IntraRefreshVOP; 134647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 134747e37c4428509524ee576920a98381f3e4872493Nick Pelly else 134847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1349dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: Unsupported port index: %u", pParam->nPortIndex); 135047e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorBadPortIndex; 135147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 135247e37c4428509524ee576920a98381f3e4872493Nick Pelly 135347e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 135447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 135547e37c4428509524ee576920a98381f3e4872493Nick Pelly case OMX_IndexConfigCommonRotate: 135647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1357826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_CONFIG_ROTATIONTYPE *pParam = 1358826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev reinterpret_cast<OMX_CONFIG_ROTATIONTYPE*>(configData); 1359826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_S32 nRotation; 1360826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1361826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(pParam->nPortIndex != PORT_INDEX_IN){ 1362dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: Unsupported port index: %u", pParam->nPortIndex); 1363826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorBadPortIndex; 1364826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1365826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if( pParam->nRotation == 0 || 1366826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev pParam->nRotation == 90 || 1367826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev pParam->nRotation == 180 || 1368826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev pParam->nRotation == 270 ) { 1369dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_HIGH("\nset_config: Rotation Angle %u", pParam->nRotation); 1370826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } else { 1371dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("ERROR: un supported Rotation %u", pParam->nRotation); 1372826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1373826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1374826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev nRotation = pParam->nRotation - m_sConfigFrameRotation.nRotation; 1375826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(nRotation < 0) 1376826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev nRotation = -nRotation; 1377826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(nRotation == 90 || nRotation == 270) { 1378826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_HIGH("\nset_config: updating device Dims"); 1379826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(handle->venc_set_config(configData, 1380826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_IndexConfigCommonRotate) != true) { 1381826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: Set OMX_IndexConfigCommonRotate failed"); 1382826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return OMX_ErrorUnsupportedSetting; 1383826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } else { 1384826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_U32 nFrameWidth; 1385826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1386826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_HIGH("\nset_config: updating port Dims"); 1387826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1388826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev nFrameWidth = m_sInPortDef.format.video.nFrameWidth; 1389826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nFrameWidth = 1390826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nFrameHeight; 1391826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nFrameHeight = nFrameWidth; 1392826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1393826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.format.video.nFrameWidth = 1394826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nFrameWidth; 1395826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sOutPortDef.format.video.nFrameHeight = 1396826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sInPortDef.format.video.nFrameHeight; 1397826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sConfigFrameRotation.nRotation = pParam->nRotation; 1398826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1399826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } else { 1400826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev m_sConfigFrameRotation.nRotation = pParam->nRotation; 1401826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1402826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev break; 1403826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1404826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev case OMX_QcomIndexConfigVideoFramePackingArrangement: 1405826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1406826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(m_sOutPortFormat.eCompressionFormat == OMX_VIDEO_CodingAVC) 1407826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1408826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev OMX_QCOM_FRAME_PACK_ARRANGEMENT *configFmt = 1409826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev (OMX_QCOM_FRAME_PACK_ARRANGEMENT *) configData; 1410826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev extra_data_handle.set_frame_pack_data(configFmt); 1411826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 1412826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev else 1413826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev { 1414826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev DEBUG_PRINT_ERROR("ERROR: FramePackingData not supported for non AVC compression"); 1415826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev } 141647e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 141747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 141847e37c4428509524ee576920a98381f3e4872493Nick Pelly default: 141947e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("ERROR: unsupported index %d", (int) configIndex); 142047e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 142147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 142247e37c4428509524ee576920a98381f3e4872493Nick Pelly 142347e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorNone; 142447e37c4428509524ee576920a98381f3e4872493Nick Pelly} 142547e37c4428509524ee576920a98381f3e4872493Nick Pelly 142647e37c4428509524ee576920a98381f3e4872493Nick Pelly/* ====================================================================== 142747e37c4428509524ee576920a98381f3e4872493Nick PellyFUNCTION 142847e37c4428509524ee576920a98381f3e4872493Nick Pelly omx_venc::ComponentDeInit 142947e37c4428509524ee576920a98381f3e4872493Nick Pelly 143047e37c4428509524ee576920a98381f3e4872493Nick PellyDESCRIPTION 143147e37c4428509524ee576920a98381f3e4872493Nick Pelly Destroys the component and release memory allocated to the heap. 143247e37c4428509524ee576920a98381f3e4872493Nick Pelly 143347e37c4428509524ee576920a98381f3e4872493Nick PellyPARAMETERS 143447e37c4428509524ee576920a98381f3e4872493Nick Pelly <TBD>. 143547e37c4428509524ee576920a98381f3e4872493Nick Pelly 143647e37c4428509524ee576920a98381f3e4872493Nick PellyRETURN VALUE 143747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX Error None if everything successful. 143847e37c4428509524ee576920a98381f3e4872493Nick Pelly 143947e37c4428509524ee576920a98381f3e4872493Nick Pelly========================================================================== */ 144047e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_ERRORTYPE omx_venc::component_deinit(OMX_IN OMX_HANDLETYPE hComp) 144147e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 144247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 i = 0; 144347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("\n omx_venc(): Inside component_deinit()"); 144447e37c4428509524ee576920a98381f3e4872493Nick Pelly if(OMX_StateLoaded != m_state) 144547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 144647e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("WARNING:Rxd DeInit,OMX not in LOADED state %d\n",\ 144747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_state); 144847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 144947e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_out_mem_ptr) 145047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 145147e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("Freeing the Output Memory\n"); 145247e37c4428509524ee576920a98381f3e4872493Nick Pelly for(i=0; i< m_sOutPortDef.nBufferCountActual; i++ ) 145347e37c4428509524ee576920a98381f3e4872493Nick Pelly { 145447e37c4428509524ee576920a98381f3e4872493Nick Pelly free_output_buffer (&m_out_mem_ptr[i]); 145547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 145647e37c4428509524ee576920a98381f3e4872493Nick Pelly free(m_out_mem_ptr); 145747e37c4428509524ee576920a98381f3e4872493Nick Pelly m_out_mem_ptr = NULL; 145847e37c4428509524ee576920a98381f3e4872493Nick Pelly } 145947e37c4428509524ee576920a98381f3e4872493Nick Pelly 146047e37c4428509524ee576920a98381f3e4872493Nick Pelly /*Check if the input buffers have to be cleaned up*/ 1461826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev if(m_inp_mem_ptr 1462826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 1463826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev && !meta_mode_enable 1464826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 1465826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev ) 146647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 146747e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("Freeing the Input Memory\n"); 146847e37c4428509524ee576920a98381f3e4872493Nick Pelly for(i=0; i<m_sInPortDef.nBufferCountActual; i++ ) 146947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 147047e37c4428509524ee576920a98381f3e4872493Nick Pelly free_input_buffer (&m_inp_mem_ptr[i]); 147147e37c4428509524ee576920a98381f3e4872493Nick Pelly } 147247e37c4428509524ee576920a98381f3e4872493Nick Pelly 147347e37c4428509524ee576920a98381f3e4872493Nick Pelly 147447e37c4428509524ee576920a98381f3e4872493Nick Pelly free(m_inp_mem_ptr); 147547e37c4428509524ee576920a98381f3e4872493Nick Pelly m_inp_mem_ptr = NULL; 147647e37c4428509524ee576920a98381f3e4872493Nick Pelly } 147747e37c4428509524ee576920a98381f3e4872493Nick Pelly 147847e37c4428509524ee576920a98381f3e4872493Nick Pelly // Reset counters in mesg queues 147947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_ftb_q.m_size=0; 148047e37c4428509524ee576920a98381f3e4872493Nick Pelly m_cmd_q.m_size=0; 148147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_etb_q.m_size=0; 148247e37c4428509524ee576920a98381f3e4872493Nick Pelly m_ftb_q.m_read = m_ftb_q.m_write =0; 148347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_cmd_q.m_read = m_cmd_q.m_write =0; 148447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_etb_q.m_read = m_etb_q.m_write =0; 148547e37c4428509524ee576920a98381f3e4872493Nick Pelly 148647e37c4428509524ee576920a98381f3e4872493Nick Pelly#ifdef _ANDROID_ 148747e37c4428509524ee576920a98381f3e4872493Nick Pelly // Clear the strong reference 148847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("Calling m_heap_ptr.clear()\n"); 148947e37c4428509524ee576920a98381f3e4872493Nick Pelly m_heap_ptr.clear(); 149047e37c4428509524ee576920a98381f3e4872493Nick Pelly#endif // _ANDROID_ 149147e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("Calling venc_close()\n"); 149247e37c4428509524ee576920a98381f3e4872493Nick Pelly handle->venc_close(); 149347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("Deleting HANDLE[%p]\n", handle); 149447e37c4428509524ee576920a98381f3e4872493Nick Pelly delete (handle); 149547e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_HIGH("OMX_Venc:Component Deinit\n"); 149647e37c4428509524ee576920a98381f3e4872493Nick Pelly return OMX_ErrorNone; 149747e37c4428509524ee576920a98381f3e4872493Nick Pelly} 149847e37c4428509524ee576920a98381f3e4872493Nick Pelly 149947e37c4428509524ee576920a98381f3e4872493Nick Pelly 150047e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_U32 omx_venc::dev_stop( void) 150147e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 150247e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_stop(); 150347e37c4428509524ee576920a98381f3e4872493Nick Pelly} 150447e37c4428509524ee576920a98381f3e4872493Nick Pelly 150547e37c4428509524ee576920a98381f3e4872493Nick Pelly 150647e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_U32 omx_venc::dev_pause(void) 150747e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 150847e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_pause(); 150947e37c4428509524ee576920a98381f3e4872493Nick Pelly} 151047e37c4428509524ee576920a98381f3e4872493Nick Pelly 151147e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_U32 omx_venc::dev_start(void) 151247e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 151347e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_start(); 151447e37c4428509524ee576920a98381f3e4872493Nick Pelly} 151547e37c4428509524ee576920a98381f3e4872493Nick Pelly 151647e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_U32 omx_venc::dev_flush(unsigned port) 151747e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 151847e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_flush(port); 151947e37c4428509524ee576920a98381f3e4872493Nick Pelly} 152047e37c4428509524ee576920a98381f3e4872493Nick PellyOMX_U32 omx_venc::dev_resume(void) 152147e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 152247e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_resume(); 152347e37c4428509524ee576920a98381f3e4872493Nick Pelly} 152447e37c4428509524ee576920a98381f3e4872493Nick Pelly 1525826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan MalchevOMX_U32 omx_venc::dev_start_done(void) 152647e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 1527826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_start_done(); 1528826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 1529826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1530dd5743ee305c8db17facba3e0176a3d07adc7499Rom LemarchandOMX_U32 omx_venc::dev_stop_done(void) 1531826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1532dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand return handle->venc_stop_done(); 1533826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 1534826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1535826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_use_buf(void *buf_addr,unsigned port,unsigned index) 1536826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1537826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_use_buf(buf_addr,port,index); 153847e37c4428509524ee576920a98381f3e4872493Nick Pelly} 153947e37c4428509524ee576920a98381f3e4872493Nick Pelly 154047e37c4428509524ee576920a98381f3e4872493Nick Pellybool omx_venc::dev_free_buf(void *buf_addr,unsigned port) 154147e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 154247e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_free_buf(buf_addr,port); 154347e37c4428509524ee576920a98381f3e4872493Nick Pelly} 154447e37c4428509524ee576920a98381f3e4872493Nick Pelly 1545826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_empty_buf(void *buffer, void *pmem_data_buf,unsigned index,unsigned fd) 154647e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 1547826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_empty_buf(buffer, pmem_data_buf,index,fd); 154847e37c4428509524ee576920a98381f3e4872493Nick Pelly} 154947e37c4428509524ee576920a98381f3e4872493Nick Pelly 1550826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_fill_buf(void *buffer, void *pmem_data_buf,unsigned index,unsigned fd) 155147e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 1552826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_fill_buf(buffer, pmem_data_buf,index,fd); 155347e37c4428509524ee576920a98381f3e4872493Nick Pelly} 155447e37c4428509524ee576920a98381f3e4872493Nick Pelly 1555826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_get_seq_hdr(void *buffer, unsigned size, unsigned *hdrlen) 1556826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1557826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_get_seq_hdr(buffer, size, hdrlen); 1558826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 1559826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1560826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_loaded_start() 1561826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1562826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_loaded_start(); 1563826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 1564826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1565826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_loaded_stop() 1566826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1567826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_loaded_stop(); 1568826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 1569826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1570826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_loaded_start_done() 1571826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1572826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_loaded_start_done(); 1573826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 1574826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev 1575826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchevbool omx_venc::dev_loaded_stop_done() 1576826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev{ 1577826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev return handle->venc_loaded_stop_done(); 1578826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev} 157947e37c4428509524ee576920a98381f3e4872493Nick Pelly 158047e37c4428509524ee576920a98381f3e4872493Nick Pellybool omx_venc::dev_get_buf_req(OMX_U32 *min_buff_count, 158147e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 *actual_buff_count, 158247e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 *buff_size, 158347e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 port) 158447e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 158547e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_get_buf_req(min_buff_count, 158647e37c4428509524ee576920a98381f3e4872493Nick Pelly actual_buff_count, 158747e37c4428509524ee576920a98381f3e4872493Nick Pelly buff_size, 158847e37c4428509524ee576920a98381f3e4872493Nick Pelly port); 158947e37c4428509524ee576920a98381f3e4872493Nick Pelly 159047e37c4428509524ee576920a98381f3e4872493Nick Pelly} 159147e37c4428509524ee576920a98381f3e4872493Nick Pelly 159247e37c4428509524ee576920a98381f3e4872493Nick Pellybool omx_venc::dev_set_buf_req(OMX_U32 *min_buff_count, 159347e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 *actual_buff_count, 159447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 *buff_size, 159547e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_U32 port) 159647e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 159747e37c4428509524ee576920a98381f3e4872493Nick Pelly return handle->venc_set_buf_req(min_buff_count, 159847e37c4428509524ee576920a98381f3e4872493Nick Pelly actual_buff_count, 159947e37c4428509524ee576920a98381f3e4872493Nick Pelly buff_size, 160047e37c4428509524ee576920a98381f3e4872493Nick Pelly port); 160147e37c4428509524ee576920a98381f3e4872493Nick Pelly 160247e37c4428509524ee576920a98381f3e4872493Nick Pelly} 160347e37c4428509524ee576920a98381f3e4872493Nick Pelly 160447e37c4428509524ee576920a98381f3e4872493Nick Pellyint omx_venc::async_message_process (void *context, void* message) 160547e37c4428509524ee576920a98381f3e4872493Nick Pelly{ 160647e37c4428509524ee576920a98381f3e4872493Nick Pelly omx_video* omx = NULL; 160747e37c4428509524ee576920a98381f3e4872493Nick Pelly struct venc_msg *m_sVenc_msg = NULL; 160847e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_BUFFERHEADERTYPE* omxhdr = NULL; 160947e37c4428509524ee576920a98381f3e4872493Nick Pelly struct venc_buffer *temp_buff = NULL; 161047e37c4428509524ee576920a98381f3e4872493Nick Pelly 161147e37c4428509524ee576920a98381f3e4872493Nick Pelly if(context == NULL || message == NULL) 161247e37c4428509524ee576920a98381f3e4872493Nick Pelly { 161347e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_ERROR("\nERROR: omx_venc::async_message_process invalid i/p params"); 161447e37c4428509524ee576920a98381f3e4872493Nick Pelly return -1; 161547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 161647e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg = (struct venc_msg *)message; 161747e37c4428509524ee576920a98381f3e4872493Nick Pelly 161847e37c4428509524ee576920a98381f3e4872493Nick Pelly omx = reinterpret_cast<omx_video*>(context); 161947e37c4428509524ee576920a98381f3e4872493Nick Pelly 162047e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_sVenc_msg->statuscode != VEN_S_SUCCESS) 162147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1622dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand DEBUG_PRINT_ERROR("\nERROR: async_msg_process() - Error statuscode = %d\n", 162347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg->statuscode); 162447e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->omx_report_error(); 162547e37c4428509524ee576920a98381f3e4872493Nick Pelly } 162647e37c4428509524ee576920a98381f3e4872493Nick Pelly 162747e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n omx_venc::async_message_process- msgcode = %d\n", 162847e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg->msgcode); 162947e37c4428509524ee576920a98381f3e4872493Nick Pelly switch(m_sVenc_msg->msgcode) 163047e37c4428509524ee576920a98381f3e4872493Nick Pelly { 1631dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 163247e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_START: 163347e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event (NULL,m_sVenc_msg->statuscode,\ 163447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_START_DONE); 163547e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 1636dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 163747e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_STOP: 163847e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event (NULL,m_sVenc_msg->statuscode,\ 163947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_STOP_DONE); 164047e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 1641dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 164247e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_RESUME: 164347e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event (NULL,m_sVenc_msg->statuscode,\ 164447e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_RESUME_DONE); 164547e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 1646dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 164747e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_PAUSE: 164847e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event (NULL,m_sVenc_msg->statuscode,\ 164947e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_PAUSE_DONE); 1650dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 165147e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 1652dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 165347e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_FLUSH_INPUT_DONE: 165447e37c4428509524ee576920a98381f3e4872493Nick Pelly 165547e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event (NULL,m_sVenc_msg->statuscode,\ 165647e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_EVENT_INPUT_FLUSH); 165747e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 165847e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_FLUSH_OUPUT_DONE: 165947e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event (NULL,m_sVenc_msg->statuscode,\ 166047e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_EVENT_OUTPUT_FLUSH); 166147e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 166247e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_INPUT_BUFFER_DONE: 166347e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr = (OMX_BUFFERHEADERTYPE* )\ 166447e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg->buf.clientdata; 166547e37c4428509524ee576920a98381f3e4872493Nick Pelly 166647e37c4428509524ee576920a98381f3e4872493Nick Pelly if(omxhdr == NULL || 1667dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand (((OMX_U32)(omxhdr - omx->m_inp_mem_ptr) > omx->m_sInPortDef.nBufferCountActual) && 1668dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand ((OMX_U32)(omxhdr - omx->meta_buffer_hdr) > omx->m_sInPortDef.nBufferCountActual))) 166947e37c4428509524ee576920a98381f3e4872493Nick Pelly { 167047e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr = NULL; 167147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg->statuscode = VEN_S_EFAIL; 167247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 1673dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 1674826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#ifdef _ANDROID_ICS_ 1675dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand omx->omx_release_meta_buffer(omxhdr); 1676826ececcbea342f7a0b92ec61847f1c95d384e05Iliyan Malchev#endif 167747e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event ((unsigned int)omxhdr,m_sVenc_msg->statuscode, 167847e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_EBD); 167947e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 168047e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_OUTPUT_BUFFER_DONE: 1681dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 168247e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr = (OMX_BUFFERHEADERTYPE*)m_sVenc_msg->buf.clientdata; 168347e37c4428509524ee576920a98381f3e4872493Nick Pelly 168447e37c4428509524ee576920a98381f3e4872493Nick Pelly if( (omxhdr != NULL) && 168547e37c4428509524ee576920a98381f3e4872493Nick Pelly ((OMX_U32)(omxhdr - omx->m_out_mem_ptr) < omx->m_sOutPortDef.nBufferCountActual)) 168647e37c4428509524ee576920a98381f3e4872493Nick Pelly { 168747e37c4428509524ee576920a98381f3e4872493Nick Pelly if(m_sVenc_msg->buf.len <= omxhdr->nAllocLen) 168847e37c4428509524ee576920a98381f3e4872493Nick Pelly { 168947e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr->nFilledLen = m_sVenc_msg->buf.len; 169047e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr->nOffset = m_sVenc_msg->buf.offset; 169147e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr->nTimeStamp = m_sVenc_msg->buf.timestamp; 169247e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n o/p TS = %u", (OMX_U32)m_sVenc_msg->buf.timestamp); 169347e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr->nFlags = m_sVenc_msg->buf.flags; 169447e37c4428509524ee576920a98381f3e4872493Nick Pelly 169547e37c4428509524ee576920a98381f3e4872493Nick Pelly /*Use buffer case*/ 169647e37c4428509524ee576920a98381f3e4872493Nick Pelly if(omx->output_use_buffer && !omx->m_use_output_pmem) 169747e37c4428509524ee576920a98381f3e4872493Nick Pelly { 169847e37c4428509524ee576920a98381f3e4872493Nick Pelly DEBUG_PRINT_LOW("\n memcpy() for o/p Heap UseBuffer"); 169947e37c4428509524ee576920a98381f3e4872493Nick Pelly memcpy(omxhdr->pBuffer, 170047e37c4428509524ee576920a98381f3e4872493Nick Pelly (m_sVenc_msg->buf.ptrbuffer), 170147e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg->buf.len); 170247e37c4428509524ee576920a98381f3e4872493Nick Pelly } 170347e37c4428509524ee576920a98381f3e4872493Nick Pelly } 170447e37c4428509524ee576920a98381f3e4872493Nick Pelly else 170547e37c4428509524ee576920a98381f3e4872493Nick Pelly { 170647e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr->nFilledLen = 0; 170747e37c4428509524ee576920a98381f3e4872493Nick Pelly } 170847e37c4428509524ee576920a98381f3e4872493Nick Pelly 170947e37c4428509524ee576920a98381f3e4872493Nick Pelly } 171047e37c4428509524ee576920a98381f3e4872493Nick Pelly else 171147e37c4428509524ee576920a98381f3e4872493Nick Pelly { 171247e37c4428509524ee576920a98381f3e4872493Nick Pelly omxhdr = NULL; 171347e37c4428509524ee576920a98381f3e4872493Nick Pelly m_sVenc_msg->statuscode = VEN_S_EFAIL; 171447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 1715dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand 171647e37c4428509524ee576920a98381f3e4872493Nick Pelly omx->post_event ((unsigned int)omxhdr,m_sVenc_msg->statuscode, 171747e37c4428509524ee576920a98381f3e4872493Nick Pelly OMX_COMPONENT_GENERATE_FBD); 171847e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 171947e37c4428509524ee576920a98381f3e4872493Nick Pelly case VEN_MSG_NEED_OUTPUT_BUFFER: 172047e37c4428509524ee576920a98381f3e4872493Nick Pelly //TBD what action needs to be done here?? 172147e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 172247e37c4428509524ee576920a98381f3e4872493Nick Pelly default: 172347e37c4428509524ee576920a98381f3e4872493Nick Pelly break; 172447e37c4428509524ee576920a98381f3e4872493Nick Pelly } 172547e37c4428509524ee576920a98381f3e4872493Nick Pelly return 0; 172647e37c4428509524ee576920a98381f3e4872493Nick Pelly} 1727dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchandbool omx_venc::is_secure_session() 1728dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand{ 1729dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand return secure_session; 1730dd5743ee305c8db17facba3e0176a3d07adc7499Rom Lemarchand} 1731