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