Home | History | Annotate | Download | only in videocodec
      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(...) ALOGI_IF(mOmxLogLevel, __VA_ARGS__)
     28 #define LOGI(...) ALOGI_IF(mOmxLogLevel, __VA_ARGS__)
     29 #define LOGW(...) ALOGI_IF(mOmxLogLevel, __VA_ARGS__)
     30 #define LOGD(...) ALOGI_IF(mOmxLogLevel, __VA_ARGS__)
     31 #define LOGE ALOGE
     32 #define LOGV_IF ALOGV_IF
     33 
     34 using android::sp;
     35 
     36 class OMXVideoEncoderBase : public OMXComponentCodecBase {
     37 public:
     38     OMXVideoEncoderBase();
     39     virtual ~OMXVideoEncoderBase();
     40 
     41 protected:
     42     virtual OMX_ERRORTYPE InitInputPort(void);
     43     virtual OMX_ERRORTYPE InitOutputPort(void);
     44     virtual OMX_ERRORTYPE InitInputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionInput);
     45     virtual OMX_ERRORTYPE InitOutputPortFormatSpecific(OMX_PARAM_PORTDEFINITIONTYPE *paramPortDefinitionOutput) = 0;
     46 
     47     virtual OMX_ERRORTYPE ProcessorInit(void);
     48     virtual OMX_ERRORTYPE ProcessorDeinit(void);
     49     //virtual OMX_ERRORTYPE ProcessorStart(void);
     50     virtual OMX_ERRORTYPE ProcessorStop(void);
     51     //virtual OMX_ERRORTYPE ProcessorPause(void);
     52     //virtual OMX_ERRORTYPE ProcessorResume(void);
     53     virtual OMX_ERRORTYPE ProcessorFlush(OMX_U32 portIndex);
     54     virtual OMX_ERRORTYPE ProcessorProcess(
     55             OMX_BUFFERHEADERTYPE **buffers,
     56             buffer_retain_t *retains,
     57             OMX_U32 numberBuffers);
     58 
     59     virtual OMX_ERRORTYPE BuildHandlerList(void);
     60 
     61     DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoPortFormat);
     62     DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoBitrate);
     63     DECLARE_HANDLER(OMXVideoEncoderBase, IntelPrivateInfo);
     64     DECLARE_HANDLER(OMXVideoEncoderBase, ConfigIntelBitrate);
     65     DECLARE_HANDLER(OMXVideoEncoderBase, ConfigIntelAIR);
     66     DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoIntraRefresh);
     67     DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoFramerate);
     68     DECLARE_HANDLER(OMXVideoEncoderBase, ConfigVideoIntraVOPRefresh);
     69     DECLARE_HANDLER(OMXVideoEncoderBase, ParamIntelAdaptiveSliceControl);
     70     //DECLARE_HANDLER(OMXVideoEncoderBase, ParamVideoProfileLevelQuerySupported);
     71     DECLARE_HANDLER(OMXVideoEncoderBase, StoreMetaDataInBuffers);
     72     DECLARE_HANDLER(OMXVideoEncoderBase, SyncEncoding);
     73     DECLARE_HANDLER(OMXVideoEncoderBase, PrependSPSPPS);
     74     DECLARE_HANDLER(OMXVideoEncoderBase, TemporalLayer);
     75     DECLARE_HANDLER(OMXVideoEncoderBase, BlackFramePointer);
     76 
     77 protected:
     78     virtual OMX_ERRORTYPE SetVideoEncoderParam();
     79 protected:
     80     OMX_VIDEO_PARAM_BITRATETYPE mParamBitrate;
     81     OMX_VIDEO_CONFIG_PRI_INFOTYPE mConfigPriInfo;
     82     OMX_VIDEO_CONFIG_INTEL_BITRATETYPE mConfigIntelBitrate;
     83     OMX_VIDEO_CONFIG_INTEL_AIR mConfigIntelAir;
     84     OMX_VIDEO_PARAM_INTRAREFRESHTYPE mParamVideoRefresh;
     85     OMX_CONFIG_FRAMERATETYPE  mConfigFramerate;
     86     OMX_VIDEO_PARAM_INTEL_ADAPTIVE_SLICE_CONTROL mParamIntelAdaptiveSliceControl;
     87     OMX_VIDEO_PARAM_PROFILELEVELTYPE mParamProfileLevel;
     88     OMX_VIDEO_PARAM_INTEL_TEMPORAL_LAYER mTemporalLayer;
     89 
     90     IVideoEncoder *mVideoEncoder;
     91     VideoParamsCommon *mEncoderParams;
     92     OMX_U32 mFrameInputCount;
     93     OMX_U32 mFrameOutputCount;
     94     OMX_BOOL mFirstFrame;
     95     OMX_BOOL mFrameRetrieved;
     96     OMX_BOOL mStoreMetaDataInBuffers;
     97     OMX_BOOL mSyncEncoding;
     98     int32_t mOmxLogLevel;
     99     OMX_PTR mBlackFramePointer;
    100 
    101 private:
    102 
    103     enum {
    104         // OMX_PARAM_PORTDEFINITIONTYPE
    105         INPORT_MIN_BUFFER_COUNT = 1,
    106         // FIXME: increate input buffer count to 5
    107 #ifdef USE_VIDEO_EFFECT
    108         INPORT_ACTUAL_BUFFER_COUNT = 5,
    109 #else
    110         INPORT_ACTUAL_BUFFER_COUNT = 2,
    111 #endif
    112         INPORT_BUFFER_SIZE = 1382400,
    113 
    114         // OMX_PARAM_PORTDEFINITIONTYPE
    115         OUTPORT_MIN_BUFFER_COUNT = 1,
    116         OUTPORT_ACTUAL_BUFFER_COUNT = 2,
    117         OUTPORT_BUFFER_SIZE = 1382400,
    118     };
    119 
    120 };
    121 
    122 #endif /* OMX_VIDEO_ENCODER_BASE_H_ */
    123