OMXVideoEncoderBase.h revision 354e38d88215e6d1c3c22bd15c8c7a1b1b0e029b
1/* 2* Copyright (c) 2009-2011 Intel Corporation. All rights reserved. 3* 4* Licensed under the Apache License, Version 2.0 (the "License"); 5* you may not use this file except in compliance with the License. 6* You may obtain a copy of the License at 7* 8* http://www.apache.org/licenses/LICENSE-2.0 9* 10* Unless required by applicable law or agreed to in writing, software 11* distributed under the License is distributed on an "AS IS" BASIS, 12* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13* See the License for the specific language governing permissions and 14* limitations under the License. 15*/ 16 17 18 19#ifndef OMX_VIDEO_ENCODER_BASE_H_ 20#define OMX_VIDEO_ENCODER_BASE_H_ 21 22#include "OMXComponentCodecBase.h" 23#include <va/va_tpi.h> 24#include <va/va_android.h> 25#include <VideoEncoderHost.h> 26 27#define LOGV(...) LOGI_IF(mOmxLogLevel, __VA_ARGS__) 28#define LOGI(...) LOGI_IF(mOmxLogLevel, __VA_ARGS__) 29#define LOGW(...) LOGI_IF(mOmxLogLevel, __VA_ARGS__) 30#define LOGD(...) LOGI_IF(mOmxLogLevel, __VA_ARGS__) 31 32using android::sp; 33 34class OMXVideoEncoderBase : public OMXComponentCodecBase { 35public: 36 OMXVideoEncoderBase(); 37 virtual ~OMXVideoEncoderBase(); 38 39protected: 40 virtual OMX_ERRORTYPE InitInputPort(void); 41 virtual OMX_ERRORTYPE InitOutputPort(void); 42 virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput); 43 virtual OMX_ERRORTYPE InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionOutput) = 0; 44 45 virtual OMX_ERRORTYPE ProcessorInit(void); 46 virtual OMX_ERRORTYPE ProcessorDeinit(void); 47 //virtual OMX_ERRORTYPE ProcessorStart(void); 48 virtual OMX_ERRORTYPE ProcessorStop(void); 49 //virtual OMX_ERRORTYPE ProcessorPause(void); 50 //virtual OMX_ERRORTYPE ProcessorResume(void); 51 virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex); 52 virtual OMX_ERRORTYPE ProcessorProcess( 53 OMX_BUFFERHEADERTYPE **buffers, 54 buffer_retain_t *retains, 55 OMX_U32 numberBuffers); 56 57 virtual OMX_ERRORTYPE BuildHandlerList(void); 58 59 DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoPortFormat); 60 DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoBitrate); 61 DECLARE_HANDLER(OMXVideoEncoderBase, IntelPrivateInfo); 62 DECLARE_HANDLER(OMXVideoEncoderBase, ParamIntelBitrate); 63 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigIntelBitrate); 64 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigIntelAIR); 65 DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoIntraRefresh); 66 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoFramerate); 67 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoIntraVOPRefresh); 68 DECLARE_HANDLER(OMXVideoEncoderBase, ParamIntelAdaptiveSliceControl); 69 //DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoProfileLevelQuerySupported); 70 DECLARE_HANDLER(OMXVideoEncoderBase, StoreMetaDataInBuffers); 71 DECLARE_HANDLER(OMXVideoEncoderBase, SyncEncoding); 72 DECLARE_HANDLER(OMXVideoEncoderBase, PrependSPSPPS); 73 DECLARE_HANDLER(OMXVideoEncoderBase, TemporalLayerNumber); 74 75protected: 76 virtual OMX_ERRORTYPE SetVideoEncoderParam(); 77protected: 78 OMX_VIDEO_PARAM_BITRATETYPE mParamBitrate; 79 OMX_VIDEO_CONFIG_PRI_INFOTYPE mConfigPriInfo; 80 OMX_VIDEO_PARAM_INTEL_BITRATETYPE mParamIntelBitrate; 81 OMX_VIDEO_CONFIG_INTEL_BITRATETYPE mConfigIntelBitrate; 82 OMX_VIDEO_CONFIG_INTEL_AIR mConfigIntelAir; 83 OMX_VIDEO_PARAM_INTRAREFRESHTYPE mParamVideoRefresh; 84 OMX_CONFIG_FRAMERATETYPE mConfigFramerate; 85 OMX_VIDEO_PARAM_INTEL_ADAPTIVE_SLICE_CONTROL mParamIntelAdaptiveSliceControl; 86 OMX_VIDEO_PARAM_PROFILELEVELTYPE mParamProfileLevel; 87 OMX_VIDEO_PARAM_INTEL_NUMBER_OF_TEMPORAL_LAYER mNumberOfTemporalLayer; 88 89 IVideoEncoder *mVideoEncoder; 90 VideoParamsCommon *mEncoderParams; 91 OMX_U32 mFrameInputCount; 92 OMX_U32 mFrameOutputCount; 93 OMX_BOOL mFirstFrame; 94 OMX_BOOL mFrameRetrieved; 95 OMX_BOOL mStoreMetaDataInBuffers; 96 OMX_BOOL mSyncEncoding; 97 int32_t mOmxLogLevel; 98 99private: 100 101 enum { 102 // OMX_PARAM_PORTDEFINITIONTYPE 103 INPORT_MIN_BUFFER_COUNT = 1, 104 // FIXME: increate input buffer count to 5 105#ifdef USE_VIDEO_EFFECT 106 INPORT_ACTUAL_BUFFER_COUNT = 5, 107#else 108 INPORT_ACTUAL_BUFFER_COUNT = 2, 109#endif 110 INPORT_BUFFER_SIZE = 1382400, 111 112 // OMX_PARAM_PORTDEFINITIONTYPE 113 OUTPORT_MIN_BUFFER_COUNT = 1, 114 OUTPORT_ACTUAL_BUFFER_COUNT = 2, 115 OUTPORT_BUFFER_SIZE = 1382400, 116 }; 117 118}; 119 120#endif /* OMX_VIDEO_ENCODER_BASE_H_ */ 121