• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, ConfigVideoBitrate);
76     DECLARE_HANDLER(OMXVideoEncoderBase, BlackFramePointer);
77 
78 protected:
79     virtual OMX_ERRORTYPE SetVideoEncoderParam();
80 protected:
81     OMX_VIDEO_PARAM_BITRATETYPE mParamBitrate;
82     OMX_VIDEO_CONFIG_PRI_INFOTYPE mConfigPriInfo;
83     OMX_VIDEO_CONFIG_INTEL_BITRATETYPE mConfigIntelBitrate;
84     OMX_VIDEO_CONFIG_INTEL_AIR mConfigIntelAir;
85     OMX_VIDEO_PARAM_INTRAREFRESHTYPE mParamVideoRefresh;
86     OMX_CONFIG_FRAMERATETYPE  mConfigFramerate;
87     OMX_VIDEO_PARAM_INTEL_ADAPTIVE_SLICE_CONTROL mParamIntelAdaptiveSliceControl;
88     OMX_VIDEO_PARAM_PROFILELEVELTYPE mParamProfileLevel;
89     OMX_VIDEO_PARAM_INTEL_TEMPORAL_LAYER mTemporalLayer;
90     OMX_VIDEO_CONFIG_BITRATETYPE mConfigBitrate;
91 
92     IVideoEncoder *mVideoEncoder;
93     VideoParamsCommon *mEncoderParams;
94     OMX_U32 mFrameInputCount;
95     OMX_U32 mFrameOutputCount;
96     OMX_BOOL mFirstFrame;
97     OMX_BOOL mFrameRetrieved;
98     OMX_BOOL mStoreMetaDataInBuffers;
99     OMX_BOOL mSyncEncoding;
100     int32_t mOmxLogLevel;
101     OMX_PTR mBlackFramePointer;
102 
103 private:
104 
105     enum {
106         // OMX_PARAM_PORTDEFINITIONTYPE
107         INPORT_MIN_BUFFER_COUNT = 1,
108         // FIXME: increate input buffer count to 5
109 #ifdef USE_VIDEO_EFFECT
110         INPORT_ACTUAL_BUFFER_COUNT = 5,
111 #else
112         INPORT_ACTUAL_BUFFER_COUNT = 2,
113 #endif
114         INPORT_BUFFER_SIZE = 1382400,
115 
116         // OMX_PARAM_PORTDEFINITIONTYPE
117         OUTPORT_MIN_BUFFER_COUNT = 1,
118         OUTPORT_ACTUAL_BUFFER_COUNT = 2,
119         OUTPORT_BUFFER_SIZE = 1382400,
120     };
121 
122 };
123 
124 #endif /* OMX_VIDEO_ENCODER_BASE_H_ */
125