3 * Copyright 2012 Samsung Electronics S.LSI Co. LTD
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 * @file Exynos_OMX_H264enc.c
21 * @author SeungBeom Kim (sbcrux.kim@samsung.com)
31 #include "Exynos_OMX_Macros.h"
32 #include "Exynos_OMX_Basecomponent.h"
33 #include "Exynos_OMX_Baseport.h"
34 #include "Exynos_OMX_Venc.h"
35 #include "Exynos_OMX_VencControl.h"
36 #include "Exynos_OSAL_ETC.h"
37 #include "Exynos_OSAL_Semaphore.h"
38 #include "Exynos_OSAL_Thread.h"
39 #include "Exynos_OSAL_Android.h"
40 #include "library_register.h"
41 #include "Exynos_OMX_H264enc.h"
42 #include "Exynos_OSAL_SharedMemory.h"
43 #include "Exynos_OSAL_Event.h"
45 /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */
46 /* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */
50 #define EXYNOS_LOG_TAG "EXYNOS_H264_ENC"
51 #define EXYNOS_LOG_OFF
52 //#define EXYNOS_TRACE_ON
53 #include "Exynos_OSAL_Log.h"
55 /* H.264 Encoder Supported Levels & profiles */
56 EXYNOS_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels
[] ={
57 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel1
},
58 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel1b
},
59 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel11
},
60 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel12
},
61 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel13
},
62 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel2
},
63 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel21
},
64 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel22
},
65 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel3
},
66 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel31
},
67 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel32
},
68 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel4
},
69 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel41
},
70 {OMX_VIDEO_AVCProfileBaseline
, OMX_VIDEO_AVCLevel42
},
72 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel1
},
73 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel1b
},
74 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel11
},
75 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel12
},
76 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel13
},
77 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel2
},
78 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel21
},
79 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel22
},
80 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel3
},
81 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel31
},
82 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel32
},
83 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel4
},
84 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel41
},
85 {OMX_VIDEO_AVCProfileMain
, OMX_VIDEO_AVCLevel42
},
87 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel1
},
88 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel1b
},
89 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel11
},
90 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel12
},
91 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel13
},
92 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel2
},
93 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel21
},
94 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel22
},
95 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel3
},
96 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel31
},
97 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel32
},
98 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel4
},
99 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel41
},
100 {OMX_VIDEO_AVCProfileHigh
, OMX_VIDEO_AVCLevel42
}};
102 static OMX_U32
OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile
)
106 if (profile
== OMX_VIDEO_AVCProfileBaseline
)
108 else if (profile
== OMX_VIDEO_AVCProfileMain
)
110 else if (profile
== OMX_VIDEO_AVCProfileHigh
)
116 static OMX_U32
OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level
)
118 OMX_U32 ret
= 11; //default OMX_VIDEO_AVCLevel4
120 if (level
== OMX_VIDEO_AVCLevel1
)
122 else if (level
== OMX_VIDEO_AVCLevel1b
)
124 else if (level
== OMX_VIDEO_AVCLevel11
)
126 else if (level
== OMX_VIDEO_AVCLevel12
)
128 else if (level
== OMX_VIDEO_AVCLevel13
)
130 else if (level
== OMX_VIDEO_AVCLevel2
)
132 else if (level
== OMX_VIDEO_AVCLevel21
)
134 else if (level
== OMX_VIDEO_AVCLevel22
)
136 else if (level
== OMX_VIDEO_AVCLevel3
)
138 else if (level
== OMX_VIDEO_AVCLevel31
)
140 else if (level
== OMX_VIDEO_AVCLevel32
)
142 else if (level
== OMX_VIDEO_AVCLevel4
)
144 else if (level
== OMX_VIDEO_AVCLevel41
)
146 else if (level
== OMX_VIDEO_AVCLevel42
)
152 static OMX_U8
*FindDelimiter(OMX_U8
*pBuffer
, OMX_U32 size
)
156 for (i
= 0; i
< size
- 3; i
++) {
157 if ((pBuffer
[i
] == 0x00) &&
158 (pBuffer
[i
+ 1] == 0x00) &&
159 (pBuffer
[i
+ 2] == 0x00) &&
160 (pBuffer
[i
+ 3] == 0x01))
161 return (pBuffer
+ i
);
167 static void Print_H264Enc_Param(ExynosVideoEncParam
*pEncParam
)
169 ExynosVideoEncCommonParam
*pCommonParam
= &pEncParam
->commonParam
;
170 ExynosVideoEncH264Param
*pH264Param
= &pEncParam
->codecParam
.h264
;
172 /* common parameters */
173 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SourceWidth : %d", pCommonParam
->SourceWidth
);
174 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SourceHeight : %d", pCommonParam
->SourceHeight
);
175 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "IDRPeriod : %d", pCommonParam
->IDRPeriod
);
176 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SliceMode : %d", pCommonParam
->SliceMode
);
177 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "RandomIntraMBRefresh : %d", pCommonParam
->RandomIntraMBRefresh
);
178 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Bitrate : %d", pCommonParam
->Bitrate
);
179 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "FrameQp : %d", pCommonParam
->FrameQp
);
180 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "FrameQp_P : %d", pCommonParam
->FrameQp_P
);
181 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "QSCodeMax : %d", pCommonParam
->QSCodeMax
);
182 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "QSCodeMin : %d", pCommonParam
->QSCodeMin
);
183 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "PadControlOn : %d", pCommonParam
->PadControlOn
);
184 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "LumaPadVal : %d", pCommonParam
->LumaPadVal
);
185 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "CbPadVal : %d", pCommonParam
->CbPadVal
);
186 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "CrPadVal : %d", pCommonParam
->CrPadVal
);
187 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "FrameMap : %d", pCommonParam
->FrameMap
);
189 /* H.264 specific parameters */
190 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "ProfileIDC : %d", pH264Param
->ProfileIDC
);
191 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "LevelIDC : %d", pH264Param
->LevelIDC
);
192 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "FrameQp_B : %d", pH264Param
->FrameQp_B
);
193 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "FrameRate : %d", pH264Param
->FrameRate
);
194 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SliceArgument : %d", pH264Param
->SliceArgument
);
195 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "NumberBFrames : %d", pH264Param
->NumberBFrames
);
196 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "NumberReferenceFrames : %d", pH264Param
->NumberReferenceFrames
);
197 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "NumberRefForPframes : %d", pH264Param
->NumberRefForPframes
);
198 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "LoopFilterDisable : %d", pH264Param
->LoopFilterDisable
);
199 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "LoopFilterAlphaC0Offset : %d", pH264Param
->LoopFilterAlphaC0Offset
);
200 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "LoopFilterBetaOffset : %d", pH264Param
->LoopFilterBetaOffset
);
201 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SymbolMode : %d", pH264Param
->SymbolMode
);
202 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "PictureInterlace : %d", pH264Param
->PictureInterlace
);
203 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Transform8x8Mode : %d", pH264Param
->Transform8x8Mode
);
204 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "DarkDisable : %d", pH264Param
->DarkDisable
);
205 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SmoothDisable : %d", pH264Param
->SmoothDisable
);
206 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "StaticDisable : %d", pH264Param
->StaticDisable
);
207 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "ActivityDisable : %d", pH264Param
->ActivityDisable
);
209 /* rate control related parameters */
210 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "EnableFRMRateControl : %d", pCommonParam
->EnableFRMRateControl
);
211 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "EnableMBRateControl : %d", pCommonParam
->EnableMBRateControl
);
212 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "CBRPeriodRf : %d", pCommonParam
->CBRPeriodRf
);
215 static void Set_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
)
217 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= NULL
;
218 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= NULL
;
219 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
220 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
221 EXYNOS_MFC_H264ENC_HANDLE
*pMFCH264Handle
= NULL
;
222 ENCODE_CODEC_EXTRA_BUFFERINFO
*pExtBufferInfo
= NULL
;
224 ExynosVideoEncParam
*pEncParam
= NULL
;
225 ExynosVideoEncCommonParam
*pCommonParam
= NULL
;
226 ExynosVideoEncH264Param
*pH264Param
= NULL
;
228 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
229 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
230 pMFCH264Handle
= &pH264Enc
->hMFCH264Handle
;
231 pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
232 pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
233 pExtBufferInfo
= (ENCODE_CODEC_EXTRA_BUFFERINFO
*)pExynosInputPort
->processData
.extInfo
;
235 pEncParam
= &pMFCH264Handle
->encParam
;
236 pCommonParam
= &pEncParam
->commonParam
;
237 pH264Param
= &pEncParam
->codecParam
.h264
;
239 pEncParam
->eCompressionFormat
= VIDEO_CODING_AVC
;
240 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "eCompressionFormat: %d", pEncParam
->eCompressionFormat
);
242 /* common parameters */
243 pCommonParam
->SourceWidth
= pExynosOutputPort
->portDefinition
.format
.video
.nFrameWidth
;
244 pCommonParam
->SourceHeight
= pExynosOutputPort
->portDefinition
.format
.video
.nFrameHeight
;
245 pCommonParam
->IDRPeriod
= pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
+ 1;
246 pCommonParam
->SliceMode
= pH264Enc
->AVCSliceFmo
.eSliceMode
;
247 pCommonParam
->Bitrate
= pExynosOutputPort
->portDefinition
.format
.video
.nBitrate
;
248 pCommonParam
->FrameQp
= pVideoEnc
->quantization
.nQpI
;
249 pCommonParam
->FrameQp_P
= pVideoEnc
->quantization
.nQpP
;
250 pCommonParam
->QSCodeMax
= 51;
251 pCommonParam
->QSCodeMin
= 10;
252 pCommonParam
->PadControlOn
= 0; /* 0: disable, 1: enable */
253 pCommonParam
->LumaPadVal
= 0;
254 pCommonParam
->CbPadVal
= 0;
255 pCommonParam
->CrPadVal
= 0;
257 if (pVideoEnc
->intraRefresh
.eRefreshMode
== OMX_VIDEO_IntraRefreshCyclic
) {
259 pCommonParam
->RandomIntraMBRefresh
= pVideoEnc
->intraRefresh
.nCirMBs
;
260 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "RandomIntraMBRefresh: %d", pCommonParam
->RandomIntraMBRefresh
);
262 /* Don't support "Adaptive" and "Cyclic + Adaptive" */
263 pCommonParam
->RandomIntraMBRefresh
= 0;
266 switch (pExtBufferInfo
->eColorFormat
) {
267 case OMX_COLOR_FormatYUV420SemiPlanar
:
268 pCommonParam
->FrameMap
= VIDEO_COLORFORMAT_NV12
;
270 case (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV21Linear
:
271 pCommonParam
->FrameMap
= VIDEO_COLORFORMAT_NV21
;
273 #ifdef USE_ENCODER_RGBINPUT_SUPPORT
274 case OMX_COLOR_FormatYUV420Planar
:
275 pCommonParam
->FrameMap
= VIDEO_COLORFORMAT_I420
;
277 case (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatYVU420Planar
:
278 pCommonParam
->FrameMap
= VIDEO_COLORFORMAT_YV12
;
280 case OMX_COLOR_Format32bitBGRA8888
:
281 pCommonParam
->FrameMap
= VIDEO_COLORFORMAT_ARGB8888
;
284 case (OMX_COLOR_FORMATTYPE
)OMX_SEC_COLOR_FormatNV12Tiled
:
286 pCommonParam
->FrameMap
= VIDEO_COLORFORMAT_NV12_TILED
;
290 /* H.264 specific parameters */
291 pH264Param
->ProfileIDC
= OMXAVCProfileToProfileIDC(pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].eProfile
); /*0: OMX_VIDEO_AVCProfileMain */
292 pH264Param
->LevelIDC
= OMXAVCLevelToLevelIDC(pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].eLevel
); /*40: OMX_VIDEO_AVCLevel4 */
293 pH264Param
->FrameQp_B
= pVideoEnc
->quantization
.nQpB
;
294 pH264Param
->FrameRate
= (pExynosInputPort
->portDefinition
.format
.video
.xFramerate
) >> 16;
295 if (pH264Enc
->AVCSliceFmo
.eSliceMode
== OMX_VIDEO_SLICEMODE_AVCDefault
)
296 pH264Param
->SliceArgument
= 0; /* Slice mb/byte size number */
298 pH264Param
->SliceArgument
= pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nSliceHeaderSpacing
;
299 pH264Param
->NumberBFrames
= 0; /* 0 ~ 2 */
300 pH264Param
->NumberReferenceFrames
= 1;
301 pH264Param
->NumberRefForPframes
= 1;
302 pH264Param
->LoopFilterDisable
= 1; /* 1: Loop Filter Disable, 0: Filter Enable */
303 pH264Param
->LoopFilterAlphaC0Offset
= 0;
304 pH264Param
->LoopFilterBetaOffset
= 0;
305 pH264Param
->SymbolMode
= 0; /* 0: CAVLC, 1: CABAC */
306 pH264Param
->PictureInterlace
= 0;
307 pH264Param
->Transform8x8Mode
= 0; /* 0: 4x4, 1: allow 8x8 */
308 pH264Param
->DarkDisable
= 1;
309 pH264Param
->SmoothDisable
= 1;
310 pH264Param
->StaticDisable
= 1;
311 pH264Param
->ActivityDisable
= 1;
313 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoEnc->eControlRate[OUTPUT_PORT_INDEX]: 0x%x", pVideoEnc
->eControlRate
[OUTPUT_PORT_INDEX
]);
314 /* rate control related parameters */
315 switch (pVideoEnc
->eControlRate
[OUTPUT_PORT_INDEX
]) {
316 case OMX_Video_ControlRateDisable
:
317 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Video Encode DBR");
318 pCommonParam
->EnableFRMRateControl
= 0; /* 0: Disable, 1: Frame level RC */
319 pCommonParam
->EnableMBRateControl
= 0; /* 0: Disable, 1:MB level RC */
320 pCommonParam
->CBRPeriodRf
= 100;
322 case OMX_Video_ControlRateConstant
:
323 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Video Encode CBR");
324 pCommonParam
->EnableFRMRateControl
= 1; /* 0: Disable, 1: Frame level RC */
325 pCommonParam
->EnableMBRateControl
= 1; /* 0: Disable, 1:MB level RC */
326 pCommonParam
->CBRPeriodRf
= 9;
328 case OMX_Video_ControlRateVariable
:
329 default: /*Android default */
330 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Video Encode VBR");
331 pCommonParam
->EnableFRMRateControl
= 1; /* 0: Disable, 1: Frame level RC */
332 pCommonParam
->EnableMBRateControl
= 1; /* 0: Disable, 1:MB level RC */
333 pCommonParam
->CBRPeriodRf
= 100;
337 Print_H264Enc_Param(pEncParam
);
340 static void Change_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
)
342 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= NULL
;
343 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= NULL
;
344 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
345 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
346 EXYNOS_MFC_H264ENC_HANDLE
*pMFCH264Handle
= NULL
;
348 ExynosVideoEncOps
*pEncOps
= NULL
;
349 ExynosVideoEncParam
*pEncParam
= NULL
;
350 ExynosVideoEncCommonParam
*pCommonParam
= NULL
;
351 ExynosVideoEncH264Param
*pH264Param
= NULL
;
355 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
356 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
357 pMFCH264Handle
= &pH264Enc
->hMFCH264Handle
;
358 pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
359 pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
360 pEncOps
= pMFCH264Handle
->pEncOps
;
362 pEncParam
= &pMFCH264Handle
->encParam
;
363 pCommonParam
= &pEncParam
->commonParam
;
364 pH264Param
= &pEncParam
->codecParam
.h264
;
366 if (pVideoEnc
->IntraRefreshVOP
== OMX_TRUE
) {
367 setParam
= VIDEO_FRAME_I
;
368 pEncOps
->Set_FrameType(pH264Enc
->hMFCH264Handle
.hMFCHandle
, setParam
);
369 pVideoEnc
->IntraRefreshVOP
= OMX_FALSE
;
371 if (pCommonParam
->IDRPeriod
!= (int)pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
+ 1) {
372 setParam
= pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
+ 1;
373 pEncOps
->Set_IDRPeriod(pH264Enc
->hMFCH264Handle
.hMFCHandle
, setParam
);
375 if (pCommonParam
->Bitrate
!= (int)pExynosOutputPort
->portDefinition
.format
.video
.nBitrate
) {
376 setParam
= pExynosOutputPort
->portDefinition
.format
.video
.nBitrate
;
377 pEncOps
->Set_BitRate(pH264Enc
->hMFCH264Handle
.hMFCHandle
, setParam
);
379 if (pH264Param
->FrameRate
!= (int)((pExynosInputPort
->portDefinition
.format
.video
.xFramerate
) >> 16)) {
380 setParam
= (pExynosInputPort
->portDefinition
.format
.video
.xFramerate
) >> 16;
381 pEncOps
->Set_FrameRate(pH264Enc
->hMFCH264Handle
.hMFCHandle
, setParam
);
384 Set_H264Enc_Param(pExynosComponent
);
387 OMX_ERRORTYPE
GetCodecInputPrivateData(OMX_PTR codecBuffer
, OMX_PTR addr
[], OMX_U32 size
[])
389 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
395 OMX_ERRORTYPE
GetCodecOutputPrivateData(OMX_PTR codecBuffer
, OMX_PTR
*pVirtAddr
, OMX_U32
*dataSize
)
397 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
398 ExynosVideoBuffer
*pCodecBuffer
;
400 if (codecBuffer
== NULL
) {
401 ret
= OMX_ErrorBadParameter
;
405 pCodecBuffer
= (ExynosVideoBuffer
*)codecBuffer
;
407 if (pVirtAddr
!= NULL
)
408 *pVirtAddr
= pCodecBuffer
->planes
[0].addr
;
410 if (dataSize
!= NULL
)
411 *dataSize
= pCodecBuffer
->planes
[0].allocSize
;
413 pCodecBuffer
= (ExynosVideoBuffer
*)codecBuffer
;
419 OMX_ERRORTYPE
H264CodecOpen(EXYNOS_H264ENC_HANDLE
*pH264Enc
)
421 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
423 ExynosVideoEncOps
*pEncOps
= NULL
;
424 ExynosVideoEncBufferOps
*pInbufOps
= NULL
;
425 ExynosVideoEncBufferOps
*pOutbufOps
= NULL
;
429 if (pH264Enc
== NULL
) {
430 ret
= OMX_ErrorBadParameter
;
431 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
435 /* alloc ops structure */
436 pEncOps
= (ExynosVideoEncOps
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoEncOps
));
437 pInbufOps
= (ExynosVideoEncBufferOps
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoEncBufferOps
));
438 pOutbufOps
= (ExynosVideoEncBufferOps
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoEncBufferOps
));
440 if ((pEncOps
== NULL
) || (pInbufOps
== NULL
) || (pOutbufOps
== NULL
)) {
441 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate encoder ops buffer");
442 ret
= OMX_ErrorInsufficientResources
;
446 pH264Enc
->hMFCH264Handle
.pEncOps
= pEncOps
;
447 pH264Enc
->hMFCH264Handle
.pInbufOps
= pInbufOps
;
448 pH264Enc
->hMFCH264Handle
.pOutbufOps
= pOutbufOps
;
450 /* function pointer mapping */
451 pEncOps
->nSize
= sizeof(ExynosVideoEncOps
);
452 pInbufOps
->nSize
= sizeof(ExynosVideoEncBufferOps
);
453 pOutbufOps
->nSize
= sizeof(ExynosVideoEncBufferOps
);
455 Exynos_Video_Register_Encoder(pEncOps
, pInbufOps
, pOutbufOps
);
457 /* check mandatory functions for encoder ops */
458 if ((pEncOps
->Init
== NULL
) || (pEncOps
->Finalize
== NULL
) ||
459 (pEncOps
->Set_FrameTag
== NULL
) || (pEncOps
->Get_FrameTag
== NULL
)) {
460 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Mandatory functions must be supplied");
461 ret
= OMX_ErrorInsufficientResources
;
465 /* check mandatory functions for buffer ops */
466 if ((pInbufOps
->Setup
== NULL
) || (pOutbufOps
->Setup
== NULL
) ||
467 (pInbufOps
->Run
== NULL
) || (pOutbufOps
->Run
== NULL
) ||
468 (pInbufOps
->Stop
== NULL
) || (pOutbufOps
->Stop
== NULL
) ||
469 (pInbufOps
->Enqueue
== NULL
) || (pOutbufOps
->Enqueue
== NULL
) ||
470 (pInbufOps
->Dequeue
== NULL
) || (pOutbufOps
->Dequeue
== NULL
)) {
471 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Mandatory functions must be supplied");
472 ret
= OMX_ErrorInsufficientResources
;
476 /* alloc context, open, querycap */
478 pH264Enc
->hMFCH264Handle
.hMFCHandle
= pH264Enc
->hMFCH264Handle
.pEncOps
->Init(V4L2_MEMORY_DMABUF
);
480 pH264Enc
->hMFCH264Handle
.hMFCHandle
= pH264Enc
->hMFCH264Handle
.pEncOps
->Init(V4L2_MEMORY_USERPTR
);
482 if (pH264Enc
->hMFCH264Handle
.hMFCHandle
== NULL
) {
483 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to allocate context buffer");
484 ret
= OMX_ErrorInsufficientResources
;
491 if (ret
!= OMX_ErrorNone
) {
492 if (pEncOps
!= NULL
) {
493 Exynos_OSAL_Free(pEncOps
);
494 pH264Enc
->hMFCH264Handle
.pEncOps
= NULL
;
496 if (pInbufOps
!= NULL
) {
497 Exynos_OSAL_Free(pInbufOps
);
498 pH264Enc
->hMFCH264Handle
.pInbufOps
= NULL
;
500 if (pOutbufOps
!= NULL
) {
501 Exynos_OSAL_Free(pOutbufOps
);
502 pH264Enc
->hMFCH264Handle
.pOutbufOps
= NULL
;
511 OMX_ERRORTYPE
H264CodecClose(EXYNOS_H264ENC_HANDLE
*pH264Enc
)
513 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
514 void *hMFCHandle
= NULL
;
515 ExynosVideoEncOps
*pEncOps
= NULL
;
516 ExynosVideoEncBufferOps
*pInbufOps
= NULL
;
517 ExynosVideoEncBufferOps
*pOutbufOps
= NULL
;
521 if (pH264Enc
== NULL
) {
522 ret
= OMX_ErrorBadParameter
;
526 hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
527 pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
528 pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
529 pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
531 if (hMFCHandle
!= NULL
) {
532 pEncOps
->Finalize(hMFCHandle
);
533 hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
= NULL
;
535 if (pOutbufOps
!= NULL
) {
536 Exynos_OSAL_Free(pOutbufOps
);
537 pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
= NULL
;
539 if (pInbufOps
!= NULL
) {
540 Exynos_OSAL_Free(pInbufOps
);
541 pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
= NULL
;
543 if (pEncOps
!= NULL
) {
544 Exynos_OSAL_Free(pEncOps
);
545 pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
= NULL
;
556 OMX_ERRORTYPE
H264CodecStart(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
558 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
559 void *hMFCHandle
= NULL
;
560 ExynosVideoEncOps
*pEncOps
= NULL
;
561 ExynosVideoEncBufferOps
*pInbufOps
= NULL
;
562 ExynosVideoEncBufferOps
*pOutbufOps
= NULL
;
563 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
564 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
568 if (pOMXComponent
== NULL
) {
569 ret
= OMX_ErrorBadParameter
;
573 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
574 if (pVideoEnc
== NULL
) {
575 ret
= OMX_ErrorBadParameter
;
579 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
580 if (pH264Enc
== NULL
) {
581 ret
= OMX_ErrorBadParameter
;
585 hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
586 pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
587 pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
588 pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
590 if (nPortIndex
== INPUT_PORT_INDEX
)
591 pInbufOps
->Run(hMFCHandle
);
592 else if (nPortIndex
== OUTPUT_PORT_INDEX
)
593 pOutbufOps
->Run(hMFCHandle
);
603 OMX_ERRORTYPE
H264CodecStop(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
605 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
606 void *hMFCHandle
= NULL
;
607 ExynosVideoEncOps
*pEncOps
= NULL
;
608 ExynosVideoEncBufferOps
*pInbufOps
= NULL
;
609 ExynosVideoEncBufferOps
*pOutbufOps
= NULL
;
610 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
611 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
615 if (pOMXComponent
== NULL
) {
616 ret
= OMX_ErrorBadParameter
;
620 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
621 if (pVideoEnc
== NULL
) {
622 ret
= OMX_ErrorBadParameter
;
625 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
626 if (pH264Enc
== NULL
) {
627 ret
= OMX_ErrorBadParameter
;
631 hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
632 pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
633 pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
634 pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
636 if ((nPortIndex
== INPUT_PORT_INDEX
) && (pInbufOps
!= NULL
))
637 pInbufOps
->Stop(hMFCHandle
);
638 else if ((nPortIndex
== OUTPUT_PORT_INDEX
) && (pOutbufOps
!= NULL
))
639 pOutbufOps
->Stop(hMFCHandle
);
649 OMX_ERRORTYPE
H264CodecOutputBufferProcessRun(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
651 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
652 void *hMFCHandle
= NULL
;
653 ExynosVideoEncOps
*pEncOps
= NULL
;
654 ExynosVideoEncBufferOps
*pInbufOps
= NULL
;
655 ExynosVideoEncBufferOps
*pOutbufOps
= NULL
;
656 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
657 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
661 if (pOMXComponent
== NULL
) {
662 ret
= OMX_ErrorBadParameter
;
666 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)((EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
)->hComponentHandle
;
667 if (pVideoEnc
== NULL
) {
668 ret
= OMX_ErrorBadParameter
;
671 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
672 if (pH264Enc
== NULL
) {
673 ret
= OMX_ErrorBadParameter
;
677 hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
678 pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
679 pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
680 pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
682 if (nPortIndex
== INPUT_PORT_INDEX
) {
683 if (pH264Enc
->bSourceStart
== OMX_FALSE
) {
684 Exynos_OSAL_SignalSet(pH264Enc
->hSourceStartEvent
);
685 Exynos_OSAL_SleepMillisec(0);
689 if (nPortIndex
== OUTPUT_PORT_INDEX
) {
690 if (pH264Enc
->bDestinationStart
== OMX_FALSE
) {
691 Exynos_OSAL_SignalSet(pH264Enc
->hDestinationStartEvent
);
692 Exynos_OSAL_SleepMillisec(0);
704 OMX_ERRORTYPE
H264CodecRegistCodecBuffers(
705 OMX_COMPONENTTYPE
*pOMXComponent
,
709 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
710 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
711 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
712 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
713 void *hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
714 CODEC_ENC_BUFFER
**ppCodecBuffer
= NULL
;
715 ExynosVideoEncBufferOps
*pBufOps
= NULL
;
716 ExynosVideoPlane
*pPlanes
= NULL
;
718 OMX_U32 nPlaneCnt
= 0;
723 if (nPortIndex
== INPUT_PORT_INDEX
) {
724 ppCodecBuffer
= &(pVideoEnc
->pMFCEncInputBuffer
[0]);
725 pBufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
727 ppCodecBuffer
= &(pVideoEnc
->pMFCEncOutputBuffer
[0]);
728 pBufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
730 nPlaneCnt
= pExynosComponent
->pExynosPort
[nPortIndex
].nPlaneCnt
;
732 pPlanes
= (ExynosVideoPlane
*)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane
) * nPlaneCnt
);
733 if (pPlanes
== NULL
) {
734 ret
= OMX_ErrorInsufficientResources
;
738 /* Register buffer */
739 for (i
= 0; i
< nBufferCnt
; i
++) {
740 for (j
= 0; j
< nPlaneCnt
; j
++) {
741 pPlanes
[j
].addr
= ppCodecBuffer
[i
]->pVirAddr
[j
];
742 pPlanes
[j
].fd
= ppCodecBuffer
[i
]->fd
[j
];
743 pPlanes
[j
].allocSize
= ppCodecBuffer
[i
]->bufferSize
[j
];
746 if (pBufOps
->Register(hMFCHandle
, pPlanes
, nPlaneCnt
) != VIDEO_ERROR_NONE
) {
747 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "PORT[%d]: Failed to Register buffer", nPortIndex
);
748 ret
= OMX_ErrorInsufficientResources
;
749 Exynos_OSAL_Free(pPlanes
);
754 Exynos_OSAL_Free(pPlanes
);
764 OMX_ERRORTYPE
H264CodecEnqueueAllBuffer(OMX_COMPONENTTYPE
*pOMXComponent
, OMX_U32 nPortIndex
)
766 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
767 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
768 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
769 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
770 void *hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
771 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
772 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
775 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
776 ExynosVideoEncBufferOps
*pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
777 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
781 if ((nPortIndex
!= INPUT_PORT_INDEX
) && (nPortIndex
!= OUTPUT_PORT_INDEX
)) {
782 ret
= OMX_ErrorBadPortIndex
;
786 if ((nPortIndex
== INPUT_PORT_INDEX
) &&
787 (pH264Enc
->bSourceStart
== OMX_TRUE
)) {
788 Exynos_CodecBufferReset(pExynosComponent
, INPUT_PORT_INDEX
);
790 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
791 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoEnc->pMFCEncInputBuffer[%d]: 0x%x", i
, pVideoEnc
->pMFCEncInputBuffer
[i
]);
792 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoEnc
->pMFCEncInputBuffer
[i
]->pVirAddr
[0]);
793 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[1]: 0x%x", i
, pVideoEnc
->pMFCEncInputBuffer
[i
]->pVirAddr
[1]);
795 Exynos_CodecBufferEnqueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoEnc
->pMFCEncInputBuffer
[i
]);
798 pInbufOps
->Clear_Queue(hMFCHandle
);
799 } else if ((nPortIndex
== OUTPUT_PORT_INDEX
) &&
800 (pH264Enc
->bDestinationStart
== OMX_TRUE
)) {
801 Exynos_CodecBufferReset(pExynosComponent
, OUTPUT_PORT_INDEX
);
803 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
804 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoEnc->pMFCEncOutputBuffer[%d]: 0x%x", i
, pVideoEnc
->pMFCEncOutputBuffer
[i
]);
805 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "pVideoEnc->pMFCEncInputBuffer[%d]->pVirAddr[0]: 0x%x", i
, pVideoEnc
->pMFCEncInputBuffer
[i
]->pVirAddr
[0]);
807 Exynos_CodecBufferEnqueue(pExynosComponent
, OUTPUT_PORT_INDEX
, pVideoEnc
->pMFCEncOutputBuffer
[i
]);
810 pOutbufOps
->Clear_Queue(hMFCHandle
);
819 OMX_ERRORTYPE
H264CodecSrcSetup(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
821 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
822 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
823 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
824 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
825 EXYNOS_MFC_H264ENC_HANDLE
*pMFCH264Handle
= &pH264Enc
->hMFCH264Handle
;
826 void *hMFCHandle
= pMFCH264Handle
->hMFCHandle
;
827 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
828 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
829 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
831 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
832 ExynosVideoEncBufferOps
*pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
833 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
834 ExynosVideoEncParam
*pEncParam
= NULL
;
836 ExynosVideoGeometry bufferConf
;
837 OMX_U32 inputBufferNumber
= 0;
842 if ((oneFrameSize
<= 0) && (pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
)) {
843 BYPASS_BUFFER_INFO
*pBufferInfo
= (BYPASS_BUFFER_INFO
*)Exynos_OSAL_Malloc(sizeof(BYPASS_BUFFER_INFO
));
844 if (pBufferInfo
== NULL
) {
845 ret
= OMX_ErrorInsufficientResources
;
849 pBufferInfo
->nFlags
= pSrcInputData
->nFlags
;
850 pBufferInfo
->timeStamp
= pSrcInputData
->timeStamp
;
851 ret
= Exynos_OSAL_Queue(&pH264Enc
->bypassBufferInfoQ
, (void *)pBufferInfo
);
852 Exynos_OSAL_SignalSet(pH264Enc
->hDestinationStartEvent
);
858 Set_H264Enc_Param(pExynosComponent
);
859 pEncParam
= &pMFCH264Handle
->encParam
;
860 if (pEncOps
->Set_EncParam
) {
861 if(pEncOps
->Set_EncParam(pH264Enc
->hMFCH264Handle
.hMFCHandle
, pEncParam
) != VIDEO_ERROR_NONE
) {
862 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for input buffer");
863 ret
= OMX_ErrorInsufficientResources
;
868 if (pMFCH264Handle
->bPrependSpsPpsToIdr
== OMX_TRUE
) {
869 if (pEncOps
->Enable_PrependSpsPpsToIdr
)
870 pEncOps
->Enable_PrependSpsPpsToIdr(pH264Enc
->hMFCH264Handle
.hMFCHandle
);
872 Exynos_OSAL_Log(EXYNOS_LOG_WARNING
, "%s: Not supported control: Enable_PrependSpsPpsToIdr", __func__
);
875 /* input buffer info: only 3 config values needed */
876 Exynos_OSAL_Memset(&bufferConf
, 0, sizeof(bufferConf
));
877 bufferConf
.eColorFormat
= pEncParam
->commonParam
.FrameMap
;
878 bufferConf
.nFrameWidth
= pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
;
879 bufferConf
.nFrameHeight
= pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
;
880 bufferConf
.nPlaneCnt
= pExynosInputPort
->nPlaneCnt
;
881 pInbufOps
->Set_Shareable(hMFCHandle
);
882 inputBufferNumber
= MAX_INPUTBUFFER_NUM_DYNAMIC
;
884 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
885 /* should be done before prepare input buffer */
886 if (pInbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
887 ret
= OMX_ErrorInsufficientResources
;
892 /* set input buffer geometry */
893 if (pInbufOps
->Set_Geometry
) {
894 if (pInbufOps
->Set_Geometry(hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
895 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for input buffer");
896 ret
= OMX_ErrorInsufficientResources
;
901 /* setup input buffer */
902 if (pInbufOps
->Setup(hMFCHandle
, inputBufferNumber
) != VIDEO_ERROR_NONE
) {
903 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup input buffer");
904 ret
= OMX_ErrorInsufficientResources
;
908 if ((pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) &&
909 (pExynosInputPort
->bStoreMetaData
!= OMX_TRUE
)) {
910 ret
= OMX_ErrorNotImplemented
;
914 pH264Enc
->hMFCH264Handle
.bConfiguredMFCSrc
= OMX_TRUE
;
923 OMX_ERRORTYPE
H264CodecDstSetup(OMX_COMPONENTTYPE
*pOMXComponent
)
925 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
926 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
927 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
928 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
929 EXYNOS_MFC_H264ENC_HANDLE
*pMFCH264Handle
= &pH264Enc
->hMFCH264Handle
;
930 void *hMFCHandle
= pMFCH264Handle
->hMFCHandle
;
931 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
932 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
934 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
935 ExynosVideoEncBufferOps
*pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
936 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
937 ExynosVideoGeometry bufferConf
;
942 int OutBufferSize
= pExynosOutputPort
->portDefinition
.nBufferSize
;
944 /* set geometry for output (dst) */
945 if (pOutbufOps
->Set_Geometry
) {
946 /* output buffer info: only 2 config values needed */
947 bufferConf
.eCompressionFormat
= VIDEO_CODING_AVC
;
948 bufferConf
.nSizeImage
= OutBufferSize
;
949 bufferConf
.nPlaneCnt
= pExynosOutputPort
->nPlaneCnt
;
951 if (pOutbufOps
->Set_Geometry(pH264Enc
->hMFCH264Handle
.hMFCHandle
, &bufferConf
) != VIDEO_ERROR_NONE
) {
952 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to set geometry for output buffer");
953 ret
= OMX_ErrorInsufficientResources
;
958 /* should be done before prepare output buffer */
959 if (pOutbufOps
->Enable_Cacheable(hMFCHandle
) != VIDEO_ERROR_NONE
) {
960 ret
= OMX_ErrorInsufficientResources
;
964 pOutbufOps
->Set_Shareable(hMFCHandle
);
965 int SetupBufferNumber
= 0;
966 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
)
967 SetupBufferNumber
= MFC_OUTPUT_BUFFER_NUM_MAX
;
969 SetupBufferNumber
= pExynosOutputPort
->portDefinition
.nBufferCountActual
;
970 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "SetupBufferNumber:%d", SetupBufferNumber
);
972 if (pOutbufOps
->Setup(pH264Enc
->hMFCH264Handle
.hMFCHandle
, SetupBufferNumber
) != VIDEO_ERROR_NONE
) {
973 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to setup output buffer");
974 ret
= OMX_ErrorInsufficientResources
;
978 OMX_U32 dataLen
[VIDEO_BUFFER_MAX_PLANES
] = {0, 0 ,0};
979 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
980 OMX_U32 nPlaneSize
[VIDEO_BUFFER_MAX_PLANES
] = {0, 0, 0};
981 nPlaneSize
[0] = OutBufferSize
;
982 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
, MFC_OUTPUT_BUFFER_NUM_MAX
, nPlaneSize
);
983 if (ret
!= OMX_ErrorNone
)
986 /* Enqueue output buffer */
987 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
988 pOutbufOps
->ExtensionEnqueue(hMFCHandle
,
989 (unsigned char **)pVideoEnc
->pMFCEncOutputBuffer
[i
]->pVirAddr
,
990 (unsigned char **)pVideoEnc
->pMFCEncOutputBuffer
[i
]->fd
,
991 (unsigned int *)pVideoEnc
->pMFCEncOutputBuffer
[i
]->bufferSize
,
992 (unsigned int *)dataLen
, pExynosOutputPort
->nPlaneCnt
, NULL
);
995 if (pOutbufOps
->Run(hMFCHandle
) != VIDEO_ERROR_NONE
) {
996 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to run output buffer");
997 ret
= OMX_ErrorInsufficientResources
;
1000 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1001 /* Register output buffer */
1006 pH264Enc
->hMFCH264Handle
.bConfiguredMFCDst
= OMX_TRUE
;
1008 ret
= OMX_ErrorNone
;
1016 OMX_ERRORTYPE
Exynos_H264Enc_GetParameter(
1017 OMX_IN OMX_HANDLETYPE hComponent
,
1018 OMX_IN OMX_INDEXTYPE nParamIndex
,
1019 OMX_INOUT OMX_PTR pComponentParameterStructure
)
1021 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1022 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1023 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1027 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1028 ret
= OMX_ErrorBadParameter
;
1031 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1032 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1033 if (ret
!= OMX_ErrorNone
) {
1036 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1037 ret
= OMX_ErrorBadParameter
;
1041 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1042 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1043 ret
= OMX_ErrorInvalidState
;
1047 switch (nParamIndex
) {
1048 case OMX_IndexParamVideoAvc
:
1050 OMX_VIDEO_PARAM_AVCTYPE
*pDstAVCComponent
= (OMX_VIDEO_PARAM_AVCTYPE
*)pComponentParameterStructure
;
1051 OMX_VIDEO_PARAM_AVCTYPE
*pSrcAVCComponent
= NULL
;
1052 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1054 ret
= Exynos_OMX_Check_SizeVersion(pDstAVCComponent
, sizeof(OMX_VIDEO_PARAM_AVCTYPE
));
1055 if (ret
!= OMX_ErrorNone
) {
1059 if (pDstAVCComponent
->nPortIndex
>= ALL_PORT_NUM
) {
1060 ret
= OMX_ErrorBadPortIndex
;
1064 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1065 pSrcAVCComponent
= &pH264Enc
->AVCComponent
[pDstAVCComponent
->nPortIndex
];
1067 Exynos_OSAL_Memcpy(pDstAVCComponent
, pSrcAVCComponent
, sizeof(OMX_VIDEO_PARAM_AVCTYPE
));
1070 case OMX_IndexParamVideoSliceFMO
:
1072 OMX_VIDEO_PARAM_AVCSLICEFMO
*pDstSliceFmo
= (OMX_VIDEO_PARAM_AVCSLICEFMO
*)pComponentParameterStructure
;
1073 OMX_VIDEO_PARAM_AVCSLICEFMO
*pSrcSliceFmo
= NULL
;
1074 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1076 ret
= Exynos_OMX_Check_SizeVersion(pDstSliceFmo
, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO
));
1077 if (ret
!= OMX_ErrorNone
) {
1081 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1082 pSrcSliceFmo
= &pH264Enc
->AVCSliceFmo
;
1084 Exynos_OSAL_Memcpy(pDstSliceFmo
, pSrcSliceFmo
, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO
));
1087 case OMX_IndexParamStandardComponentRole
:
1089 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1090 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1091 if (ret
!= OMX_ErrorNone
) {
1095 Exynos_OSAL_Strcpy((char *)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H264_ENC_ROLE
);
1098 case OMX_IndexParamVideoProfileLevelQuerySupported
:
1100 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1101 EXYNOS_OMX_VIDEO_PROFILELEVEL
*pProfileLevel
= NULL
;
1102 OMX_U32 maxProfileLevelNum
= 0;
1104 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1105 if (ret
!= OMX_ErrorNone
) {
1109 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1110 ret
= OMX_ErrorBadPortIndex
;
1114 pProfileLevel
= supportedAVCProfileLevels
;
1115 maxProfileLevelNum
= sizeof(supportedAVCProfileLevels
) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL
);
1117 if (pDstProfileLevel
->nProfileIndex
>= maxProfileLevelNum
) {
1118 ret
= OMX_ErrorNoMore
;
1122 pProfileLevel
+= pDstProfileLevel
->nProfileIndex
;
1123 pDstProfileLevel
->eProfile
= pProfileLevel
->profile
;
1124 pDstProfileLevel
->eLevel
= pProfileLevel
->level
;
1127 case OMX_IndexParamVideoProfileLevelCurrent
:
1129 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pDstProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1130 OMX_VIDEO_PARAM_AVCTYPE
*pSrcAVCComponent
= NULL
;
1131 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1133 ret
= Exynos_OMX_Check_SizeVersion(pDstProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1134 if (ret
!= OMX_ErrorNone
) {
1138 if (pDstProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1139 ret
= OMX_ErrorBadPortIndex
;
1143 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1144 pSrcAVCComponent
= &pH264Enc
->AVCComponent
[pDstProfileLevel
->nPortIndex
];
1146 pDstProfileLevel
->eProfile
= pSrcAVCComponent
->eProfile
;
1147 pDstProfileLevel
->eLevel
= pSrcAVCComponent
->eLevel
;
1150 case OMX_IndexParamVideoErrorCorrection
:
1152 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1153 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= NULL
;
1154 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1156 ret
= Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1157 if (ret
!= OMX_ErrorNone
) {
1161 if (pDstErrorCorrectionType
->nPortIndex
!= OUTPUT_PORT_INDEX
) {
1162 ret
= OMX_ErrorBadPortIndex
;
1166 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1167 pSrcErrorCorrectionType
= &pH264Enc
->errorCorrectionType
[OUTPUT_PORT_INDEX
];
1169 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1170 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1171 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1172 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1173 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1177 ret
= Exynos_OMX_VideoEncodeGetParameter(hComponent
, nParamIndex
, pComponentParameterStructure
);
1186 OMX_ERRORTYPE
Exynos_H264Enc_SetParameter(
1187 OMX_IN OMX_HANDLETYPE hComponent
,
1188 OMX_IN OMX_INDEXTYPE nIndex
,
1189 OMX_IN OMX_PTR pComponentParameterStructure
)
1191 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1192 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1193 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1197 if (hComponent
== NULL
|| pComponentParameterStructure
== NULL
) {
1198 ret
= OMX_ErrorBadParameter
;
1201 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1202 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1203 if (ret
!= OMX_ErrorNone
) {
1206 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1207 ret
= OMX_ErrorBadParameter
;
1211 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1212 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1213 ret
= OMX_ErrorInvalidState
;
1218 case OMX_IndexParamVideoAvc
:
1220 OMX_VIDEO_PARAM_AVCTYPE
*pDstAVCComponent
= NULL
;
1221 OMX_VIDEO_PARAM_AVCTYPE
*pSrcAVCComponent
= (OMX_VIDEO_PARAM_AVCTYPE
*)pComponentParameterStructure
;
1222 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1224 ret
= Exynos_OMX_Check_SizeVersion(pSrcAVCComponent
, sizeof(OMX_VIDEO_PARAM_AVCTYPE
));
1225 if (ret
!= OMX_ErrorNone
) {
1229 if (pSrcAVCComponent
->nPortIndex
>= ALL_PORT_NUM
) {
1230 ret
= OMX_ErrorBadPortIndex
;
1234 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1235 pDstAVCComponent
= &pH264Enc
->AVCComponent
[pSrcAVCComponent
->nPortIndex
];
1237 Exynos_OSAL_Memcpy(pDstAVCComponent
, pSrcAVCComponent
, sizeof(OMX_VIDEO_PARAM_AVCTYPE
));
1240 case OMX_IndexParamVideoSliceFMO
:
1242 OMX_VIDEO_PARAM_AVCSLICEFMO
*pSrcSliceFmo
= (OMX_VIDEO_PARAM_AVCSLICEFMO
*)pComponentParameterStructure
;
1243 OMX_VIDEO_PARAM_AVCSLICEFMO
*pDstSliceFmo
= NULL
;
1244 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1246 ret
= Exynos_OMX_Check_SizeVersion(pSrcSliceFmo
, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO
));
1247 if (ret
!= OMX_ErrorNone
) {
1251 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1252 pDstSliceFmo
= &pH264Enc
->AVCSliceFmo
;
1254 Exynos_OSAL_Memcpy(pDstSliceFmo
, pSrcSliceFmo
, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO
));
1257 case OMX_IndexParamStandardComponentRole
:
1259 OMX_PARAM_COMPONENTROLETYPE
*pComponentRole
= (OMX_PARAM_COMPONENTROLETYPE
*)pComponentParameterStructure
;
1261 ret
= Exynos_OMX_Check_SizeVersion(pComponentRole
, sizeof(OMX_PARAM_COMPONENTROLETYPE
));
1262 if (ret
!= OMX_ErrorNone
) {
1266 if ((pExynosComponent
->currentState
!= OMX_StateLoaded
) && (pExynosComponent
->currentState
!= OMX_StateWaitForResources
)) {
1267 ret
= OMX_ErrorIncorrectStateOperation
;
1271 if (!Exynos_OSAL_Strcmp((char*)pComponentRole
->cRole
, EXYNOS_OMX_COMPONENT_H264_ENC_ROLE
)) {
1272 pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
].portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingAVC
;
1274 ret
= OMX_ErrorBadParameter
;
1279 case OMX_IndexParamVideoProfileLevelCurrent
:
1281 OMX_VIDEO_PARAM_PROFILELEVELTYPE
*pSrcProfileLevel
= (OMX_VIDEO_PARAM_PROFILELEVELTYPE
*)pComponentParameterStructure
;
1282 OMX_VIDEO_PARAM_AVCTYPE
*pDstAVCComponent
= NULL
;
1283 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1285 ret
= Exynos_OMX_Check_SizeVersion(pSrcProfileLevel
, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE
));
1286 if (ret
!= OMX_ErrorNone
)
1289 if (pSrcProfileLevel
->nPortIndex
>= ALL_PORT_NUM
) {
1290 ret
= OMX_ErrorBadPortIndex
;
1294 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1296 pDstAVCComponent
= &pH264Enc
->AVCComponent
[pSrcProfileLevel
->nPortIndex
];
1297 pDstAVCComponent
->eProfile
= pSrcProfileLevel
->eProfile
;
1298 pDstAVCComponent
->eLevel
= pSrcProfileLevel
->eLevel
;
1301 case OMX_IndexParamVideoErrorCorrection
:
1303 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pSrcErrorCorrectionType
= (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*)pComponentParameterStructure
;
1304 OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
*pDstErrorCorrectionType
= NULL
;
1305 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1307 ret
= Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType
, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE
));
1308 if (ret
!= OMX_ErrorNone
) {
1312 if (pSrcErrorCorrectionType
->nPortIndex
!= OUTPUT_PORT_INDEX
) {
1313 ret
= OMX_ErrorBadPortIndex
;
1317 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1318 pDstErrorCorrectionType
= &pH264Enc
->errorCorrectionType
[OUTPUT_PORT_INDEX
];
1320 pDstErrorCorrectionType
->bEnableHEC
= pSrcErrorCorrectionType
->bEnableHEC
;
1321 pDstErrorCorrectionType
->bEnableResync
= pSrcErrorCorrectionType
->bEnableResync
;
1322 pDstErrorCorrectionType
->nResynchMarkerSpacing
= pSrcErrorCorrectionType
->nResynchMarkerSpacing
;
1323 pDstErrorCorrectionType
->bEnableDataPartitioning
= pSrcErrorCorrectionType
->bEnableDataPartitioning
;
1324 pDstErrorCorrectionType
->bEnableRVLC
= pSrcErrorCorrectionType
->bEnableRVLC
;
1327 #ifdef USE_H264_PREPEND_SPS_PPS
1328 case OMX_IndexParamPrependSPSPPSToIDR
:
1330 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1332 ret
= Exynos_OSAL_SetPrependSPSPPSToIDR(pComponentParameterStructure
, &(pH264Enc
->hMFCH264Handle
.bPrependSpsPpsToIdr
));
1337 ret
= Exynos_OMX_VideoEncodeSetParameter(hComponent
, nIndex
, pComponentParameterStructure
);
1346 OMX_ERRORTYPE
Exynos_H264Enc_GetConfig(
1347 OMX_HANDLETYPE hComponent
,
1348 OMX_INDEXTYPE nIndex
,
1349 OMX_PTR pComponentConfigStructure
)
1351 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1352 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1353 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1354 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1358 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1359 ret
= OMX_ErrorBadParameter
;
1362 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1363 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1364 if (ret
!= OMX_ErrorNone
) {
1367 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1368 ret
= OMX_ErrorBadParameter
;
1371 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1372 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1373 ret
= OMX_ErrorInvalidState
;
1376 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1379 case OMX_IndexConfigVideoAVCIntraPeriod
:
1381 OMX_VIDEO_CONFIG_AVCINTRAPERIOD
*pAVCIntraPeriod
= (OMX_VIDEO_CONFIG_AVCINTRAPERIOD
*)pComponentConfigStructure
;
1382 OMX_U32 portIndex
= pAVCIntraPeriod
->nPortIndex
;
1384 if ((portIndex
!= OUTPUT_PORT_INDEX
)) {
1385 ret
= OMX_ErrorBadPortIndex
;
1388 pAVCIntraPeriod
->nIDRPeriod
= pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
+ 1;
1389 pAVCIntraPeriod
->nPFrames
= pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
;
1394 ret
= Exynos_OMX_VideoEncodeGetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1404 OMX_ERRORTYPE
Exynos_H264Enc_SetConfig(
1405 OMX_HANDLETYPE hComponent
,
1406 OMX_INDEXTYPE nIndex
,
1407 OMX_PTR pComponentConfigStructure
)
1409 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1410 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1411 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1412 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
1413 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
1417 if (hComponent
== NULL
|| pComponentConfigStructure
== NULL
) {
1418 ret
= OMX_ErrorBadParameter
;
1421 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1422 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1423 if (ret
!= OMX_ErrorNone
) {
1426 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1427 ret
= OMX_ErrorBadParameter
;
1430 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1431 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1432 ret
= OMX_ErrorInvalidState
;
1436 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1437 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1440 case OMX_IndexConfigVideoIntraPeriod
:
1442 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVEncBase
= ((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
);
1443 OMX_U32 nPFrames
= (*((OMX_U32
*)pComponentConfigStructure
)) - 1;
1445 pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
= nPFrames
;
1447 ret
= OMX_ErrorNone
;
1450 case OMX_IndexConfigVideoAVCIntraPeriod
:
1452 OMX_VIDEO_CONFIG_AVCINTRAPERIOD
*pAVCIntraPeriod
= (OMX_VIDEO_CONFIG_AVCINTRAPERIOD
*)pComponentConfigStructure
;
1453 OMX_U32 portIndex
= pAVCIntraPeriod
->nPortIndex
;
1455 if ((portIndex
!= OUTPUT_PORT_INDEX
)) {
1456 ret
= OMX_ErrorBadPortIndex
;
1459 if (pAVCIntraPeriod
->nIDRPeriod
== (pAVCIntraPeriod
->nPFrames
+ 1))
1460 pH264Enc
->AVCComponent
[OUTPUT_PORT_INDEX
].nPFrames
= pAVCIntraPeriod
->nPFrames
;
1462 ret
= OMX_ErrorBadParameter
;
1469 ret
= Exynos_OMX_VideoEncodeSetConfig(hComponent
, nIndex
, pComponentConfigStructure
);
1474 if (ret
== OMX_ErrorNone
)
1475 pVideoEnc
->configChange
= OMX_TRUE
;
1482 OMX_ERRORTYPE
Exynos_H264Enc_GetExtensionIndex(
1483 OMX_IN OMX_HANDLETYPE hComponent
,
1484 OMX_IN OMX_STRING cParameterName
,
1485 OMX_OUT OMX_INDEXTYPE
*pIndexType
)
1487 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1488 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1489 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1493 if (hComponent
== NULL
) {
1494 ret
= OMX_ErrorBadParameter
;
1497 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
1498 ret
= Exynos_OMX_Check_SizeVersion(pOMXComponent
, sizeof(OMX_COMPONENTTYPE
));
1499 if (ret
!= OMX_ErrorNone
) {
1502 if (pOMXComponent
->pComponentPrivate
== NULL
) {
1503 ret
= OMX_ErrorBadParameter
;
1506 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1507 if ((cParameterName
== NULL
) || (pIndexType
== NULL
)) {
1508 ret
= OMX_ErrorBadParameter
;
1511 if (pExynosComponent
->currentState
== OMX_StateInvalid
) {
1512 ret
= OMX_ErrorInvalidState
;
1515 if (Exynos_OSAL_Strcmp(cParameterName
, EXYNOS_INDEX_CONFIG_VIDEO_INTRAPERIOD
) == 0) {
1516 *pIndexType
= OMX_IndexConfigVideoIntraPeriod
;
1517 ret
= OMX_ErrorNone
;
1518 #ifdef USE_H264_PREPEND_SPS_PPS
1519 } else if (Exynos_OSAL_Strcmp(cParameterName
, EXYNOS_INDEX_PARAM_PREPEND_SPSPPS_TO_IDR
) == 0) {
1520 *pIndexType
= OMX_IndexParamPrependSPSPPSToIDR
;
1524 ret
= Exynos_OMX_VideoEncodeGetExtensionIndex(hComponent
, cParameterName
, pIndexType
);
1533 OMX_ERRORTYPE
Exynos_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent
, OMX_U8
*cRole
, OMX_U32 nIndex
)
1535 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1536 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
1537 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
1541 if ((hComponent
== NULL
) || (cRole
== NULL
)) {
1542 ret
= OMX_ErrorBadParameter
;
1545 if (nIndex
== (MAX_COMPONENT_ROLE_NUM
-1)) {
1546 Exynos_OSAL_Strcpy((char *)cRole
, EXYNOS_OMX_COMPONENT_H264_ENC_ROLE
);
1547 ret
= OMX_ErrorNone
;
1549 ret
= OMX_ErrorNoMore
;
1559 OMX_ERRORTYPE
Exynos_H264Enc_Init(OMX_COMPONENTTYPE
*pOMXComponent
)
1561 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1562 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1563 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1564 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1565 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1566 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;;
1567 EXYNOS_MFC_H264ENC_HANDLE
*pMFCH264Handle
= &pH264Enc
->hMFCH264Handle
;
1568 ENCODE_CODEC_EXTRA_BUFFERINFO
*pExtBufferInfo
= pExynosInputPort
->processData
.extInfo
;
1569 OMX_PTR hMFCHandle
= NULL
;
1570 OMX_COLOR_FORMATTYPE eColorFormat
;
1572 ExynosVideoEncOps
*pEncOps
= NULL
;
1573 ExynosVideoEncBufferOps
*pInbufOps
= NULL
;
1574 ExynosVideoEncBufferOps
*pOutbufOps
= NULL
;
1576 CSC_METHOD csc_method
= CSC_METHOD_SW
;
1581 pH264Enc
->hMFCH264Handle
.bConfiguredMFCSrc
= OMX_FALSE
;
1582 pH264Enc
->hMFCH264Handle
.bConfiguredMFCDst
= OMX_FALSE
;
1583 pVideoEnc
->bFirstOutput
= OMX_FALSE
;
1584 pExynosComponent
->bUseFlagEOF
= OMX_TRUE
;
1585 pExynosComponent
->bSaveFlagEOS
= OMX_FALSE
;
1586 pExynosComponent
->bBehaviorEOS
= OMX_FALSE
;
1588 eColorFormat
= pExynosInputPort
->portDefinition
.format
.video
.eColorFormat
;
1589 if (pExynosInputPort
->bStoreMetaData
== OMX_TRUE
) {
1590 if (eColorFormat
== OMX_COLOR_FormatAndroidOpaque
) {
1591 pExynosInputPort
->bufferProcessType
= BUFFER_COPY
;
1593 pExynosInputPort
->bufferProcessType
= BUFFER_SHARE
;
1596 pExynosInputPort
->bufferProcessType
= BUFFER_COPY
;
1599 /* H.264 Codec Open */
1600 ret
= H264CodecOpen(pH264Enc
);
1601 if (ret
!= OMX_ErrorNone
) {
1605 pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
1606 pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
1607 pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
1608 hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
1610 #ifdef USE_ENCODER_RGBINPUT_SUPPORT
1611 if (pEncOps
->Check_RGBSupport(hMFCHandle
) != VIDEO_ERROR_NOSUPPORT
)
1612 pVideoEnc
->bRGBSupport
= OMX_TRUE
;
1615 pVideoEnc
->nInbufSpareSize
= pInbufOps
->Get_SpareSize(hMFCHandle
);
1617 pExynosInputPort
->nPlaneCnt
= MFC_DEFAULT_INPUT_BUFFER_PLANE
;
1618 if ((pExynosInputPort
->bStoreMetaData
!= OMX_TRUE
) &&
1619 (eColorFormat
!= OMX_COLOR_FormatAndroidOpaque
)) {
1620 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1621 OMX_U32 nPlaneSize
[MAX_BUFFER_PLANE
] = {0, 0, 0};
1623 if (pVideoEnc
->bRGBSupport
== OMX_TRUE
) {
1624 pExynosInputPort
->nPlaneCnt
= Exynos_OSAL_GetPlaneCount(eColorFormat
);
1625 Exynos_OSAL_GetPlaneSize(eColorFormat
, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nPlaneSize
);
1627 pExtBufferInfo
->eColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
1628 pExynosInputPort
->nPlaneCnt
= Exynos_OSAL_GetPlaneCount(OMX_COLOR_FormatYUV420SemiPlanar
);
1629 Exynos_OSAL_GetPlaneSize(OMX_COLOR_FormatYUV420SemiPlanar
, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nPlaneSize
);
1632 if (pVideoEnc
->nInbufSpareSize
> 0) {
1633 for (i
= 0; i
< pExynosInputPort
->nPlaneCnt
; i
++)
1634 nPlaneSize
[i
] += pVideoEnc
->nInbufSpareSize
;
1637 Exynos_OSAL_SemaphoreCreate(&pExynosInputPort
->codecSemID
);
1638 Exynos_OSAL_QueueCreate(&pExynosInputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1640 ret
= Exynos_Allocate_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
, MFC_INPUT_BUFFER_NUM_MAX
, nPlaneSize
);
1641 if (ret
!= OMX_ErrorNone
)
1644 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++)
1645 Exynos_CodecBufferEnqueue(pExynosComponent
, INPUT_PORT_INDEX
, pVideoEnc
->pMFCEncInputBuffer
[i
]);
1646 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1650 /* Does not require any actions. */
1654 pExynosOutputPort
->nPlaneCnt
= MFC_DEFAULT_OUTPUT_BUFFER_PLANE
;
1655 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1656 Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort
->codecSemID
);
1657 Exynos_OSAL_QueueCreate(&pExynosOutputPort
->codecBufferQ
, MAX_QUEUE_ELEMENTS
);
1658 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1662 /* Does not require any actions. */
1665 pH264Enc
->bSourceStart
= OMX_FALSE
;
1666 Exynos_OSAL_SignalCreate(&pH264Enc
->hSourceStartEvent
);
1667 pH264Enc
->bDestinationStart
= OMX_FALSE
;
1668 Exynos_OSAL_SignalCreate(&pH264Enc
->hDestinationStartEvent
);
1670 Exynos_OSAL_Memset(pExynosComponent
->timeStamp
, -19771003, sizeof(OMX_TICKS
) * MAX_TIMESTAMP
);
1671 Exynos_OSAL_Memset(pExynosComponent
->nFlags
, 0, sizeof(OMX_U32
) * MAX_FLAGS
);
1672 pH264Enc
->hMFCH264Handle
.indexTimestamp
= 0;
1673 pH264Enc
->hMFCH264Handle
.outputIndexTimestamp
= 0;
1675 pExynosComponent
->getAllDelayBuffer
= OMX_FALSE
;
1677 Exynos_OSAL_QueueCreate(&pH264Enc
->bypassBufferInfoQ
, QUEUE_ELEMENTS
);
1680 csc_method
= CSC_METHOD_HW
;
1682 if (pVideoEnc
->bDRMPlayerMode
== OMX_TRUE
) {
1683 pVideoEnc
->csc_handle
= csc_init(CSC_METHOD_HW
);
1684 csc_set_hw_property(pVideoEnc
->csc_handle
, CSC_HW_PROPERTY_FIXED_NODE
, 2);
1685 csc_set_hw_property(pVideoEnc
->csc_handle
, CSC_HW_PROPERTY_MODE_DRM
, pVideoEnc
->bDRMPlayerMode
);
1687 pVideoEnc
->csc_handle
= csc_init(csc_method
);
1689 if (pVideoEnc
->csc_handle
== NULL
) {
1690 ret
= OMX_ErrorInsufficientResources
;
1693 pVideoEnc
->csc_set_format
= OMX_FALSE
;
1702 OMX_ERRORTYPE
Exynos_H264Enc_Terminate(OMX_COMPONENTTYPE
*pOMXComponent
)
1704 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1705 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1706 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= ((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
);
1707 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1708 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1709 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1710 OMX_PTR hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
1712 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
1713 ExynosVideoEncBufferOps
*pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
1714 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
1716 int i
= 0, plane
= 0;
1720 if (pVideoEnc
->csc_handle
!= NULL
) {
1721 csc_deinit(pVideoEnc
->csc_handle
);
1722 pVideoEnc
->csc_handle
= NULL
;
1725 Exynos_OSAL_QueueTerminate(&pH264Enc
->bypassBufferInfoQ
);
1727 Exynos_OSAL_SignalTerminate(pH264Enc
->hDestinationStartEvent
);
1728 pH264Enc
->hDestinationStartEvent
= NULL
;
1729 pH264Enc
->bDestinationStart
= OMX_FALSE
;
1730 Exynos_OSAL_SignalTerminate(pH264Enc
->hSourceStartEvent
);
1731 pH264Enc
->hSourceStartEvent
= NULL
;
1732 pH264Enc
->bSourceStart
= OMX_FALSE
;
1734 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
1735 Exynos_Free_CodecBuffers(pOMXComponent
, OUTPUT_PORT_INDEX
);
1736 Exynos_OSAL_QueueTerminate(&pExynosOutputPort
->codecBufferQ
);
1737 Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort
->codecSemID
);
1738 } else if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
1742 /* Does not require any actions. */
1745 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1746 Exynos_Free_CodecBuffers(pOMXComponent
, INPUT_PORT_INDEX
);
1747 Exynos_OSAL_QueueTerminate(&pExynosInputPort
->codecBufferQ
);
1748 Exynos_OSAL_SemaphoreTerminate(pExynosInputPort
->codecSemID
);
1749 } else if (pExynosInputPort
->bufferProcessType
& BUFFER_SHARE
) {
1753 /* Does not require any actions. */
1755 H264CodecClose(pH264Enc
);
1763 OMX_ERRORTYPE
Exynos_H264Enc_SrcIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
1765 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1766 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1767 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1768 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
1769 void *hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
1770 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1771 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1772 OMX_U32 oneFrameSize
= pSrcInputData
->dataLen
;
1773 ENCODE_CODEC_EXTRA_BUFFERINFO
*pExtBufferInfo
= pSrcInputData
->extInfo
;
1775 OMX_BUFFERHEADERTYPE tempBufferHeader
;
1776 void *pPrivate
= NULL
;
1778 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
1779 ExynosVideoEncBufferOps
*pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
1780 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
1781 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1787 if (pH264Enc
->hMFCH264Handle
.bConfiguredMFCSrc
== OMX_FALSE
) {
1788 ret
= H264CodecSrcSetup(pOMXComponent
, pSrcInputData
);
1789 if ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)
1792 if (pH264Enc
->hMFCH264Handle
.bConfiguredMFCDst
== OMX_FALSE
) {
1793 ret
= H264CodecDstSetup(pOMXComponent
);
1796 if (pVideoEnc
->configChange
== OMX_TRUE
) {
1797 Change_H264Enc_Param(pExynosComponent
);
1798 pVideoEnc
->configChange
= OMX_FALSE
;
1801 if ((pSrcInputData
->dataLen
> 0) ||
1802 ((pSrcInputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
)) {
1803 OMX_U32 nAllocLen
[MAX_BUFFER_PLANE
] = {0, 0, 0};
1804 OMX_U32 nMFCYUVDataSize
[MAX_BUFFER_PLANE
] = {0, 0, 0};
1806 pExynosComponent
->timeStamp
[pH264Enc
->hMFCH264Handle
.indexTimestamp
] = pSrcInputData
->timeStamp
;
1807 pExynosComponent
->nFlags
[pH264Enc
->hMFCH264Handle
.indexTimestamp
] = pSrcInputData
->nFlags
;
1808 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData
->timeStamp
, pSrcInputData
->timeStamp
/ 1E6
, pH264Enc
->hMFCH264Handle
.indexTimestamp
, pSrcInputData
->nFlags
);
1809 pEncOps
->Set_FrameTag(hMFCHandle
, pH264Enc
->hMFCH264Handle
.indexTimestamp
);
1810 pH264Enc
->hMFCH264Handle
.indexTimestamp
++;
1811 pH264Enc
->hMFCH264Handle
.indexTimestamp
%= MAX_TIMESTAMP
;
1813 if ((pVideoEnc
->bQosChanged
== OMX_TRUE
) &&
1814 (pEncOps
->Set_QosRatio
!= NULL
)) {
1815 pEncOps
->Set_QosRatio(hMFCHandle
, pVideoEnc
->nQosRatio
);
1816 pVideoEnc
->bQosChanged
= OMX_FALSE
;
1819 /* queue work for input buffer */
1820 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "Exynos_H264Enc_SrcIn(): oneFrameSize: %d, bufferHeader: 0x%x", oneFrameSize
, pSrcInputData
->bufferHeader
);
1822 if (pExynosInputPort
->bufferProcessType
== BUFFER_COPY
) {
1823 Exynos_OSAL_GetPlaneSize(pExtBufferInfo
->eColorFormat
, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nMFCYUVDataSize
);
1824 tempBufferHeader
.nFlags
= pSrcInputData
->nFlags
;
1825 tempBufferHeader
.nTimeStamp
= pSrcInputData
->timeStamp
;
1826 pPrivate
= (void *)&tempBufferHeader
;
1828 Exynos_OSAL_GetPlaneSize(pExtBufferInfo
->eColorFormat
,
1829 pExynosInputPort
->portDefinition
.format
.video
.nFrameWidth
,
1830 pExynosInputPort
->portDefinition
.format
.video
.nFrameHeight
,
1832 pPrivate
= (void *)pSrcInputData
->bufferHeader
;
1835 if (pVideoEnc
->nInbufSpareSize
> 0) {
1836 for (i
= 0; i
< pExynosInputPort
->nPlaneCnt
; i
++)
1837 nAllocLen
[i
] = nMFCYUVDataSize
[i
] + pVideoEnc
->nInbufSpareSize
;
1840 codecReturn
= pInbufOps
->ExtensionEnqueue(hMFCHandle
,
1841 (unsigned char **)pSrcInputData
->buffer
.multiPlaneBuffer
.dataBuffer
,
1842 (unsigned char **)pSrcInputData
->buffer
.multiPlaneBuffer
.fd
,
1843 (unsigned int *)nAllocLen
, (unsigned int *)nMFCYUVDataSize
,
1844 pExynosInputPort
->nPlaneCnt
, pPrivate
);
1845 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1846 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - pInbufOps->Enqueue", __FUNCTION__
, __LINE__
);
1847 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecEncode
;
1850 H264CodecStart(pOMXComponent
, INPUT_PORT_INDEX
);
1851 if (pH264Enc
->bSourceStart
== OMX_FALSE
) {
1852 pH264Enc
->bSourceStart
= OMX_TRUE
;
1853 Exynos_OSAL_SignalSet(pH264Enc
->hSourceStartEvent
);
1854 Exynos_OSAL_SleepMillisec(0);
1856 if (pH264Enc
->bDestinationStart
== OMX_FALSE
) {
1857 pH264Enc
->bDestinationStart
= OMX_TRUE
;
1858 Exynos_OSAL_SignalSet(pH264Enc
->hDestinationStartEvent
);
1859 Exynos_OSAL_SleepMillisec(0);
1863 ret
= OMX_ErrorNone
;
1871 OMX_ERRORTYPE
Exynos_H264Enc_SrcOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
1873 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1874 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1875 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1876 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
1877 void *hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
1878 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
1880 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
1881 ExynosVideoEncBufferOps
*pInbufOps
= pH264Enc
->hMFCH264Handle
.pInbufOps
;
1882 ExynosVideoBuffer
*pVideoBuffer
= NULL
;
1883 ExynosVideoBuffer videoBuffer
;
1887 if (pInbufOps
->ExtensionDequeue(hMFCHandle
, &videoBuffer
) == VIDEO_ERROR_NONE
)
1888 pVideoBuffer
= &videoBuffer
;
1890 pVideoBuffer
= NULL
;
1892 pSrcOutputData
->dataLen
= 0;
1893 pSrcOutputData
->usedDataLen
= 0;
1894 pSrcOutputData
->remainDataLen
= 0;
1895 pSrcOutputData
->nFlags
= 0;
1896 pSrcOutputData
->timeStamp
= 0;
1897 pSrcOutputData
->allocSize
= 0;
1898 pSrcOutputData
->bufferHeader
= NULL
;
1900 if (pVideoBuffer
== NULL
) {
1901 pSrcOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= NULL
;
1902 pSrcOutputData
->pPrivate
= NULL
;
1905 for (plane
= 0; plane
< pExynosInputPort
->nPlaneCnt
; plane
++) {
1906 pSrcOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[plane
] = pVideoBuffer
->planes
[plane
].addr
;
1907 pSrcOutputData
->buffer
.multiPlaneBuffer
.fd
[plane
] = pVideoBuffer
->planes
[plane
].fd
;
1909 pSrcOutputData
->allocSize
+= pVideoBuffer
->planes
[plane
].allocSize
;
1912 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
1914 for (i
= 0; i
< MFC_INPUT_BUFFER_NUM_MAX
; i
++) {
1915 if (pSrcOutputData
->buffer
.multiPlaneBuffer
.dataBuffer
[0] ==
1916 pVideoEnc
->pMFCEncInputBuffer
[i
]->pVirAddr
[0]) {
1917 pVideoEnc
->pMFCEncInputBuffer
[i
]->dataSize
= 0;
1918 pSrcOutputData
->pPrivate
= pVideoEnc
->pMFCEncInputBuffer
[i
];
1923 if (i
>= MFC_INPUT_BUFFER_NUM_MAX
) {
1924 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - Lost buffer", __FUNCTION__
, __LINE__
);
1925 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecEncode
;
1930 /* For Share Buffer */
1931 if (pExynosInputPort
->bufferProcessType
== BUFFER_SHARE
)
1932 pSrcOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
1935 ret
= OMX_ErrorNone
;
1943 OMX_ERRORTYPE
Exynos_H264Enc_DstIn(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
1945 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1946 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1947 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1948 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1949 void *hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
1950 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1951 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
1952 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
1953 OMX_U32 dataLen
= 0;
1954 ExynosVideoErrorType codecReturn
= VIDEO_ERROR_NONE
;
1958 if (pDstInputData
->buffer
.singlePlaneBuffer
.dataBuffer
== NULL
) {
1959 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Failed to find input buffer");
1960 ret
= OMX_ErrorBadParameter
;
1964 OMX_U32 nAllocLen
[VIDEO_BUFFER_MAX_PLANES
] = {0, 0, 0};
1965 nAllocLen
[0] = pExynosOutputPort
->portDefinition
.format
.video
.nFrameWidth
* pExynosOutputPort
->portDefinition
.format
.video
.nFrameHeight
* 3 / 2;
1967 codecReturn
= pOutbufOps
->ExtensionEnqueue(hMFCHandle
,
1968 (unsigned char **)&pDstInputData
->buffer
.singlePlaneBuffer
.dataBuffer
,
1969 (unsigned char **)&pDstInputData
->buffer
.singlePlaneBuffer
.fd
,
1970 (unsigned int *)nAllocLen
, (unsigned int *)&dataLen
,
1971 pExynosOutputPort
->nPlaneCnt
, pDstInputData
->bufferHeader
);
1972 if (codecReturn
!= VIDEO_ERROR_NONE
) {
1973 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - pOutbufOps->Enqueue", __FUNCTION__
, __LINE__
);
1974 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecEncode
;
1977 H264CodecStart(pOMXComponent
, OUTPUT_PORT_INDEX
);
1979 ret
= OMX_ErrorNone
;
1987 OMX_ERRORTYPE
Exynos_H264Enc_DstOut(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
1989 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
1990 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
1991 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
1992 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
1993 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
1994 void *hMFCHandle
= pH264Enc
->hMFCH264Handle
.hMFCHandle
;
1995 ExynosVideoEncOps
*pEncOps
= pH264Enc
->hMFCH264Handle
.pEncOps
;
1996 ExynosVideoEncBufferOps
*pOutbufOps
= pH264Enc
->hMFCH264Handle
.pOutbufOps
;
1997 ExynosVideoBuffer
*pVideoBuffer
;
1998 ExynosVideoBuffer videoBuffer
;
1999 ExynosVideoFrameStatusType displayStatus
= VIDEO_FRAME_STATUS_UNKNOWN
;
2000 ExynosVideoGeometry bufferGeometry
;
2001 OMX_S32 indexTimestamp
= 0;
2005 if (pH264Enc
->bDestinationStart
== OMX_FALSE
) {
2006 ret
= OMX_ErrorNone
;
2010 if (pOutbufOps
->ExtensionDequeue(hMFCHandle
, &videoBuffer
) == VIDEO_ERROR_NONE
) {
2011 pVideoBuffer
= &videoBuffer
;
2013 pVideoBuffer
= NULL
;
2014 ret
= OMX_ErrorNone
;
2018 pH264Enc
->hMFCH264Handle
.outputIndexTimestamp
++;
2019 pH264Enc
->hMFCH264Handle
.outputIndexTimestamp
%= MAX_TIMESTAMP
;
2021 pDstOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
= pVideoBuffer
->planes
[0].addr
;
2022 pDstOutputData
->buffer
.singlePlaneBuffer
.fd
= pVideoBuffer
->planes
[0].fd
;
2023 pDstOutputData
->allocSize
= pVideoBuffer
->planes
[0].allocSize
;
2024 pDstOutputData
->dataLen
= pVideoBuffer
->planes
[0].dataSize
;
2025 pDstOutputData
->remainDataLen
= pVideoBuffer
->planes
[0].dataSize
;
2026 pDstOutputData
->usedDataLen
= 0;
2027 pDstOutputData
->pPrivate
= pVideoBuffer
;
2028 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
2030 pDstOutputData
->pPrivate
= NULL
;
2031 for (i
= 0; i
< MFC_OUTPUT_BUFFER_NUM_MAX
; i
++) {
2032 if (pDstOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
==
2033 pVideoEnc
->pMFCEncOutputBuffer
[i
]->pVirAddr
[0]) {
2034 pDstOutputData
->pPrivate
= pVideoEnc
->pMFCEncOutputBuffer
[i
];
2039 if (pDstOutputData
->pPrivate
== NULL
) {
2040 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "Can not find buffer");
2041 ret
= (OMX_ERRORTYPE
)OMX_ErrorCodecEncode
;
2046 /* For Share Buffer */
2047 pDstOutputData
->bufferHeader
= (OMX_BUFFERHEADERTYPE
*)pVideoBuffer
->pPrivate
;
2049 if (pVideoEnc
->bFirstOutput
== OMX_FALSE
) {
2050 if (pVideoEnc
->bDRMPlayerMode
== OMX_FALSE
) {
2055 /* start header return */
2056 /* Calculate sps/pps size if needed */
2057 p
= FindDelimiter((OMX_U8
*)(pDstOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
+ 4),
2058 pDstOutputData
->dataLen
- 4);
2060 iSpsSize
= (unsigned int)p
- (unsigned int)pDstOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
;
2061 pH264Enc
->hMFCH264Handle
.headerData
.pHeaderSPS
=
2062 (OMX_PTR
)pDstOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
;
2063 pH264Enc
->hMFCH264Handle
.headerData
.SPSLen
= iSpsSize
;
2065 iPpsSize
= pDstOutputData
->dataLen
- iSpsSize
;
2066 pH264Enc
->hMFCH264Handle
.headerData
.pHeaderPPS
=
2067 (OMX_U8
*)pDstOutputData
->buffer
.singlePlaneBuffer
.dataBuffer
+ iSpsSize
;
2068 pH264Enc
->hMFCH264Handle
.headerData
.PPSLen
= iPpsSize
;
2071 pDstOutputData
->timeStamp
= 0;
2072 pDstOutputData
->nFlags
|= OMX_BUFFERFLAG_CODECCONFIG
;
2073 pDstOutputData
->nFlags
|= OMX_BUFFERFLAG_ENDOFFRAME
;
2074 pVideoEnc
->bFirstOutput
= OMX_TRUE
;
2076 indexTimestamp
= pEncOps
->Get_FrameTag(pH264Enc
->hMFCH264Handle
.hMFCHandle
);
2077 if ((indexTimestamp
< 0) || (indexTimestamp
>= MAX_TIMESTAMP
)) {
2078 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[pH264Enc
->hMFCH264Handle
.outputIndexTimestamp
];
2079 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[pH264Enc
->hMFCH264Handle
.outputIndexTimestamp
];
2081 pDstOutputData
->timeStamp
= pExynosComponent
->timeStamp
[indexTimestamp
];
2082 pDstOutputData
->nFlags
= pExynosComponent
->nFlags
[indexTimestamp
];
2085 pDstOutputData
->nFlags
|= OMX_BUFFERFLAG_ENDOFFRAME
;
2086 if (pVideoBuffer
->frameType
== VIDEO_FRAME_I
)
2087 pDstOutputData
->nFlags
|= OMX_BUFFERFLAG_SYNCFRAME
;
2090 if ((displayStatus
== VIDEO_FRAME_STATUS_CHANGE_RESOL
) ||
2091 (((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
) &&
2092 (pExynosComponent
->bBehaviorEOS
== OMX_FALSE
))) {
2093 Exynos_OSAL_Log(EXYNOS_LOG_TRACE
, "%x displayStatus:%d, nFlags0x%x", pExynosComponent
, displayStatus
, pDstOutputData
->nFlags
);
2094 pDstOutputData
->remainDataLen
= 0;
2097 if (((pDstOutputData
->nFlags
& OMX_BUFFERFLAG_EOS
) == OMX_BUFFERFLAG_EOS
) &&
2098 (pExynosComponent
->bBehaviorEOS
== OMX_TRUE
))
2099 pExynosComponent
->bBehaviorEOS
= OMX_FALSE
;
2101 ret
= OMX_ErrorNone
;
2109 OMX_ERRORTYPE
Exynos_H264Enc_srcInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcInputData
)
2111 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2112 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2113 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2114 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2118 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2119 ret
= OMX_ErrorNone
;
2122 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2123 ret
= OMX_ErrorNone
;
2127 ret
= Exynos_H264Enc_SrcIn(pOMXComponent
, pSrcInputData
);
2128 if (ret
!= OMX_ErrorNone
) {
2129 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - SrcIn -> event is thrown to client", __FUNCTION__
, __LINE__
);
2130 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2131 pExynosComponent
->callbackData
,
2132 OMX_EventError
, ret
, 0, NULL
);
2141 OMX_ERRORTYPE
Exynos_H264Enc_srcOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pSrcOutputData
)
2143 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2144 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2145 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2146 EXYNOS_OMX_BASEPORT
*pExynosInputPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2150 if ((!CHECK_PORT_ENABLED(pExynosInputPort
)) || (!CHECK_PORT_POPULATED(pExynosInputPort
))) {
2151 ret
= OMX_ErrorNone
;
2155 if (pExynosInputPort
->bufferProcessType
& BUFFER_COPY
) {
2156 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, INPUT_PORT_INDEX
)) {
2157 ret
= OMX_ErrorNone
;
2161 if ((pH264Enc
->bSourceStart
== OMX_FALSE
) &&
2162 (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort
))) {
2163 Exynos_OSAL_SignalWait(pH264Enc
->hSourceStartEvent
, DEF_MAX_WAIT_TIME
);
2164 Exynos_OSAL_SignalReset(pH264Enc
->hSourceStartEvent
);
2167 ret
= Exynos_H264Enc_SrcOut(pOMXComponent
, pSrcOutputData
);
2168 if ((ret
!= OMX_ErrorNone
) && (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2169 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - SrcOut -> event is thrown to client", __FUNCTION__
, __LINE__
);
2170 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2171 pExynosComponent
->callbackData
,
2172 OMX_EventError
, ret
, 0, NULL
);
2181 OMX_ERRORTYPE
Exynos_H264Enc_dstInputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstInputData
)
2183 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2184 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2185 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2186 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2190 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2191 ret
= OMX_ErrorNone
;
2194 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2195 ret
= OMX_ErrorNone
;
2198 if (pExynosOutputPort
->bufferProcessType
& BUFFER_SHARE
) {
2199 if ((pH264Enc
->bDestinationStart
== OMX_FALSE
) &&
2200 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2201 Exynos_OSAL_SignalWait(pH264Enc
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2202 Exynos_OSAL_SignalReset(pH264Enc
->hDestinationStartEvent
);
2205 if (Exynos_OSAL_GetElemNum(&pH264Enc
->bypassBufferInfoQ
) > 0) {
2206 BYPASS_BUFFER_INFO
*pBufferInfo
= (BYPASS_BUFFER_INFO
*)Exynos_OSAL_Dequeue(&pH264Enc
->bypassBufferInfoQ
);
2207 if (pBufferInfo
== NULL
) {
2208 ret
= OMX_ErrorUndefined
;
2212 pDstInputData
->bufferHeader
->nFlags
= pBufferInfo
->nFlags
;
2213 pDstInputData
->bufferHeader
->nTimeStamp
= pBufferInfo
->timeStamp
;
2214 Exynos_OMX_OutputBufferReturn(pOMXComponent
, pDstInputData
->bufferHeader
);
2215 Exynos_OSAL_Free(pBufferInfo
);
2217 ret
= OMX_ErrorNone
;
2221 if (pH264Enc
->hMFCH264Handle
.bConfiguredMFCDst
== OMX_TRUE
) {
2222 ret
= Exynos_H264Enc_DstIn(pOMXComponent
, pDstInputData
);
2223 if (ret
!= OMX_ErrorNone
) {
2224 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - DstIn -> event is thrown to client", __FUNCTION__
, __LINE__
);
2225 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2226 pExynosComponent
->callbackData
,
2227 OMX_EventError
, ret
, 0, NULL
);
2237 OMX_ERRORTYPE
Exynos_H264Enc_dstOutputBufferProcess(OMX_COMPONENTTYPE
*pOMXComponent
, EXYNOS_OMX_DATA
*pDstOutputData
)
2239 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2240 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2241 EXYNOS_H264ENC_HANDLE
*pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
;
2242 EXYNOS_OMX_BASEPORT
*pExynosOutputPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2246 if ((!CHECK_PORT_ENABLED(pExynosOutputPort
)) || (!CHECK_PORT_POPULATED(pExynosOutputPort
))) {
2247 ret
= OMX_ErrorNone
;
2250 if (OMX_FALSE
== Exynos_Check_BufferProcess_State(pExynosComponent
, OUTPUT_PORT_INDEX
)) {
2251 ret
= OMX_ErrorNone
;
2255 if (pExynosOutputPort
->bufferProcessType
& BUFFER_COPY
) {
2256 if ((pH264Enc
->bDestinationStart
== OMX_FALSE
) &&
2257 (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort
))) {
2258 Exynos_OSAL_SignalWait(pH264Enc
->hDestinationStartEvent
, DEF_MAX_WAIT_TIME
);
2259 Exynos_OSAL_SignalReset(pH264Enc
->hDestinationStartEvent
);
2262 if (Exynos_OSAL_GetElemNum(&pH264Enc
->bypassBufferInfoQ
) > 0) {
2263 EXYNOS_OMX_DATABUFFER
*dstOutputUseBuffer
= &pExynosOutputPort
->way
.port2WayDataBuffer
.outputDataBuffer
;
2264 OMX_BUFFERHEADERTYPE
*pOMXBuffer
= NULL
;
2265 BYPASS_BUFFER_INFO
*pBufferInfo
= NULL
;
2267 if (dstOutputUseBuffer
->dataValid
== OMX_FALSE
) {
2268 pOMXBuffer
= Exynos_OutputBufferGetQueue_Direct(pExynosComponent
);
2269 if (pOMXBuffer
== NULL
) {
2270 ret
= OMX_ErrorUndefined
;
2274 pOMXBuffer
= dstOutputUseBuffer
->bufferHeader
;
2277 pBufferInfo
= Exynos_OSAL_Dequeue(&pH264Enc
->bypassBufferInfoQ
);
2278 if (pBufferInfo
== NULL
) {
2279 ret
= OMX_ErrorUndefined
;
2283 pOMXBuffer
->nFlags
= pBufferInfo
->nFlags
;
2284 pOMXBuffer
->nTimeStamp
= pBufferInfo
->timeStamp
;
2285 Exynos_OMX_OutputBufferReturn(pOMXComponent
, pOMXBuffer
);
2286 Exynos_OSAL_Free(pBufferInfo
);
2288 dstOutputUseBuffer
->dataValid
= OMX_FALSE
;
2290 ret
= OMX_ErrorNone
;
2294 ret
= Exynos_H264Enc_DstOut(pOMXComponent
, pDstOutputData
);
2295 if ((ret
!= OMX_ErrorNone
) && (pExynosComponent
->currentState
== OMX_StateExecuting
)) {
2296 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "%s: %d: Failed - DstOut -> event is thrown to client", __FUNCTION__
, __LINE__
);
2297 pExynosComponent
->pCallbacks
->EventHandler((OMX_HANDLETYPE
)pOMXComponent
,
2298 pExynosComponent
->callbackData
,
2299 OMX_EventError
, ret
, 0, NULL
);
2308 OSCL_EXPORT_REF OMX_ERRORTYPE
Exynos_OMX_ComponentInit(
2309 OMX_HANDLETYPE hComponent
,
2310 OMX_STRING componentName
)
2312 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2313 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2314 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2315 EXYNOS_OMX_BASEPORT
*pExynosPort
= NULL
;
2316 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
2317 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
2318 OMX_BOOL bDRMPlayerMode
= OMX_FALSE
;
2323 if ((hComponent
== NULL
) || (componentName
== NULL
)) {
2324 ret
= OMX_ErrorBadParameter
;
2325 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, Line:%d", __LINE__
);
2329 if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_ENC
, componentName
) == 0) {
2330 bDRMPlayerMode
= OMX_FALSE
;
2331 } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DRM_ENC
, componentName
) == 0) {
2332 bDRMPlayerMode
= OMX_TRUE
;
2334 ret
= OMX_ErrorBadParameter
;
2335 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName
, __LINE__
);
2339 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2340 ret
= Exynos_OMX_VideoEncodeComponentInit(pOMXComponent
);
2341 if (ret
!= OMX_ErrorNone
) {
2342 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_Error, Line:%d", __LINE__
);
2345 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2346 pExynosComponent
->codecType
= HW_VIDEO_ENC_CODEC
;
2348 pExynosComponent
->componentName
= (OMX_STRING
)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE
);
2349 if (pExynosComponent
->componentName
== NULL
) {
2350 Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent
);
2351 ret
= OMX_ErrorInsufficientResources
;
2352 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2355 Exynos_OSAL_Memset(pExynosComponent
->componentName
, 0, MAX_OMX_COMPONENT_NAME_SIZE
);
2357 pH264Enc
= Exynos_OSAL_Malloc(sizeof(EXYNOS_H264ENC_HANDLE
));
2358 if (pH264Enc
== NULL
) {
2359 Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent
);
2360 ret
= OMX_ErrorInsufficientResources
;
2361 Exynos_OSAL_Log(EXYNOS_LOG_ERROR
, "OMX_ErrorInsufficientResources, Line:%d", __LINE__
);
2364 Exynos_OSAL_Memset(pH264Enc
, 0, sizeof(EXYNOS_H264ENC_HANDLE
));
2365 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2366 pVideoEnc
->hCodecHandle
= (OMX_HANDLETYPE
)pH264Enc
;
2367 pVideoEnc
->quantization
.nQpI
= 20;
2368 pVideoEnc
->quantization
.nQpP
= 20;
2369 pVideoEnc
->quantization
.nQpB
= 20;
2371 if (bDRMPlayerMode
== OMX_TRUE
)
2372 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H264_DRM_ENC
);
2374 Exynos_OSAL_Strcpy(pExynosComponent
->componentName
, EXYNOS_OMX_COMPONENT_H264_ENC
);
2376 pVideoEnc
->bDRMPlayerMode
= bDRMPlayerMode
;
2378 /* Set componentVersion */
2379 pExynosComponent
->componentVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2380 pExynosComponent
->componentVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2381 pExynosComponent
->componentVersion
.s
.nRevision
= REVISION_NUMBER
;
2382 pExynosComponent
->componentVersion
.s
.nStep
= STEP_NUMBER
;
2383 /* Set specVersion */
2384 pExynosComponent
->specVersion
.s
.nVersionMajor
= VERSIONMAJOR_NUMBER
;
2385 pExynosComponent
->specVersion
.s
.nVersionMinor
= VERSIONMINOR_NUMBER
;
2386 pExynosComponent
->specVersion
.s
.nRevision
= REVISION_NUMBER
;
2387 pExynosComponent
->specVersion
.s
.nStep
= STEP_NUMBER
;
2390 pExynosPort
= &pExynosComponent
->pExynosPort
[INPUT_PORT_INDEX
];
2391 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2392 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2393 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2394 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_INPUT_BUFFER_SIZE
;
2395 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingUnused
;
2396 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2397 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "raw/video");
2398 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatYUV420SemiPlanar
;
2399 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2400 pExynosPort
->bufferProcessType
= BUFFER_COPY
;
2401 pExynosPort
->portWayType
= WAY2_PORT
;
2404 pExynosPort
= &pExynosComponent
->pExynosPort
[OUTPUT_PORT_INDEX
];
2405 pExynosPort
->portDefinition
.format
.video
.nFrameWidth
= DEFAULT_FRAME_WIDTH
;
2406 pExynosPort
->portDefinition
.format
.video
.nFrameHeight
= DEFAULT_FRAME_HEIGHT
;
2407 pExynosPort
->portDefinition
.format
.video
.nStride
= 0; /*DEFAULT_FRAME_WIDTH;*/
2408 pExynosPort
->portDefinition
.nBufferSize
= DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE
;
2409 pExynosPort
->portDefinition
.format
.video
.eCompressionFormat
= OMX_VIDEO_CodingAVC
;
2410 Exynos_OSAL_Memset(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, 0, MAX_OMX_MIMETYPE_SIZE
);
2411 Exynos_OSAL_Strcpy(pExynosPort
->portDefinition
.format
.video
.cMIMEType
, "video/avc");
2412 pExynosPort
->portDefinition
.format
.video
.eColorFormat
= OMX_COLOR_FormatUnused
;
2413 pExynosPort
->portDefinition
.bEnabled
= OMX_TRUE
;
2414 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2415 if (bDRMPlayerMode
== OMX_TRUE
)
2416 pExynosPort
->bufferProcessType
= BUFFER_SHARE
;
2417 pExynosPort
->portWayType
= WAY2_PORT
;
2419 for(i
= 0; i
< ALL_PORT_NUM
; i
++) {
2420 INIT_SET_SIZE_VERSION(&pH264Enc
->AVCComponent
[i
], OMX_VIDEO_PARAM_AVCTYPE
);
2421 pH264Enc
->AVCComponent
[i
].nPortIndex
= i
;
2422 pH264Enc
->AVCComponent
[i
].eProfile
= OMX_VIDEO_AVCProfileBaseline
;
2423 pH264Enc
->AVCComponent
[i
].eLevel
= OMX_VIDEO_AVCLevel31
;
2425 pH264Enc
->AVCComponent
[i
].nPFrames
= 20;
2428 pOMXComponent
->GetParameter
= &Exynos_H264Enc_GetParameter
;
2429 pOMXComponent
->SetParameter
= &Exynos_H264Enc_SetParameter
;
2430 pOMXComponent
->GetConfig
= &Exynos_H264Enc_GetConfig
;
2431 pOMXComponent
->SetConfig
= &Exynos_H264Enc_SetConfig
;
2432 pOMXComponent
->GetExtensionIndex
= &Exynos_H264Enc_GetExtensionIndex
;
2433 pOMXComponent
->ComponentRoleEnum
= &Exynos_H264Enc_ComponentRoleEnum
;
2434 pOMXComponent
->ComponentDeInit
= &Exynos_OMX_ComponentDeinit
;
2436 pExynosComponent
->exynos_codec_componentInit
= &Exynos_H264Enc_Init
;
2437 pExynosComponent
->exynos_codec_componentTerminate
= &Exynos_H264Enc_Terminate
;
2439 pVideoEnc
->exynos_codec_srcInputProcess
= &Exynos_H264Enc_srcInputBufferProcess
;
2440 pVideoEnc
->exynos_codec_srcOutputProcess
= &Exynos_H264Enc_srcOutputBufferProcess
;
2441 pVideoEnc
->exynos_codec_dstInputProcess
= &Exynos_H264Enc_dstInputBufferProcess
;
2442 pVideoEnc
->exynos_codec_dstOutputProcess
= &Exynos_H264Enc_dstOutputBufferProcess
;
2444 pVideoEnc
->exynos_codec_start
= &H264CodecStart
;
2445 pVideoEnc
->exynos_codec_stop
= &H264CodecStop
;
2446 pVideoEnc
->exynos_codec_bufferProcessRun
= &H264CodecOutputBufferProcessRun
;
2447 pVideoEnc
->exynos_codec_enqueueAllBuffer
= &H264CodecEnqueueAllBuffer
;
2449 pVideoEnc
->exynos_checkInputFrame
= NULL
;
2450 pVideoEnc
->exynos_codec_getCodecInputPrivateData
= &GetCodecInputPrivateData
;
2451 pVideoEnc
->exynos_codec_getCodecOutputPrivateData
= &GetCodecOutputPrivateData
;
2453 pVideoEnc
->hSharedMemory
= Exynos_OSAL_SharedMemory_Open();
2454 if (pVideoEnc
->hSharedMemory
== NULL
) {
2455 Exynos_OSAL_Free(pH264Enc
);
2456 pH264Enc
= ((EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
)->hCodecHandle
= NULL
;
2457 Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent
);
2458 ret
= OMX_ErrorInsufficientResources
;
2462 pExynosComponent
->currentState
= OMX_StateLoaded
;
2464 ret
= OMX_ErrorNone
;
2472 OMX_ERRORTYPE
Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent
)
2474 OMX_ERRORTYPE ret
= OMX_ErrorNone
;
2475 OMX_COMPONENTTYPE
*pOMXComponent
= NULL
;
2476 EXYNOS_OMX_BASECOMPONENT
*pExynosComponent
= NULL
;
2477 EXYNOS_OMX_VIDEOENC_COMPONENT
*pVideoEnc
= NULL
;
2478 EXYNOS_H264ENC_HANDLE
*pH264Enc
= NULL
;
2482 if (hComponent
== NULL
) {
2483 ret
= OMX_ErrorBadParameter
;
2486 pOMXComponent
= (OMX_COMPONENTTYPE
*)hComponent
;
2487 pExynosComponent
= (EXYNOS_OMX_BASECOMPONENT
*)pOMXComponent
->pComponentPrivate
;
2488 pVideoEnc
= (EXYNOS_OMX_VIDEOENC_COMPONENT
*)pExynosComponent
->hComponentHandle
;
2490 Exynos_OSAL_SharedMemory_Close(pVideoEnc
->hSharedMemory
);
2492 Exynos_OSAL_Free(pExynosComponent
->componentName
);
2493 pExynosComponent
->componentName
= NULL
;
2495 pH264Enc
= (EXYNOS_H264ENC_HANDLE
*)pVideoEnc
->hCodecHandle
;
2496 if (pH264Enc
!= NULL
) {
2497 Exynos_OSAL_Free(pH264Enc
);
2498 pH264Enc
= pVideoEnc
->hCodecHandle
= NULL
;
2501 ret
= Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent
);
2502 if (ret
!= OMX_ErrorNone
) {
2506 ret
= OMX_ErrorNone
;