OMXVideoEncoderBase.h revision e2cc802b1588648ff0a8b45a102d3d2663209c77
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 <IntelBufferSharing.h> 24#include <va/va_tpi.h> 25#include <va/va_android.h> 26#include<VideoEncoderHost.h> 27 28using android::sp; 29using android::BufferShareRegistry; 30 31#define SHARED_BUFFER_CNT 7 32 33class OMXVideoEncoderBase : public OMXComponentCodecBase { 34public: 35 OMXVideoEncoderBase(); 36 virtual ~OMXVideoEncoderBase(); 37 38protected: 39 virtual OMX_ERRORTYPE InitInputPort(void); 40 virtual OMX_ERRORTYPE InitOutputPort(void); 41 virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput); 42 virtual OMX_ERRORTYPE InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionOutput) = 0; 43 44 virtual OMX_ERRORTYPE ProcessorInit(void); 45 virtual OMX_ERRORTYPE ProcessorDeinit(void); 46 //virtual OMX_ERRORTYPE ProcessorStart(void); 47 virtual OMX_ERRORTYPE ProcessorStop(void); 48 //virtual OMX_ERRORTYPE ProcessorPause(void); 49 //virtual OMX_ERRORTYPE ProcessorResume(void); 50 virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex); 51 virtual OMX_ERRORTYPE ProcessorProcess( 52 OMX_BUFFERHEADERTYPE **buffers, 53 buffer_retain_t *retains, 54 OMX_U32 numberBuffers); 55 56 virtual OMX_ERRORTYPE BuildHandlerList(void); 57 58 DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoPortFormat); 59 DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoBitrate); 60 DECLARE_HANDLER(OMXVideoEncoderBase, IntelPrivateInfo); 61 DECLARE_HANDLER(OMXVideoEncoderBase, ParamIntelBitrate); 62 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigIntelBitrate); 63 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigIntelAIR); 64 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoFramerate); 65 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoIntraVOPRefresh); 66 DECLARE_HANDLER(OMXVideoEncoderBase, ParamIntelAdaptiveSliceControl); 67 DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoProfileLevelQuerySupported); 68 DECLARE_HANDLER(OMXVideoEncoderBase, StoreMetaDataInBuffers); 69 70protected: 71 virtual OMX_ERRORTYPE InitBSMode(void); 72 virtual OMX_ERRORTYPE DeinitBSMode(void); 73 virtual OMX_ERRORTYPE StartBufferSharing(void); 74 virtual OMX_ERRORTYPE StopBufferSharing(void); 75 virtual OMX_ERRORTYPE SetVideoEncoderParam(); 76private: 77 OMX_ERRORTYPE CheckAndEnableBSMode(); 78 OMX_ERRORTYPE AllocateSharedBuffers(int width, int height); 79 OMX_ERRORTYPE UploadSharedBuffers(); 80 OMX_ERRORTYPE SetBSInfoToPort(); 81 OMX_ERRORTYPE TriggerBSMode(); 82protected: 83 OMX_VIDEO_PARAM_BITRATETYPE mParamBitrate; 84 OMX_VIDEO_CONFIG_PRI_INFOTYPE mConfigPriInfo; 85 OMX_VIDEO_PARAM_INTEL_BITRATETYPE mParamIntelBitrate; 86 OMX_VIDEO_CONFIG_INTEL_BITRATETYPE mConfigIntelBitrate; 87 OMX_VIDEO_CONFIG_INTEL_AIR mConfigIntelAir; 88 OMX_CONFIG_FRAMERATETYPE mConfigFramerate; 89 OMX_VIDEO_PARAM_INTEL_ADAPTIVE_SLICE_CONTROL mParamIntelAdaptiveSliceControl; 90 OMX_VIDEO_PARAM_PROFILELEVELTYPE mParamProfileLevel; 91 92 IVideoEncoder *mVideoEncoder; 93 VideoParamsCommon *mEncoderParams; 94 OMX_U32 mFrameInputCount; 95 OMX_U32 mFrameOutputCount; 96 OMX_BOOL mFirstFrame; 97 OMX_BOOL mFrameRetrieved; 98 99 enum { 100 BS_STATE_INVALID, 101 BS_STATE_LOADED, 102 BS_STATE_EXECUTING, 103 BS_STATE_FAILD 104 } mBsState; 105 106 SharedBufferType *mSharedBufArray; 107 OMX_BOOL mForceBufferSharing; 108 109private: 110 111 enum { 112 // OMX_PARAM_PORTDEFINITIONTYPE 113 INPORT_MIN_BUFFER_COUNT = 1, 114 INPORT_ACTUAL_BUFFER_COUNT = 2, 115 INPORT_BUFFER_SIZE = 1382400, 116 117 // OMX_PARAM_PORTDEFINITIONTYPE 118 OUTPORT_MIN_BUFFER_COUNT = 1, 119 OUTPORT_ACTUAL_BUFFER_COUNT = 2, 120 OUTPORT_BUFFER_SIZE = 1382400, 121 }; 122 123 sp<BufferShareRegistry> mBsInstance; 124 OMX_U32 mSharedBufCnt; 125 OMX_U32 mPFrames; 126}; 127 128#endif /* OMX_VIDEO_ENCODER_BASE_H_ */ 129