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_H264dec.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_Vdec.h" | |
35 | #include "Exynos_OSAL_ETC.h" | |
36 | #include "Exynos_OSAL_Semaphore.h" | |
37 | #include "Exynos_OSAL_Thread.h" | |
38 | #include "library_register.h" | |
39 | #include "Exynos_OMX_H264dec.h" | |
40 | #include "ExynosVideoApi.h" | |
41 | #include "Exynos_OSAL_SharedMemory.h" | |
42 | #include "Exynos_OSAL_Event.h" | |
43 | ||
44 | #ifdef USE_ANB | |
45 | #include "Exynos_OSAL_Android.h" | |
46 | #endif | |
47 | ||
48 | /* To use CSC_METHOD_HW in EXYNOS OMX, gralloc should allocate physical memory using FIMC */ | |
49 | /* It means GRALLOC_USAGE_HW_FIMC1 should be set on Native Window usage */ | |
50 | #include "csc.h" | |
51 | ||
52 | #undef EXYNOS_LOG_TAG | |
53 | #define EXYNOS_LOG_TAG "EXYNOS_H264_DEC" | |
54 | #define EXYNOS_LOG_OFF | |
55 | //#define EXYNOS_TRACE_ON | |
56 | #include "Exynos_OSAL_Log.h" | |
57 | ||
58 | #define H264_DEC_NUM_OF_EXTRA_BUFFERS 7 | |
59 | ||
60 | //#define ADD_SPS_PPS_I_FRAME | |
61 | //#define FULL_FRAME_SEARCH | |
62 | ||
63 | /* H.264 Decoder Supported Levels & profiles */ | |
64 | EXYNOS_OMX_VIDEO_PROFILELEVEL supportedAVCProfileLevels[] ={ | |
65 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1}, | |
66 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel1b}, | |
67 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel11}, | |
68 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel12}, | |
69 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel13}, | |
70 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel2}, | |
71 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel21}, | |
72 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel22}, | |
73 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel3}, | |
74 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel31}, | |
75 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel32}, | |
76 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel4}, | |
77 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel41}, | |
78 | {OMX_VIDEO_AVCProfileBaseline, OMX_VIDEO_AVCLevel42}, | |
79 | ||
80 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1}, | |
81 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel1b}, | |
82 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel11}, | |
83 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel12}, | |
84 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel13}, | |
85 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel2}, | |
86 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel21}, | |
87 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel22}, | |
88 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel3}, | |
89 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel31}, | |
90 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel32}, | |
91 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel4}, | |
92 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel41}, | |
93 | {OMX_VIDEO_AVCProfileMain, OMX_VIDEO_AVCLevel42}, | |
94 | ||
95 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1}, | |
96 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel1b}, | |
97 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel11}, | |
98 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel12}, | |
99 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel13}, | |
100 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel2}, | |
101 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel21}, | |
102 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel22}, | |
103 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel3}, | |
104 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel31}, | |
105 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel32}, | |
106 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel4}, | |
107 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel41}, | |
108 | {OMX_VIDEO_AVCProfileHigh, OMX_VIDEO_AVCLevel42}}; | |
109 | ||
110 | static OMX_ERRORTYPE GetCodecInputPrivateData(OMX_PTR codecBuffer, void *pVirtAddr, OMX_U32 *dataSize) | |
111 | { | |
112 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
113 | ||
114 | EXIT: | |
115 | return ret; | |
116 | } | |
117 | ||
118 | static OMX_ERRORTYPE GetCodecOutputPrivateData(OMX_PTR codecBuffer, void *addr[], int size[]) | |
119 | { | |
120 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
121 | ExynosVideoBuffer *pCodecBuffer; | |
122 | ||
123 | if (codecBuffer == NULL) { | |
124 | ret = OMX_ErrorBadParameter; | |
125 | goto EXIT; | |
126 | } | |
127 | ||
128 | pCodecBuffer = (ExynosVideoBuffer *)codecBuffer; | |
129 | ||
130 | if (addr != NULL) { | |
131 | addr[0] = pCodecBuffer->planes[0].addr; | |
132 | addr[1] = pCodecBuffer->planes[1].addr; | |
133 | addr[2] = pCodecBuffer->planes[2].addr; | |
134 | } | |
135 | ||
136 | if (size != NULL) { | |
137 | size[0] = pCodecBuffer->planes[0].allocSize; | |
138 | size[1] = pCodecBuffer->planes[1].allocSize; | |
139 | size[2] = pCodecBuffer->planes[2].allocSize; | |
140 | } | |
141 | ||
142 | EXIT: | |
143 | return ret; | |
144 | } | |
145 | ||
146 | int Check_H264_Frame( | |
147 | OMX_U8 *pInputStream, | |
148 | OMX_U32 buffSize, | |
149 | OMX_U32 flag, | |
150 | OMX_BOOL bPreviousFrameEOF, | |
151 | OMX_BOOL *pbEndOfFrame) | |
152 | { | |
153 | OMX_U32 preFourByte = (OMX_U32)-1; | |
154 | int accessUnitSize = 0; | |
155 | int frameTypeBoundary = 0; | |
156 | int nextNaluSize = 0; | |
157 | int naluStart = 0; | |
158 | ||
159 | if (bPreviousFrameEOF == OMX_TRUE) | |
160 | naluStart = 0; | |
161 | else | |
162 | naluStart = 1; | |
163 | ||
164 | while (1) { | |
165 | int inputOneByte = 0; | |
166 | ||
167 | if (accessUnitSize == (int)buffSize) | |
168 | goto EXIT; | |
169 | ||
170 | inputOneByte = *(pInputStream++); | |
171 | accessUnitSize += 1; | |
172 | ||
173 | if (preFourByte == 0x00000001 || (preFourByte << 8) == 0x00000100) { | |
174 | int naluType = inputOneByte & 0x1F; | |
175 | ||
176 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NaluType : %d", naluType); | |
177 | if (naluStart == 0) { | |
178 | #ifdef ADD_SPS_PPS_I_FRAME | |
179 | if (naluType == 1 || naluType == 5) | |
180 | #else | |
181 | if (naluType == 1 || naluType == 5 || naluType == 7 || naluType == 8) | |
182 | #endif | |
183 | naluStart = 1; | |
184 | } else { | |
185 | #ifdef OLD_DETECT | |
186 | frameTypeBoundary = (8 - naluType) & (naluType - 10); //AUD(9) | |
187 | #else | |
188 | if (naluType == 9) | |
189 | frameTypeBoundary = -2; | |
190 | #endif | |
191 | if (naluType == 1 || naluType == 5) { | |
192 | if (accessUnitSize == (int)buffSize) { | |
193 | accessUnitSize--; | |
194 | goto EXIT; | |
195 | } | |
196 | inputOneByte = *pInputStream++; | |
197 | accessUnitSize += 1; | |
198 | ||
199 | if (inputOneByte >= 0x80) | |
200 | frameTypeBoundary = -1; | |
201 | } | |
202 | if (frameTypeBoundary < 0) { | |
203 | break; | |
204 | } | |
205 | } | |
206 | ||
207 | } | |
208 | preFourByte = (preFourByte << 8) + inputOneByte; | |
209 | } | |
210 | ||
211 | *pbEndOfFrame = OMX_TRUE; | |
212 | nextNaluSize = -5; | |
213 | if (frameTypeBoundary == -1) | |
214 | nextNaluSize = -6; | |
215 | if (preFourByte != 0x00000001) | |
216 | nextNaluSize++; | |
217 | return (accessUnitSize + nextNaluSize); | |
218 | ||
219 | EXIT: | |
220 | *pbEndOfFrame = OMX_FALSE; | |
221 | ||
222 | return accessUnitSize; | |
223 | } | |
224 | ||
225 | static OMX_BOOL Check_H264_StartCode( | |
226 | OMX_U8 *pInputStream, | |
227 | OMX_U32 streamSize) | |
228 | { | |
229 | if (streamSize < 4) { | |
230 | return OMX_FALSE; | |
231 | } | |
232 | ||
233 | if ((pInputStream[0] == 0x00) && | |
234 | (pInputStream[1] == 0x00) && | |
235 | (pInputStream[2] == 0x00) && | |
236 | (pInputStream[3] != 0x00) && | |
237 | ((pInputStream[3] >> 3) == 0x00)) { | |
238 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NaluType : %d, 0x%x, 0x%x, 0x%x", (pInputStream[4] & 0x1F), pInputStream[3], pInputStream[4], pInputStream[5]); | |
239 | return OMX_TRUE; | |
240 | } else if ((pInputStream[0] == 0x00) && | |
241 | (pInputStream[1] == 0x00) && | |
242 | (pInputStream[2] != 0x00) && | |
243 | ((pInputStream[2] >> 3) == 0x00)) { | |
244 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "NaluType : %d, 0x%x, 0x%x, 0x%x", (pInputStream[3] & 0x1F), pInputStream[2], pInputStream[3], pInputStream[4]); | |
245 | return OMX_TRUE; | |
246 | } else { | |
247 | return OMX_FALSE; | |
248 | } | |
249 | } | |
250 | ||
251 | OMX_ERRORTYPE H264CodecOpen(EXYNOS_H264DEC_HANDLE *pH264Dec) | |
252 | { | |
253 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
254 | ExynosVideoDecOps *pDecOps = NULL; | |
255 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
256 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
257 | ||
258 | FunctionIn(); | |
259 | ||
260 | if (pH264Dec == NULL) { | |
261 | ret = OMX_ErrorBadParameter; | |
262 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
263 | goto EXIT; | |
264 | } | |
265 | ||
266 | /* alloc ops structure */ | |
267 | pDecOps = (ExynosVideoDecOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecOps)); | |
268 | pInbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps)); | |
269 | pOutbufOps = (ExynosVideoDecBufferOps *)Exynos_OSAL_Malloc(sizeof(ExynosVideoDecBufferOps)); | |
270 | ||
271 | if ((pDecOps == NULL) || (pInbufOps == NULL) || (pOutbufOps == NULL)) { | |
272 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate decoder ops buffer"); | |
273 | ret = OMX_ErrorInsufficientResources; | |
274 | goto EXIT; | |
275 | } | |
276 | ||
277 | pH264Dec->hMFCH264Handle.pDecOps = pDecOps; | |
278 | pH264Dec->hMFCH264Handle.pInbufOps = pInbufOps; | |
279 | pH264Dec->hMFCH264Handle.pOutbufOps = pOutbufOps; | |
280 | ||
281 | /* function pointer mapping */ | |
282 | pDecOps->nSize = sizeof(ExynosVideoDecOps); | |
283 | pInbufOps->nSize = sizeof(ExynosVideoDecBufferOps); | |
284 | pOutbufOps->nSize = sizeof(ExynosVideoDecBufferOps); | |
285 | ||
286 | Exynos_Video_Register_Decoder(pDecOps, pInbufOps, pOutbufOps); | |
287 | ||
288 | /* check mandatory functions for decoder ops */ | |
289 | if ((pDecOps->Init == NULL) || (pDecOps->Finalize == NULL) || | |
290 | (pDecOps->Get_ActualBufferCount == NULL) || (pDecOps->Set_FrameTag == NULL) || | |
064c4768 SKR |
291 | #ifdef USE_S3D_SUPPORT |
292 | (pDecOps->Enable_SEIParsing == NULL) || (pDecOps->Get_FramePackingInfo == NULL) || | |
293 | #endif | |
c6f4bc34 YK |
294 | (pDecOps->Get_FrameTag == NULL)) { |
295 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied"); | |
296 | ret = OMX_ErrorInsufficientResources; | |
297 | goto EXIT; | |
298 | } | |
299 | ||
300 | /* check mandatory functions for buffer ops */ | |
301 | if ((pInbufOps->Setup == NULL) || (pOutbufOps->Setup == NULL) || | |
302 | (pInbufOps->Run == NULL) || (pOutbufOps->Run == NULL) || | |
303 | (pInbufOps->Stop == NULL) || (pOutbufOps->Stop == NULL) || | |
304 | (pInbufOps->Enqueue == NULL) || (pOutbufOps->Enqueue == NULL) || | |
305 | (pInbufOps->Dequeue == NULL) || (pOutbufOps->Dequeue == NULL)) { | |
306 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Mandatory functions must be supplied"); | |
307 | ret = OMX_ErrorInsufficientResources; | |
308 | goto EXIT; | |
309 | } | |
310 | ||
311 | /* alloc context, open, querycap */ | |
312 | pH264Dec->hMFCH264Handle.hMFCHandle = pH264Dec->hMFCH264Handle.pDecOps->Init(V4L2_MEMORY_DMABUF); | |
313 | if (pH264Dec->hMFCH264Handle.hMFCHandle == NULL) { | |
314 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to allocate context buffer"); | |
315 | ret = OMX_ErrorInsufficientResources; | |
316 | goto EXIT; | |
317 | } | |
318 | ||
064c4768 SKR |
319 | #ifdef USE_S3D_SUPPORT |
320 | /* S3D: Enable SEI parsing to check Frame Packing */ | |
321 | if (pDecOps->Enable_SEIParsing(pH264Dec->hMFCH264Handle.hMFCHandle) != VIDEO_ERROR_NONE) { | |
322 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Enable SEI Parsing"); | |
323 | ret = OMX_ErrorInsufficientResources; | |
324 | goto EXIT; | |
325 | } | |
326 | #endif | |
327 | ||
c6f4bc34 YK |
328 | ret = OMX_ErrorNone; |
329 | ||
330 | EXIT: | |
331 | if (ret != OMX_ErrorNone) { | |
332 | if (pDecOps != NULL) { | |
333 | Exynos_OSAL_Free(pDecOps); | |
334 | pH264Dec->hMFCH264Handle.pDecOps = NULL; | |
335 | } | |
336 | if (pInbufOps != NULL) { | |
337 | Exynos_OSAL_Free(pInbufOps); | |
338 | pH264Dec->hMFCH264Handle.pInbufOps = NULL; | |
339 | } | |
340 | if (pOutbufOps != NULL) { | |
341 | Exynos_OSAL_Free(pOutbufOps); | |
342 | pH264Dec->hMFCH264Handle.pOutbufOps = NULL; | |
343 | } | |
344 | } | |
345 | ||
346 | FunctionOut(); | |
347 | ||
348 | return ret; | |
349 | } | |
350 | ||
351 | OMX_ERRORTYPE H264CodecClose(EXYNOS_H264DEC_HANDLE *pH264Dec) | |
352 | { | |
e4e150b8 | 353 | OMX_ERRORTYPE ret = OMX_ErrorNone; |
c6f4bc34 YK |
354 | void *hMFCHandle = NULL; |
355 | ExynosVideoDecOps *pDecOps = NULL; | |
356 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
357 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
358 | ||
359 | FunctionIn(); | |
360 | ||
361 | if (pH264Dec == NULL) { | |
362 | ret = OMX_ErrorBadParameter; | |
363 | goto EXIT; | |
364 | } | |
365 | ||
366 | hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
367 | pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
368 | pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
369 | pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
370 | ||
371 | if (hMFCHandle != NULL) { | |
372 | pDecOps->Finalize(hMFCHandle); | |
373 | pH264Dec->hMFCH264Handle.hMFCHandle = NULL; | |
374 | } | |
375 | if (pOutbufOps != NULL) { | |
376 | Exynos_OSAL_Free(pOutbufOps); | |
377 | pH264Dec->hMFCH264Handle.pOutbufOps = NULL; | |
378 | } | |
379 | if (pInbufOps != NULL) { | |
380 | Exynos_OSAL_Free(pInbufOps); | |
381 | pH264Dec->hMFCH264Handle.pInbufOps = NULL; | |
382 | } | |
383 | if (pDecOps != NULL) { | |
384 | Exynos_OSAL_Free(pDecOps); | |
385 | pH264Dec->hMFCH264Handle.pDecOps = NULL; | |
386 | } | |
387 | ||
388 | ret = OMX_ErrorNone; | |
389 | ||
390 | EXIT: | |
391 | FunctionOut(); | |
392 | ||
393 | return ret; | |
394 | } | |
395 | ||
396 | OMX_ERRORTYPE H264CodecStart(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
397 | { | |
398 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
399 | void *hMFCHandle = NULL; | |
400 | ExynosVideoDecOps *pDecOps = NULL; | |
401 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
402 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
403 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
404 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
405 | ||
406 | FunctionIn(); | |
407 | ||
408 | if (pOMXComponent == NULL) { | |
409 | ret = OMX_ErrorBadParameter; | |
410 | goto EXIT; | |
411 | } | |
412 | ||
413 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
414 | if (pVideoDec == NULL) { | |
415 | ret = OMX_ErrorBadParameter; | |
416 | goto EXIT; | |
417 | } | |
418 | ||
419 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle; | |
420 | if (pH264Dec == NULL) { | |
421 | ret = OMX_ErrorBadParameter; | |
422 | goto EXIT; | |
423 | } | |
424 | ||
425 | hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
426 | pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
427 | pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
428 | pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
429 | ||
430 | if (nPortIndex == INPUT_PORT_INDEX) | |
431 | pInbufOps->Run(hMFCHandle); | |
432 | else if (nPortIndex == OUTPUT_PORT_INDEX) | |
433 | pOutbufOps->Run(hMFCHandle); | |
434 | ||
435 | ret = OMX_ErrorNone; | |
436 | ||
437 | EXIT: | |
438 | FunctionOut(); | |
439 | ||
440 | return ret; | |
441 | } | |
442 | ||
443 | OMX_ERRORTYPE H264CodecStop(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
444 | { | |
445 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
446 | void *hMFCHandle = NULL; | |
447 | ExynosVideoDecOps *pDecOps = NULL; | |
448 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
449 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
450 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
451 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
452 | ||
453 | FunctionIn(); | |
454 | ||
455 | if (pOMXComponent == NULL) { | |
456 | ret = OMX_ErrorBadParameter; | |
457 | goto EXIT; | |
458 | } | |
459 | ||
460 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
461 | if (pVideoDec == NULL) { | |
462 | ret = OMX_ErrorBadParameter; | |
463 | goto EXIT; | |
464 | } | |
465 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle; | |
466 | if (pH264Dec == NULL) { | |
467 | ret = OMX_ErrorBadParameter; | |
468 | goto EXIT; | |
469 | } | |
470 | ||
471 | hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
472 | pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
473 | pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
474 | pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
475 | ||
476 | if ((nPortIndex == INPUT_PORT_INDEX) && (pInbufOps != NULL)) | |
477 | pInbufOps->Stop(hMFCHandle); | |
478 | else if ((nPortIndex == OUTPUT_PORT_INDEX) && (pOutbufOps != NULL)) | |
479 | pOutbufOps->Stop(hMFCHandle); | |
480 | ||
481 | ret = OMX_ErrorNone; | |
482 | ||
483 | EXIT: | |
484 | FunctionOut(); | |
485 | ||
486 | return ret; | |
487 | } | |
488 | ||
489 | OMX_ERRORTYPE H264CodecOutputBufferProcessRun(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
490 | { | |
491 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
492 | void *hMFCHandle = NULL; | |
493 | ExynosVideoDecOps *pDecOps = NULL; | |
494 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
495 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
496 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
497 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
498 | ||
499 | FunctionIn(); | |
500 | ||
501 | if (pOMXComponent == NULL) { | |
502 | ret = OMX_ErrorBadParameter; | |
503 | goto EXIT; | |
504 | } | |
505 | ||
506 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)((EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate)->hComponentHandle; | |
507 | if (pVideoDec == NULL) { | |
508 | ret = OMX_ErrorBadParameter; | |
509 | goto EXIT; | |
510 | } | |
511 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle; | |
512 | if (pH264Dec == NULL) { | |
513 | ret = OMX_ErrorBadParameter; | |
514 | goto EXIT; | |
515 | } | |
516 | ||
517 | hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
518 | pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
519 | pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
520 | pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
521 | ||
522 | if (nPortIndex == INPUT_PORT_INDEX) { | |
523 | if (pH264Dec->bSourceStart == OMX_FALSE) { | |
524 | Exynos_OSAL_SignalSet(pH264Dec->hSourceStartEvent); | |
525 | Exynos_OSAL_SleepMillisec(0); | |
526 | } | |
527 | } | |
528 | ||
529 | if (nPortIndex == OUTPUT_PORT_INDEX) { | |
530 | if (pH264Dec->bDestinationStart == OMX_FALSE) { | |
531 | Exynos_OSAL_SignalSet(pH264Dec->hDestinationStartEvent); | |
532 | Exynos_OSAL_SleepMillisec(0); | |
533 | } | |
534 | } | |
535 | ||
536 | ret = OMX_ErrorNone; | |
537 | ||
538 | EXIT: | |
539 | FunctionOut(); | |
540 | ||
541 | return ret; | |
542 | } | |
543 | ||
544 | OMX_ERRORTYPE H264CodecEnQueueAllBuffer(OMX_COMPONENTTYPE *pOMXComponent, OMX_U32 nPortIndex) | |
545 | { | |
546 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
547 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
548 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
549 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
550 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
551 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
552 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
553 | int i, nOutbufs; | |
554 | ||
555 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
556 | ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
557 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
558 | ||
559 | FunctionIn(); | |
560 | ||
561 | if ((nPortIndex == INPUT_PORT_INDEX) && | |
562 | (pH264Dec->bSourceStart == OMX_TRUE)) { | |
563 | Exynos_CodecBufferReset(pExynosComponent, INPUT_PORT_INDEX); | |
564 | ||
565 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
566 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]); | |
567 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[0]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]); | |
568 | ||
569 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]); | |
570 | } | |
571 | ||
572 | pInbufOps->Clear_Queue(hMFCHandle); | |
573 | } else if ((nPortIndex == OUTPUT_PORT_INDEX) && | |
574 | (pH264Dec->bDestinationStart == OMX_TRUE)) { | |
575 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; | |
576 | ExynosVideoBuffer *pBuffer = NULL; | |
577 | ||
578 | Exynos_CodecBufferReset(pExynosComponent, OUTPUT_PORT_INDEX); | |
579 | ||
580 | nOutbufs = pDecOps->Get_ActualBufferCount(hMFCHandle); | |
581 | nOutbufs += EXTRA_DPB_NUM; | |
582 | for (i = 0; i < nOutbufs; i++) { | |
583 | pOutbufOps->Get_Buffer(hMFCHandle, i, &pBuffer); | |
584 | Exynos_CodecBufferEnQueue(pExynosComponent, OUTPUT_PORT_INDEX, (OMX_PTR)pBuffer); | |
585 | } | |
586 | pOutbufOps->Clear_Queue(hMFCHandle); | |
587 | } else { | |
588 | ret = OMX_ErrorBadParameter; | |
589 | goto EXIT; | |
590 | } | |
591 | ||
592 | EXIT: | |
593 | FunctionOut(); | |
594 | ||
595 | return ret; | |
596 | } | |
597 | ||
064c4768 SKR |
598 | #ifdef USE_S3D_SUPPORT |
599 | OMX_BOOL H264CodecCheckFramePacking(OMX_COMPONENTTYPE *pOMXComponent) | |
600 | { | |
601 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
602 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
603 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
604 | ExynosVideoFramePacking framePacking; | |
605 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
606 | OMX_BOOL ret = OMX_FALSE; | |
607 | ||
608 | /* Get Frame packing information*/ | |
609 | if (pDecOps->Get_FramePackingInfo(pH264Dec->hMFCH264Handle.hMFCHandle, &framePacking) != VIDEO_ERROR_NONE) { | |
610 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Get Frame Packing Information"); | |
611 | ret = OMX_FALSE; | |
612 | goto EXIT; | |
613 | } | |
614 | ||
615 | if (framePacking.available) { | |
616 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "arrangement ID: 0x%08x", framePacking.arrangement_id); | |
617 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "arrangement_type: %d", framePacking.arrangement_type); | |
618 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "content_interpretation_type: %d", framePacking.content_interpretation_type); | |
619 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "current_frame_is_frame0_flag: %d", framePacking.current_frame_is_frame0_flag); | |
620 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "spatial_flipping_flag: %d", framePacking.spatial_flipping_flag); | |
621 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "fr0X:%d fr0Y:%d fr0X:%d fr0Y:%d", framePacking.frame0_grid_pos_x, | |
622 | framePacking.frame0_grid_pos_y, framePacking.frame1_grid_pos_x, framePacking.frame1_grid_pos_y); | |
623 | ||
624 | pH264Dec->hMFCH264Handle.S3DFPArgmtType = (EXYNOS_OMX_FPARGMT_TYPE) framePacking.arrangement_type; | |
625 | /** Send Port Settings changed call back - output color format change */ | |
626 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
627 | (pOMXComponent, | |
628 | pExynosComponent->callbackData, | |
629 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
630 | OMX_DirOutput, /* This is the port index */ | |
631 | 0, | |
632 | NULL); | |
633 | ||
634 | Exynos_OSAL_SleepMillisec(0); | |
635 | ret = OMX_TRUE; | |
636 | } | |
637 | ||
638 | EXIT: | |
639 | return ret; | |
640 | } | |
641 | #endif | |
642 | ||
c6f4bc34 YK |
643 | OMX_ERRORTYPE H264CodecSrcSetup(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) |
644 | { | |
645 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
646 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
647 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
648 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
649 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
650 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
651 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
e4e150b8 | 652 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; |
c6f4bc34 YK |
653 | |
654 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
655 | ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
656 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
657 | ExynosVideoGeometry bufferConf; | |
658 | OMX_U32 inputBufferNumber = 0; | |
659 | int i; | |
660 | ||
661 | FunctionIn(); | |
662 | ||
663 | if ((oneFrameSize <= 0) && (pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS)) { | |
664 | OMX_BUFFERHEADERTYPE *OMXBuffer = NULL; | |
665 | OMXBuffer = Exynos_OutputBufferGetQueue_Direct(pExynosComponent); | |
666 | if (OMXBuffer == NULL) { | |
667 | ret = OMX_ErrorUndefined; | |
668 | goto EXIT; | |
669 | } | |
670 | ||
671 | OMXBuffer->nTimeStamp = pSrcInputData->timeStamp; | |
672 | OMXBuffer->nFlags = pSrcInputData->nFlags; | |
673 | Exynos_OMX_OutputBufferReturn(pOMXComponent, OMXBuffer); | |
674 | ||
675 | ret = OMX_ErrorNone; | |
676 | goto EXIT; | |
677 | } | |
678 | ||
679 | if (pVideoDec->bThumbnailMode == OMX_TRUE) | |
680 | pDecOps->Set_DisplayDelay(hMFCHandle, 0); | |
681 | ||
682 | /* input buffer info */ | |
683 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
684 | bufferConf.eCompressionFormat = VIDEO_CODING_AVC; | |
685 | pInbufOps->Set_Shareable(hMFCHandle); | |
24ec2c82 | 686 | if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
687 | bufferConf.nSizeImage = pExynosInputPort->portDefinition.format.video.nFrameWidth |
688 | * pExynosInputPort->portDefinition.format.video.nFrameHeight * 3 / 2; | |
689 | inputBufferNumber = MAX_VIDEO_INPUTBUFFER_NUM; | |
24ec2c82 | 690 | } else if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
691 | bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE; |
692 | inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX; | |
693 | } | |
694 | ||
695 | /* should be done before prepare input buffer */ | |
696 | if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
697 | ret = OMX_ErrorInsufficientResources; | |
698 | goto EXIT; | |
699 | } | |
700 | ||
701 | /* set input buffer geometry */ | |
702 | if (pInbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
703 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer"); | |
704 | ret = OMX_ErrorInsufficientResources; | |
705 | goto EXIT; | |
706 | } | |
707 | ||
708 | /* setup input buffer */ | |
709 | if (pInbufOps->Setup(hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) { | |
710 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer"); | |
711 | ret = OMX_ErrorInsufficientResources; | |
712 | goto EXIT; | |
713 | } | |
714 | ||
24ec2c82 | 715 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
716 | /* Register input buffer */ |
717 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
718 | ExynosVideoPlane plane; | |
719 | plane.addr = pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]; | |
720 | plane.allocSize = pVideoDec->pMFCDecInputBuffer[i]->bufferSize[0]; | |
721 | plane.fd = pVideoDec->pMFCDecInputBuffer[i]->fd[0]; | |
722 | if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
723 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); | |
724 | ret = OMX_ErrorInsufficientResources; | |
725 | goto EXIT; | |
726 | } | |
727 | } | |
24ec2c82 | 728 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
729 | /* Register input buffer */ |
730 | for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) { | |
731 | ExynosVideoPlane plane; | |
e4e150b8 HK |
732 | if (pVideoDec->bDRMPlayerMode == OMX_TRUE) { |
733 | plane.addr = Exynos_OSAL_SharedMemory_IONToVirt(pVideoDec->hSharedMemory, pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer); | |
c6f4bc34 | 734 | } else { |
e4e150b8 | 735 | plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; |
c6f4bc34 YK |
736 | } |
737 | plane.allocSize = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->nAllocLen; | |
738 | plane.fd = pExynosInputPort->extendBufferHeader[i].buf_fd[0]; | |
739 | if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
740 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); | |
741 | ret = OMX_ErrorInsufficientResources; | |
742 | goto EXIT; | |
743 | } | |
744 | } | |
745 | } | |
746 | ||
747 | /* set output geometry */ | |
748 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
749 | pH264Dec->hMFCH264Handle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12_TILED; | |
750 | if (pOutbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
751 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer"); | |
752 | ret = OMX_ErrorInsufficientResources; | |
753 | goto EXIT; | |
754 | } | |
755 | ||
756 | /* input buffer enqueue for header parsing */ | |
757 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d", oneFrameSize); | |
758 | if (pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, | |
759 | (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader) != VIDEO_ERROR_NONE) { | |
760 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer for header parsing"); | |
761 | // ret = OMX_ErrorInsufficientResources; | |
762 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecInit; | |
763 | goto EXIT; | |
764 | } | |
765 | ||
766 | /* start header parsing */ | |
767 | if (pInbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
768 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run input buffer for header parsing"); | |
769 | ret = OMX_ErrorCodecInit; | |
770 | goto EXIT; | |
771 | } | |
772 | ||
773 | /* get geometry for output */ | |
774 | Exynos_OSAL_Memset(&pH264Dec->hMFCH264Handle.codecOutbufConf, 0, sizeof(ExynosVideoGeometry)); | |
775 | if (pOutbufOps->Get_Geometry(hMFCHandle, &pH264Dec->hMFCH264Handle.codecOutbufConf) != VIDEO_ERROR_NONE) { | |
776 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get geometry for parsed header info"); | |
777 | ret = OMX_ErrorInsufficientResources; | |
778 | goto EXIT; | |
779 | } | |
780 | ||
781 | /* get dpb count */ | |
782 | pH264Dec->hMFCH264Handle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle); | |
783 | if (pVideoDec->bThumbnailMode == OMX_FALSE) | |
784 | pH264Dec->hMFCH264Handle.maxDPBNum += EXTRA_DPB_NUM; | |
785 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "H264CodecSetup nOutbufs: %d", pH264Dec->hMFCH264Handle.maxDPBNum); | |
786 | ||
787 | pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_TRUE; | |
788 | ||
789 | pExynosOutputPort->cropRectangle.nTop = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nTop; | |
790 | pExynosOutputPort->cropRectangle.nLeft = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nLeft; | |
791 | pExynosOutputPort->cropRectangle.nWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth; | |
792 | pExynosOutputPort->cropRectangle.nHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight; | |
793 | ||
24ec2c82 | 794 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
795 | if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) || |
796 | (pExynosInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight)) { | |
797 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth; | |
798 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight; | |
799 | pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
800 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
801 | ||
802 | Exynos_UpdateFrameSize(pOMXComponent); | |
803 | pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE; | |
804 | ||
805 | /** Send Port Settings changed call back **/ | |
806 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
807 | (pOMXComponent, | |
808 | pExynosComponent->callbackData, | |
809 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
810 | OMX_DirOutput, /* This is the port index */ | |
811 | 0, | |
812 | NULL); | |
813 | } | |
24ec2c82 | 814 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
815 | if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth) || |
816 | (pExynosInputPort->portDefinition.format.video.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight) || | |
817 | (pExynosOutputPort->portDefinition.nBufferCountActual != pH264Dec->hMFCH264Handle.maxDPBNum)) { | |
818 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth; | |
819 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight; | |
820 | pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
821 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
822 | ||
823 | pExynosOutputPort->portDefinition.nBufferCountActual = pH264Dec->hMFCH264Handle.maxDPBNum - 2; | |
824 | pExynosOutputPort->portDefinition.nBufferCountMin = pH264Dec->hMFCH264Handle.maxDPBNum - 2; | |
825 | ||
826 | Exynos_UpdateFrameSize(pOMXComponent); | |
827 | pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE; | |
828 | ||
829 | /** Send Port Settings changed call back **/ | |
830 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
831 | (pOMXComponent, | |
832 | pExynosComponent->callbackData, | |
833 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
834 | OMX_DirOutput, /* This is the port index */ | |
835 | 0, | |
836 | NULL); | |
837 | } | |
838 | } | |
839 | if ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth != pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nWidth) || | |
840 | (pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight != pH264Dec->hMFCH264Handle.codecOutbufConf.cropRect.nHeight)) { | |
841 | /* Check Crop */ | |
842 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth; | |
843 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight; | |
844 | pExynosInputPort->portDefinition.format.video.nStride = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
845 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
846 | Exynos_UpdateFrameSize(pOMXComponent); | |
847 | ||
848 | /** Send crop info call back **/ | |
849 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
850 | (pOMXComponent, | |
851 | pExynosComponent->callbackData, | |
852 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
853 | OMX_DirOutput, /* This is the port index */ | |
854 | OMX_IndexConfigCommonOutputCrop, | |
855 | NULL); | |
856 | } | |
857 | ||
858 | Exynos_OSAL_SleepMillisec(0); | |
859 | ret = OMX_ErrorInputDataDecodeYet; | |
860 | H264CodecStop(pOMXComponent, INPUT_PORT_INDEX); | |
861 | ||
862 | EXIT: | |
863 | FunctionOut(); | |
864 | ||
865 | return ret; | |
866 | } | |
867 | ||
868 | OMX_ERRORTYPE H264CodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) | |
869 | { | |
870 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
871 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
872 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
873 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
874 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
875 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
876 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
877 | ||
878 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
879 | ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
880 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
881 | ||
882 | int i, nOutbufs; | |
883 | ||
884 | FunctionIn(); | |
885 | ||
886 | /* get dpb count */ | |
887 | nOutbufs = pH264Dec->hMFCH264Handle.maxDPBNum; | |
888 | ||
24ec2c82 | 889 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
890 | /* should be done before prepare output buffer */ |
891 | if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
892 | ret = OMX_ErrorInsufficientResources; | |
893 | goto EXIT; | |
894 | } | |
895 | } | |
896 | ||
897 | pOutbufOps->Set_Shareable(hMFCHandle); | |
898 | if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) { | |
899 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer"); | |
900 | ret = OMX_ErrorInsufficientResources; | |
901 | goto EXIT; | |
902 | } | |
903 | ||
904 | ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE]; | |
905 | OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; | |
906 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; | |
907 | int plane; | |
908 | ||
909 | nAllocLen[0] = calc_plane(pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth, | |
910 | pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight); | |
911 | nAllocLen[1] = calc_plane(pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameWidth, | |
912 | pH264Dec->hMFCH264Handle.codecOutbufConf.nFrameHeight >> 1); | |
913 | ||
24ec2c82 | 914 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
915 | MEMORY_TYPE memoryType; |
916 | if (pVideoDec->bDRMPlayerMode == OMX_TRUE) | |
917 | memoryType = SECURE_MEMORY; | |
918 | else | |
919 | memoryType = NORMAL_MEMORY; | |
920 | ||
921 | /* Register output buffer */ | |
922 | for (i = 0; i < nOutbufs; i++) { | |
923 | pVideoDec->pMFCDecOutputBuffer[i] = (CODEC_DEC_BUFFER *)Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER)); | |
924 | Exynos_OSAL_Memset(pVideoDec->pMFCDecOutputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER)); | |
925 | ||
926 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
927 | pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] = | |
928 | (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, nAllocLen[plane], memoryType); | |
929 | if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] == NULL) { | |
930 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Alloc output buffer"); | |
931 | ret = OMX_ErrorInsufficientResources; | |
932 | goto EXIT; | |
933 | } | |
934 | pVideoDec->pMFCDecOutputBuffer[i]->fd[plane] = | |
935 | Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, | |
936 | pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]); | |
937 | pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane] = nAllocLen[plane]; | |
938 | ||
939 | planes[plane].addr = pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]; | |
940 | planes[plane].fd = pVideoDec->pMFCDecOutputBuffer[i]->fd[plane]; | |
941 | planes[plane].allocSize = pVideoDec->pMFCDecOutputBuffer[i]->bufferSize[plane]; | |
942 | } | |
943 | ||
944 | if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
945 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer"); | |
946 | ret = OMX_ErrorInsufficientResources; | |
947 | goto EXIT; | |
948 | } | |
949 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr, | |
950 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
951 | } | |
24ec2c82 | 952 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
953 | /* Register output buffer */ |
954 | /*************/ | |
955 | /* TBD */ | |
956 | /*************/ | |
957 | #ifdef USE_ANB | |
958 | if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) { | |
959 | for (i = 0; i < pExynosOutputPort->assignedBufferNum; i++) { | |
960 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
961 | planes[plane].fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[plane]; | |
962 | planes[plane].addr = pExynosOutputPort->extendBufferHeader[i].pYUVBuf[plane]; | |
963 | planes[plane].allocSize = nAllocLen[plane]; | |
964 | } | |
965 | ||
966 | if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
967 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer"); | |
968 | ret = OMX_ErrorInsufficientResources; | |
969 | goto EXIT; | |
970 | } | |
971 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pExynosOutputPort->extendBufferHeader[i].pYUVBuf, | |
972 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
973 | } | |
974 | } else { | |
975 | ret = OMX_ErrorNotImplemented; | |
976 | goto EXIT; | |
977 | } | |
978 | #else | |
979 | ret = OMX_ErrorNotImplemented; | |
980 | goto EXIT; | |
981 | #endif | |
982 | } | |
983 | ||
984 | if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
985 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer"); | |
986 | ret = OMX_ErrorInsufficientResources; | |
987 | goto EXIT; | |
988 | } | |
989 | ||
24ec2c82 | 990 | if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
991 | H264CodecStop(pOMXComponent, OUTPUT_PORT_INDEX); |
992 | } | |
993 | pH264Dec->hMFCH264Handle.bConfiguredMFCDst = OMX_TRUE; | |
994 | ||
995 | ret = OMX_ErrorNone; | |
996 | ||
997 | EXIT: | |
998 | FunctionOut(); | |
999 | ||
1000 | return ret; | |
1001 | } | |
1002 | ||
1003 | OMX_ERRORTYPE Exynos_H264Dec_GetParameter( | |
1004 | OMX_IN OMX_HANDLETYPE hComponent, | |
1005 | OMX_IN OMX_INDEXTYPE nParamIndex, | |
1006 | OMX_INOUT OMX_PTR pComponentParameterStructure) | |
1007 | { | |
1008 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1009 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1010 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1011 | ||
1012 | FunctionIn(); | |
1013 | ||
1014 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1015 | ret = OMX_ErrorBadParameter; | |
1016 | goto EXIT; | |
1017 | } | |
1018 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1019 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1020 | if (ret != OMX_ErrorNone) { | |
1021 | goto EXIT; | |
1022 | } | |
1023 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1024 | ret = OMX_ErrorBadParameter; | |
1025 | goto EXIT; | |
1026 | } | |
1027 | ||
1028 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1029 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1030 | ret = OMX_ErrorInvalidState; | |
1031 | goto EXIT; | |
1032 | } | |
1033 | ||
1034 | switch (nParamIndex) { | |
1035 | case OMX_IndexParamVideoAvc: | |
1036 | { | |
1037 | OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; | |
1038 | OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; | |
1039 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1040 | ||
1041 | ret = Exynos_OMX_Check_SizeVersion(pDstAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1042 | if (ret != OMX_ErrorNone) { | |
1043 | goto EXIT; | |
1044 | } | |
1045 | ||
1046 | if (pDstAVCComponent->nPortIndex >= ALL_PORT_NUM) { | |
1047 | ret = OMX_ErrorBadPortIndex; | |
1048 | goto EXIT; | |
1049 | } | |
1050 | ||
1051 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1052 | pSrcAVCComponent = &pH264Dec->AVCComponent[pDstAVCComponent->nPortIndex]; | |
1053 | ||
1054 | Exynos_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1055 | } | |
1056 | break; | |
1057 | case OMX_IndexParamStandardComponentRole: | |
1058 | { | |
1059 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; | |
1060 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1061 | if (ret != OMX_ErrorNone) { | |
1062 | goto EXIT; | |
1063 | } | |
1064 | ||
1065 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H264_DEC_ROLE); | |
1066 | } | |
1067 | break; | |
1068 | case OMX_IndexParamVideoProfileLevelQuerySupported: | |
1069 | { | |
1070 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; | |
1071 | EXYNOS_OMX_VIDEO_PROFILELEVEL *pProfileLevel = NULL; | |
1072 | OMX_U32 maxProfileLevelNum = 0; | |
1073 | ||
1074 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1075 | if (ret != OMX_ErrorNone) { | |
1076 | goto EXIT; | |
1077 | } | |
1078 | ||
1079 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1080 | ret = OMX_ErrorBadPortIndex; | |
1081 | goto EXIT; | |
1082 | } | |
1083 | ||
1084 | pProfileLevel = supportedAVCProfileLevels; | |
1085 | maxProfileLevelNum = sizeof(supportedAVCProfileLevels) / sizeof(EXYNOS_OMX_VIDEO_PROFILELEVEL); | |
1086 | ||
1087 | if (pDstProfileLevel->nProfileIndex >= maxProfileLevelNum) { | |
1088 | ret = OMX_ErrorNoMore; | |
1089 | goto EXIT; | |
1090 | } | |
1091 | ||
1092 | pProfileLevel += pDstProfileLevel->nProfileIndex; | |
1093 | pDstProfileLevel->eProfile = pProfileLevel->profile; | |
1094 | pDstProfileLevel->eLevel = pProfileLevel->level; | |
1095 | } | |
1096 | break; | |
1097 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1098 | { | |
1099 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pDstProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE*)pComponentParameterStructure; | |
1100 | OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = NULL; | |
1101 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1102 | ||
1103 | ret = Exynos_OMX_Check_SizeVersion(pDstProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1104 | if (ret != OMX_ErrorNone) { | |
1105 | goto EXIT; | |
1106 | } | |
1107 | ||
1108 | if (pDstProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1109 | ret = OMX_ErrorBadPortIndex; | |
1110 | goto EXIT; | |
1111 | } | |
1112 | ||
1113 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1114 | pSrcAVCComponent = &pH264Dec->AVCComponent[pDstProfileLevel->nPortIndex]; | |
1115 | ||
1116 | pDstProfileLevel->eProfile = pSrcAVCComponent->eProfile; | |
1117 | pDstProfileLevel->eLevel = pSrcAVCComponent->eLevel; | |
1118 | } | |
1119 | break; | |
1120 | case OMX_IndexParamVideoErrorCorrection: | |
1121 | { | |
1122 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1123 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; | |
1124 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1125 | ||
1126 | ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1127 | if (ret != OMX_ErrorNone) { | |
1128 | goto EXIT; | |
1129 | } | |
1130 | ||
1131 | if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { | |
1132 | ret = OMX_ErrorBadPortIndex; | |
1133 | goto EXIT; | |
1134 | } | |
1135 | ||
1136 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1137 | pSrcErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX]; | |
1138 | ||
1139 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1140 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1141 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1142 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1143 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1144 | } | |
1145 | break; | |
1146 | default: | |
1147 | ret = Exynos_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); | |
1148 | break; | |
1149 | } | |
1150 | EXIT: | |
1151 | FunctionOut(); | |
1152 | ||
1153 | return ret; | |
1154 | } | |
1155 | ||
1156 | OMX_ERRORTYPE Exynos_H264Dec_SetParameter( | |
1157 | OMX_IN OMX_HANDLETYPE hComponent, | |
1158 | OMX_IN OMX_INDEXTYPE nIndex, | |
1159 | OMX_IN OMX_PTR pComponentParameterStructure) | |
1160 | { | |
1161 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1162 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1163 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1164 | ||
1165 | FunctionIn(); | |
1166 | ||
1167 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1168 | ret = OMX_ErrorBadParameter; | |
1169 | goto EXIT; | |
1170 | } | |
1171 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1172 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1173 | if (ret != OMX_ErrorNone) { | |
1174 | goto EXIT; | |
1175 | } | |
1176 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1177 | ret = OMX_ErrorBadParameter; | |
1178 | goto EXIT; | |
1179 | } | |
1180 | ||
1181 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1182 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1183 | ret = OMX_ErrorInvalidState; | |
1184 | goto EXIT; | |
1185 | } | |
1186 | ||
1187 | switch (nIndex) { | |
1188 | case OMX_IndexParamVideoAvc: | |
1189 | { | |
1190 | OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; | |
1191 | OMX_VIDEO_PARAM_AVCTYPE *pSrcAVCComponent = (OMX_VIDEO_PARAM_AVCTYPE *)pComponentParameterStructure; | |
1192 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1193 | ||
1194 | ret = Exynos_OMX_Check_SizeVersion(pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1195 | if (ret != OMX_ErrorNone) { | |
1196 | goto EXIT; | |
1197 | } | |
1198 | ||
1199 | if (pSrcAVCComponent->nPortIndex >= ALL_PORT_NUM) { | |
1200 | ret = OMX_ErrorBadPortIndex; | |
1201 | goto EXIT; | |
1202 | } | |
1203 | ||
1204 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1205 | pDstAVCComponent = &pH264Dec->AVCComponent[pSrcAVCComponent->nPortIndex]; | |
1206 | ||
1207 | Exynos_OSAL_Memcpy(pDstAVCComponent, pSrcAVCComponent, sizeof(OMX_VIDEO_PARAM_AVCTYPE)); | |
1208 | } | |
1209 | break; | |
1210 | case OMX_IndexParamStandardComponentRole: | |
1211 | { | |
1212 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; | |
1213 | ||
1214 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1215 | if (ret != OMX_ErrorNone) { | |
1216 | goto EXIT; | |
1217 | } | |
1218 | ||
1219 | if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
1220 | ret = OMX_ErrorIncorrectStateOperation; | |
1221 | goto EXIT; | |
1222 | } | |
1223 | ||
1224 | if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_H264_DEC_ROLE)) { | |
1225 | pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; | |
1226 | } else { | |
1227 | ret = OMX_ErrorBadParameter; | |
1228 | goto EXIT; | |
1229 | } | |
1230 | } | |
1231 | break; | |
1232 | case OMX_IndexParamVideoProfileLevelCurrent: | |
1233 | { | |
1234 | OMX_VIDEO_PARAM_PROFILELEVELTYPE *pSrcProfileLevel = (OMX_VIDEO_PARAM_PROFILELEVELTYPE *)pComponentParameterStructure; | |
1235 | OMX_VIDEO_PARAM_AVCTYPE *pDstAVCComponent = NULL; | |
1236 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1237 | ||
1238 | ret = Exynos_OMX_Check_SizeVersion(pSrcProfileLevel, sizeof(OMX_VIDEO_PARAM_PROFILELEVELTYPE)); | |
1239 | if (ret != OMX_ErrorNone) | |
1240 | goto EXIT; | |
1241 | ||
1242 | if (pSrcProfileLevel->nPortIndex >= ALL_PORT_NUM) { | |
1243 | ret = OMX_ErrorBadPortIndex; | |
1244 | goto EXIT; | |
1245 | } | |
1246 | ||
1247 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1248 | ||
1249 | pDstAVCComponent = &pH264Dec->AVCComponent[pSrcProfileLevel->nPortIndex]; | |
1250 | pDstAVCComponent->eProfile = pSrcProfileLevel->eProfile; | |
1251 | pDstAVCComponent->eLevel = pSrcProfileLevel->eLevel; | |
1252 | } | |
1253 | break; | |
1254 | case OMX_IndexParamVideoErrorCorrection: | |
1255 | { | |
1256 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1257 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; | |
1258 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1259 | ||
1260 | ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1261 | if (ret != OMX_ErrorNone) { | |
1262 | goto EXIT; | |
1263 | } | |
1264 | ||
1265 | if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { | |
1266 | ret = OMX_ErrorBadPortIndex; | |
1267 | goto EXIT; | |
1268 | } | |
1269 | ||
1270 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1271 | pDstErrorCorrectionType = &pH264Dec->errorCorrectionType[INPUT_PORT_INDEX]; | |
1272 | ||
1273 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1274 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1275 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1276 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1277 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1278 | } | |
1279 | break; | |
1280 | default: | |
1281 | ret = Exynos_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); | |
1282 | break; | |
1283 | } | |
1284 | EXIT: | |
1285 | FunctionOut(); | |
1286 | ||
1287 | return ret; | |
1288 | } | |
1289 | ||
1290 | OMX_ERRORTYPE Exynos_H264Dec_GetConfig( | |
1291 | OMX_HANDLETYPE hComponent, | |
1292 | OMX_INDEXTYPE nIndex, | |
1293 | OMX_PTR pComponentConfigStructure) | |
1294 | { | |
1295 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1296 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1297 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1298 | ||
1299 | FunctionIn(); | |
1300 | ||
1301 | if (hComponent == NULL) { | |
1302 | ret = OMX_ErrorBadParameter; | |
1303 | goto EXIT; | |
1304 | } | |
1305 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1306 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1307 | if (ret != OMX_ErrorNone) { | |
1308 | goto EXIT; | |
1309 | } | |
1310 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1311 | ret = OMX_ErrorBadParameter; | |
1312 | goto EXIT; | |
1313 | } | |
1314 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1315 | if (pComponentConfigStructure == NULL) { | |
1316 | ret = OMX_ErrorBadParameter; | |
1317 | goto EXIT; | |
1318 | } | |
1319 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1320 | ret = OMX_ErrorInvalidState; | |
1321 | goto EXIT; | |
1322 | } | |
1323 | ||
1324 | switch (nIndex) { | |
1325 | case OMX_IndexConfigCommonOutputCrop: | |
1326 | { | |
1327 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1328 | OMX_CONFIG_RECTTYPE *pSrcRectType = NULL; | |
1329 | OMX_CONFIG_RECTTYPE *pDstRectType = NULL; | |
1330 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1331 | ||
1332 | if (pH264Dec->hMFCH264Handle.bConfiguredMFCSrc == OMX_FALSE) { | |
1333 | ret = OMX_ErrorNotReady; | |
1334 | break; | |
1335 | } | |
1336 | ||
1337 | pDstRectType = (OMX_CONFIG_RECTTYPE *)pComponentConfigStructure; | |
1338 | ||
1339 | if ((pDstRectType->nPortIndex != INPUT_PORT_INDEX) && | |
1340 | (pDstRectType->nPortIndex != OUTPUT_PORT_INDEX)) { | |
1341 | ret = OMX_ErrorBadPortIndex; | |
1342 | goto EXIT; | |
1343 | } | |
1344 | ||
1345 | EXYNOS_OMX_BASEPORT *pExynosPort = &pExynosComponent->pExynosPort[pDstRectType->nPortIndex]; | |
1346 | ||
1347 | pSrcRectType = &(pExynosPort->cropRectangle); | |
1348 | ||
1349 | pDstRectType->nTop = pSrcRectType->nTop; | |
1350 | pDstRectType->nLeft = pSrcRectType->nLeft; | |
1351 | pDstRectType->nHeight = pSrcRectType->nHeight; | |
1352 | pDstRectType->nWidth = pSrcRectType->nWidth; | |
1353 | } | |
1354 | break; | |
064c4768 SKR |
1355 | #ifdef USE_S3D_SUPPORT |
1356 | case OMX_IndexVendorS3DMode: | |
1357 | { | |
1358 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
1359 | OMX_U32 *pS3DMode = NULL; | |
1360 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1361 | ||
1362 | pS3DMode = (OMX_U32 *)pComponentConfigStructure; | |
1363 | *pS3DMode = (OMX_U32) pH264Dec->hMFCH264Handle.S3DFPArgmtType; | |
1364 | } | |
1365 | break; | |
1366 | #endif | |
c6f4bc34 YK |
1367 | default: |
1368 | ret = Exynos_OMX_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1369 | break; | |
1370 | } | |
1371 | ||
1372 | EXIT: | |
1373 | FunctionOut(); | |
1374 | ||
1375 | return ret; | |
1376 | } | |
1377 | ||
1378 | OMX_ERRORTYPE Exynos_H264Dec_SetConfig( | |
1379 | OMX_HANDLETYPE hComponent, | |
1380 | OMX_INDEXTYPE nIndex, | |
1381 | OMX_PTR pComponentConfigStructure) | |
1382 | { | |
1383 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1384 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1385 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1386 | ||
1387 | FunctionIn(); | |
1388 | ||
1389 | if (hComponent == NULL) { | |
1390 | ret = OMX_ErrorBadParameter; | |
1391 | goto EXIT; | |
1392 | } | |
1393 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1394 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1395 | if (ret != OMX_ErrorNone) { | |
1396 | goto EXIT; | |
1397 | } | |
1398 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1399 | ret = OMX_ErrorBadParameter; | |
1400 | goto EXIT; | |
1401 | } | |
1402 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1403 | if (pComponentConfigStructure == NULL) { | |
1404 | ret = OMX_ErrorBadParameter; | |
1405 | goto EXIT; | |
1406 | } | |
1407 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1408 | ret = OMX_ErrorInvalidState; | |
1409 | goto EXIT; | |
1410 | } | |
1411 | ||
1412 | switch (nIndex) { | |
1413 | default: | |
1414 | ret = Exynos_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1415 | break; | |
1416 | } | |
1417 | ||
1418 | EXIT: | |
1419 | FunctionOut(); | |
1420 | ||
1421 | return ret; | |
1422 | } | |
1423 | ||
1424 | OMX_ERRORTYPE Exynos_H264Dec_GetExtensionIndex( | |
1425 | OMX_IN OMX_HANDLETYPE hComponent, | |
1426 | OMX_IN OMX_STRING cParameterName, | |
1427 | OMX_OUT OMX_INDEXTYPE *pIndexType) | |
1428 | { | |
1429 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1430 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1431 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1432 | ||
1433 | FunctionIn(); | |
1434 | ||
1435 | if (hComponent == NULL) { | |
1436 | ret = OMX_ErrorBadParameter; | |
1437 | goto EXIT; | |
1438 | } | |
1439 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1440 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1441 | if (ret != OMX_ErrorNone) { | |
1442 | goto EXIT; | |
1443 | } | |
1444 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1445 | ret = OMX_ErrorBadParameter; | |
1446 | goto EXIT; | |
1447 | } | |
1448 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1449 | if ((cParameterName == NULL) || (pIndexType == NULL)) { | |
1450 | ret = OMX_ErrorBadParameter; | |
1451 | goto EXIT; | |
1452 | } | |
1453 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1454 | ret = OMX_ErrorInvalidState; | |
1455 | goto EXIT; | |
1456 | } | |
1457 | ||
1458 | if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { | |
1459 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1460 | *pIndexType = OMX_IndexVendorThumbnailMode; | |
1461 | ret = OMX_ErrorNone; | |
064c4768 SKR |
1462 | } |
1463 | #ifdef USE_S3D_SUPPORT | |
1464 | else if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_GET_S3D) == 0) { | |
1465 | *pIndexType = OMX_IndexVendorS3DMode; | |
1466 | ret = OMX_ErrorNone; | |
1467 | } | |
1468 | #endif | |
1469 | else { | |
c6f4bc34 YK |
1470 | ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); |
1471 | } | |
1472 | ||
1473 | EXIT: | |
1474 | FunctionOut(); | |
1475 | ||
1476 | return ret; | |
1477 | } | |
1478 | ||
1479 | OMX_ERRORTYPE Exynos_H264Dec_ComponentRoleEnum( | |
1480 | OMX_HANDLETYPE hComponent, | |
1481 | OMX_U8 *cRole, | |
1482 | OMX_U32 nIndex) | |
1483 | { | |
1484 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1485 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1486 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1487 | ||
1488 | FunctionIn(); | |
1489 | ||
1490 | if ((hComponent == NULL) || (cRole == NULL)) { | |
1491 | ret = OMX_ErrorBadParameter; | |
1492 | goto EXIT; | |
1493 | } | |
1494 | if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { | |
1495 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_H264_DEC_ROLE); | |
1496 | ret = OMX_ErrorNone; | |
1497 | } else { | |
1498 | ret = OMX_ErrorNoMore; | |
1499 | } | |
1500 | ||
1501 | EXIT: | |
1502 | FunctionOut(); | |
1503 | ||
1504 | return ret; | |
1505 | } | |
1506 | ||
1507 | /* MFC Init */ | |
1508 | OMX_ERRORTYPE Exynos_H264Dec_Init(OMX_COMPONENTTYPE *pOMXComponent) | |
1509 | { | |
1510 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1511 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1512 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1513 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1514 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1515 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle; | |
1516 | OMX_PTR hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
1517 | ||
1518 | ExynosVideoDecOps *pDecOps = NULL; | |
1519 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
1520 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
1521 | ||
1522 | CSC_METHOD csc_method = CSC_METHOD_SW; | |
1523 | int i, plane; | |
1524 | ||
1525 | FunctionIn(); | |
1526 | ||
1527 | pH264Dec->hMFCH264Handle.bConfiguredMFCSrc = OMX_FALSE; | |
1528 | pH264Dec->hMFCH264Handle.bConfiguredMFCDst = OMX_FALSE; | |
1529 | pExynosComponent->bUseFlagEOF = OMX_TRUE; | |
1530 | pExynosComponent->bSaveFlagEOS = OMX_FALSE; | |
1531 | ||
1532 | /* H.264 Codec Open */ | |
1533 | ret = H264CodecOpen(pH264Dec); | |
1534 | if (ret != OMX_ErrorNone) { | |
1535 | goto EXIT; | |
1536 | } | |
1537 | ||
1538 | pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
1539 | pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
1540 | pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
1541 | ||
24ec2c82 | 1542 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1543 | Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID); |
1544 | Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
1545 | ||
1546 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
1547 | pVideoDec->pMFCDecInputBuffer[i] = Exynos_OSAL_Malloc(sizeof(CODEC_DEC_BUFFER)); | |
1548 | Exynos_OSAL_Memset(pVideoDec->pMFCDecInputBuffer[i], 0, sizeof(CODEC_DEC_BUFFER)); | |
1549 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]: 0x%x", i, pVideoDec->pMFCDecInputBuffer[i]); | |
1550 | ||
1551 | for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) { | |
1552 | /* Use ION Allocator */ | |
1553 | pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] = (void *)Exynos_OSAL_SharedMemory_Alloc(pVideoDec->hSharedMemory, DEFAULT_MFC_INPUT_BUFFER_SIZE, NORMAL_MEMORY); | |
1554 | pVideoDec->pMFCDecInputBuffer[i]->fd[plane] = Exynos_OSAL_SharedMemory_VirtToION(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]); | |
1555 | pVideoDec->pMFCDecInputBuffer[i]->bufferSize[plane] = DEFAULT_MFC_INPUT_BUFFER_SIZE; | |
1556 | pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0; | |
1557 | if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] == NULL) { | |
1558 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail input buffer"); | |
1559 | ret = OMX_ErrorInsufficientResources; | |
1560 | goto EXIT; | |
1561 | } | |
1562 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "pVideoDec->pMFCDecInputBuffer[%d]->pVirAddr[%d]: 0x%x", i, plane, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]); | |
1563 | } | |
1564 | ||
1565 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]); | |
1566 | } | |
24ec2c82 | 1567 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1568 | /*************/ |
1569 | /* TBD */ | |
1570 | /*************/ | |
1571 | /* Does not require any actions. */ | |
1572 | } | |
1573 | ||
24ec2c82 | 1574 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1575 | Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); |
1576 | Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
24ec2c82 | 1577 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1578 | /*************/ |
1579 | /* TBD */ | |
1580 | /*************/ | |
1581 | /* Does not require any actions. */ | |
1582 | } | |
1583 | ||
1584 | pH264Dec->bSourceStart = OMX_FALSE; | |
1585 | Exynos_OSAL_SignalCreate(&pH264Dec->hSourceStartEvent); | |
1586 | pH264Dec->bDestinationStart = OMX_FALSE; | |
1587 | Exynos_OSAL_SignalCreate(&pH264Dec->hDestinationStartEvent); | |
1588 | ||
1589 | Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); | |
1590 | Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); | |
1591 | pH264Dec->hMFCH264Handle.indexTimestamp = 0; | |
1592 | pH264Dec->hMFCH264Handle.outputIndexTimestamp = 0; | |
1593 | ||
1594 | pExynosComponent->getAllDelayBuffer = OMX_FALSE; | |
1595 | ||
1596 | #if 0//defined(USE_CSC_GSCALER) | |
1597 | csc_method = CSC_METHOD_HW; //in case of Use ION buffer. | |
1598 | #endif | |
1599 | if (pVideoDec->bDRMPlayerMode == OMX_TRUE) { | |
1600 | pVideoDec->csc_handle = csc_init(CSC_METHOD_HW); | |
1601 | csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_FIXED_NODE, 2); | |
1602 | csc_set_hw_property(pVideoDec->csc_handle, CSC_HW_PROPERTY_MODE_DRM, pVideoDec->bDRMPlayerMode); | |
1603 | } else { | |
1604 | pVideoDec->csc_handle = csc_init(csc_method); | |
1605 | } | |
1606 | ||
1607 | if (pVideoDec->csc_handle == NULL) { | |
1608 | ret = OMX_ErrorInsufficientResources; | |
1609 | goto EXIT; | |
1610 | } | |
1611 | pVideoDec->csc_set_format = OMX_FALSE; | |
1612 | ||
1613 | EXIT: | |
1614 | FunctionOut(); | |
1615 | ||
1616 | return ret; | |
1617 | } | |
1618 | ||
1619 | /* MFC Terminate */ | |
1620 | OMX_ERRORTYPE Exynos_H264Dec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) | |
1621 | { | |
1622 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1623 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1624 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1625 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1626 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1627 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1628 | OMX_PTR hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
1629 | ||
1630 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
1631 | ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
1632 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
1633 | ||
1634 | int i, plane; | |
1635 | ||
1636 | FunctionIn(); | |
1637 | ||
1638 | if (pVideoDec->csc_handle != NULL) { | |
1639 | csc_deinit(pVideoDec->csc_handle); | |
1640 | pVideoDec->csc_handle = NULL; | |
1641 | } | |
1642 | ||
1643 | Exynos_OSAL_SignalTerminate(pH264Dec->hDestinationStartEvent); | |
1644 | pH264Dec->hDestinationStartEvent = NULL; | |
1645 | pH264Dec->bDestinationStart = OMX_FALSE; | |
1646 | Exynos_OSAL_SignalTerminate(pH264Dec->hSourceStartEvent); | |
1647 | pH264Dec->hSourceStartEvent = NULL; | |
1648 | pH264Dec->bSourceStart = OMX_FALSE; | |
1649 | ||
24ec2c82 | 1650 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1651 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { |
1652 | if (pVideoDec->pMFCDecOutputBuffer[i] != NULL) { | |
1653 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
1654 | if (pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane] != NULL) | |
1655 | Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[plane]); | |
1656 | } | |
1657 | ||
1658 | Exynos_OSAL_Free(pVideoDec->pMFCDecOutputBuffer[i]); | |
1659 | pVideoDec->pMFCDecOutputBuffer[i] = NULL; | |
1660 | } | |
1661 | } | |
1662 | ||
1663 | Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ); | |
1664 | Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID); | |
24ec2c82 | 1665 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1666 | /*************/ |
1667 | /* TBD */ | |
1668 | /*************/ | |
1669 | /* Does not require any actions. */ | |
1670 | } | |
1671 | ||
24ec2c82 | 1672 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1673 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { |
1674 | if (pVideoDec->pMFCDecInputBuffer[i] != NULL) { | |
1675 | for (plane = 0; plane < MFC_INPUT_BUFFER_PLANE; plane++) { | |
1676 | if (pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane] != NULL) | |
1677 | Exynos_OSAL_SharedMemory_Free(pVideoDec->hSharedMemory, pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[plane]); | |
1678 | } | |
1679 | Exynos_OSAL_Free(pVideoDec->pMFCDecInputBuffer[i]); | |
1680 | pVideoDec->pMFCDecInputBuffer[i] = NULL; | |
1681 | } | |
1682 | } | |
1683 | ||
1684 | Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); | |
1685 | Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); | |
24ec2c82 | 1686 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
1687 | /*************/ |
1688 | /* TBD */ | |
1689 | /*************/ | |
1690 | /* Does not require any actions. */ | |
1691 | } | |
1692 | H264CodecClose(pH264Dec); | |
1693 | ||
1694 | EXIT: | |
1695 | FunctionOut(); | |
1696 | ||
1697 | return ret; | |
1698 | } | |
1699 | ||
1700 | OMX_ERRORTYPE Exynos_H264Dec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
1701 | { | |
1702 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1703 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1704 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1705 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1706 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
1707 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1708 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1709 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
1710 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
1711 | ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
1712 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
1713 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1714 | int i; | |
1715 | ||
1716 | FunctionIn(); | |
1717 | ||
1718 | if (pH264Dec->hMFCH264Handle.bConfiguredMFCSrc == OMX_FALSE) { | |
1719 | ret = H264CodecSrcSetup(pOMXComponent, pSrcInputData); | |
1720 | goto EXIT; | |
1721 | } | |
1722 | if (pH264Dec->hMFCH264Handle.bConfiguredMFCDst == OMX_FALSE) { | |
1723 | ret = H264CodecDstSetup(pOMXComponent); | |
1724 | } | |
1725 | ||
1726 | if (((pVideoDec->bDRMPlayerMode == OMX_TRUE) || | |
1727 | (Check_H264_StartCode(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, oneFrameSize) == OMX_TRUE)) || | |
1728 | ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { | |
1729 | pExynosComponent->timeStamp[pH264Dec->hMFCH264Handle.indexTimestamp] = pSrcInputData->timeStamp; | |
1730 | pExynosComponent->nFlags[pH264Dec->hMFCH264Handle.indexTimestamp] = pSrcInputData->nFlags; | |
1731 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "input timestamp %lld us (%.2f secs), Tag: %d, nFlags: 0x%x", pSrcInputData->timeStamp, pSrcInputData->timeStamp / 1E6, pH264Dec->hMFCH264Handle.indexTimestamp, pSrcInputData->nFlags); | |
1732 | pDecOps->Set_FrameTag(hMFCHandle, pH264Dec->hMFCH264Handle.indexTimestamp); | |
1733 | pH264Dec->hMFCH264Handle.indexTimestamp++; | |
1734 | pH264Dec->hMFCH264Handle.indexTimestamp %= MAX_TIMESTAMP; | |
1735 | ||
1736 | /* queue work for input buffer */ | |
1737 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize, pSrcInputData->bufferHeader, pSrcInputData->buffer.singlePlaneBuffer.dataBuffer); | |
1738 | codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, | |
1739 | (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader); | |
1740 | if (codecReturn != VIDEO_ERROR_NONE) { | |
1741 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1742 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); | |
1743 | goto EXIT; | |
1744 | } | |
1745 | H264CodecStart(pOMXComponent, INPUT_PORT_INDEX); | |
1746 | if (pH264Dec->bSourceStart == OMX_FALSE) { | |
1747 | pH264Dec->bSourceStart = OMX_TRUE; | |
1748 | Exynos_OSAL_SignalSet(pH264Dec->hSourceStartEvent); | |
1749 | Exynos_OSAL_SleepMillisec(0); | |
1750 | } | |
1751 | if (pH264Dec->bDestinationStart == OMX_FALSE) { | |
1752 | pH264Dec->bDestinationStart = OMX_TRUE; | |
1753 | Exynos_OSAL_SignalSet(pH264Dec->hDestinationStartEvent); | |
1754 | Exynos_OSAL_SleepMillisec(0); | |
1755 | } | |
1756 | } | |
1757 | ||
1758 | ret = OMX_ErrorNone; | |
1759 | ||
1760 | EXIT: | |
1761 | FunctionOut(); | |
1762 | ||
1763 | return ret; | |
1764 | } | |
1765 | ||
1766 | OMX_ERRORTYPE Exynos_H264Dec_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
1767 | { | |
1768 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1769 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1770 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1771 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1772 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
1773 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1774 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
1775 | ExynosVideoDecBufferOps *pInbufOps = pH264Dec->hMFCH264Handle.pInbufOps; | |
1776 | ExynosVideoBuffer *pVideoBuffer; | |
1777 | ||
1778 | FunctionIn(); | |
1779 | ||
1780 | pVideoBuffer = pInbufOps->Dequeue(hMFCHandle); | |
1781 | ||
1782 | pSrcOutputData->dataLen = 0; | |
1783 | pSrcOutputData->usedDataLen = 0; | |
1784 | pSrcOutputData->remainDataLen = 0; | |
1785 | pSrcOutputData->nFlags = 0; | |
1786 | pSrcOutputData->timeStamp = 0; | |
1787 | ||
1788 | if (pVideoBuffer == NULL) { | |
1789 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL; | |
1790 | pSrcOutputData->allocSize = 0; | |
1791 | pSrcOutputData->pPrivate = NULL; | |
1792 | pSrcOutputData->bufferHeader = NULL; | |
1793 | } else { | |
1794 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr; | |
1795 | pSrcOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd; | |
1796 | pSrcOutputData->allocSize = pVideoBuffer->planes[0].allocSize; | |
1797 | ||
24ec2c82 | 1798 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
1799 | int i = 0; |
1800 | while (pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer != pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]) { | |
1801 | if (i >= MFC_INPUT_BUFFER_NUM_MAX) { | |
1802 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); | |
1803 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1804 | goto EXIT; | |
1805 | } | |
1806 | i++; | |
1807 | } | |
1808 | pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0; | |
1809 | pSrcOutputData->pPrivate = pVideoDec->pMFCDecInputBuffer[i]; | |
1810 | } | |
1811 | ||
1812 | /* For Share Buffer */ | |
1813 | pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate; | |
1814 | } | |
1815 | ||
1816 | ret = OMX_ErrorNone; | |
1817 | ||
1818 | EXIT: | |
1819 | FunctionOut(); | |
1820 | ||
1821 | return ret; | |
1822 | } | |
1823 | ||
1824 | OMX_ERRORTYPE Exynos_H264Dec_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
1825 | { | |
1826 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1827 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1828 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1829 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1830 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
1831 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1832 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
1833 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
1834 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0,}; | |
1835 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1836 | ||
1837 | FunctionIn(); | |
1838 | ||
1839 | if (pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) { | |
1840 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer"); | |
1841 | ret = OMX_ErrorBadParameter; | |
1842 | goto EXIT; | |
1843 | } | |
1844 | ||
1845 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__, __LINE__, | |
1846 | pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0], | |
1847 | pDstInputData->buffer.multiPlaneBuffer.dataBuffer[1]); | |
1848 | ||
1849 | codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pDstInputData->buffer.multiPlaneBuffer.dataBuffer, | |
1850 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, pDstInputData->bufferHeader); | |
1851 | ||
1852 | if (codecReturn != VIDEO_ERROR_NONE) { | |
1853 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); | |
1854 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1855 | goto EXIT; | |
1856 | } | |
1857 | H264CodecStart(pOMXComponent, OUTPUT_PORT_INDEX); | |
1858 | ||
1859 | ret = OMX_ErrorNone; | |
1860 | ||
1861 | EXIT: | |
1862 | FunctionOut(); | |
1863 | ||
1864 | return ret; | |
1865 | } | |
1866 | ||
1867 | OMX_ERRORTYPE Exynos_H264Dec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
1868 | { | |
1869 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1870 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1871 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1872 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle; | |
1873 | void *hMFCHandle = pH264Dec->hMFCH264Handle.hMFCHandle; | |
1874 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1875 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1876 | ExynosVideoDecOps *pDecOps = pH264Dec->hMFCH264Handle.pDecOps; | |
1877 | ExynosVideoDecBufferOps *pOutbufOps = pH264Dec->hMFCH264Handle.pOutbufOps; | |
ca86e5fa | 1878 | ExynosVideoBuffer *pVideoBuffer = NULL; |
c6f4bc34 YK |
1879 | ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN; |
1880 | ExynosVideoGeometry *bufferGeometry; | |
1881 | DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL; | |
1882 | OMX_S32 indexTimestamp = 0; | |
1883 | int plane; | |
1884 | ||
1885 | FunctionIn(); | |
1886 | ||
1887 | if (pH264Dec->bDestinationStart == OMX_FALSE) { | |
1888 | ret = OMX_ErrorNone; | |
1889 | goto EXIT; | |
1890 | } | |
1891 | ||
1892 | while (1) { | |
1893 | if ((pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle)) == NULL) { | |
1894 | ret = OMX_ErrorNone; | |
1895 | goto EXIT; | |
1896 | } | |
1897 | displayStatus = pVideoBuffer->displayStatus; | |
1898 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus: 0x%x", displayStatus); | |
1899 | ||
1900 | if ((displayStatus == VIDEO_FRAME_STATUS_DISPLAY_DECODING) || | |
1901 | (displayStatus == VIDEO_FRAME_STATUS_DISPLAY_ONLY) || | |
1902 | (displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
1903 | (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
ca86e5fa TK |
1904 | ret = OMX_ErrorNone; |
1905 | break; | |
c6f4bc34 YK |
1906 | } |
1907 | } | |
1908 | ||
c6f4bc34 YK |
1909 | pH264Dec->hMFCH264Handle.outputIndexTimestamp++; |
1910 | pH264Dec->hMFCH264Handle.outputIndexTimestamp %= MAX_TIMESTAMP; | |
1911 | ||
1912 | pDstOutputData->allocSize = pDstOutputData->dataLen = 0; | |
1913 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
1914 | pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr; | |
1915 | pDstOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd; | |
1916 | pDstOutputData->allocSize += pVideoBuffer->planes[plane].allocSize; | |
1917 | pDstOutputData->dataLen += pVideoBuffer->planes[plane].dataSize; | |
1918 | } | |
1919 | pDstOutputData->usedDataLen = 0; | |
1920 | pDstOutputData->pPrivate = pVideoBuffer; | |
1921 | /* For Share Buffer */ | |
1922 | pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; | |
1923 | ||
1924 | pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)pDstOutputData->extInfo; | |
1925 | bufferGeometry = &pH264Dec->hMFCH264Handle.codecOutbufConf; | |
1926 | pBufferInfo->imageWidth = bufferGeometry->nFrameWidth; | |
1927 | pBufferInfo->imageHeight = bufferGeometry->nFrameHeight; | |
1928 | switch (bufferGeometry->eColorFormat) { | |
1929 | case VIDEO_COLORFORMAT_NV12: | |
1930 | pBufferInfo->ColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; | |
1931 | break; | |
1932 | case VIDEO_COLORFORMAT_NV12_TILED: | |
1933 | default: | |
1934 | pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12Tiled; | |
1935 | break; | |
1936 | } | |
1937 | ||
064c4768 SKR |
1938 | #ifdef USE_S3D_SUPPORT |
1939 | /* Check Whether frame packing information is available */ | |
1940 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY && | |
1941 | pVideoDec->bThumbnailMode == OMX_FALSE && | |
1942 | pH264Dec->hMFCH264Handle.S3DFPArgmtType == OMX_SEC_FPARGMT_NONE) { | |
1943 | H264CodecCheckFramePacking(pOMXComponent); | |
1944 | } | |
1945 | #endif | |
1946 | ||
c6f4bc34 YK |
1947 | indexTimestamp = pDecOps->Get_FrameTag(hMFCHandle); |
1948 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "out indexTimestamp: %d", indexTimestamp); | |
1949 | if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) { | |
1950 | if ((pExynosComponent->checkTimeStamp.needSetStartTimeStamp != OMX_TRUE) && | |
1951 | (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp != OMX_TRUE)) { | |
1952 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[pH264Dec->hMFCH264Handle.outputIndexTimestamp]; | |
1953 | pDstOutputData->nFlags = pExynosComponent->nFlags[pH264Dec->hMFCH264Handle.outputIndexTimestamp]; | |
1954 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "missing out indexTimestamp: %d", indexTimestamp); | |
1955 | } else { | |
1956 | pDstOutputData->timeStamp = 0x00; | |
1957 | pDstOutputData->nFlags = 0x00; | |
1958 | } | |
1959 | } else { | |
1960 | /* For timestamp correction. if mfc support frametype detect */ | |
1961 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoBuffer->frameType); | |
1962 | #ifdef NEED_TIMESTAMP_REORDER | |
1963 | if ((pVideoBuffer->frameType == VIDEO_FRAME_I)) { | |
1964 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp]; | |
1965 | pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp]; | |
1966 | pH264Dec->hMFCH264Handle.outputIndexTimestamp = indexTimestamp; | |
1967 | } else { | |
1968 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[pH264Dec->hMFCH264Handle.outputIndexTimestamp]; | |
1969 | pDstOutputData->nFlags = pExynosComponent->nFlags[pH264Dec->hMFCH264Handle.outputIndexTimestamp]; | |
1970 | } | |
1971 | #else | |
1972 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp]; | |
1973 | pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp]; | |
1974 | #endif | |
1975 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData->timeStamp, pDstOutputData->timeStamp / 1E6, indexTimestamp, pDstOutputData->nFlags); | |
1976 | } | |
1977 | ||
1978 | if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
1979 | ((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { | |
1980 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus:%d, nFlags0x%x", displayStatus, pDstOutputData->nFlags); | |
1981 | pDstOutputData->remainDataLen = 0; | |
1982 | } else { | |
1983 | pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2; | |
1984 | } | |
1985 | ||
1986 | ret = OMX_ErrorNone; | |
1987 | ||
1988 | EXIT: | |
1989 | FunctionOut(); | |
1990 | ||
1991 | return ret; | |
1992 | } | |
1993 | ||
1994 | OMX_ERRORTYPE Exynos_H264Dec_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
1995 | { | |
1996 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1997 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1998 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1999 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2000 | ||
2001 | FunctionIn(); | |
2002 | ||
2003 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2004 | ret = OMX_ErrorNone; | |
2005 | goto EXIT; | |
2006 | } | |
2007 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
2008 | ret = OMX_ErrorNone; | |
2009 | goto EXIT; | |
2010 | } | |
2011 | ||
2012 | ret = Exynos_H264Dec_SrcIn(pOMXComponent, pSrcInputData); | |
2013 | if ((ret != OMX_ErrorNone) && (ret != OMX_ErrorInputDataDecodeYet)) { | |
2014 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2015 | pExynosComponent->callbackData, | |
2016 | OMX_EventError, ret, 0, NULL); | |
2017 | } | |
2018 | ||
2019 | EXIT: | |
2020 | FunctionOut(); | |
2021 | ||
2022 | return ret; | |
2023 | } | |
2024 | ||
2025 | OMX_ERRORTYPE Exynos_H264Dec_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
2026 | { | |
2027 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2028 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2029 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2030 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2031 | ||
2032 | FunctionIn(); | |
2033 | ||
2034 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2035 | ret = OMX_ErrorNone; | |
2036 | goto EXIT; | |
2037 | } | |
2038 | ||
24ec2c82 | 2039 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
2040 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { |
2041 | ret = OMX_ErrorNone; | |
2042 | goto EXIT; | |
2043 | } | |
2044 | } | |
2045 | if ((pH264Dec->bSourceStart == OMX_FALSE) && | |
2046 | (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) { | |
2047 | Exynos_OSAL_SignalWait(pH264Dec->hSourceStartEvent, DEF_MAX_WAIT_TIME); | |
2048 | Exynos_OSAL_SignalReset(pH264Dec->hSourceStartEvent); | |
2049 | } | |
2050 | ||
2051 | ret = Exynos_H264Dec_SrcOut(pOMXComponent, pSrcOutputData); | |
2052 | if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2053 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2054 | pExynosComponent->callbackData, | |
2055 | OMX_EventError, ret, 0, NULL); | |
2056 | } | |
2057 | ||
2058 | EXIT: | |
2059 | FunctionOut(); | |
2060 | ||
2061 | return ret; | |
2062 | } | |
2063 | ||
2064 | OMX_ERRORTYPE Exynos_H264Dec_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
2065 | { | |
2066 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2067 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2068 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2069 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2070 | ||
2071 | FunctionIn(); | |
2072 | ||
2073 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2074 | ret = OMX_ErrorNone; | |
2075 | goto EXIT; | |
2076 | } | |
2077 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2078 | ret = OMX_ErrorNone; | |
2079 | goto EXIT; | |
2080 | } | |
24ec2c82 | 2081 | if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
c6f4bc34 YK |
2082 | if ((pH264Dec->bDestinationStart == OMX_FALSE) && |
2083 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2084 | Exynos_OSAL_SignalWait(pH264Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2085 | Exynos_OSAL_SignalReset(pH264Dec->hDestinationStartEvent); | |
2086 | } | |
2087 | } | |
2088 | if (pH264Dec->hMFCH264Handle.bConfiguredMFCDst == OMX_TRUE) { | |
2089 | ret = Exynos_H264Dec_DstIn(pOMXComponent, pDstInputData); | |
2090 | if (ret != OMX_ErrorNone) { | |
2091 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2092 | pExynosComponent->callbackData, | |
2093 | OMX_EventError, ret, 0, NULL); | |
2094 | } | |
2095 | } | |
2096 | ||
2097 | EXIT: | |
2098 | FunctionOut(); | |
2099 | ||
2100 | return ret; | |
2101 | } | |
2102 | ||
2103 | OMX_ERRORTYPE Exynos_H264Dec_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
2104 | { | |
2105 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2106 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2107 | EXYNOS_H264DEC_HANDLE *pH264Dec = (EXYNOS_H264DEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2108 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2109 | ||
2110 | FunctionIn(); | |
2111 | ||
2112 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2113 | ret = OMX_ErrorNone; | |
2114 | goto EXIT; | |
2115 | } | |
2116 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2117 | ret = OMX_ErrorNone; | |
2118 | goto EXIT; | |
2119 | } | |
2120 | ||
24ec2c82 | 2121 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
c6f4bc34 YK |
2122 | if ((pH264Dec->bDestinationStart == OMX_FALSE) && |
2123 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2124 | Exynos_OSAL_SignalWait(pH264Dec->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2125 | Exynos_OSAL_SignalReset(pH264Dec->hDestinationStartEvent); | |
2126 | } | |
2127 | } | |
2128 | ret = Exynos_H264Dec_DstOut(pOMXComponent, pDstOutputData); | |
2129 | if ((ret != OMX_ErrorNone) && (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2130 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2131 | pExynosComponent->callbackData, | |
2132 | OMX_EventError, ret, 0, NULL); | |
2133 | } | |
2134 | ||
2135 | EXIT: | |
2136 | FunctionOut(); | |
2137 | ||
2138 | return ret; | |
2139 | } | |
2140 | ||
2141 | OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit(OMX_HANDLETYPE hComponent, OMX_STRING componentName) | |
2142 | { | |
2143 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2144 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2145 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2146 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
2147 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
2148 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
2149 | OMX_BOOL bDRMPlayerMode = OMX_FALSE; | |
2150 | int i = 0; | |
2151 | ||
2152 | FunctionIn(); | |
2153 | ||
2154 | if ((hComponent == NULL) || (componentName == NULL)) { | |
2155 | ret = OMX_ErrorBadParameter; | |
2156 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
2157 | goto EXIT; | |
2158 | } | |
2159 | if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DEC, componentName) == 0) { | |
2160 | bDRMPlayerMode = OMX_FALSE; | |
2161 | } else if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_H264_DRM_DEC, componentName) == 0) { | |
2162 | bDRMPlayerMode = OMX_TRUE; | |
2163 | } else { | |
2164 | ret = OMX_ErrorBadParameter; | |
2165 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); | |
2166 | goto EXIT; | |
2167 | } | |
2168 | ||
2169 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2170 | ret = Exynos_OMX_VideoDecodeComponentInit(pOMXComponent); | |
2171 | if (ret != OMX_ErrorNone) { | |
2172 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); | |
2173 | goto EXIT; | |
2174 | } | |
2175 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2176 | pExynosComponent->codecType = HW_VIDEO_DEC_CODEC; | |
2177 | ||
2178 | pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); | |
2179 | if (pExynosComponent->componentName == NULL) { | |
2180 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2181 | ret = OMX_ErrorInsufficientResources; | |
2182 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2183 | goto EXIT; | |
2184 | } | |
2185 | Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); | |
2186 | ||
2187 | pH264Dec = Exynos_OSAL_Malloc(sizeof(EXYNOS_H264DEC_HANDLE)); | |
2188 | if (pH264Dec == NULL) { | |
2189 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2190 | ret = OMX_ErrorInsufficientResources; | |
2191 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2192 | goto EXIT; | |
2193 | } | |
2194 | Exynos_OSAL_Memset(pH264Dec, 0, sizeof(EXYNOS_H264DEC_HANDLE)); | |
2195 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2196 | pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pH264Dec; | |
2197 | ||
2198 | if (bDRMPlayerMode == OMX_TRUE) | |
2199 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DRM_DEC); | |
2200 | else | |
2201 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_H264_DEC); | |
2202 | ||
2203 | pVideoDec->bDRMPlayerMode = bDRMPlayerMode; | |
064c4768 SKR |
2204 | #ifdef USE_S3D_SUPPORT |
2205 | pH264Dec->hMFCH264Handle.S3DFPArgmtType = OMX_SEC_FPARGMT_NONE; | |
2206 | #endif | |
c6f4bc34 YK |
2207 | |
2208 | /* Set componentVersion */ | |
2209 | pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2210 | pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2211 | pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER; | |
2212 | pExynosComponent->componentVersion.s.nStep = STEP_NUMBER; | |
2213 | /* Set specVersion */ | |
2214 | pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2215 | pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2216 | pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER; | |
2217 | pExynosComponent->specVersion.s.nStep = STEP_NUMBER; | |
2218 | ||
2219 | /* Input port */ | |
2220 | pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2221 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2222 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2223 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2224 | pExynosPort->portDefinition.format.video.nSliceHeight = 0; | |
2225 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; | |
2226 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingAVC; | |
2227 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2228 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/avc"); | |
2229 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2230 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2231 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; | |
2232 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2233 | pExynosPort->bufferProcessType = BUFFER_SHARE; | |
2234 | if (bDRMPlayerMode == OMX_TRUE) | |
2235 | pExynosPort->bufferProcessType = BUFFER_SHARE; | |
2236 | pExynosPort->portWayType = WAY2_PORT; | |
2237 | ||
2238 | /* Output port */ | |
2239 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2240 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2241 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2242 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2243 | pExynosPort->portDefinition.format.video.nSliceHeight = 0; | |
2244 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; | |
2245 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; | |
2246 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2247 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video"); | |
2248 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2249 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2250 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; | |
2251 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2252 | pExynosPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE; | |
2253 | pExynosPort->portWayType = WAY2_PORT; | |
2254 | ||
2255 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2256 | INIT_SET_SIZE_VERSION(&pH264Dec->AVCComponent[i], OMX_VIDEO_PARAM_AVCTYPE); | |
2257 | pH264Dec->AVCComponent[i].nPortIndex = i; | |
2258 | pH264Dec->AVCComponent[i].eProfile = OMX_VIDEO_AVCProfileBaseline; | |
2259 | pH264Dec->AVCComponent[i].eLevel = OMX_VIDEO_AVCLevel4; | |
2260 | } | |
2261 | ||
2262 | pOMXComponent->GetParameter = &Exynos_H264Dec_GetParameter; | |
2263 | pOMXComponent->SetParameter = &Exynos_H264Dec_SetParameter; | |
2264 | pOMXComponent->GetConfig = &Exynos_H264Dec_GetConfig; | |
2265 | pOMXComponent->SetConfig = &Exynos_H264Dec_SetConfig; | |
2266 | pOMXComponent->GetExtensionIndex = &Exynos_H264Dec_GetExtensionIndex; | |
2267 | pOMXComponent->ComponentRoleEnum = &Exynos_H264Dec_ComponentRoleEnum; | |
2268 | pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit; | |
2269 | ||
2270 | pExynosComponent->exynos_codec_componentInit = &Exynos_H264Dec_Init; | |
2271 | pExynosComponent->exynos_codec_componentTerminate = &Exynos_H264Dec_Terminate; | |
2272 | ||
2273 | pVideoDec->exynos_codec_srcInputProcess = &Exynos_H264Dec_srcInputBufferProcess; | |
2274 | pVideoDec->exynos_codec_srcOutputProcess = &Exynos_H264Dec_srcOutputBufferProcess; | |
2275 | pVideoDec->exynos_codec_dstInputProcess = &Exynos_H264Dec_dstInputBufferProcess; | |
2276 | pVideoDec->exynos_codec_dstOutputProcess = &Exynos_H264Dec_dstOutputBufferProcess; | |
2277 | ||
2278 | pVideoDec->exynos_codec_start = &H264CodecStart; | |
2279 | pVideoDec->exynos_codec_stop = &H264CodecStop; | |
2280 | pVideoDec->exynos_codec_bufferProcessRun = &H264CodecOutputBufferProcessRun; | |
2281 | pVideoDec->exynos_codec_enqueueAllBuffer = &H264CodecEnQueueAllBuffer; | |
2282 | ||
2283 | pVideoDec->exynos_checkInputFrame = &Check_H264_Frame; | |
2284 | pVideoDec->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; | |
2285 | pVideoDec->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData; | |
2286 | ||
2287 | pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open(); | |
2288 | if (pVideoDec->hSharedMemory == NULL) { | |
2289 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2290 | Exynos_OSAL_Free(pH264Dec); | |
2291 | pH264Dec = ((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL; | |
2292 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2293 | ret = OMX_ErrorInsufficientResources; | |
2294 | goto EXIT; | |
2295 | } | |
2296 | ||
2297 | pExynosComponent->currentState = OMX_StateLoaded; | |
2298 | ||
2299 | ret = OMX_ErrorNone; | |
2300 | ||
2301 | EXIT: | |
2302 | FunctionOut(); | |
2303 | ||
2304 | return ret; | |
2305 | } | |
2306 | ||
2307 | OMX_ERRORTYPE Exynos_OMX_ComponentDeinit(OMX_HANDLETYPE hComponent) | |
2308 | { | |
2309 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2310 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2311 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2312 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
2313 | EXYNOS_H264DEC_HANDLE *pH264Dec = NULL; | |
2314 | ||
2315 | FunctionIn(); | |
2316 | ||
2317 | if (hComponent == NULL) { | |
2318 | ret = OMX_ErrorBadParameter; | |
2319 | goto EXIT; | |
2320 | } | |
2321 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2322 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2323 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2324 | ||
2325 | Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory); | |
2326 | ||
2327 | Exynos_OSAL_Free(pExynosComponent->componentName); | |
2328 | pExynosComponent->componentName = NULL; | |
2329 | ||
2330 | pH264Dec = (EXYNOS_H264DEC_HANDLE *)pVideoDec->hCodecHandle; | |
2331 | if (pH264Dec != NULL) { | |
2332 | Exynos_OSAL_Free(pH264Dec); | |
2333 | pH264Dec = pVideoDec->hCodecHandle = NULL; | |
2334 | } | |
2335 | ||
2336 | ret = Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2337 | if (ret != OMX_ErrorNone) { | |
2338 | goto EXIT; | |
2339 | } | |
2340 | ||
2341 | ret = OMX_ErrorNone; | |
2342 | ||
2343 | EXIT: | |
2344 | FunctionOut(); | |
2345 | ||
2346 | return ret; | |
2347 | } |