Commit | Line | Data |
---|---|---|
c6f4bc34 YK |
1 | /* |
2 | * | |
3 | * Copyright 2012 Samsung Electronics S.LSI Co. LTD | |
4 | * | |
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 | |
8 | * | |
9 | * http://www.apache.org/licenses/LICENSE-2.0 | |
10 | * | |
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. | |
16 | */ | |
17 | ||
18 | /* | |
19 | * @file Exynos_OMX_H264enc.c | |
20 | * @brief | |
21 | * @author SeungBeom Kim (sbcrux.kim@samsung.com) | |
22 | * @version 2.0.0 | |
23 | * @history | |
24 | * 2012.02.20 : Create | |
25 | */ | |
26 | ||
27 | #include <stdio.h> | |
28 | #include <stdlib.h> | |
29 | #include <string.h> | |
30 | ||
31 | #include "Exynos_OMX_Macros.h" | |
32 | #include "Exynos_OMX_Basecomponent.h" | |
33 | #include "Exynos_OMX_Baseport.h" | |
34 | #include "Exynos_OMX_Venc.h" | |
433e798a | 35 | #include "Exynos_OMX_VencControl.h" |
c6f4bc34 YK |
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" | |
c6f4bc34 YK |
42 | #include "Exynos_OSAL_SharedMemory.h" |
43 | #include "Exynos_OSAL_Event.h" | |
44 | ||
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 */ | |
47 | #include "csc.h" | |
48 | ||
49 | #undef EXYNOS_LOG_TAG | |
50 | #define EXYNOS_LOG_TAG "EXYNOS_H264_ENC" | |
51 | #define EXYNOS_LOG_OFF | |
52 | //#define EXYNOS_TRACE_ON | |
53 | #include "Exynos_OSAL_Log.h" | |
54 | ||
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}, | |
71 | ||
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}, | |
86 | ||
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}}; | |
101 | ||
102 | static OMX_U32 OMXAVCProfileToProfileIDC(OMX_VIDEO_AVCPROFILETYPE profile) | |
103 | { | |
104 | OMX_U32 ret = 0; | |
105 | ||
106 | if (profile == OMX_VIDEO_AVCProfileBaseline) | |
107 | ret = 0; | |
108 | else if (profile == OMX_VIDEO_AVCProfileMain) | |
109 | ret = 2; | |
110 | else if (profile == OMX_VIDEO_AVCProfileHigh) | |
111 | ret = 4; | |
112 | ||
113 | return ret; | |
114 | } | |
115 | ||
116 | static OMX_U32 OMXAVCLevelToLevelIDC(OMX_VIDEO_AVCLEVELTYPE level) | |
117 | { | |
118 | OMX_U32 ret = 11; //default OMX_VIDEO_AVCLevel4 | |
119 | ||
120 | if (level == OMX_VIDEO_AVCLevel1) | |
121 | ret = 0; | |
122 | else if (level == OMX_VIDEO_AVCLevel1b) | |
123 | ret = 1; | |
124 | else if (level == OMX_VIDEO_AVCLevel11) | |
125 | ret = 2; | |
126 | else if (level == OMX_VIDEO_AVCLevel12) | |
127 | ret = 3; | |
128 | else if (level == OMX_VIDEO_AVCLevel13) | |
129 | ret = 4; | |
130 | else if (level == OMX_VIDEO_AVCLevel2) | |
131 | ret = 5; | |
132 | else if (level == OMX_VIDEO_AVCLevel21) | |
133 | ret = 6; | |
134 | else if (level == OMX_VIDEO_AVCLevel22) | |
135 | ret = 7; | |
136 | else if (level == OMX_VIDEO_AVCLevel3) | |
137 | ret = 8; | |
138 | else if (level == OMX_VIDEO_AVCLevel31) | |
139 | ret = 9; | |
140 | else if (level == OMX_VIDEO_AVCLevel32) | |
141 | ret = 10; | |
142 | else if (level == OMX_VIDEO_AVCLevel4) | |
143 | ret = 11; | |
144 | else if (level == OMX_VIDEO_AVCLevel41) | |
145 | ret = 12; | |
146 | else if (level == OMX_VIDEO_AVCLevel42) | |
147 | ret = 13; | |
148 | ||
149 | return ret; | |
150 | } | |
151 | ||
152 | static OMX_U8 *FindDelimiter(OMX_U8 *pBuffer, OMX_U32 size) | |
153 | { | |
154 | OMX_U32 i; | |
155 | ||
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); | |
162 | } | |
163 | ||
164 | return NULL; | |
165 | } | |
166 | ||
167 | static void Print_H264Enc_Param(ExynosVideoEncParam *pEncParam) | |
168 | { | |
169 | ExynosVideoEncCommonParam *pCommonParam = &pEncParam->commonParam; | |
170 | ExynosVideoEncH264Param *pH264Param = &pEncParam->codecParam.h264; | |
171 | ||
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); | |
188 | ||
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); | |
208 | ||
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); | |
213 | } | |
214 | ||
215 | static void Set_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) | |
216 | { | |
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; | |
433e798a | 222 | ENCODE_CODEC_EXTRA_BUFFERINFO *pExtBufferInfo = NULL; |
c6f4bc34 YK |
223 | |
224 | ExynosVideoEncParam *pEncParam = NULL; | |
225 | ExynosVideoEncCommonParam *pCommonParam = NULL; | |
226 | ExynosVideoEncH264Param *pH264Param = NULL; | |
227 | ||
433e798a EC |
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; | |
234 | ||
235 | pEncParam = &pMFCH264Handle->encParam; | |
236 | pCommonParam = &pEncParam->commonParam; | |
237 | pH264Param = &pEncParam->codecParam.h264; | |
c6f4bc34 | 238 | |
c6f4bc34 YK |
239 | pEncParam->eCompressionFormat = VIDEO_CODING_AVC; |
240 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "eCompressionFormat: %d", pEncParam->eCompressionFormat); | |
241 | ||
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; | |
433e798a | 246 | pCommonParam->SliceMode = pH264Enc->AVCSliceFmo.eSliceMode; |
c6f4bc34 YK |
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; | |
256 | ||
aa4a2b3e TK |
257 | if (pVideoEnc->intraRefresh.eRefreshMode == OMX_VIDEO_IntraRefreshCyclic) { |
258 | /* Cyclic Mode */ | |
259 | pCommonParam->RandomIntraMBRefresh = pVideoEnc->intraRefresh.nCirMBs; | |
260 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "RandomIntraMBRefresh: %d", pCommonParam->RandomIntraMBRefresh); | |
261 | } else { | |
262 | /* Don't support "Adaptive" and "Cyclic + Adaptive" */ | |
263 | pCommonParam->RandomIntraMBRefresh = 0; | |
264 | } | |
265 | ||
433e798a | 266 | switch (pExtBufferInfo->eColorFormat) { |
565c1e8e | 267 | case OMX_COLOR_FormatYUV420SemiPlanar: |
565c1e8e TK |
268 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12; |
269 | break; | |
433e798a | 270 | case (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV21Linear: |
565c1e8e TK |
271 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV21; |
272 | break; | |
433e798a EC |
273 | #ifdef USE_ENCODER_RGBINPUT_SUPPORT |
274 | case OMX_COLOR_FormatYUV420Planar: | |
275 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_I420; | |
276 | break; | |
277 | case (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatYVU420Planar: | |
278 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_YV12; | |
279 | break; | |
280 | case OMX_COLOR_Format32bitBGRA8888: | |
281 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_ARGB8888; | |
282 | break; | |
283 | #endif | |
284 | case (OMX_COLOR_FORMATTYPE)OMX_SEC_COLOR_FormatNV12Tiled: | |
565c1e8e TK |
285 | default: |
286 | pCommonParam->FrameMap = VIDEO_COLORFORMAT_NV12_TILED; | |
287 | break; | |
c6f4bc34 YK |
288 | } |
289 | ||
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; | |
433e798a EC |
295 | if (pH264Enc->AVCSliceFmo.eSliceMode == OMX_VIDEO_SLICEMODE_AVCDefault) |
296 | pH264Param->SliceArgument = 0; /* Slice mb/byte size number */ | |
297 | else | |
298 | pH264Param->SliceArgument = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nSliceHeaderSpacing; | |
c6f4bc34 YK |
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; | |
312 | ||
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; | |
321 | break; | |
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; | |
327 | break; | |
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; | |
334 | break; | |
335 | } | |
336 | ||
337 | Print_H264Enc_Param(pEncParam); | |
338 | } | |
339 | ||
340 | static void Change_H264Enc_Param(EXYNOS_OMX_BASECOMPONENT *pExynosComponent) | |
341 | { | |
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; | |
347 | ||
348 | ExynosVideoEncOps *pEncOps = NULL; | |
349 | ExynosVideoEncParam *pEncParam = NULL; | |
350 | ExynosVideoEncCommonParam *pCommonParam = NULL; | |
351 | ExynosVideoEncH264Param *pH264Param = NULL; | |
352 | ||
353 | int setParam = 0; | |
354 | ||
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; | |
361 | ||
362 | pEncParam = &pMFCH264Handle->encParam; | |
363 | pCommonParam = &pEncParam->commonParam; | |
364 | pH264Param = &pEncParam->codecParam.h264; | |
365 | ||
366 | if (pVideoEnc->IntraRefreshVOP == OMX_TRUE) { | |
367 | setParam = VIDEO_FRAME_I; | |
368 | pEncOps->Set_FrameType(pH264Enc->hMFCH264Handle.hMFCHandle, setParam); | |
369 | pVideoEnc->IntraRefreshVOP = OMX_FALSE; | |
370 | } | |
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); | |
374 | } | |
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); | |
378 | } | |
c2ad0c51 | 379 | if (pH264Param->FrameRate != (int)((pExynosInputPort->portDefinition.format.video.xFramerate) >> 16)) { |
c6f4bc34 YK |
380 | setParam = (pExynosInputPort->portDefinition.format.video.xFramerate) >> 16; |
381 | pEncOps->Set_FrameRate(pH264Enc->hMFCH264Handle.hMFCHandle, setParam); | |
382 | } | |
383 | ||
384 | Set_H264Enc_Param(pExynosComponent); | |
385 | } | |
386 | ||
387 | OMX_ERRORTYPE GetCodecInputPrivateData(OMX_PTR codecBuffer, OMX_PTR addr[], OMX_U32 size[]) | |
388 | { | |
389 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
390 | ||
391 | EXIT: | |
392 | return ret; | |
393 | } | |
394 | ||
395 | OMX_ERRORTYPE GetCodecOutputPrivateData(OMX_PTR codecBuffer, OMX_PTR *pVirtAddr, OMX_U32 *dataSize) | |
396 | { | |
397 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
398 | ExynosVideoBuffer *pCodecBuffer; | |
399 | ||
400 | if (codecBuffer == NULL) { | |
401 | ret = OMX_ErrorBadParameter; | |
402 | goto EXIT; | |
403 | } | |
404 | ||
405 | pCodecBuffer = (ExynosVideoBuffer *)codecBuffer; | |
406 | ||
407 | if (pVirtAddr != NULL) | |
408 | *pVirtAddr = pCodecBuffer->planes[0].addr; | |
409 | ||
410 | if (dataSize != NULL) | |
411 | *dataSize = pCodecBuffer->planes[0].allocSize; | |
412 | ||
413 | pCodecBuffer = (ExynosVideoBuffer *)codecBuffer; | |
414 | ||
415 | EXIT: | |
416 | return ret; | |
417 | } | |
418 | ||
419 | OMX_ERRORTYPE H264CodecOpen(EXYNOS_H264ENC_HANDLE *pH264Enc) | |
420 | { | |
421 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
422 | ||
423 | ExynosVideoEncOps *pEncOps = NULL; | |
424 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
425 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
426 | ||
427 | FunctionIn(); | |
428 | ||
429 | if (pH264Enc == NULL) { | |
430 | ret = OMX_ErrorBadParameter; | |
431 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
432 | goto EXIT; | |
433 | } | |
434 | ||
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)); | |
439 | ||
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; | |
443 | goto EXIT; | |
444 | } | |
445 | ||
446 | pH264Enc->hMFCH264Handle.pEncOps = pEncOps; | |
447 | pH264Enc->hMFCH264Handle.pInbufOps = pInbufOps; | |
448 | pH264Enc->hMFCH264Handle.pOutbufOps = pOutbufOps; | |
449 | ||
450 | /* function pointer mapping */ | |
451 | pEncOps->nSize = sizeof(ExynosVideoEncOps); | |
452 | pInbufOps->nSize = sizeof(ExynosVideoEncBufferOps); | |
453 | pOutbufOps->nSize = sizeof(ExynosVideoEncBufferOps); | |
454 | ||
455 | Exynos_Video_Register_Encoder(pEncOps, pInbufOps, pOutbufOps); | |
456 | ||
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; | |
462 | goto EXIT; | |
463 | } | |
464 | ||
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; | |
473 | goto EXIT; | |
474 | } | |
475 | ||
476 | /* alloc context, open, querycap */ | |
faa0e22c | 477 | #ifdef USE_DMA_BUF |
c6f4bc34 | 478 | pH264Enc->hMFCH264Handle.hMFCHandle = pH264Enc->hMFCH264Handle.pEncOps->Init(V4L2_MEMORY_DMABUF); |
faa0e22c SKR |
479 | #else |
480 | pH264Enc->hMFCH264Handle.hMFCHandle = pH264Enc->hMFCH264Handle.pEncOps->Init(V4L2_MEMORY_USERPTR); | |
481 | #endif | |
c6f4bc34 YK |
482 | if (pH264Enc->hMFCH264Handle.hMFCHandle == NULL) { |
483 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer"); | |
484 | ret = OMX_ErrorInsufficientResources; | |
485 | goto EXIT; | |
486 | } | |
487 | ||
488 | ret = OMX_ErrorNone; | |
489 | ||
490 | EXIT: | |
491 | if (ret != OMX_ErrorNone) { | |
492 | if (pEncOps != NULL) { | |
493 | Exynos_OSAL_Free(pEncOps); | |
494 | pH264Enc->hMFCH264Handle.pEncOps = NULL; | |
495 | } | |
496 | if (pInbufOps != NULL) { | |
497 | Exynos_OSAL_Free(pInbufOps); | |
498 | pH264Enc->hMFCH264Handle.pInbufOps = NULL; | |
499 | } | |
500 | if (pOutbufOps != NULL) { | |
501 | Exynos_OSAL_Free(pOutbufOps); | |
502 | pH264Enc->hMFCH264Handle.pOutbufOps = NULL; | |
503 | } | |
504 | } | |
505 | ||
506 | FunctionOut(); | |
507 | ||
508 | return ret; | |
509 | } | |
510 | ||
511 | OMX_ERRORTYPE H264CodecClose(EXYNOS_H264ENC_HANDLE *pH264Enc) | |
512 | { | |
513 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
514 | void *hMFCHandle = NULL; | |
515 | ExynosVideoEncOps *pEncOps = NULL; | |
516 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
517 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
518 | ||
519 | FunctionIn(); | |
520 | ||
521 | if (pH264Enc == NULL) { | |
522 | ret = OMX_ErrorBadParameter; | |
523 | goto EXIT; | |
524 | } | |
525 | ||
526 | hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
527 | pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
528 | pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
529 | pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
530 | ||
531 | if (hMFCHandle != NULL) { | |
532 | pEncOps->Finalize(hMFCHandle); | |
533 | hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle = NULL; | |
534 | } | |
535 | if (pOutbufOps != NULL) { | |
536 | Exynos_OSAL_Free(pOutbufOps); | |
537 | pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps = NULL; | |
538 | } | |
539 | if (pInbufOps != NULL) { | |
540 | Exynos_OSAL_Free(pInbufOps); | |
541 | pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps = NULL; | |
542 | } | |
543 | if (pEncOps != NULL) { | |
544 | Exynos_OSAL_Free(pEncOps); | |
545 | pEncOps = pH264Enc->hMFCH264Handle.pEncOps = NULL; | |
546 | } | |
547 | ||
548 | ret = OMX_ErrorNone; | |
549 | ||
550 | EXIT: | |
551 | FunctionOut(); | |
552 | ||
553 | return ret; | |
554 | } | |
555 | ||
556 | OMX_ERRORTYPE H264CodecStart(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
557 | { | |
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; | |
565 | ||
566 | FunctionIn(); | |
567 | ||
568 | if (pOMXComponent == NULL) { | |
569 | ret = OMX_ErrorBadParameter; | |
570 | goto EXIT; | |
571 | } | |
572 | ||
573 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
574 | if (pVideoEnc == NULL) { | |
575 | ret = OMX_ErrorBadParameter; | |
576 | goto EXIT; | |
577 | } | |
578 | ||
579 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
580 | if (pH264Enc == NULL) { | |
581 | ret = OMX_ErrorBadParameter; | |
582 | goto EXIT; | |
583 | } | |
584 | ||
585 | hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
586 | pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
587 | pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
588 | pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
589 | ||
590 | if (nPortIndex == INPUT_PORT_INDEX) | |
591 | pInbufOps->Run(hMFCHandle); | |
592 | else if (nPortIndex == OUTPUT_PORT_INDEX) | |
593 | pOutbufOps->Run(hMFCHandle); | |
594 | ||
595 | ret = OMX_ErrorNone; | |
596 | ||
597 | EXIT: | |
598 | FunctionOut(); | |
599 | ||
600 | return ret; | |
601 | } | |
602 | ||
603 | OMX_ERRORTYPE H264CodecStop(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
604 | { | |
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; | |
612 | ||
613 | FunctionIn(); | |
614 | ||
615 | if (pOMXComponent == NULL) { | |
616 | ret = OMX_ErrorBadParameter; | |
617 | goto EXIT; | |
618 | } | |
619 | ||
620 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
621 | if (pVideoEnc == NULL) { | |
622 | ret = OMX_ErrorBadParameter; | |
623 | goto EXIT; | |
624 | } | |
625 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
626 | if (pH264Enc == NULL) { | |
627 | ret = OMX_ErrorBadParameter; | |
628 | goto EXIT; | |
629 | } | |
630 | ||
631 | hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
632 | pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
633 | pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
634 | pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
635 | ||
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); | |
640 | ||
641 | ret = OMX_ErrorNone; | |
642 | ||
643 | EXIT: | |
644 | FunctionOut(); | |
645 | ||
646 | return ret; | |
647 | } | |
648 | ||
649 | OMX_ERRORTYPE H264CodecOutputBufferProcessRun(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
650 | { | |
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; | |
658 | ||
659 | FunctionIn(); | |
660 | ||
661 | if (pOMXComponent == NULL) { | |
662 | ret = OMX_ErrorBadParameter; | |
663 | goto EXIT; | |
664 | } | |
665 | ||
666 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
667 | if (pVideoEnc == NULL) { | |
668 | ret = OMX_ErrorBadParameter; | |
669 | goto EXIT; | |
670 | } | |
671 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
672 | if (pH264Enc == NULL) { | |
673 | ret = OMX_ErrorBadParameter; | |
674 | goto EXIT; | |
675 | } | |
676 | ||
677 | hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
678 | pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
679 | pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
680 | pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
681 | ||
682 | if (nPortIndex == INPUT_PORT_INDEX) { | |
683 | if (pH264Enc->bSourceStart == OMX_FALSE) { | |
684 | Exynos_OSAL_SignalSet(pH264Enc->hSourceStartEvent); | |
685 | Exynos_OSAL_SleepMillisec(0); | |
686 | } | |
687 | } | |
688 | ||
689 | if (nPortIndex == OUTPUT_PORT_INDEX) { | |
690 | if (pH264Enc->bDestinationStart == OMX_FALSE) { | |
691 | Exynos_OSAL_SignalSet(pH264Enc->hDestinationStartEvent); | |
692 | Exynos_OSAL_SleepMillisec(0); | |
693 | } | |
694 | } | |
695 | ||
696 | ret = OMX_ErrorNone; | |
697 | ||
698 | EXIT: | |
699 | FunctionOut(); | |
700 | ||
701 | return ret; | |
702 | } | |
703 | ||
6dfe5a02 TK |
704 | OMX_ERRORTYPE H264CodecRegistCodecBuffers( |
705 | OMX_COMPONENTTYPE *pOMXComponent, | |
706 | OMX_U32 nPortIndex, | |
707 | OMX_U32 nBufferCnt) | |
708 | { | |
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; | |
717 | ||
718 | OMX_U32 nPlaneCnt = 0; | |
719 | int i, j; | |
720 | ||
721 | FunctionIn(); | |
722 | ||
723 | if (nPortIndex == INPUT_PORT_INDEX) { | |
724 | ppCodecBuffer = &(pVideoEnc->pMFCEncInputBuffer[0]); | |
6dfe5a02 TK |
725 | pBufOps = pH264Enc->hMFCH264Handle.pInbufOps; |
726 | } else { | |
727 | ppCodecBuffer = &(pVideoEnc->pMFCEncOutputBuffer[0]); | |
6dfe5a02 TK |
728 | pBufOps = pH264Enc->hMFCH264Handle.pOutbufOps; |
729 | } | |
433e798a | 730 | nPlaneCnt = pExynosComponent->pExynosPort[nPortIndex].nPlaneCnt; |
6dfe5a02 TK |
731 | |
732 | pPlanes = (ExynosVideoPlane *)Exynos_OSAL_Malloc(sizeof(ExynosVideoPlane) * nPlaneCnt); | |
733 | if (pPlanes == NULL) { | |
734 | ret = OMX_ErrorInsufficientResources; | |
735 | goto EXIT; | |
736 | } | |
737 | ||
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]; | |
744 | } | |
745 | ||
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); | |
750 | goto EXIT; | |
751 | } | |
752 | } | |
753 | ||
754 | Exynos_OSAL_Free(pPlanes); | |
755 | ||
756 | ret = OMX_ErrorNone; | |
757 | ||
758 | EXIT: | |
759 | FunctionOut(); | |
760 | ||
761 | return ret; | |
762 | } | |
763 | ||
e4e150b8 | 764 | OMX_ERRORTYPE H264CodecEnqueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) |
c6f4bc34 YK |
765 | { |
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]; | |
773 | int i, nOutbufs; | |
774 | ||
775 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
776 | ExynosVideoEncBufferOps *pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
777 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
778 | ||
779 | FunctionIn(); | |
780 | ||
a3b57b8a TK |
781 | if ((nPortIndex != INPUT_PORT_INDEX) && (nPortIndex != OUTPUT_PORT_INDEX)) { |
782 | ret = OMX_ErrorBadPortIndex; | |
783 | goto EXIT; | |
784 | } | |
785 | ||
c6f4bc34 YK |
786 | if ((nPortIndex == INPUT_PORT_INDEX) && |
787 | (pH264Enc->bSourceStart == OMX_TRUE)) { | |
788 | Exynos_CodecBufferReset(pExynosComponent, INPUT_PORT_INDEX); | |
789 | ||
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]); | |
794 | ||
e4e150b8 | 795 | Exynos_CodecBufferEnqueue(pExynosComponent, INPUT_PORT_INDEX, pVideoEnc->pMFCEncInputBuffer[i]); |
c6f4bc34 YK |
796 | } |
797 | ||
798 | pInbufOps->Clear_Queue(hMFCHandle); | |
799 | } else if ((nPortIndex == OUTPUT_PORT_INDEX) && | |
800 | (pH264Enc->bDestinationStart == OMX_TRUE)) { | |
c6f4bc34 YK |
801 | Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX); |
802 | ||
803 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
c6f4bc34 YK |
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]); | |
e50b9040 TK |
806 | |
807 | Exynos_CodecBufferEnqueue(pExynosComponent, OUTPUT_PORT_INDEX, pVideoEnc->pMFCEncOutputBuffer[i]); | |
c6f4bc34 | 808 | } |
e50b9040 | 809 | |
c6f4bc34 | 810 | pOutbufOps->Clear_Queue(hMFCHandle); |
c6f4bc34 YK |
811 | } |
812 | ||
813 | EXIT: | |
814 | FunctionOut(); | |
815 | ||
816 | return ret; | |
817 | } | |
818 | ||
819 | OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
820 | { | |
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; | |
830 | ||
831 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
832 | ExynosVideoEncBufferOps *pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
833 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
834 | ExynosVideoEncParam *pEncParam = NULL; | |
835 | ||
836 | ExynosVideoGeometry bufferConf; | |
837 | OMX_U32 inputBufferNumber = 0; | |
838 | int i, nOutbufs; | |
839 | ||
840 | FunctionIn(); | |
841 | ||
842 | if ((oneFrameSize <= 0) && (pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS)) { | |
433e798a EC |
843 | BYPASS_BUFFER_INFO *pBufferInfo = (BYPASS_BUFFER_INFO *)Exynos_OSAL_Malloc(sizeof(BYPASS_BUFFER_INFO)); |
844 | if (pBufferInfo == NULL) { | |
845 | ret = OMX_ErrorInsufficientResources; | |
c6f4bc34 YK |
846 | goto EXIT; |
847 | } | |
848 | ||
433e798a EC |
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); | |
c6f4bc34 YK |
853 | |
854 | ret = OMX_ErrorNone; | |
855 | goto EXIT; | |
856 | } | |
857 | ||
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; | |
864 | goto EXIT; | |
865 | } | |
866 | } | |
867 | ||
d2ab55ed JY |
868 | if (pMFCH264Handle->bPrependSpsPpsToIdr == OMX_TRUE) { |
869 | if (pEncOps->Enable_PrependSpsPpsToIdr) | |
870 | pEncOps->Enable_PrependSpsPpsToIdr(pH264Enc->hMFCH264Handle.hMFCHandle); | |
871 | else | |
872 | Exynos_OSAL_Log(EXYNOS_LOG_WARNING, "%s: Not supported control: Enable_PrependSpsPpsToIdr", __func__); | |
873 | } | |
874 | ||
c6f4bc34 YK |
875 | /* input buffer info: only 3 config values needed */ |
876 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
e4e150b8 | 877 | bufferConf.eColorFormat = pEncParam->commonParam.FrameMap; |
c6f4bc34 YK |
878 | bufferConf.nFrameWidth = pExynosInputPort->portDefinition.format.video.nFrameWidth; |
879 | bufferConf.nFrameHeight = pExynosInputPort->portDefinition.format.video.nFrameHeight; | |
433e798a | 880 | bufferConf.nPlaneCnt = pExynosInputPort->nPlaneCnt; |
c6f4bc34 | 881 | pInbufOps->Set_Shareable(hMFCHandle); |
433e798a | 882 | inputBufferNumber = MAX_INPUTBUFFER_NUM_DYNAMIC; |
c6f4bc34 | 883 | |
24ec2c82 | 884 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
885 | /* should be done before prepare input buffer */ |
886 | if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
887 | ret = OMX_ErrorInsufficientResources; | |
888 | goto EXIT; | |
889 | } | |
890 | } | |
891 | ||
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; | |
897 | goto EXIT; | |
898 | } | |
899 | } | |
900 | ||
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; | |
905 | goto EXIT; | |
906 | } | |
907 | ||
433e798a EC |
908 | if ((pExynosInputPort->bufferProcessType & BUFFER_SHARE) && |
909 | (pExynosInputPort->bStoreMetaData != OMX_TRUE)) { | |
910 | ret = OMX_ErrorNotImplemented; | |
911 | goto EXIT; | |
c6f4bc34 YK |
912 | } |
913 | ||
914 | pH264Enc->hMFCH264Handle.bConfiguredMFCSrc = OMX_TRUE; | |
915 | ret = OMX_ErrorNone; | |
916 | ||
917 | EXIT: | |
918 | FunctionOut(); | |
919 | ||
920 | return ret; | |
921 | } | |
922 | ||
923 | OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) | |
924 | { | |
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]; | |
933 | ||
934 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
935 | ExynosVideoEncBufferOps *pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
936 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
937 | ExynosVideoGeometry bufferConf; | |
938 | int i, nOutbufs; | |
939 | ||
940 | FunctionIn(); | |
941 | ||
433e798a EC |
942 | int OutBufferSize = pExynosOutputPort->portDefinition.nBufferSize; |
943 | ||
c6f4bc34 YK |
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; | |
433e798a | 949 | bufferConf.nPlaneCnt = pExynosOutputPort->nPlaneCnt; |
c6f4bc34 YK |
950 | |
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; | |
954 | goto EXIT; | |
955 | } | |
956 | } | |
957 | ||
958 | /* should be done before prepare output buffer */ | |
959 | if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
960 | ret = OMX_ErrorInsufficientResources; | |
961 | goto EXIT; | |
962 | } | |
963 | ||
964 | pOutbufOps->Set_Shareable(hMFCHandle); | |
965 | int SetupBufferNumber = 0; | |
24ec2c82 | 966 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) |
c6f4bc34 YK |
967 | SetupBufferNumber = MFC_OUTPUT_BUFFER_NUM_MAX; |
968 | else | |
969 | SetupBufferNumber = pExynosOutputPort->portDefinition.nBufferCountActual; | |
970 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "SetupBufferNumber:%d", SetupBufferNumber); | |
971 | ||
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; | |
975 | goto EXIT; | |
976 | } | |
977 | ||
433e798a | 978 | OMX_U32 dataLen[VIDEO_BUFFER_MAX_PLANES] = {0, 0 ,0}; |
24ec2c82 | 979 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
433e798a | 980 | OMX_U32 nPlaneSize[VIDEO_BUFFER_MAX_PLANES] = {0, 0, 0}; |
6dfe5a02 TK |
981 | nPlaneSize[0] = OutBufferSize; |
982 | ret = Exynos_Allocate_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX, MFC_OUTPUT_BUFFER_NUM_MAX, nPlaneSize); | |
983 | if (ret != OMX_ErrorNone) | |
984 | goto EXIT; | |
c6f4bc34 | 985 | |
6dfe5a02 TK |
986 | /* Enqueue output buffer */ |
987 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
433e798a EC |
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); | |
993 | } | |
994 | ||
995 | if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
996 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer"); | |
997 | ret = OMX_ErrorInsufficientResources; | |
998 | goto EXIT; | |
c6f4bc34 | 999 | } |
24ec2c82 | 1000 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
10db72aa | 1001 | /* Register output buffer */ |
c6f4bc34 YK |
1002 | /*************/ |
1003 | /* TBD */ | |
1004 | /*************/ | |
c6f4bc34 | 1005 | } |
c6f4bc34 YK |
1006 | pH264Enc->hMFCH264Handle.bConfiguredMFCDst = OMX_TRUE; |
1007 | ||
1008 | ret = OMX_ErrorNone; | |
1009 | ||
1010 | EXIT: | |
1011 | FunctionOut(); | |
1012 | ||
1013 | return ret; | |
1014 | } | |
1015 | ||
1016 | OMX_ERRORTYPE Exynos_H264Enc_GetParameter( | |
1017 | OMX_IN OMX_HANDLETYPE hComponent, | |
1018 | OMX_IN OMX_INDEXTYPE nParamIndex, | |
1019 | OMX_INOUT OMX_PTR pComponentParameterStructure) | |
1020 | { | |
1021 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1022 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1023 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1024 | ||
1025 | FunctionIn(); | |
1026 | ||
1027 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1028 | ret = OMX_ErrorBadParameter; | |
1029 | goto EXIT; | |
1030 | } | |
1031 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1032 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1033 | if (ret != OMX_ErrorNone) { | |
1034 | goto EXIT; | |
1035 | } | |
1036 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1037 | ret = OMX_ErrorBadParameter; | |
1038 | goto EXIT; | |
1039 | } | |
1040 | ||
1041 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1042 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1043 | ret = OMX_ErrorInvalidState; | |
1044 | goto EXIT; | |
1045 | } | |
1046 | ||
1047 | switch (nParamIndex) { | |
1048 | case OMX_IndexParamVideoAvc: | |
1049 | { | |
1050 | OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; | |
1051 | OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; | |
1052 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1053 | ||
1054 | ret = Exynos_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1055 | if (ret != OMX_ErrorNone) { | |
1056 | goto EXIT; | |
1057 | } | |
1058 | ||
1059 | if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) { | |
1060 | ret = OMX_ErrorBadPortIndex; | |
1061 | goto EXIT; | |
1062 | } | |
1063 | ||
1064 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1065 | pSrcAVCComponent = &pH264Enc->AVCComponent[pDstAVCComponent->nPortIndex]; | |
1066 | ||
1067 | Exynos_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1068 | } | |
1069 | break; | |
433e798a EC |
1070 | case OMX_IndexParamVideoSliceFMO: |
1071 | { | |
1072 | OMX_VIDEO_PARAM_AVCSLICEFMO *pDstSliceFmo = (OMX_VIDEO_PARAM_AVCSLICEFMO *)pComponentParameterStructure; | |
1073 | OMX_VIDEO_PARAM_AVCSLICEFMO *pSrcSliceFmo = NULL; | |
1074 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1075 | ||
1076 | ret = Exynos_OMX_Check_SizeVersion(pDstSliceFmo, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO)); | |
1077 | if (ret != OMX_ErrorNone) { | |
1078 | goto EXIT; | |
1079 | } | |
1080 | ||
1081 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1082 | pSrcSliceFmo = &pH264Enc->AVCSliceFmo; | |
1083 | ||
1084 | Exynos_OSAL_Memcpy(pDstSliceFmo, pSrcSliceFmo, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO)); | |
1085 | } | |
1086 | break; | |
c6f4bc34 YK |
1087 | case OMX_IndexParamStandardComponentRole: |
1088 | { | |
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) { | |
1092 | goto EXIT; | |
1093 | } | |
1094 | ||
1095 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H264_ENC_ROLE); | |
1096 | } | |
1097 | break; | |
1098 | case OMX_IndexParamVideoProfileLevelQuerySupported: | |
1099 | { | |
1100 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; | |
1101 | EXYNOS_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; | |
1102 | OMX_U32 maxProfileLevelNum = 0; | |
1103 | ||
1104 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1105 | if (ret != OMX_ErrorNone) { | |
1106 | goto EXIT; | |
1107 | } | |
1108 | ||
1109 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1110 | ret = OMX_ErrorBadPortIndex; | |
1111 | goto EXIT; | |
1112 | } | |
1113 | ||
1114 | pProfileLevel = supportedAVCProfileLevels; | |
1115 | maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL); | |
1116 | ||
1117 | if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { | |
1118 | ret = OMX_ErrorNoMore; | |
1119 | goto EXIT; | |
1120 | } | |
1121 | ||
1122 | pProfileLevel += pDstProfileLevel->nProfileIndex; | |
1123 | pDstProfileLevel->eProfile = pProfileLevel->profile; | |
1124 | pDstProfileLevel->eLevel = pProfileLevel->level; | |
1125 | } | |
1126 | break; | |
1127 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1128 | { | |
1129 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; | |
1130 | OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; | |
1131 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1132 | ||
1133 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1134 | if (ret != OMX_ErrorNone) { | |
1135 | goto EXIT; | |
1136 | } | |
1137 | ||
1138 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1139 | ret = OMX_ErrorBadPortIndex; | |
1140 | goto EXIT; | |
1141 | } | |
1142 | ||
1143 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1144 | pSrcAVCComponent = &pH264Enc->AVCComponent[pDstProfileLevel->nPortIndex]; | |
1145 | ||
1146 | pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile; | |
1147 | pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel; | |
1148 | } | |
1149 | break; | |
1150 | case OMX_IndexParamVideoErrorCorrection: | |
1151 | { | |
1152 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1153 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; | |
1154 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1155 | ||
1156 | ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1157 | if (ret != OMX_ErrorNone) { | |
1158 | goto EXIT; | |
1159 | } | |
1160 | ||
1161 | if (pDstErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { | |
1162 | ret = OMX_ErrorBadPortIndex; | |
1163 | goto EXIT; | |
1164 | } | |
1165 | ||
1166 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1167 | pSrcErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; | |
1168 | ||
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; | |
1174 | } | |
1175 | break; | |
1176 | default: | |
1177 | ret = Exynos_OMX_VideoEncodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); | |
1178 | break; | |
1179 | } | |
1180 | EXIT: | |
1181 | FunctionOut(); | |
1182 | ||
1183 | return ret; | |
1184 | } | |
1185 | ||
1186 | OMX_ERRORTYPE Exynos_H264Enc_SetParameter( | |
1187 | OMX_IN OMX_HANDLETYPE hComponent, | |
1188 | OMX_IN OMX_INDEXTYPE nIndex, | |
1189 | OMX_IN OMX_PTR pComponentParameterStructure) | |
1190 | { | |
1191 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1192 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1193 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1194 | ||
1195 | FunctionIn(); | |
1196 | ||
1197 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1198 | ret = OMX_ErrorBadParameter; | |
1199 | goto EXIT; | |
1200 | } | |
1201 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1202 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1203 | if (ret != OMX_ErrorNone) { | |
1204 | goto EXIT; | |
1205 | } | |
1206 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1207 | ret = OMX_ErrorBadParameter; | |
1208 | goto EXIT; | |
1209 | } | |
1210 | ||
1211 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1212 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1213 | ret = OMX_ErrorInvalidState; | |
1214 | goto EXIT; | |
1215 | } | |
1216 | ||
1217 | switch (nIndex) { | |
1218 | case OMX_IndexParamVideoAvc: | |
1219 | { | |
1220 | OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; | |
1221 | OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; | |
1222 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1223 | ||
1224 | ret = Exynos_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1225 | if (ret != OMX_ErrorNone) { | |
1226 | goto EXIT; | |
1227 | } | |
1228 | ||
1229 | if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) { | |
1230 | ret = OMX_ErrorBadPortIndex; | |
1231 | goto EXIT; | |
1232 | } | |
1233 | ||
1234 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1235 | pDstAVCComponent = &pH264Enc->AVCComponent[pSrcAVCComponent->nPortIndex]; | |
1236 | ||
1237 | Exynos_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1238 | } | |
1239 | break; | |
433e798a EC |
1240 | case OMX_IndexParamVideoSliceFMO: |
1241 | { | |
1242 | OMX_VIDEO_PARAM_AVCSLICEFMO *pSrcSliceFmo = (OMX_VIDEO_PARAM_AVCSLICEFMO *)pComponentParameterStructure; | |
1243 | OMX_VIDEO_PARAM_AVCSLICEFMO *pDstSliceFmo = NULL; | |
1244 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1245 | ||
1246 | ret = Exynos_OMX_Check_SizeVersion(pSrcSliceFmo, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO)); | |
1247 | if (ret != OMX_ErrorNone) { | |
1248 | goto EXIT; | |
1249 | } | |
1250 | ||
1251 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1252 | pDstSliceFmo = &pH264Enc->AVCSliceFmo; | |
1253 | ||
1254 | Exynos_OSAL_Memcpy(pDstSliceFmo, pSrcSliceFmo, sizeof(OMX_VIDEO_PARAM_AVCSLICEFMO)); | |
1255 | } | |
1256 | break; | |
c6f4bc34 YK |
1257 | case OMX_IndexParamStandardComponentRole: |
1258 | { | |
1259 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; | |
1260 | ||
1261 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1262 | if (ret != OMX_ErrorNone) { | |
1263 | goto EXIT; | |
1264 | } | |
1265 | ||
1266 | if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
1267 | ret = OMX_ErrorIncorrectStateOperation; | |
1268 | goto EXIT; | |
1269 | } | |
1270 | ||
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; | |
1273 | } else { | |
1274 | ret = OMX_ErrorBadParameter; | |
1275 | goto EXIT; | |
1276 | } | |
1277 | } | |
1278 | break; | |
1279 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1280 | { | |
1281 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1282 | OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; | |
1283 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1284 | ||
1285 | ret = Exynos_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1286 | if (ret != OMX_ErrorNone) | |
1287 | goto EXIT; | |
1288 | ||
1289 | if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1290 | ret = OMX_ErrorBadPortIndex; | |
1291 | goto EXIT; | |
1292 | } | |
1293 | ||
1294 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1295 | ||
1296 | pDstAVCComponent = &pH264Enc->AVCComponent[pSrcProfileLevel->nPortIndex]; | |
1297 | pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile; | |
1298 | pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel; | |
1299 | } | |
1300 | break; | |
1301 | case OMX_IndexParamVideoErrorCorrection: | |
1302 | { | |
1303 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1304 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; | |
1305 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1306 | ||
1307 | ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1308 | if (ret != OMX_ErrorNone) { | |
1309 | goto EXIT; | |
1310 | } | |
1311 | ||
1312 | if (pSrcErrorCorrectionType->nPortIndex != OUTPUT_PORT_INDEX) { | |
1313 | ret = OMX_ErrorBadPortIndex; | |
1314 | goto EXIT; | |
1315 | } | |
1316 | ||
1317 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1318 | pDstErrorCorrectionType = &pH264Enc->errorCorrectionType[OUTPUT_PORT_INDEX]; | |
1319 | ||
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; | |
1325 | } | |
1326 | break; | |
d2ab55ed JY |
1327 | #ifdef USE_H264_PREPEND_SPS_PPS |
1328 | case OMX_IndexParamPrependSPSPPSToIDR: | |
1329 | { | |
7e42e410 | 1330 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; |
d2ab55ed | 1331 | |
7e42e410 | 1332 | ret = Exynos_OSAL_SetPrependSPSPPSToIDR(pComponentParameterStructure, &(pH264Enc->hMFCH264Handle.bPrependSpsPpsToIdr)); |
d2ab55ed JY |
1333 | } |
1334 | break; | |
1335 | #endif | |
c6f4bc34 YK |
1336 | default: |
1337 | ret = Exynos_OMX_VideoEncodeSetParameter(hComponent, nIndex, pComponentParameterStructure); | |
1338 | break; | |
1339 | } | |
1340 | EXIT: | |
1341 | FunctionOut(); | |
1342 | ||
1343 | return ret; | |
1344 | } | |
1345 | ||
1346 | OMX_ERRORTYPE Exynos_H264Enc_GetConfig( | |
1347 | OMX_HANDLETYPE hComponent, | |
1348 | OMX_INDEXTYPE nIndex, | |
1349 | OMX_PTR pComponentConfigStructure) | |
1350 | { | |
1351 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1352 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1353 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1354 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
1355 | ||
1356 | FunctionIn(); | |
1357 | ||
1358 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1359 | ret = OMX_ErrorBadParameter; | |
1360 | goto EXIT; | |
1361 | } | |
1362 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1363 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1364 | if (ret != OMX_ErrorNone) { | |
1365 | goto EXIT; | |
1366 | } | |
1367 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1368 | ret = OMX_ErrorBadParameter; | |
1369 | goto EXIT; | |
1370 | } | |
1371 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1372 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1373 | ret = OMX_ErrorInvalidState; | |
1374 | goto EXIT; | |
1375 | } | |
1376 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1377 | ||
1378 | switch (nIndex) { | |
1379 | case OMX_IndexConfigVideoAVCIntraPeriod: | |
1380 | { | |
1381 | OMX_VIDEO_CONFIG_AVCINTRAPERIOD *pAVCIntraPeriod = (OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pComponentConfigStructure; | |
1382 | OMX_U32 portIndex = pAVCIntraPeriod->nPortIndex; | |
1383 | ||
1384 | if ((portIndex != OUTPUT_PORT_INDEX)) { | |
1385 | ret = OMX_ErrorBadPortIndex; | |
1386 | goto EXIT; | |
1387 | } else { | |
1388 | pAVCIntraPeriod->nIDRPeriod = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames + 1; | |
1389 | pAVCIntraPeriod->nPFrames = pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames; | |
1390 | } | |
1391 | } | |
1392 | break; | |
1393 | default: | |
1394 | ret = Exynos_OMX_VideoEncodeGetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1395 | break; | |
1396 | } | |
1397 | ||
1398 | EXIT: | |
1399 | FunctionOut(); | |
1400 | ||
1401 | return ret; | |
1402 | } | |
1403 | ||
1404 | OMX_ERRORTYPE Exynos_H264Enc_SetConfig( | |
1405 | OMX_HANDLETYPE hComponent, | |
1406 | OMX_INDEXTYPE nIndex, | |
1407 | OMX_PTR pComponentConfigStructure) | |
1408 | { | |
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; | |
1414 | ||
1415 | FunctionIn(); | |
1416 | ||
1417 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1418 | ret = OMX_ErrorBadParameter; | |
1419 | goto EXIT; | |
1420 | } | |
1421 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1422 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1423 | if (ret != OMX_ErrorNone) { | |
1424 | goto EXIT; | |
1425 | } | |
1426 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1427 | ret = OMX_ErrorBadParameter; | |
1428 | goto EXIT; | |
1429 | } | |
1430 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1431 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1432 | ret = OMX_ErrorInvalidState; | |
1433 | goto EXIT; | |
1434 | } | |
1435 | ||
1436 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1437 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1438 | ||
1439 | switch (nIndex) { | |
1440 | case OMX_IndexConfigVideoIntraPeriod: | |
1441 | { | |
1442 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVEncBase = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle); | |
1443 | OMX_U32 nPFrames = (*((OMX_U32 *)pComponentConfigStructure)) - 1; | |
1444 | ||
1445 | pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames = nPFrames; | |
1446 | ||
1447 | ret = OMX_ErrorNone; | |
1448 | } | |
1449 | break; | |
1450 | case OMX_IndexConfigVideoAVCIntraPeriod: | |
1451 | { | |
1452 | OMX_VIDEO_CONFIG_AVCINTRAPERIOD *pAVCIntraPeriod = (OMX_VIDEO_CONFIG_AVCINTRAPERIOD *)pComponentConfigStructure; | |
1453 | OMX_U32 portIndex = pAVCIntraPeriod->nPortIndex; | |
1454 | ||
1455 | if ((portIndex != OUTPUT_PORT_INDEX)) { | |
1456 | ret = OMX_ErrorBadPortIndex; | |
1457 | goto EXIT; | |
1458 | } else { | |
1459 | if (pAVCIntraPeriod->nIDRPeriod == (pAVCIntraPeriod->nPFrames + 1)) | |
1460 | pH264Enc->AVCComponent[OUTPUT_PORT_INDEX].nPFrames = pAVCIntraPeriod->nPFrames; | |
1461 | else { | |
1462 | ret = OMX_ErrorBadParameter; | |
1463 | goto EXIT; | |
1464 | } | |
1465 | } | |
1466 | } | |
1467 | break; | |
1468 | default: | |
1469 | ret = Exynos_OMX_VideoEncodeSetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1470 | break; | |
1471 | } | |
1472 | ||
1473 | EXIT: | |
1474 | if (ret == OMX_ErrorNone) | |
1475 | pVideoEnc->configChange = OMX_TRUE; | |
1476 | ||
1477 | FunctionOut(); | |
1478 | ||
1479 | return ret; | |
1480 | } | |
1481 | ||
1482 | OMX_ERRORTYPE Exynos_H264Enc_GetExtensionIndex( | |
1483 | OMX_IN OMX_HANDLETYPE hComponent, | |
1484 | OMX_IN OMX_STRING cParameterName, | |
1485 | OMX_OUT OMX_INDEXTYPE *pIndexType) | |
1486 | { | |
1487 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1488 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1489 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1490 | ||
1491 | FunctionIn(); | |
1492 | ||
1493 | if (hComponent == NULL) { | |
1494 | ret = OMX_ErrorBadParameter; | |
1495 | goto EXIT; | |
1496 | } | |
1497 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1498 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1499 | if (ret != OMX_ErrorNone) { | |
1500 | goto EXIT; | |
1501 | } | |
1502 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1503 | ret = OMX_ErrorBadParameter; | |
1504 | goto EXIT; | |
1505 | } | |
1506 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1507 | if ((cParameterName == NULL) || (pIndexType == NULL)) { | |
1508 | ret = OMX_ErrorBadParameter; | |
1509 | goto EXIT; | |
1510 | } | |
1511 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1512 | ret = OMX_ErrorInvalidState; | |
1513 | goto EXIT; | |
1514 | } | |
1515 | if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_CONFIG_VIDEO_INTRAPERIOD) == 0) { | |
1516 | *pIndexType = OMX_IndexConfigVideoIntraPeriod; | |
1517 | ret = OMX_ErrorNone; | |
d2ab55ed JY |
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; | |
1521 | goto EXIT; | |
1522 | #endif | |
c6f4bc34 YK |
1523 | } else { |
1524 | ret = Exynos_OMX_VideoEncodeGetExtensionIndex(hComponent, cParameterName, pIndexType); | |
1525 | } | |
1526 | ||
1527 | EXIT: | |
1528 | FunctionOut(); | |
1529 | ||
1530 | return ret; | |
1531 | } | |
1532 | ||
1533 | OMX_ERRORTYPE Exynos_H264Enc_ComponentRoleEnum(OMX_HANDLETYPE hComponent, OMX_U8 *cRole, OMX_U32 nIndex) | |
1534 | { | |
1535 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1536 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1537 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1538 | ||
1539 | FunctionIn(); | |
1540 | ||
1541 | if ((hComponent == NULL) || (cRole == NULL)) { | |
1542 | ret = OMX_ErrorBadParameter; | |
1543 | goto EXIT; | |
1544 | } | |
1545 | if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { | |
1546 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_H264_ENC_ROLE); | |
1547 | ret = OMX_ErrorNone; | |
1548 | } else { | |
1549 | ret = OMX_ErrorNoMore; | |
1550 | } | |
1551 | ||
1552 | EXIT: | |
1553 | FunctionOut(); | |
1554 | ||
1555 | return ret; | |
1556 | } | |
1557 | ||
1558 | /* MFC Init */ | |
1559 | OMX_ERRORTYPE Exynos_H264Enc_Init(OMX_COMPONENTTYPE *pOMXComponent) | |
1560 | { | |
433e798a EC |
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; | |
c6f4bc34 YK |
1571 | |
1572 | ExynosVideoEncOps *pEncOps = NULL; | |
1573 | ExynosVideoEncBufferOps *pInbufOps = NULL; | |
1574 | ExynosVideoEncBufferOps *pOutbufOps = NULL; | |
1575 | ||
1576 | CSC_METHOD csc_method = CSC_METHOD_SW; | |
1577 | int i = 0; | |
1578 | ||
1579 | FunctionIn(); | |
1580 | ||
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; | |
e100a12d | 1586 | pExynosComponent->bBehaviorEOS = OMX_FALSE; |
c6f4bc34 YK |
1587 | |
1588 | eColorFormat = pExynosInputPort->portDefinition.format.video.eColorFormat; | |
1589 | if (pExynosInputPort->bStoreMetaData == OMX_TRUE) { | |
1590 | if (eColorFormat == OMX_COLOR_FormatAndroidOpaque) { | |
1591 | pExynosInputPort->bufferProcessType = BUFFER_COPY; | |
1592 | } else { | |
1593 | pExynosInputPort->bufferProcessType = BUFFER_SHARE; | |
1594 | } | |
1595 | } else { | |
1596 | pExynosInputPort->bufferProcessType = BUFFER_COPY; | |
1597 | } | |
1598 | ||
1599 | /* H.264 Codec Open */ | |
1600 | ret = H264CodecOpen(pH264Enc); | |
1601 | if (ret != OMX_ErrorNone) { | |
1602 | goto EXIT; | |
1603 | } | |
1604 | ||
1605 | pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
1606 | pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
1607 | pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
433e798a EC |
1608 | hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; |
1609 | ||
1610 | #ifdef USE_ENCODER_RGBINPUT_SUPPORT | |
1611 | if (pEncOps->Check_RGBSupport(hMFCHandle) != VIDEO_ERROR_NOSUPPORT) | |
1612 | pVideoEnc->bRGBSupport = OMX_TRUE; | |
1613 | #endif | |
c6f4bc34 | 1614 | |
433e798a EC |
1615 | pVideoEnc->nInbufSpareSize = pInbufOps->Get_SpareSize(hMFCHandle); |
1616 | ||
1617 | pExynosInputPort->nPlaneCnt = MFC_DEFAULT_INPUT_BUFFER_PLANE; | |
433e798a | 1618 | pExynosOutputPort->nPlaneCnt = MFC_DEFAULT_OUTPUT_BUFFER_PLANE; |
24ec2c82 | 1619 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1620 | Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); |
1621 | Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
24ec2c82 | 1622 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1623 | /*************/ |
1624 | /* TBD */ | |
1625 | /*************/ | |
1626 | /* Does not require any actions. */ | |
1627 | } | |
1628 | ||
1629 | pH264Enc->bSourceStart = OMX_FALSE; | |
1630 | Exynos_OSAL_SignalCreate(&pH264Enc->hSourceStartEvent); | |
1631 | pH264Enc->bDestinationStart = OMX_FALSE; | |
1632 | Exynos_OSAL_SignalCreate(&pH264Enc->hDestinationStartEvent); | |
1633 | ||
1634 | Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); | |
1635 | Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); | |
1636 | pH264Enc->hMFCH264Handle.indexTimestamp = 0; | |
1637 | pH264Enc->hMFCH264Handle.outputIndexTimestamp = 0; | |
1638 | ||
1639 | pExynosComponent->getAllDelayBuffer = OMX_FALSE; | |
1640 | ||
433e798a EC |
1641 | Exynos_OSAL_QueueCreate(&pH264Enc->bypassBufferInfoQ, QUEUE_ELEMENTS); |
1642 | ||
a80c3bc5 TK |
1643 | #ifdef USE_CSC_HW |
1644 | csc_method = CSC_METHOD_HW; | |
c6f4bc34 | 1645 | #endif |
10db72aa SK |
1646 | if (pVideoEnc->bDRMPlayerMode == OMX_TRUE) { |
1647 | pVideoEnc->csc_handle = csc_init(CSC_METHOD_HW); | |
1648 | csc_set_hw_property(pVideoEnc->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 2); | |
1649 | csc_set_hw_property(pVideoEnc->csc_handle, CSC_HW_PROPERTY_MODE_DRM, pVideoEnc->bDRMPlayerMode); | |
1650 | } else { | |
1651 | pVideoEnc->csc_handle = csc_init(csc_method); | |
1652 | } | |
c6f4bc34 YK |
1653 | if (pVideoEnc->csc_handle == NULL) { |
1654 | ret = OMX_ErrorInsufficientResources; | |
1655 | goto EXIT; | |
1656 | } | |
1657 | pVideoEnc->csc_set_format = OMX_FALSE; | |
1658 | ||
1659 | EXIT: | |
1660 | FunctionOut(); | |
1661 | ||
1662 | return ret; | |
1663 | } | |
1664 | ||
1665 | /* MFC Terminate */ | |
1666 | OMX_ERRORTYPE Exynos_H264Enc_Terminate(OMX_COMPONENTTYPE *pOMXComponent) | |
1667 | { | |
1668 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1669 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1670 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle); | |
1671 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1672 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1673 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1674 | OMX_PTR hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
1675 | ||
1676 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
1677 | ExynosVideoEncBufferOps *pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
1678 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
1679 | ||
1680 | int i = 0, plane = 0; | |
1681 | ||
1682 | FunctionIn(); | |
1683 | ||
1684 | if (pVideoEnc->csc_handle != NULL) { | |
1685 | csc_deinit(pVideoEnc->csc_handle); | |
1686 | pVideoEnc->csc_handle = NULL; | |
1687 | } | |
1688 | ||
433e798a EC |
1689 | Exynos_OSAL_QueueTerminate(&pH264Enc->bypassBufferInfoQ); |
1690 | ||
c6f4bc34 YK |
1691 | Exynos_OSAL_SignalTerminate(pH264Enc->hDestinationStartEvent); |
1692 | pH264Enc->hDestinationStartEvent = NULL; | |
1693 | pH264Enc->bDestinationStart = OMX_FALSE; | |
1694 | Exynos_OSAL_SignalTerminate(pH264Enc->hSourceStartEvent); | |
1695 | pH264Enc->hSourceStartEvent = NULL; | |
1696 | pH264Enc->bSourceStart = OMX_FALSE; | |
1697 | ||
24ec2c82 | 1698 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
6dfe5a02 | 1699 | Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX); |
c6f4bc34 YK |
1700 | Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ); |
1701 | Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID); | |
24ec2c82 | 1702 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1703 | /*************/ |
1704 | /* TBD */ | |
1705 | /*************/ | |
1706 | /* Does not require any actions. */ | |
1707 | } | |
1708 | ||
24ec2c82 | 1709 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
6dfe5a02 | 1710 | Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX); |
c6f4bc34 YK |
1711 | Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); |
1712 | Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); | |
728e5d6f | 1713 | pVideoEnc->bFirstInput = OMX_TRUE; |
24ec2c82 | 1714 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1715 | /*************/ |
1716 | /* TBD */ | |
1717 | /*************/ | |
1718 | /* Does not require any actions. */ | |
1719 | } | |
1720 | H264CodecClose(pH264Enc); | |
1721 | ||
1722 | EXIT: | |
1723 | FunctionOut(); | |
1724 | ||
1725 | return ret; | |
1726 | } | |
1727 | ||
1728 | OMX_ERRORTYPE Exynos_H264Enc_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
1729 | { | |
433e798a EC |
1730 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1731 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1732 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1733 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
1734 | void *hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
1735 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1736 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1737 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
1738 | ENCODE_CODEC_EXTRA_BUFFERINFO *pExtBufferInfo = pSrcInputData->extInfo; | |
1739 | ||
1740 | OMX_BUFFERHEADERTYPE tempBufferHeader; | |
1741 | void *pPrivate = NULL; | |
1742 | ||
1743 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
1744 | ExynosVideoEncBufferOps *pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
1745 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
1746 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1747 | ||
c6f4bc34 YK |
1748 | int i; |
1749 | ||
1750 | FunctionIn(); | |
1751 | ||
1752 | if (pH264Enc->hMFCH264Handle.bConfiguredMFCSrc == OMX_FALSE) { | |
1753 | ret = H264CodecSrcSetup(pOMXComponent, pSrcInputData); | |
1754 | if ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) | |
1755 | goto EXIT; | |
1756 | } | |
1757 | if (pH264Enc->hMFCH264Handle.bConfiguredMFCDst == OMX_FALSE) { | |
1758 | ret = H264CodecDstSetup(pOMXComponent); | |
1759 | } | |
1760 | ||
c2ad0c51 TK |
1761 | if (pVideoEnc->configChange == OMX_TRUE) { |
1762 | Change_H264Enc_Param(pExynosComponent); | |
1763 | pVideoEnc->configChange = OMX_FALSE; | |
1764 | } | |
1765 | ||
ca86e5fa | 1766 | if ((pSrcInputData->dataLen > 0) || |
c6f4bc34 | 1767 | ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { |
433e798a EC |
1768 | OMX_U32 nAllocLen[MAX_BUFFER_PLANE] = {0, 0, 0}; |
1769 | OMX_U32 nMFCYUVDataSize[MAX_BUFFER_PLANE] = {0, 0, 0}; | |
c6f4bc34 YK |
1770 | |
1771 | pExynosComponent->timeStamp[pH264Enc->hMFCH264Handle.indexTimestamp] = pSrcInputData->timeStamp; | |
1772 | pExynosComponent->nFlags[pH264Enc->hMFCH264Handle.indexTimestamp] = pSrcInputData->nFlags; | |
1773 | 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); | |
1774 | pEncOps->Set_FrameTag(hMFCHandle, pH264Enc->hMFCH264Handle.indexTimestamp); | |
1775 | pH264Enc->hMFCH264Handle.indexTimestamp++; | |
1776 | pH264Enc->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP; | |
433e798a EC |
1777 | #ifdef USE_QOS_CTRL |
1778 | if ((pVideoEnc->bQosChanged == OMX_TRUE) && | |
1779 | (pEncOps->Set_QosRatio != NULL)) { | |
1780 | pEncOps->Set_QosRatio(hMFCHandle, pVideoEnc->nQosRatio); | |
1781 | pVideoEnc->bQosChanged = OMX_FALSE; | |
1782 | } | |
1783 | #endif | |
c6f4bc34 YK |
1784 | /* queue work for input buffer */ |
1785 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "Exynos_H264Enc_SrcIn(): oneFrameSize: %d, bufferHeader: 0x%x", oneFrameSize, pSrcInputData->bufferHeader); | |
433e798a EC |
1786 | |
1787 | if (pExynosInputPort->bufferProcessType == BUFFER_COPY) { | |
1788 | Exynos_OSAL_GetPlaneSize(pExtBufferInfo->eColorFormat, ALIGN_TO_16B(1920), ALIGN_TO_16B(1080), nMFCYUVDataSize); | |
1789 | tempBufferHeader.nFlags = pSrcInputData->nFlags; | |
1790 | tempBufferHeader.nTimeStamp = pSrcInputData->timeStamp; | |
1791 | pPrivate = (void *)&tempBufferHeader; | |
c6f4bc34 | 1792 | } else { |
433e798a EC |
1793 | Exynos_OSAL_GetPlaneSize(pExtBufferInfo->eColorFormat, |
1794 | pExynosInputPort->portDefinition.format.video.nFrameWidth, | |
1795 | pExynosInputPort->portDefinition.format.video.nFrameHeight, | |
1796 | nMFCYUVDataSize); | |
1797 | pPrivate = (void *)pSrcInputData->bufferHeader; | |
c6f4bc34 | 1798 | } |
433e798a EC |
1799 | |
1800 | if (pVideoEnc->nInbufSpareSize> 0) { | |
1801 | for (i = 0; i < pExynosInputPort->nPlaneCnt; i++) | |
1802 | nAllocLen[i] = nMFCYUVDataSize[i] + pVideoEnc->nInbufSpareSize; | |
1803 | } | |
1804 | ||
1805 | codecReturn = pInbufOps->ExtensionEnqueue(hMFCHandle, | |
1806 | (unsigned char **)pSrcInputData->buffer.multiPlaneBuffer.dataBuffer, | |
1807 | (unsigned char **)pSrcInputData->buffer.multiPlaneBuffer.fd, | |
1808 | (unsigned int *)nAllocLen, (unsigned int *)nMFCYUVDataSize, | |
1809 | pExynosInputPort->nPlaneCnt, pPrivate); | |
c6f4bc34 YK |
1810 | if (codecReturn != VIDEO_ERROR_NONE) { |
1811 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - pInbufOps->Enqueue", __FUNCTION__, __LINE__); | |
1812 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
1813 | goto EXIT; | |
1814 | } | |
1815 | H264CodecStart(pOMXComponent, INPUT_PORT_INDEX); | |
1816 | if (pH264Enc->bSourceStart == OMX_FALSE) { | |
1817 | pH264Enc->bSourceStart = OMX_TRUE; | |
1818 | Exynos_OSAL_SignalSet(pH264Enc->hSourceStartEvent); | |
1819 | Exynos_OSAL_SleepMillisec(0); | |
1820 | } | |
1821 | if (pH264Enc->bDestinationStart == OMX_FALSE) { | |
1822 | pH264Enc->bDestinationStart = OMX_TRUE; | |
1823 | Exynos_OSAL_SignalSet(pH264Enc->hDestinationStartEvent); | |
1824 | Exynos_OSAL_SleepMillisec(0); | |
1825 | } | |
1826 | } | |
1827 | ||
1828 | ret = OMX_ErrorNone; | |
1829 | ||
1830 | EXIT: | |
1831 | FunctionOut(); | |
1832 | ||
1833 | return ret; | |
1834 | } | |
1835 | ||
1836 | OMX_ERRORTYPE Exynos_H264Enc_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
1837 | { | |
433e798a EC |
1838 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
1839 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1840 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1841 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
1842 | void *hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
1843 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1844 | ||
1845 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
1846 | ExynosVideoEncBufferOps *pInbufOps = pH264Enc->hMFCH264Handle.pInbufOps; | |
1847 | ExynosVideoBuffer *pVideoBuffer = NULL; | |
c6f4bc34 YK |
1848 | ExynosVideoBuffer videoBuffer; |
1849 | ||
1850 | FunctionIn(); | |
1851 | ||
433e798a EC |
1852 | if (pInbufOps->ExtensionDequeue(hMFCHandle, &videoBuffer) == VIDEO_ERROR_NONE) |
1853 | pVideoBuffer = &videoBuffer; | |
1854 | else | |
1855 | pVideoBuffer = NULL; | |
c6f4bc34 YK |
1856 | |
1857 | pSrcOutputData->dataLen = 0; | |
1858 | pSrcOutputData->usedDataLen = 0; | |
1859 | pSrcOutputData->remainDataLen = 0; | |
433e798a EC |
1860 | pSrcOutputData->nFlags = 0; |
1861 | pSrcOutputData->timeStamp = 0; | |
1862 | pSrcOutputData->allocSize = 0; | |
1863 | pSrcOutputData->bufferHeader = NULL; | |
c6f4bc34 YK |
1864 | |
1865 | if (pVideoBuffer == NULL) { | |
1866 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL; | |
c6f4bc34 | 1867 | pSrcOutputData->pPrivate = NULL; |
c6f4bc34 YK |
1868 | } else { |
1869 | int plane = 0; | |
433e798a | 1870 | for (plane = 0; plane < pExynosInputPort->nPlaneCnt; plane++) { |
c6f4bc34 YK |
1871 | pSrcOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr; |
1872 | pSrcOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd; | |
433e798a EC |
1873 | |
1874 | pSrcOutputData->allocSize += pVideoBuffer->planes[plane].allocSize; | |
c6f4bc34 | 1875 | } |
c6f4bc34 | 1876 | |
24ec2c82 | 1877 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
9c39c5ff TK |
1878 | int i; |
1879 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
1880 | if (pSrcOutputData->buffer.multiPlaneBuffer.dataBuffer[0] == | |
1881 | pVideoEnc->pMFCEncInputBuffer[i]->pVirAddr[0]) { | |
1882 | pVideoEnc->pMFCEncInputBuffer[i]->dataSize = 0; | |
1883 | pSrcOutputData->pPrivate = pVideoEnc->pMFCEncInputBuffer[i]; | |
1884 | break; | |
c6f4bc34 | 1885 | } |
c6f4bc34 | 1886 | } |
9c39c5ff TK |
1887 | |
1888 | if (i >= MFC_INPUT_BUFFER_NUM_MAX) { | |
1889 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - Lost buffer", __FUNCTION__, __LINE__); | |
1890 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
1891 | goto EXIT; | |
1892 | } | |
c6f4bc34 YK |
1893 | } |
1894 | ||
1895 | /* For Share Buffer */ | |
433e798a EC |
1896 | if (pExynosInputPort->bufferProcessType == BUFFER_SHARE) |
1897 | pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate; | |
c6f4bc34 YK |
1898 | } |
1899 | ||
1900 | ret = OMX_ErrorNone; | |
1901 | ||
1902 | EXIT: | |
1903 | FunctionOut(); | |
1904 | ||
1905 | return ret; | |
1906 | } | |
1907 | ||
1908 | OMX_ERRORTYPE Exynos_H264Enc_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
1909 | { | |
1910 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1911 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1912 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1913 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1914 | void *hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; | |
433e798a | 1915 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; |
c6f4bc34 YK |
1916 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; |
1917 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
1918 | OMX_U32 dataLen = 0; | |
1919 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1920 | ||
1921 | FunctionIn(); | |
1922 | ||
1923 | if (pDstInputData->buffer.singlePlaneBuffer.dataBuffer == NULL) { | |
1924 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer"); | |
1925 | ret = OMX_ErrorBadParameter; | |
1926 | goto EXIT; | |
1927 | } | |
1928 | ||
433e798a EC |
1929 | OMX_U32 nAllocLen[VIDEO_BUFFER_MAX_PLANES] = {0, 0, 0}; |
1930 | nAllocLen[0] = pExynosOutputPort->portDefinition.format.video.nFrameWidth * pExynosOutputPort->portDefinition.format.video.nFrameHeight * 3 / 2; | |
c6f4bc34 | 1931 | |
433e798a EC |
1932 | codecReturn = pOutbufOps->ExtensionEnqueue(hMFCHandle, |
1933 | (unsigned char **)&pDstInputData->buffer.singlePlaneBuffer.dataBuffer, | |
1934 | (unsigned char **)&pDstInputData->buffer.singlePlaneBuffer.fd, | |
1935 | (unsigned int *)nAllocLen, (unsigned int *)&dataLen, | |
1936 | pExynosOutputPort->nPlaneCnt, pDstInputData->bufferHeader); | |
c6f4bc34 YK |
1937 | if (codecReturn != VIDEO_ERROR_NONE) { |
1938 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - pOutbufOps->Enqueue", __FUNCTION__, __LINE__); | |
1939 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
1940 | goto EXIT; | |
1941 | } | |
1942 | H264CodecStart(pOMXComponent, OUTPUT_PORT_INDEX); | |
1943 | ||
1944 | ret = OMX_ErrorNone; | |
1945 | ||
1946 | EXIT: | |
1947 | FunctionOut(); | |
1948 | ||
1949 | return ret; | |
1950 | } | |
1951 | ||
1952 | OMX_ERRORTYPE Exynos_H264Enc_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
1953 | { | |
1954 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1955 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1956 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1957 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
e50b9040 | 1958 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; |
c6f4bc34 YK |
1959 | void *hMFCHandle = pH264Enc->hMFCH264Handle.hMFCHandle; |
1960 | ExynosVideoEncOps *pEncOps = pH264Enc->hMFCH264Handle.pEncOps; | |
1961 | ExynosVideoEncBufferOps *pOutbufOps = pH264Enc->hMFCH264Handle.pOutbufOps; | |
1962 | ExynosVideoBuffer *pVideoBuffer; | |
433e798a | 1963 | ExynosVideoBuffer videoBuffer; |
c6f4bc34 YK |
1964 | ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN; |
1965 | ExynosVideoGeometry bufferGeometry; | |
1966 | OMX_S32 indexTimestamp = 0; | |
1967 | ||
1968 | FunctionIn(); | |
1969 | ||
1970 | if (pH264Enc->bDestinationStart == OMX_FALSE) { | |
1971 | ret = OMX_ErrorNone; | |
1972 | goto EXIT; | |
1973 | } | |
1974 | ||
433e798a EC |
1975 | if (pOutbufOps->ExtensionDequeue(hMFCHandle, &videoBuffer) == VIDEO_ERROR_NONE) { |
1976 | pVideoBuffer = &videoBuffer; | |
1977 | } else { | |
1978 | pVideoBuffer = NULL; | |
c6f4bc34 YK |
1979 | ret = OMX_ErrorNone; |
1980 | goto EXIT; | |
1981 | } | |
1982 | ||
1983 | pH264Enc->hMFCH264Handle.outputIndexTimestamp++; | |
1984 | pH264Enc->hMFCH264Handle.outputIndexTimestamp %= MAX_TIMESTAMP; | |
1985 | ||
1986 | pDstOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr; | |
1987 | pDstOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd; | |
1988 | pDstOutputData->allocSize = pVideoBuffer->planes[0].allocSize; | |
1989 | pDstOutputData->dataLen = pVideoBuffer->planes[0].dataSize; | |
1990 | pDstOutputData->remainDataLen = pVideoBuffer->planes[0].dataSize; | |
1991 | pDstOutputData->usedDataLen = 0; | |
1992 | pDstOutputData->pPrivate = pVideoBuffer; | |
e50b9040 TK |
1993 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
1994 | int i = 0; | |
1995 | pDstOutputData->pPrivate = NULL; | |
1996 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
1997 | if (pDstOutputData->buffer.singlePlaneBuffer.dataBuffer == | |
1998 | pVideoEnc->pMFCEncOutputBuffer[i]->pVirAddr[0]) { | |
433e798a | 1999 | pDstOutputData->pPrivate = pVideoEnc->pMFCEncOutputBuffer[i]; |
e50b9040 TK |
2000 | break; |
2001 | } | |
2002 | } | |
2003 | ||
2004 | if (pDstOutputData->pPrivate == NULL) { | |
2005 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); | |
2006 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecEncode; | |
2007 | goto EXIT; | |
2008 | } | |
2009 | } | |
2010 | ||
c6f4bc34 YK |
2011 | /* For Share Buffer */ |
2012 | pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; | |
2013 | ||
2014 | if (pVideoEnc->bFirstOutput == OMX_FALSE) { | |
10db72aa SK |
2015 | if (pVideoEnc->bDRMPlayerMode == OMX_FALSE) { |
2016 | OMX_U8 *p = NULL; | |
2017 | int iSpsSize = 0; | |
2018 | int iPpsSize = 0; | |
2019 | ||
2020 | /* start header return */ | |
2021 | /* Calculate sps/pps size if needed */ | |
2022 | p = FindDelimiter((OMX_U8 *)(pDstOutputData->buffer.singlePlaneBuffer.dataBuffer + 4), | |
2023 | pDstOutputData->dataLen - 4); | |
2024 | ||
2025 | iSpsSize = (unsigned int)p - (unsigned int)pDstOutputData->buffer.singlePlaneBuffer.dataBuffer; | |
2026 | pH264Enc->hMFCH264Handle.headerData.pHeaderSPS = | |
2027 | (OMX_PTR)pDstOutputData->buffer.singlePlaneBuffer.dataBuffer; | |
2028 | pH264Enc->hMFCH264Handle.headerData.SPSLen = iSpsSize; | |
2029 | ||
2030 | iPpsSize = pDstOutputData->dataLen - iSpsSize; | |
2031 | pH264Enc->hMFCH264Handle.headerData.pHeaderPPS = | |
2032 | (OMX_U8 *)pDstOutputData->buffer.singlePlaneBuffer.dataBuffer + iSpsSize; | |
2033 | pH264Enc->hMFCH264Handle.headerData.PPSLen = iPpsSize; | |
2034 | } | |
c6f4bc34 YK |
2035 | |
2036 | pDstOutputData->timeStamp = 0; | |
2037 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_CODECCONFIG; | |
2038 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; | |
2039 | pVideoEnc->bFirstOutput = OMX_TRUE; | |
2040 | } else { | |
2041 | indexTimestamp = pEncOps->Get_FrameTag(pH264Enc->hMFCH264Handle.hMFCHandle); | |
2042 | if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) { | |
2043 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[pH264Enc->hMFCH264Handle.outputIndexTimestamp]; | |
2044 | pDstOutputData->nFlags = pExynosComponent->nFlags[pH264Enc->hMFCH264Handle.outputIndexTimestamp]; | |
2045 | } else { | |
2046 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp]; | |
2047 | pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp]; | |
2048 | } | |
2049 | ||
2050 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_ENDOFFRAME; | |
2051 | if (pVideoBuffer->frameType == VIDEO_FRAME_I) | |
2052 | pDstOutputData->nFlags |= OMX_BUFFERFLAG_SYNCFRAME; | |
2053 | } | |
2054 | ||
2055 | if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
e100a12d SK |
2056 | (((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) && |
2057 | (pExynosComponent->bBehaviorEOS == OMX_FALSE))) { | |
c6f4bc34 YK |
2058 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%x displayStatus:%d, nFlags0x%x", pExynosComponent, displayStatus, pDstOutputData->nFlags); |
2059 | pDstOutputData->remainDataLen = 0; | |
2060 | } | |
2061 | ||
e100a12d SK |
2062 | if (((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) && |
2063 | (pExynosComponent->bBehaviorEOS == OMX_TRUE)) | |
2064 | pExynosComponent->bBehaviorEOS = OMX_FALSE; | |
2065 | ||
c6f4bc34 YK |
2066 | ret = OMX_ErrorNone; |
2067 | ||
2068 | EXIT: | |
2069 | FunctionOut(); | |
2070 | ||
2071 | return ret; | |
2072 | } | |
2073 | ||
2074 | OMX_ERRORTYPE Exynos_H264Enc_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
2075 | { | |
2076 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2077 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2078 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2079 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2080 | ||
2081 | FunctionIn(); | |
2082 | ||
2083 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2084 | ret = OMX_ErrorNone; | |
2085 | goto EXIT; | |
2086 | } | |
2087 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
2088 | ret = OMX_ErrorNone; | |
2089 | goto EXIT; | |
2090 | } | |
2091 | ||
2092 | ret = Exynos_H264Enc_SrcIn(pOMXComponent, pSrcInputData); | |
2093 | if (ret != OMX_ErrorNone) { | |
2094 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - SrcIn -> event is thrown to client", __FUNCTION__, __LINE__); | |
2095 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2096 | pExynosComponent->callbackData, | |
2097 | OMX_EventError, ret, 0, NULL); | |
2098 | } | |
2099 | ||
2100 | EXIT: | |
2101 | FunctionOut(); | |
2102 | ||
2103 | return ret; | |
2104 | } | |
2105 | ||
2106 | OMX_ERRORTYPE Exynos_H264Enc_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
2107 | { | |
2108 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2109 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2110 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2111 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2112 | ||
2113 | FunctionIn(); | |
2114 | ||
2115 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2116 | ret = OMX_ErrorNone; | |
2117 | goto EXIT; | |
2118 | } | |
2119 | ||
24ec2c82 | 2120 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
2121 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { |
2122 | ret = OMX_ErrorNone; | |
2123 | goto EXIT; | |
2124 | } | |
2125 | } | |
2126 | if ((pH264Enc->bSourceStart == OMX_FALSE) && | |
2127 | (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) { | |
2128 | Exynos_OSAL_SignalWait(pH264Enc->hSourceStartEvent, DEF_MAX_WAIT_TIME); | |
2129 | Exynos_OSAL_SignalReset(pH264Enc->hSourceStartEvent); | |
2130 | } | |
2131 | ||
2132 | ret = Exynos_H264Enc_SrcOut(pOMXComponent, pSrcOutputData); | |
2133 | if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2134 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - SrcOut -> event is thrown to client", __FUNCTION__, __LINE__); | |
2135 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2136 | pExynosComponent->callbackData, | |
2137 | OMX_EventError, ret, 0, NULL); | |
2138 | } | |
2139 | ||
2140 | EXIT: | |
2141 | FunctionOut(); | |
2142 | ||
2143 | return ret; | |
2144 | } | |
2145 | ||
2146 | OMX_ERRORTYPE Exynos_H264Enc_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
2147 | { | |
2148 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2149 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2150 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2151 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2152 | ||
2153 | FunctionIn(); | |
2154 | ||
2155 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2156 | ret = OMX_ErrorNone; | |
2157 | goto EXIT; | |
2158 | } | |
2159 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2160 | ret = OMX_ErrorNone; | |
2161 | goto EXIT; | |
2162 | } | |
24ec2c82 | 2163 | if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
2164 | if ((pH264Enc->bDestinationStart == OMX_FALSE) && |
2165 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2166 | Exynos_OSAL_SignalWait(pH264Enc->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2167 | Exynos_OSAL_SignalReset(pH264Enc->hDestinationStartEvent); | |
2168 | } | |
433e798a EC |
2169 | |
2170 | if (Exynos_OSAL_GetElemNum(&pH264Enc->bypassBufferInfoQ) > 0) { | |
2171 | BYPASS_BUFFER_INFO *pBufferInfo = (BYPASS_BUFFER_INFO *)Exynos_OSAL_Dequeue(&pH264Enc->bypassBufferInfoQ); | |
2172 | if (pBufferInfo == NULL) { | |
2173 | ret = OMX_ErrorUndefined; | |
2174 | goto EXIT; | |
2175 | } | |
2176 | ||
2177 | pDstInputData->bufferHeader->nFlags = pBufferInfo->nFlags; | |
2178 | pDstInputData->bufferHeader->nTimeStamp = pBufferInfo->timeStamp; | |
2179 | Exynos_OMX_OutputBufferReturn(pOMXComponent, pDstInputData->bufferHeader); | |
2180 | Exynos_OSAL_Free(pBufferInfo); | |
2181 | ||
2182 | ret = OMX_ErrorNone; | |
2183 | goto EXIT; | |
2184 | } | |
c6f4bc34 YK |
2185 | } |
2186 | if (pH264Enc->hMFCH264Handle.bConfiguredMFCDst == OMX_TRUE) { | |
2187 | ret = Exynos_H264Enc_DstIn(pOMXComponent, pDstInputData); | |
2188 | if (ret != OMX_ErrorNone) { | |
2189 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - DstIn -> event is thrown to client", __FUNCTION__, __LINE__); | |
2190 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2191 | pExynosComponent->callbackData, | |
2192 | OMX_EventError, ret, 0, NULL); | |
2193 | } | |
2194 | } | |
2195 | ||
2196 | EXIT: | |
2197 | FunctionOut(); | |
2198 | ||
2199 | return ret; | |
2200 | } | |
2201 | ||
2202 | OMX_ERRORTYPE Exynos_H264Enc_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
2203 | { | |
2204 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2205 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2206 | EXYNOS_H264ENC_HANDLE *pH264Enc = (EXYNOS_H264ENC_HANDLE *)((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2207 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2208 | ||
2209 | FunctionIn(); | |
2210 | ||
2211 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2212 | ret = OMX_ErrorNone; | |
2213 | goto EXIT; | |
2214 | } | |
2215 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2216 | ret = OMX_ErrorNone; | |
2217 | goto EXIT; | |
2218 | } | |
2219 | ||
24ec2c82 | 2220 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
2221 | if ((pH264Enc->bDestinationStart == OMX_FALSE) && |
2222 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2223 | Exynos_OSAL_SignalWait(pH264Enc->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2224 | Exynos_OSAL_SignalReset(pH264Enc->hDestinationStartEvent); | |
2225 | } | |
433e798a EC |
2226 | |
2227 | if (Exynos_OSAL_GetElemNum(&pH264Enc->bypassBufferInfoQ) > 0) { | |
2228 | EXYNOS_OMX_DATABUFFER *dstOutputUseBuffer = &pExynosOutputPort->way.port2WayDataBuffer.outputDataBuffer; | |
2229 | OMX_BUFFERHEADERTYPE *pOMXBuffer = NULL; | |
2230 | BYPASS_BUFFER_INFO *pBufferInfo = NULL; | |
2231 | ||
2232 | if (dstOutputUseBuffer->dataValid == OMX_FALSE) { | |
2233 | pOMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent); | |
2234 | if (pOMXBuffer == NULL) { | |
2235 | ret = OMX_ErrorUndefined; | |
2236 | goto EXIT; | |
2237 | } | |
2238 | } else { | |
2239 | pOMXBuffer = dstOutputUseBuffer->bufferHeader; | |
2240 | } | |
2241 | ||
2242 | pBufferInfo = Exynos_OSAL_Dequeue(&pH264Enc->bypassBufferInfoQ); | |
2243 | if (pBufferInfo == NULL) { | |
2244 | ret = OMX_ErrorUndefined; | |
2245 | goto EXIT; | |
2246 | } | |
2247 | ||
2248 | pOMXBuffer->nFlags = pBufferInfo->nFlags; | |
2249 | pOMXBuffer->nTimeStamp = pBufferInfo->timeStamp; | |
2250 | Exynos_OMX_OutputBufferReturn(pOMXComponent, pOMXBuffer); | |
2251 | Exynos_OSAL_Free(pBufferInfo); | |
2252 | ||
2253 | dstOutputUseBuffer->dataValid = OMX_FALSE; | |
2254 | ||
2255 | ret = OMX_ErrorNone; | |
2256 | goto EXIT; | |
2257 | } | |
c6f4bc34 YK |
2258 | } |
2259 | ret = Exynos_H264Enc_DstOut(pOMXComponent, pDstOutputData); | |
2260 | if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2261 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s: %d: Failed - DstOut -> event is thrown to client", __FUNCTION__, __LINE__); | |
2262 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2263 | pExynosComponent->callbackData, | |
2264 | OMX_EventError, ret, 0, NULL); | |
2265 | } | |
2266 | ||
2267 | EXIT: | |
2268 | FunctionOut(); | |
2269 | ||
2270 | return ret; | |
2271 | } | |
2272 | ||
e4e150b8 HK |
2273 | OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit( |
2274 | OMX_HANDLETYPE hComponent, | |
2275 | OMX_STRING componentName) | |
c6f4bc34 YK |
2276 | { |
2277 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2278 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2279 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2280 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
2281 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
2282 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
10db72aa | 2283 | OMX_BOOL bDRMPlayerMode = OMX_FALSE; |
c6f4bc34 YK |
2284 | int i = 0; |
2285 | ||
2286 | FunctionIn(); | |
2287 | ||
2288 | if ((hComponent == NULL) || (componentName == NULL)) { | |
2289 | ret = OMX_ErrorBadParameter; | |
2290 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
2291 | goto EXIT; | |
2292 | } | |
10db72aa SK |
2293 | |
2294 | if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_ENC, componentName) == 0) { | |
2295 | bDRMPlayerMode = OMX_FALSE; | |
2296 | } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DRM_ENC, componentName) == 0) { | |
2297 | bDRMPlayerMode = OMX_TRUE; | |
2298 | } else { | |
c6f4bc34 YK |
2299 | ret = OMX_ErrorBadParameter; |
2300 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); | |
2301 | goto EXIT; | |
2302 | } | |
2303 | ||
2304 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2305 | ret = Exynos_OMX_VideoEncodeComponentInit(pOMXComponent); | |
2306 | if (ret != OMX_ErrorNone) { | |
2307 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); | |
2308 | goto EXIT; | |
2309 | } | |
2310 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2311 | pExynosComponent->codecType = HW_VIDEO_ENC_CODEC; | |
2312 | ||
2313 | pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); | |
2314 | if (pExynosComponent->componentName == NULL) { | |
2315 | Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2316 | ret = OMX_ErrorInsufficientResources; | |
2317 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2318 | goto EXIT; | |
2319 | } | |
2320 | Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); | |
2321 | ||
2322 | pH264Enc = Exynos_OSAL_Malloc(sizeof(EXYNOS_H264ENC_HANDLE)); | |
2323 | if (pH264Enc == NULL) { | |
2324 | Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2325 | ret = OMX_ErrorInsufficientResources; | |
2326 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2327 | goto EXIT; | |
2328 | } | |
2329 | Exynos_OSAL_Memset(pH264Enc, 0, sizeof(EXYNOS_H264ENC_HANDLE)); | |
2330 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2331 | pVideoEnc->hCodecHandle = (OMX_HANDLETYPE)pH264Enc; | |
2332 | pVideoEnc->quantization.nQpI = 20; | |
2333 | pVideoEnc->quantization.nQpP = 20; | |
2334 | pVideoEnc->quantization.nQpB = 20; | |
2335 | ||
10db72aa SK |
2336 | if (bDRMPlayerMode == OMX_TRUE) |
2337 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DRM_ENC); | |
2338 | else | |
2339 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_ENC); | |
2340 | ||
2341 | pVideoEnc->bDRMPlayerMode = bDRMPlayerMode; | |
2342 | ||
c6f4bc34 YK |
2343 | /* Set componentVersion */ |
2344 | pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2345 | pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2346 | pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER; | |
2347 | pExynosComponent->componentVersion.s.nStep = STEP_NUMBER; | |
2348 | /* Set specVersion */ | |
2349 | pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2350 | pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2351 | pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER; | |
2352 | pExynosComponent->specVersion.s.nStep = STEP_NUMBER; | |
2353 | ||
2354 | /* Input port */ | |
2355 | pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2356 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2357 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2358 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2359 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; | |
2360 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; | |
2361 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2362 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video"); | |
2363 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; | |
2364 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2365 | pExynosPort->bufferProcessType = BUFFER_COPY; | |
2366 | pExynosPort->portWayType = WAY2_PORT; | |
2367 | ||
2368 | /* Output port */ | |
2369 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2370 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2371 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2372 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2373 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; | |
2374 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; | |
2375 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2376 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/avc"); | |
2377 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; | |
2378 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2379 | pExynosPort->bufferProcessType = BUFFER_SHARE; | |
10db72aa SK |
2380 | if (bDRMPlayerMode == OMX_TRUE) |
2381 | pExynosPort->bufferProcessType = BUFFER_SHARE; | |
c6f4bc34 YK |
2382 | pExynosPort->portWayType = WAY2_PORT; |
2383 | ||
2384 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2385 | INIT_SET_SIZE_VERSION(&pH264Enc->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE); | |
2386 | pH264Enc->AVCComponent[i].nPortIndex = i; | |
2387 | pH264Enc->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline; | |
2388 | pH264Enc->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel31; | |
2389 | ||
2390 | pH264Enc->AVCComponent[i].nPFrames = 20; | |
2391 | } | |
2392 | ||
2393 | pOMXComponent->GetParameter = &Exynos_H264Enc_GetParameter; | |
2394 | pOMXComponent->SetParameter = &Exynos_H264Enc_SetParameter; | |
2395 | pOMXComponent->GetConfig = &Exynos_H264Enc_GetConfig; | |
2396 | pOMXComponent->SetConfig = &Exynos_H264Enc_SetConfig; | |
2397 | pOMXComponent->GetExtensionIndex = &Exynos_H264Enc_GetExtensionIndex; | |
2398 | pOMXComponent->ComponentRoleEnum = &Exynos_H264Enc_ComponentRoleEnum; | |
2399 | pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit; | |
2400 | ||
2401 | pExynosComponent->exynos_codec_componentInit = &Exynos_H264Enc_Init; | |
2402 | pExynosComponent->exynos_codec_componentTerminate = &Exynos_H264Enc_Terminate; | |
2403 | ||
2404 | pVideoEnc->exynos_codec_srcInputProcess = &Exynos_H264Enc_srcInputBufferProcess; | |
2405 | pVideoEnc->exynos_codec_srcOutputProcess = &Exynos_H264Enc_srcOutputBufferProcess; | |
2406 | pVideoEnc->exynos_codec_dstInputProcess = &Exynos_H264Enc_dstInputBufferProcess; | |
2407 | pVideoEnc->exynos_codec_dstOutputProcess = &Exynos_H264Enc_dstOutputBufferProcess; | |
2408 | ||
2409 | pVideoEnc->exynos_codec_start = &H264CodecStart; | |
2410 | pVideoEnc->exynos_codec_stop = &H264CodecStop; | |
2411 | pVideoEnc->exynos_codec_bufferProcessRun = &H264CodecOutputBufferProcessRun; | |
e4e150b8 | 2412 | pVideoEnc->exynos_codec_enqueueAllBuffer = &H264CodecEnqueueAllBuffer; |
c6f4bc34 YK |
2413 | |
2414 | pVideoEnc->exynos_checkInputFrame = NULL; | |
2415 | pVideoEnc->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; | |
2416 | pVideoEnc->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData; | |
2417 | ||
2418 | pVideoEnc->hSharedMemory = Exynos_OSAL_SharedMemory_Open(); | |
2419 | if (pVideoEnc->hSharedMemory == NULL) { | |
2420 | Exynos_OSAL_Free(pH264Enc); | |
2421 | pH264Enc = ((EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL; | |
2422 | Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2423 | ret = OMX_ErrorInsufficientResources; | |
2424 | goto EXIT; | |
2425 | } | |
2426 | ||
2427 | pExynosComponent->currentState = OMX_StateLoaded; | |
2428 | ||
2429 | ret = OMX_ErrorNone; | |
2430 | ||
2431 | EXIT: | |
2432 | FunctionOut(); | |
2433 | ||
2434 | return ret; | |
2435 | } | |
2436 | ||
2437 | OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) | |
2438 | { | |
2439 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2440 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2441 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2442 | EXYNOS_OMX_VIDEOENC_COMPONENT *pVideoEnc = NULL; | |
2443 | EXYNOS_H264ENC_HANDLE *pH264Enc = NULL; | |
2444 | ||
2445 | FunctionIn(); | |
2446 | ||
2447 | if (hComponent == NULL) { | |
2448 | ret = OMX_ErrorBadParameter; | |
2449 | goto EXIT; | |
2450 | } | |
2451 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2452 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2453 | pVideoEnc = (EXYNOS_OMX_VIDEOENC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2454 | ||
2455 | Exynos_OSAL_SharedMemory_Close(pVideoEnc->hSharedMemory); | |
2456 | ||
2457 | Exynos_OSAL_Free(pExynosComponent->componentName); | |
2458 | pExynosComponent->componentName = NULL; | |
2459 | ||
2460 | pH264Enc = (EXYNOS_H264ENC_HANDLE *)pVideoEnc->hCodecHandle; | |
2461 | if (pH264Enc != NULL) { | |
2462 | Exynos_OSAL_Free(pH264Enc); | |
2463 | pH264Enc = pVideoEnc->hCodecHandle = NULL; | |
2464 | } | |
2465 | ||
2466 | ret = Exynos_OMX_VideoEncodeComponentDeinit(pOMXComponent); | |
2467 | if (ret != OMX_ErrorNone) { | |
2468 | goto EXIT; | |
2469 | } | |
2470 | ||
2471 | ret = OMX_ErrorNone; | |
2472 | ||
2473 | EXIT: | |
2474 | FunctionOut(); | |
2475 | ||
2476 | return ret; | |
2477 | } |