OMXVideoEncoderBase.h revision 7ac0b6c4ed773c7f43dfb35f098f6f989a52d6e2
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#include <hal/hal_public.h> 28 29using android::sp; 30 31#define SHARED_BUFFER_CNT 7 32#define OMX_COLOR_FormatAndroidOpaque 0x7F000789 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, ConfigVideoFramerate); 66 DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoIntraVOPRefresh); 67 DECLARE_HANDLER(OMXVideoEncoderBase, ParamIntelAdaptiveSliceControl); 68 //DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoProfileLevelQuerySupported); 69 DECLARE_HANDLER(OMXVideoEncoderBase, StoreMetaDataInBuffers); 70 71protected: 72 virtual OMX_ERRORTYPE SetVideoEncoderParam(); 73protected: 74 OMX_VIDEO_PARAM_BITRATETYPE mParamBitrate; 75 OMX_VIDEO_CONFIG_PRI_INFOTYPE mConfigPriInfo; 76 OMX_VIDEO_PARAM_INTEL_BITRATETYPE mParamIntelBitrate; 77 OMX_VIDEO_CONFIG_INTEL_BITRATETYPE mConfigIntelBitrate; 78 OMX_VIDEO_CONFIG_INTEL_AIR mConfigIntelAir; 79 OMX_CONFIG_FRAMERATETYPE mConfigFramerate; 80 OMX_VIDEO_PARAM_INTEL_ADAPTIVE_SLICE_CONTROL mParamIntelAdaptiveSliceControl; 81 OMX_VIDEO_PARAM_PROFILELEVELTYPE mParamProfileLevel; 82 83 IVideoEncoder *mVideoEncoder; 84 VideoParamsCommon *mEncoderParams; 85 OMX_U32 mFrameInputCount; 86 OMX_U32 mFrameOutputCount; 87 OMX_BOOL mFirstFrame; 88 OMX_BOOL mFrameRetrieved; 89 OMX_BOOL mStoreMetaDataInBuffers; 90 91private: 92 93 enum { 94 // OMX_PARAM_PORTDEFINITIONTYPE 95 INPORT_MIN_BUFFER_COUNT = 1, 96 // FIXME: increate input buffer count to 5 97#if (MFLD_GI || YUKKA) 98 INPORT_ACTUAL_BUFFER_COUNT = 2, 99#else 100 INPORT_ACTUAL_BUFFER_COUNT = 5, 101#endif 102 INPORT_BUFFER_SIZE = 1382400, 103 104 // OMX_PARAM_PORTDEFINITIONTYPE 105 OUTPORT_MIN_BUFFER_COUNT = 1, 106 OUTPORT_ACTUAL_BUFFER_COUNT = 2, 107 OUTPORT_BUFFER_SIZE = 1382400, 108 }; 109 110 OMX_U32 mPFrames; 111 112public: 113 struct { 114 OMX_BUFFERHEADERTYPE* mHeader; 115 buffer_handle_t srcBuffer; 116 uint8_t backBuffer[4 + sizeof(buffer_handle_t)]; 117 IMG_native_handle_t* mHandle; 118 int32_t mStride; 119 void *vaddr[3]; 120 } mBufferHandleMaps[INPORT_ACTUAL_BUFFER_COUNT]; 121 OMX_BOOL bAndroidOpaqueFormat; 122 alloc_device_t *mAllocDev; 123 IMG_gralloc_module_public_t const *mGrallocMod; 124 int32_t mCurHandle; 125 int32_t rgba2nv12conversion(OMX_BUFFERHEADERTYPE*); 126 127}; 128 129#endif /* OMX_VIDEO_ENCODER_BASE_H_ */ 130