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 | ||
c70316c7 JY |
811 | if ((pDecOps->Enable_DTSMode != NULL) && |
812 | (pVideoDec->bDTSMode == OMX_TRUE)) | |
813 | pDecOps->Enable_DTSMode(hMFCHandle); | |
814 | ||
9c5c94d6 SKR |
815 | if (pSrcInputData->nFlags & OMX_BUFFERFLAG_CODECCONFIG) { |
816 | BitmapInfoHhr *pBitmapInfoHeader; | |
817 | pBitmapInfoHeader = (BitmapInfoHhr *)pSrcInputData->buffer.singlePlaneBuffer.dataBuffer; | |
818 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "OMX_BUFFERFLAG_CODECCONFIG"); | |
819 | if (pBitmapInfoHeader->BiCompression == wmv3) { | |
820 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "WMV_FORMAT_WMV3"); | |
821 | pWmvDec->hMFCWmvHandle.wmvFormat = WMV_FORMAT_WMV3; | |
822 | } else if ((pBitmapInfoHeader->BiCompression == wvc1) || (pBitmapInfoHeader->BiCompression == wmva)) { | |
823 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "WMV_FORMAT_VC1"); | |
824 | pWmvDec->hMFCWmvHandle.wmvFormat = WMV_FORMAT_VC1; | |
825 | } | |
826 | } | |
827 | ||
828 | /* input buffer info */ | |
829 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
830 | if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_WMV3) { | |
831 | bufferConf.eCompressionFormat = VIDEO_CODING_VC1_RCV; | |
832 | } else if (pWmvDec->hMFCWmvHandle.wmvFormat == WMV_FORMAT_VC1) { | |
833 | bufferConf.eCompressionFormat = VIDEO_CODING_VC1; | |
834 | } else { | |
835 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Unsupported WMV Codec Format Type"); | |
836 | ret = OMX_ErrorUndefined; | |
837 | goto EXIT; | |
838 | } | |
839 | ||
840 | pInbufOps->Set_Shareable(hMFCHandle); | |
841 | if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { | |
842 | bufferConf.nSizeImage = pExynosInputPort->portDefinition.format.video.nFrameWidth | |
843 | * pExynosInputPort->portDefinition.format.video.nFrameHeight * 3 / 2; | |
844 | inputBufferNumber = MAX_VIDEO_INPUTBUFFER_NUM; | |
845 | } else if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { | |
846 | bufferConf.nSizeImage = DEFAULT_MFC_INPUT_BUFFER_SIZE; | |
847 | inputBufferNumber = MFC_INPUT_BUFFER_NUM_MAX; | |
848 | } | |
849 | ||
850 | /* should be done before prepare input buffer */ | |
851 | if (pInbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
852 | ret = OMX_ErrorInsufficientResources; | |
853 | goto EXIT; | |
854 | } | |
855 | ||
856 | /* set input buffer geometry */ | |
857 | if (pInbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
858 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for input buffer"); | |
859 | ret = OMX_ErrorInsufficientResources; | |
860 | goto EXIT; | |
861 | } | |
862 | ||
863 | /* setup input buffer */ | |
864 | if (pInbufOps->Setup(hMFCHandle, inputBufferNumber) != VIDEO_ERROR_NONE) { | |
865 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup input buffer"); | |
866 | ret = OMX_ErrorInsufficientResources; | |
867 | goto EXIT; | |
868 | } | |
869 | ||
870 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { | |
0641ae29 TK |
871 | ret = WMVCodecRegistCodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX); |
872 | if (ret != OMX_ErrorNone) | |
873 | goto EXIT; | |
9c5c94d6 SKR |
874 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
875 | /* Register input buffer */ | |
876 | for (i = 0; i < pExynosInputPort->portDefinition.nBufferCountActual; i++) { | |
877 | ExynosVideoPlane plane; | |
878 | plane.addr = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->pBuffer; | |
879 | plane.allocSize = pExynosInputPort->extendBufferHeader[i].OMXBufferHeader->nAllocLen; | |
880 | plane.fd = pExynosInputPort->extendBufferHeader[i].buf_fd[0]; | |
881 | if (pInbufOps->Register(hMFCHandle, &plane, MFC_INPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
882 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register input buffer"); | |
883 | ret = OMX_ErrorInsufficientResources; | |
884 | goto EXIT; | |
885 | } | |
886 | } | |
887 | } | |
888 | ||
889 | /* set output geometry */ | |
890 | Exynos_OSAL_Memset(&bufferConf, 0, sizeof(bufferConf)); | |
891 | pWmvDec->hMFCWmvHandle.MFCOutputColorType = bufferConf.eColorFormat = VIDEO_COLORFORMAT_NV12_TILED; | |
892 | if (pOutbufOps->Set_Geometry(hMFCHandle, &bufferConf) != VIDEO_ERROR_NONE) { | |
893 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to set geometry for output buffer"); | |
894 | ret = OMX_ErrorInsufficientResources; | |
895 | goto EXIT; | |
896 | } | |
897 | ||
898 | bMetaData = Make_Stream_MetaData(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, &oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat); | |
899 | if (bMetaData == OMX_FALSE) { | |
900 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail to Make Stream MetaData"); | |
901 | ret = OMX_ErrorInsufficientResources; | |
902 | goto EXIT; | |
903 | } | |
904 | ||
905 | /* input buffer enqueue for header parsing */ | |
906 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d", oneFrameSize); | |
907 | if (pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, | |
908 | (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader) != VIDEO_ERROR_NONE) { | |
909 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to enqueue input buffer for header parsing"); | |
910 | // ret = OMX_ErrorInsufficientResources; | |
911 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecInit; | |
912 | goto EXIT; | |
913 | } | |
914 | ||
915 | /* start header parsing */ | |
916 | if (pInbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
917 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run input buffer for header parsing"); | |
918 | ret = OMX_ErrorCodecInit; | |
919 | goto EXIT; | |
920 | } | |
921 | ||
922 | /* get geometry for output */ | |
923 | Exynos_OSAL_Memset(&pWmvDec->hMFCWmvHandle.codecOutbufConf, 0, sizeof(ExynosVideoGeometry)); | |
924 | if (pOutbufOps->Get_Geometry(hMFCHandle, &pWmvDec->hMFCWmvHandle.codecOutbufConf) != VIDEO_ERROR_NONE) { | |
925 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to get geometry for parsed header info"); | |
926 | ret = OMX_ErrorInsufficientResources; | |
927 | goto EXIT; | |
928 | } | |
929 | ||
930 | /* get dpb count */ | |
931 | pWmvDec->hMFCWmvHandle.maxDPBNum = pDecOps->Get_ActualBufferCount(hMFCHandle); | |
932 | if (pVideoDec->bThumbnailMode == OMX_FALSE) | |
933 | pWmvDec->hMFCWmvHandle.maxDPBNum += EXTRA_DPB_NUM; | |
934 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "WmvCodecSetup nOutbufs: %d", pWmvDec->hMFCWmvHandle.maxDPBNum); | |
935 | ||
936 | pWmvDec->hMFCWmvHandle.bConfiguredMFCSrc = OMX_TRUE; | |
937 | ||
938 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { | |
939 | if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameWidth) || | |
940 | (pExynosInputPort->portDefinition.format.video.nFrameHeight != pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight)) { | |
a947bcc1 TK |
941 | pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE; |
942 | ||
9c5c94d6 SKR |
943 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameWidth; |
944 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight; | |
945 | pExynosInputPort->portDefinition.format.video.nStride = ((pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
946 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
947 | ||
948 | Exynos_UpdateFrameSize(pOMXComponent); | |
9c5c94d6 SKR |
949 | |
950 | /** Send Port Settings changed call back **/ | |
951 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
952 | (pOMXComponent, | |
953 | pExynosComponent->callbackData, | |
954 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
955 | OMX_DirOutput, /* This is the port index */ | |
956 | 0, | |
957 | NULL); | |
958 | } | |
959 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { | |
960 | if ((pExynosInputPort->portDefinition.format.video.nFrameWidth != pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameWidth) || | |
961 | (pExynosInputPort->portDefinition.format.video.nFrameHeight != pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight) || | |
962 | (pExynosOutputPort->portDefinition.nBufferCountActual != pWmvDec->hMFCWmvHandle.maxDPBNum)) { | |
a947bcc1 TK |
963 | pExynosOutputPort->exceptionFlag = NEED_PORT_DISABLE; |
964 | ||
9c5c94d6 SKR |
965 | pExynosInputPort->portDefinition.format.video.nFrameWidth = pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameWidth; |
966 | pExynosInputPort->portDefinition.format.video.nFrameHeight = pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight; | |
967 | pExynosInputPort->portDefinition.format.video.nStride = ((pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameWidth + 15) & (~15)); | |
968 | pExynosInputPort->portDefinition.format.video.nSliceHeight = ((pWmvDec->hMFCWmvHandle.codecOutbufConf.nFrameHeight + 15) & (~15)); | |
969 | ||
970 | pExynosOutputPort->portDefinition.nBufferCountActual = pWmvDec->hMFCWmvHandle.maxDPBNum - 2; | |
971 | pExynosOutputPort->portDefinition.nBufferCountMin = pWmvDec->hMFCWmvHandle.maxDPBNum - 2; | |
972 | ||
973 | Exynos_UpdateFrameSize(pOMXComponent); | |
9c5c94d6 SKR |
974 | |
975 | /** Send Port Settings changed call back **/ | |
976 | (*(pExynosComponent->pCallbacks->EventHandler)) | |
977 | (pOMXComponent, | |
978 | pExynosComponent->callbackData, | |
979 | OMX_EventPortSettingsChanged, /* The command was completed */ | |
980 | OMX_DirOutput, /* This is the port index */ | |
981 | 0, | |
982 | NULL); | |
983 | } | |
984 | } | |
985 | Exynos_OSAL_SleepMillisec(0); | |
986 | ret = OMX_ErrorInputDataDecodeYet; | |
987 | WmvCodecStop(pOMXComponent, INPUT_PORT_INDEX); | |
988 | ||
989 | EXIT: | |
990 | FunctionOut(); | |
991 | ||
992 | return ret; | |
993 | } | |
994 | ||
995 | OMX_ERRORTYPE WmvCodecDstSetup(OMX_COMPONENTTYPE *pOMXComponent) | |
996 | { | |
997 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
998 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
999 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1000 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1001 | void *hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1002 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1003 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1004 | ||
1005 | ExynosVideoDecOps *pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1006 | ExynosVideoDecBufferOps *pInbufOps = pWmvDec->hMFCWmvHandle.pInbufOps; | |
1007 | ExynosVideoDecBufferOps *pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps; | |
1008 | ||
1009 | int i, nOutbufs; | |
1010 | ||
e02ebaac TK |
1011 | OMX_U32 nAllocLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; |
1012 | OMX_U32 dataLen[MFC_OUTPUT_BUFFER_PLANE] = {0, 0}; | |
1013 | ||
9c5c94d6 SKR |
1014 | FunctionIn(); |
1015 | ||
e02ebaac TK |
1016 | nAllocLen[0] = pWmvDec->hMFCWmvHandle.codecOutbufConf.nAlignPlaneSize[0]; |
1017 | nAllocLen[1] = pWmvDec->hMFCWmvHandle.codecOutbufConf.nAlignPlaneSize[1]; | |
1018 | ||
1019 | pOutbufOps->Set_Shareable(hMFCHandle); | |
1020 | ||
9c5c94d6 SKR |
1021 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
1022 | /* should be done before prepare output buffer */ | |
1023 | if (pOutbufOps->Enable_Cacheable(hMFCHandle) != VIDEO_ERROR_NONE) { | |
1024 | ret = OMX_ErrorInsufficientResources; | |
1025 | goto EXIT; | |
1026 | } | |
9c5c94d6 | 1027 | |
a38b0597 TK |
1028 | /* get dpb count */ |
1029 | nOutbufs = pWmvDec->hMFCWmvHandle.maxDPBNum; | |
1030 | if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) { | |
1031 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer"); | |
1032 | ret = OMX_ErrorInsufficientResources; | |
1033 | goto EXIT; | |
1034 | } | |
1035 | ||
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 | } | |
98034ac0 SK |
1049 | |
1050 | if (pOutbufOps->Run(hMFCHandle) != VIDEO_ERROR_NONE) { | |
1051 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to run output buffer"); | |
1052 | ret = OMX_ErrorInsufficientResources; | |
1053 | goto EXIT; | |
1054 | } | |
9c5c94d6 | 1055 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { |
e02ebaac TK |
1056 | ExynosVideoPlane planes[MFC_OUTPUT_BUFFER_PLANE]; |
1057 | int plane; | |
1058 | ||
a38b0597 TK |
1059 | /* get dpb count */ |
1060 | nOutbufs = pExynosOutputPort->portDefinition.nBufferCountActual; | |
1061 | if (pOutbufOps->Setup(hMFCHandle, nOutbufs) != VIDEO_ERROR_NONE) { | |
1062 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to setup output buffer"); | |
1063 | ret = OMX_ErrorInsufficientResources; | |
1064 | goto EXIT; | |
1065 | } | |
1066 | ||
9c5c94d6 SKR |
1067 | /* Register output buffer */ |
1068 | /*************/ | |
1069 | /* TBD */ | |
1070 | /*************/ | |
1071 | #ifdef USE_ANB | |
1072 | if (pExynosOutputPort->bIsANBEnabled == OMX_TRUE) { | |
1073 | for (i = 0; i < pExynosOutputPort->assignedBufferNum; i++) { | |
1074 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
1075 | planes[plane].fd = pExynosOutputPort->extendBufferHeader[i].buf_fd[plane]; | |
1076 | planes[plane].addr = pExynosOutputPort->extendBufferHeader[i].pYUVBuf[plane]; | |
1077 | planes[plane].allocSize = nAllocLen[plane]; | |
1078 | } | |
1079 | ||
1080 | if (pOutbufOps->Register(hMFCHandle, planes, MFC_OUTPUT_BUFFER_PLANE) != VIDEO_ERROR_NONE) { | |
1081 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Register output buffer"); | |
1082 | ret = OMX_ErrorInsufficientResources; | |
1083 | goto EXIT; | |
1084 | } | |
1085 | pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pExynosOutputPort->extendBufferHeader[i].pYUVBuf, | |
1086 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, NULL); | |
1087 | } | |
98034ac0 SK |
1088 | |
1089 | if (pOutbufOps->Apply_RegisteredBuffer(hMFCHandle) != VIDEO_ERROR_NONE) { | |
1090 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to Apply output buffer"); | |
1091 | ret = OMX_ErrorHardware; | |
1092 | goto EXIT; | |
1093 | } | |
9c5c94d6 SKR |
1094 | } else { |
1095 | ret = OMX_ErrorNotImplemented; | |
1096 | goto EXIT; | |
1097 | } | |
1098 | #else | |
1099 | ret = OMX_ErrorNotImplemented; | |
1100 | goto EXIT; | |
1101 | #endif | |
1102 | } | |
1103 | ||
9c5c94d6 SKR |
1104 | pWmvDec->hMFCWmvHandle.bConfiguredMFCDst = OMX_TRUE; |
1105 | ||
1106 | ret = OMX_ErrorNone; | |
1107 | ||
1108 | EXIT: | |
1109 | FunctionOut(); | |
1110 | ||
1111 | return ret; | |
1112 | } | |
1113 | ||
1114 | OMX_ERRORTYPE Exynos_WmvDec_GetParameter( | |
1115 | OMX_IN OMX_HANDLETYPE hComponent, | |
1116 | OMX_IN OMX_INDEXTYPE nParamIndex, | |
1117 | OMX_INOUT OMX_PTR pComponentParameterStructure) | |
1118 | { | |
1119 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1120 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1121 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1122 | ||
1123 | FunctionIn(); | |
1124 | ||
1125 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1126 | ret = OMX_ErrorBadParameter; | |
1127 | goto EXIT; | |
1128 | } | |
1129 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1130 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1131 | if (ret != OMX_ErrorNone) { | |
1132 | goto EXIT; | |
1133 | } | |
1134 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1135 | ret = OMX_ErrorBadParameter; | |
1136 | goto EXIT; | |
1137 | } | |
1138 | ||
1139 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1140 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1141 | ret = OMX_ErrorInvalidState; | |
1142 | goto EXIT; | |
1143 | } | |
1144 | ||
1145 | switch (nParamIndex) { | |
1146 | case OMX_IndexParamVideoWmv: | |
1147 | { | |
1148 | OMX_VIDEO_PARAM_WMVTYPE *pDstWmvParam = (OMX_VIDEO_PARAM_WMVTYPE *)pComponentParameterStructure; | |
1149 | OMX_VIDEO_PARAM_WMVTYPE *pSrcWmvParam = NULL; | |
1150 | EXYNOS_WMVDEC_HANDLE *pWmvDec = NULL; | |
1151 | ret = Exynos_OMX_Check_SizeVersion(pDstWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); | |
1152 | if (ret != OMX_ErrorNone) { | |
1153 | goto EXIT; | |
1154 | } | |
1155 | ||
1156 | if (pDstWmvParam->nPortIndex > OUTPUT_PORT_INDEX) { | |
1157 | ret = OMX_ErrorBadPortIndex; | |
9c39c5ff | 1158 | goto EXIT; |
9c5c94d6 SKR |
1159 | } |
1160 | ||
1161 | pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1162 | pSrcWmvParam = &pWmvDec->WmvComponent[pDstWmvParam->nPortIndex]; | |
1163 | ||
1164 | Exynos_OSAL_Memcpy(pDstWmvParam, pSrcWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); | |
1165 | } | |
1166 | break; | |
1167 | ||
1168 | case OMX_IndexParamStandardComponentRole: | |
1169 | { | |
1170 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE *)pComponentParameterStructure; | |
1171 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1172 | if (ret != OMX_ErrorNone) { | |
1173 | goto EXIT; | |
1174 | } | |
1175 | ||
1176 | Exynos_OSAL_Strcpy((char *)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_WMV_DEC_ROLE); | |
1177 | } | |
1178 | break; | |
1179 | case OMX_IndexParamVideoErrorCorrection: | |
1180 | { | |
1181 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1182 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = NULL; | |
1183 | EXYNOS_WMVDEC_HANDLE *pWmvDec = NULL; | |
1184 | ||
1185 | ret = Exynos_OMX_Check_SizeVersion(pDstErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1186 | if (ret != OMX_ErrorNone) { | |
1187 | goto EXIT; | |
1188 | } | |
1189 | ||
1190 | if (pDstErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { | |
1191 | ret = OMX_ErrorBadPortIndex; | |
1192 | goto EXIT; | |
1193 | } | |
1194 | ||
1195 | pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1196 | pSrcErrorCorrectionType = &pWmvDec->errorCorrectionType[INPUT_PORT_INDEX]; | |
1197 | ||
1198 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1199 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1200 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1201 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1202 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1203 | } | |
1204 | break; | |
1205 | default: | |
1206 | ret = Exynos_OMX_VideoDecodeGetParameter(hComponent, nParamIndex, pComponentParameterStructure); | |
1207 | break; | |
1208 | } | |
1209 | EXIT: | |
1210 | FunctionOut(); | |
1211 | ||
1212 | return ret; | |
1213 | } | |
1214 | ||
1215 | OMX_ERRORTYPE Exynos_WmvDec_SetParameter( | |
1216 | OMX_IN OMX_HANDLETYPE hComponent, | |
1217 | OMX_IN OMX_INDEXTYPE nIndex, | |
1218 | OMX_IN OMX_PTR pComponentParameterStructure) | |
1219 | { | |
1220 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1221 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1222 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1223 | ||
1224 | FunctionIn(); | |
1225 | ||
1226 | if (hComponent == NULL || pComponentParameterStructure == NULL) { | |
1227 | ret = OMX_ErrorBadParameter; | |
1228 | goto EXIT; | |
1229 | } | |
1230 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1231 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1232 | if (ret != OMX_ErrorNone) { | |
1233 | goto EXIT; | |
1234 | } | |
1235 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1236 | ret = OMX_ErrorBadParameter; | |
1237 | goto EXIT; | |
1238 | } | |
1239 | ||
1240 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1241 | if (pExynosComponent->currentState == OMX_StateInvalid ) { | |
1242 | ret = OMX_ErrorInvalidState; | |
1243 | goto EXIT; | |
1244 | } | |
1245 | ||
1246 | switch (nIndex) { | |
1247 | case OMX_IndexParamVideoWmv: | |
1248 | { | |
1249 | OMX_VIDEO_PARAM_WMVTYPE *pDstWmvParam = NULL; | |
1250 | OMX_VIDEO_PARAM_WMVTYPE *pSrcWmvParam = (OMX_VIDEO_PARAM_WMVTYPE *)pComponentParameterStructure; | |
1251 | EXYNOS_WMVDEC_HANDLE *pWmvDec = NULL; | |
1252 | ret = Exynos_OMX_Check_SizeVersion(pSrcWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); | |
1253 | if (ret != OMX_ErrorNone) { | |
1254 | goto EXIT; | |
1255 | } | |
1256 | ||
1257 | if (pSrcWmvParam->nPortIndex > OUTPUT_PORT_INDEX) { | |
1258 | ret = OMX_ErrorBadPortIndex; | |
1259 | goto EXIT; | |
1260 | } | |
1261 | ||
1262 | pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1263 | pDstWmvParam = &pWmvDec->WmvComponent[pSrcWmvParam->nPortIndex]; | |
1264 | ||
1265 | Exynos_OSAL_Memcpy(pDstWmvParam, pSrcWmvParam, sizeof(OMX_VIDEO_PARAM_WMVTYPE)); | |
1266 | } | |
1267 | break; | |
1268 | case OMX_IndexParamStandardComponentRole: | |
1269 | { | |
1270 | OMX_PARAM_COMPONENTROLETYPE *pComponentRole = (OMX_PARAM_COMPONENTROLETYPE*)pComponentParameterStructure; | |
1271 | ||
1272 | ret = Exynos_OMX_Check_SizeVersion(pComponentRole, sizeof(OMX_PARAM_COMPONENTROLETYPE)); | |
1273 | if (ret != OMX_ErrorNone) { | |
1274 | goto EXIT; | |
1275 | } | |
1276 | ||
1277 | if ((pExynosComponent->currentState != OMX_StateLoaded) && (pExynosComponent->currentState != OMX_StateWaitForResources)) { | |
1278 | ret = OMX_ErrorIncorrectStateOperation; | |
1279 | goto EXIT; | |
1280 | } | |
1281 | ||
1282 | if (!Exynos_OSAL_Strcmp((char*)pComponentRole->cRole, EXYNOS_OMX_COMPONENT_WMV_DEC_ROLE)) { | |
1283 | pExynosComponent->pExynosPort[INPUT_PORT_INDEX].portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV; | |
1284 | } else { | |
1285 | ret = OMX_ErrorBadParameter; | |
1286 | goto EXIT; | |
1287 | } | |
1288 | } | |
1289 | break; | |
1290 | case OMX_IndexParamVideoErrorCorrection: | |
1291 | { | |
1292 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pSrcErrorCorrectionType = (OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *)pComponentParameterStructure; | |
1293 | OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE *pDstErrorCorrectionType = NULL; | |
1294 | EXYNOS_WMVDEC_HANDLE *pWmvDec = NULL; | |
1295 | ||
1296 | ret = Exynos_OMX_Check_SizeVersion(pSrcErrorCorrectionType, sizeof(OMX_VIDEO_PARAM_ERRORCORRECTIONTYPE)); | |
1297 | if (ret != OMX_ErrorNone) { | |
1298 | goto EXIT; | |
1299 | } | |
1300 | ||
1301 | if (pSrcErrorCorrectionType->nPortIndex != INPUT_PORT_INDEX) { | |
1302 | ret = OMX_ErrorBadPortIndex; | |
1303 | goto EXIT; | |
1304 | } | |
1305 | ||
1306 | pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1307 | pDstErrorCorrectionType = &pWmvDec->errorCorrectionType[INPUT_PORT_INDEX]; | |
1308 | ||
1309 | pDstErrorCorrectionType->bEnableHEC = pSrcErrorCorrectionType->bEnableHEC; | |
1310 | pDstErrorCorrectionType->bEnableResync = pSrcErrorCorrectionType->bEnableResync; | |
1311 | pDstErrorCorrectionType->nResynchMarkerSpacing = pSrcErrorCorrectionType->nResynchMarkerSpacing; | |
1312 | pDstErrorCorrectionType->bEnableDataPartitioning = pSrcErrorCorrectionType->bEnableDataPartitioning; | |
1313 | pDstErrorCorrectionType->bEnableRVLC = pSrcErrorCorrectionType->bEnableRVLC; | |
1314 | } | |
1315 | break; | |
1316 | default: | |
1317 | ret = Exynos_OMX_VideoDecodeSetParameter(hComponent, nIndex, pComponentParameterStructure); | |
1318 | break; | |
1319 | } | |
1320 | EXIT: | |
1321 | FunctionOut(); | |
1322 | ||
1323 | return ret; | |
1324 | } | |
1325 | ||
1326 | OMX_ERRORTYPE Exynos_WmvDec_GetConfig( | |
1327 | OMX_HANDLETYPE hComponent, | |
1328 | OMX_INDEXTYPE nIndex, | |
1329 | OMX_PTR pComponentConfigStructure) | |
1330 | { | |
1331 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1332 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1333 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1334 | ||
1335 | FunctionIn(); | |
1336 | ||
1337 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1338 | ret = OMX_ErrorBadParameter; | |
1339 | goto EXIT; | |
1340 | } | |
1341 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1342 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1343 | if (ret != OMX_ErrorNone) { | |
1344 | goto EXIT; | |
1345 | } | |
1346 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1347 | ret = OMX_ErrorBadParameter; | |
1348 | goto EXIT; | |
1349 | } | |
1350 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1351 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1352 | ret = OMX_ErrorInvalidState; | |
1353 | goto EXIT; | |
1354 | } | |
1355 | ||
1356 | switch (nIndex) { | |
1357 | default: | |
1358 | ret = Exynos_OMX_VideoDecodeGetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1359 | break; | |
1360 | } | |
1361 | ||
1362 | EXIT: | |
1363 | FunctionOut(); | |
1364 | ||
1365 | return ret; | |
1366 | } | |
1367 | ||
1368 | OMX_ERRORTYPE Exynos_WmvDec_SetConfig( | |
1369 | OMX_HANDLETYPE hComponent, | |
1370 | OMX_INDEXTYPE nIndex, | |
1371 | OMX_PTR pComponentConfigStructure) | |
1372 | { | |
1373 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1374 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1375 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1376 | ||
1377 | FunctionIn(); | |
1378 | ||
1379 | if (hComponent == NULL || pComponentConfigStructure == NULL) { | |
1380 | ret = OMX_ErrorBadParameter; | |
1381 | goto EXIT; | |
1382 | } | |
1383 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1384 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1385 | if (ret != OMX_ErrorNone) { | |
1386 | goto EXIT; | |
1387 | } | |
1388 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1389 | ret = OMX_ErrorBadParameter; | |
1390 | goto EXIT; | |
1391 | } | |
1392 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1393 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1394 | ret = OMX_ErrorInvalidState; | |
1395 | goto EXIT; | |
1396 | } | |
1397 | ||
1398 | switch (nIndex) { | |
1399 | default: | |
1400 | ret = Exynos_OMX_VideoDecodeSetConfig(hComponent, nIndex, pComponentConfigStructure); | |
1401 | break; | |
1402 | } | |
1403 | ||
1404 | EXIT: | |
1405 | FunctionOut(); | |
1406 | ||
1407 | return ret; | |
1408 | } | |
1409 | ||
1410 | OMX_ERRORTYPE Exynos_WmvDec_GetExtensionIndex( | |
1411 | OMX_IN OMX_HANDLETYPE hComponent, | |
1412 | OMX_IN OMX_STRING cParameterName, | |
1413 | OMX_OUT OMX_INDEXTYPE *pIndexType) | |
1414 | { | |
1415 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1416 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1417 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1418 | ||
1419 | FunctionIn(); | |
1420 | ||
1421 | if (hComponent == NULL) { | |
1422 | ret = OMX_ErrorBadParameter; | |
1423 | goto EXIT; | |
1424 | } | |
1425 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
1426 | ret = Exynos_OMX_Check_SizeVersion(pOMXComponent, sizeof(OMX_COMPONENTTYPE)); | |
1427 | if (ret != OMX_ErrorNone) { | |
1428 | goto EXIT; | |
1429 | } | |
1430 | if (pOMXComponent->pComponentPrivate == NULL) { | |
1431 | ret = OMX_ErrorBadParameter; | |
1432 | goto EXIT; | |
1433 | } | |
1434 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1435 | if ((cParameterName == NULL) || (pIndexType == NULL)) { | |
1436 | ret = OMX_ErrorBadParameter; | |
1437 | goto EXIT; | |
1438 | } | |
1439 | if (pExynosComponent->currentState == OMX_StateInvalid) { | |
1440 | ret = OMX_ErrorInvalidState; | |
1441 | goto EXIT; | |
1442 | } | |
1443 | ||
1444 | if (Exynos_OSAL_Strcmp(cParameterName, EXYNOS_INDEX_PARAM_ENABLE_THUMBNAIL) == 0) { | |
1445 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1446 | *pIndexType = OMX_IndexVendorThumbnailMode; | |
1447 | ret = OMX_ErrorNone; | |
1448 | } else { | |
1449 | ret = Exynos_OMX_VideoDecodeGetExtensionIndex(hComponent, cParameterName, pIndexType); | |
1450 | } | |
1451 | ||
1452 | EXIT: | |
1453 | FunctionOut(); | |
1454 | ||
1455 | return ret; | |
1456 | } | |
1457 | ||
1458 | OMX_ERRORTYPE Exynos_WmvDec_ComponentRoleEnum( | |
1459 | OMX_HANDLETYPE hComponent, | |
1460 | OMX_U8 *cRole, | |
1461 | OMX_U32 nIndex) | |
1462 | { | |
1463 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1464 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
1465 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
1466 | ||
1467 | FunctionIn(); | |
1468 | ||
1469 | if ((hComponent == NULL) || (cRole == NULL)) { | |
1470 | ret = OMX_ErrorBadParameter; | |
1471 | goto EXIT; | |
1472 | } | |
1473 | if (nIndex == (MAX_COMPONENT_ROLE_NUM-1)) { | |
1474 | Exynos_OSAL_Strcpy((char *)cRole, EXYNOS_OMX_COMPONENT_WMV_DEC_ROLE); | |
1475 | ret = OMX_ErrorNone; | |
1476 | } else { | |
1477 | ret = OMX_ErrorNoMore; | |
1478 | } | |
1479 | ||
1480 | EXIT: | |
1481 | FunctionOut(); | |
1482 | ||
1483 | return ret; | |
1484 | } | |
1485 | ||
1486 | /* MFC Init */ | |
1487 | OMX_ERRORTYPE Exynos_WmvDec_Init(OMX_COMPONENTTYPE *pOMXComponent) | |
1488 | { | |
1489 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1490 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1491 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1492 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1493 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1494 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)pVideoDec->hCodecHandle; | |
1495 | OMX_PTR hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1496 | ||
1497 | ExynosVideoDecOps *pDecOps = NULL; | |
1498 | ExynosVideoDecBufferOps *pInbufOps = NULL; | |
1499 | ExynosVideoDecBufferOps *pOutbufOps = NULL; | |
1500 | ||
1501 | CSC_METHOD csc_method = CSC_METHOD_SW; | |
1502 | int i, plane; | |
1503 | ||
1504 | FunctionIn(); | |
1505 | ||
1506 | pWmvDec->hMFCWmvHandle.bConfiguredMFCSrc = OMX_FALSE; | |
1507 | pWmvDec->hMFCWmvHandle.bConfiguredMFCDst = OMX_FALSE; | |
1508 | pExynosComponent->bUseFlagEOF = OMX_TRUE; | |
1509 | pExynosComponent->bSaveFlagEOS = OMX_FALSE; | |
e100a12d | 1510 | pExynosComponent->bBehaviorEOS = OMX_FALSE; |
9c5c94d6 SKR |
1511 | |
1512 | /* WMV Codec Open */ | |
1513 | ret = WmvCodecOpen(pWmvDec); | |
1514 | if (ret != OMX_ErrorNone) { | |
1515 | goto EXIT; | |
1516 | } | |
1517 | ||
1518 | pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1519 | pInbufOps = pWmvDec->hMFCWmvHandle.pInbufOps; | |
1520 | pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps; | |
1521 | ||
1522 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { | |
0641ae29 | 1523 | OMX_U32 nPlaneSize[MFC_INPUT_BUFFER_PLANE] = {DEFAULT_MFC_INPUT_BUFFER_SIZE}; |
9c5c94d6 SKR |
1524 | Exynos_OSAL_SemaphoreCreate(&pExynosInputPort->codecSemID); |
1525 | Exynos_OSAL_QueueCreate(&pExynosInputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
0641ae29 TK |
1526 | ret = Exynos_Allocate_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX, MFC_INPUT_BUFFER_NUM_MAX, nPlaneSize); |
1527 | if (ret != OMX_ErrorNone) | |
1528 | goto EXIT; | |
9c5c94d6 | 1529 | |
0641ae29 | 1530 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) |
9c5c94d6 | 1531 | Exynos_CodecBufferEnQueue(pExynosComponent, INPUT_PORT_INDEX, pVideoDec->pMFCDecInputBuffer[i]); |
9c5c94d6 SKR |
1532 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { |
1533 | /*************/ | |
1534 | /* TBD */ | |
1535 | /*************/ | |
1536 | /* Does not require any actions. */ | |
1537 | } | |
1538 | ||
1539 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { | |
1540 | Exynos_OSAL_SemaphoreCreate(&pExynosOutputPort->codecSemID); | |
1541 | Exynos_OSAL_QueueCreate(&pExynosOutputPort->codecBufferQ, MAX_QUEUE_ELEMENTS); | |
1542 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { | |
1543 | /*************/ | |
1544 | /* TBD */ | |
1545 | /*************/ | |
1546 | /* Does not require any actions. */ | |
1547 | } | |
1548 | ||
1549 | pWmvDec->bSourceStart = OMX_FALSE; | |
1550 | Exynos_OSAL_SignalCreate(&pWmvDec->hSourceStartEvent); | |
1551 | pWmvDec->bDestinationStart = OMX_FALSE; | |
1552 | Exynos_OSAL_SignalCreate(&pWmvDec->hDestinationStartEvent); | |
1553 | ||
1554 | Exynos_OSAL_Memset(pExynosComponent->timeStamp, -19771003, sizeof(OMX_TICKS) * MAX_TIMESTAMP); | |
1555 | Exynos_OSAL_Memset(pExynosComponent->nFlags, 0, sizeof(OMX_U32) * MAX_FLAGS); | |
1556 | pWmvDec->hMFCWmvHandle.indexTimestamp = 0; | |
1557 | pWmvDec->hMFCWmvHandle.outputIndexTimestamp = 0; | |
1558 | /* Default WMV codec format is set as VC1*/ | |
1559 | pWmvDec->hMFCWmvHandle.wmvFormat = WMV_FORMAT_VC1; | |
1560 | ||
1561 | pExynosComponent->getAllDelayBuffer = OMX_FALSE; | |
1562 | ||
a80c3bc5 TK |
1563 | #ifdef USE_CSC_HW |
1564 | csc_method = CSC_METHOD_HW; | |
9c5c94d6 SKR |
1565 | #endif |
1566 | pVideoDec->csc_handle = csc_init(csc_method); | |
1567 | if (pVideoDec->csc_handle == NULL) { | |
1568 | ret = OMX_ErrorInsufficientResources; | |
1569 | goto EXIT; | |
1570 | } | |
1571 | pVideoDec->csc_set_format = OMX_FALSE; | |
1572 | ||
1573 | EXIT: | |
1574 | FunctionOut(); | |
1575 | ||
1576 | return ret; | |
1577 | } | |
1578 | ||
1579 | /* MFC Terminate */ | |
1580 | OMX_ERRORTYPE Exynos_WmvDec_Terminate(OMX_COMPONENTTYPE *pOMXComponent) | |
1581 | { | |
1582 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1583 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1584 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1585 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1586 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1587 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1588 | OMX_PTR hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1589 | ||
1590 | ExynosVideoDecOps *pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1591 | ExynosVideoDecBufferOps *pInbufOps = pWmvDec->hMFCWmvHandle.pInbufOps; | |
1592 | ExynosVideoDecBufferOps *pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps; | |
1593 | ||
1594 | int i, plane; | |
1595 | ||
1596 | FunctionIn(); | |
1597 | ||
1598 | if (pVideoDec->csc_handle != NULL) { | |
1599 | csc_deinit(pVideoDec->csc_handle); | |
1600 | pVideoDec->csc_handle = NULL; | |
1601 | } | |
1602 | ||
1603 | Exynos_OSAL_SignalTerminate(pWmvDec->hDestinationStartEvent); | |
1604 | pWmvDec->hDestinationStartEvent = NULL; | |
1605 | pWmvDec->bDestinationStart = OMX_FALSE; | |
1606 | Exynos_OSAL_SignalTerminate(pWmvDec->hSourceStartEvent); | |
1607 | pWmvDec->hSourceStartEvent = NULL; | |
1608 | pWmvDec->bSourceStart = OMX_FALSE; | |
1609 | ||
1610 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { | |
0641ae29 | 1611 | Exynos_Free_CodecBuffers(pOMXComponent, OUTPUT_PORT_INDEX); |
9c5c94d6 SKR |
1612 | Exynos_OSAL_QueueTerminate(&pExynosOutputPort->codecBufferQ); |
1613 | Exynos_OSAL_SemaphoreTerminate(pExynosOutputPort->codecSemID); | |
1614 | } else if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { | |
1615 | /*************/ | |
1616 | /* TBD */ | |
1617 | /*************/ | |
1618 | /* Does not require any actions. */ | |
1619 | } | |
1620 | ||
1621 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { | |
0641ae29 | 1622 | Exynos_Free_CodecBuffers(pOMXComponent, INPUT_PORT_INDEX); |
9c5c94d6 SKR |
1623 | Exynos_OSAL_QueueTerminate(&pExynosInputPort->codecBufferQ); |
1624 | Exynos_OSAL_SemaphoreTerminate(pExynosInputPort->codecSemID); | |
1625 | } else if (pExynosInputPort->bufferProcessType & BUFFER_SHARE) { | |
1626 | /*************/ | |
1627 | /* TBD */ | |
1628 | /*************/ | |
1629 | /* Does not require any actions. */ | |
1630 | } | |
1631 | WmvCodecClose(pWmvDec); | |
1632 | ||
e100a12d SK |
1633 | Exynos_ResetAllPortConfig(pOMXComponent); |
1634 | ||
9c5c94d6 SKR |
1635 | EXIT: |
1636 | FunctionOut(); | |
1637 | ||
1638 | return ret; | |
1639 | } | |
1640 | ||
1641 | OMX_ERRORTYPE Exynos_WmvDec_SrcIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
1642 | { | |
1643 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1644 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1645 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1646 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1647 | void *hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1648 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1649 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1650 | OMX_U32 oneFrameSize = pSrcInputData->dataLen; | |
1651 | OMX_BOOL bStartCode = OMX_FALSE; | |
1652 | ExynosVideoDecOps *pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1653 | ExynosVideoDecBufferOps *pInbufOps = pWmvDec->hMFCWmvHandle.pInbufOps; | |
1654 | ExynosVideoDecBufferOps *pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps; | |
1655 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1656 | int i; | |
1657 | ||
1658 | FunctionIn(); | |
1659 | ||
1660 | if (pWmvDec->hMFCWmvHandle.bConfiguredMFCSrc == OMX_FALSE) { | |
1661 | ret = WmvCodecSrcSetup(pOMXComponent, pSrcInputData); | |
1662 | goto EXIT; | |
1663 | } | |
1664 | if (pWmvDec->hMFCWmvHandle.bConfiguredMFCDst == OMX_FALSE) { | |
1665 | ret = WmvCodecDstSetup(pOMXComponent); | |
1666 | } | |
1667 | ||
1668 | bStartCode = Check_Stream_PrefixCode(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat); | |
09ccc01b TK |
1669 | if ((bStartCode == OMX_FALSE) && |
1670 | ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) != OMX_BUFFERFLAG_EOS)) { | |
9c5c94d6 SKR |
1671 | if (pSrcInputData->allocSize < oneFrameSize+4) { |
1672 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can't attach startcode due to lack of buffer space"); | |
1673 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1674 | goto EXIT; | |
1675 | } | |
1676 | ||
1677 | bStartCode = Make_Stream_StartCode(pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, &oneFrameSize, pWmvDec->hMFCWmvHandle.wmvFormat); | |
1678 | if (bStartCode == OMX_FALSE) { | |
1679 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Fail to Make Stream Start Code"); | |
1680 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1681 | goto EXIT; | |
1682 | } | |
1683 | } | |
1684 | ||
1685 | if ((bStartCode == OMX_TRUE) || ((pSrcInputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)){ | |
1686 | pExynosComponent->timeStamp[pWmvDec->hMFCWmvHandle.indexTimestamp] = pSrcInputData->timeStamp; | |
1687 | pExynosComponent->nFlags[pWmvDec->hMFCWmvHandle.indexTimestamp] = pSrcInputData->nFlags; | |
1688 | 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); | |
1689 | pDecOps->Set_FrameTag(hMFCHandle, pWmvDec->hMFCWmvHandle.indexTimestamp); | |
1690 | pWmvDec->hMFCWmvHandle.indexTimestamp++; | |
1691 | pWmvDec->hMFCWmvHandle.indexTimestamp %= MAX_TIMESTAMP; | |
1692 | ||
1693 | /* queue work for input buffer */ | |
1694 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "oneFrameSize: %d, bufferHeader: 0x%x, dataBuffer: 0x%x", oneFrameSize, pSrcInputData->bufferHeader, pSrcInputData->buffer.singlePlaneBuffer.dataBuffer); | |
1695 | codecReturn = pInbufOps->Enqueue(hMFCHandle, (unsigned char **)&pSrcInputData->buffer.singlePlaneBuffer.dataBuffer, | |
1696 | (unsigned int *)&oneFrameSize, MFC_INPUT_BUFFER_PLANE, pSrcInputData->bufferHeader); | |
1697 | if (codecReturn != VIDEO_ERROR_NONE) { | |
1698 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1699 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); | |
1700 | goto EXIT; | |
1701 | } | |
1702 | WmvCodecStart(pOMXComponent, INPUT_PORT_INDEX); | |
1703 | if (pWmvDec->bSourceStart == OMX_FALSE) { | |
1704 | pWmvDec->bSourceStart = OMX_TRUE; | |
1705 | Exynos_OSAL_SignalSet(pWmvDec->hSourceStartEvent); | |
1706 | Exynos_OSAL_SleepMillisec(0); | |
1707 | } | |
1708 | if (pWmvDec->bDestinationStart == OMX_FALSE) { | |
1709 | pWmvDec->bDestinationStart = OMX_TRUE; | |
1710 | Exynos_OSAL_SignalSet(pWmvDec->hDestinationStartEvent); | |
1711 | Exynos_OSAL_SleepMillisec(0); | |
1712 | } | |
1713 | } | |
1714 | ||
1715 | ret = OMX_ErrorNone; | |
1716 | ||
1717 | EXIT: | |
1718 | FunctionOut(); | |
1719 | ||
1720 | return ret; | |
1721 | } | |
1722 | ||
1723 | OMX_ERRORTYPE Exynos_WmvDec_SrcOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
1724 | { | |
1725 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1726 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1727 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1728 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1729 | void *hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1730 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1731 | ExynosVideoDecOps *pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1732 | ExynosVideoDecBufferOps *pInbufOps = pWmvDec->hMFCWmvHandle.pInbufOps; | |
1733 | ExynosVideoBuffer *pVideoBuffer; | |
1734 | ||
1735 | FunctionIn(); | |
1736 | ||
1737 | pVideoBuffer = pInbufOps->Dequeue(hMFCHandle); | |
1738 | ||
1739 | pSrcOutputData->dataLen = 0; | |
1740 | pSrcOutputData->usedDataLen = 0; | |
1741 | pSrcOutputData->remainDataLen = 0; | |
1742 | pSrcOutputData->nFlags = 0; | |
1743 | pSrcOutputData->timeStamp = 0; | |
1744 | ||
1745 | if (pVideoBuffer == NULL) { | |
1746 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = NULL; | |
1747 | pSrcOutputData->allocSize = 0; | |
1748 | pSrcOutputData->pPrivate = NULL; | |
1749 | pSrcOutputData->bufferHeader = NULL; | |
1750 | } else { | |
1751 | pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer = pVideoBuffer->planes[0].addr; | |
1752 | pSrcOutputData->buffer.singlePlaneBuffer.fd = pVideoBuffer->planes[0].fd; | |
1753 | pSrcOutputData->allocSize = pVideoBuffer->planes[0].allocSize; | |
1754 | ||
1755 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { | |
9c39c5ff TK |
1756 | int i; |
1757 | for (i = 0; i < MFC_INPUT_BUFFER_NUM_MAX; i++) { | |
1758 | if (pSrcOutputData->buffer.singlePlaneBuffer.dataBuffer == | |
1759 | pVideoDec->pMFCDecInputBuffer[i]->pVirAddr[0]) { | |
1760 | pVideoDec->pMFCDecInputBuffer[i]->dataSize = 0; | |
1761 | pSrcOutputData->pPrivate = pVideoDec->pMFCDecInputBuffer[i]; | |
1762 | break; | |
9c5c94d6 | 1763 | } |
9c5c94d6 | 1764 | } |
9c39c5ff TK |
1765 | |
1766 | if (i >= MFC_INPUT_BUFFER_NUM_MAX) { | |
1767 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); | |
1768 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1769 | goto EXIT; | |
1770 | } | |
9c5c94d6 SKR |
1771 | } |
1772 | ||
1773 | /* For Share Buffer */ | |
1774 | pSrcOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE*)pVideoBuffer->pPrivate; | |
1775 | } | |
1776 | ||
1777 | ret = OMX_ErrorNone; | |
1778 | ||
1779 | EXIT: | |
1780 | FunctionOut(); | |
1781 | ||
1782 | return ret; | |
1783 | } | |
1784 | ||
1785 | OMX_ERRORTYPE Exynos_WmvDec_DstIn(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
1786 | { | |
1787 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1788 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1789 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1790 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1791 | void *hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1792 | ExynosVideoDecOps *pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1793 | ExynosVideoDecBufferOps *pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps; | |
1794 | OMX_U32 dataLen[2] = {0,}; | |
1795 | ExynosVideoErrorType codecReturn = VIDEO_ERROR_NONE; | |
1796 | ||
1797 | FunctionIn(); | |
1798 | ||
1799 | if (pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0] == NULL) { | |
1800 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Failed to find input buffer"); | |
1801 | ret = OMX_ErrorBadParameter; | |
1802 | goto EXIT; | |
1803 | } | |
1804 | ||
1805 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "%s : %d => ADDR[0]: 0x%x, ADDR[1]: 0x%x", __FUNCTION__, __LINE__, | |
1806 | pDstInputData->buffer.multiPlaneBuffer.dataBuffer[0], | |
1807 | pDstInputData->buffer.multiPlaneBuffer.dataBuffer[1]); | |
1808 | ||
1809 | codecReturn = pOutbufOps->Enqueue(hMFCHandle, (unsigned char **)pDstInputData->buffer.multiPlaneBuffer.dataBuffer, | |
1810 | (unsigned int *)dataLen, MFC_OUTPUT_BUFFER_PLANE, pDstInputData->bufferHeader); | |
1811 | ||
1812 | if (codecReturn != VIDEO_ERROR_NONE) { | |
1813 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "%s : %d", __FUNCTION__, __LINE__); | |
1814 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1815 | goto EXIT; | |
1816 | } | |
1817 | WmvCodecStart(pOMXComponent, OUTPUT_PORT_INDEX); | |
1818 | ||
1819 | ret = OMX_ErrorNone; | |
1820 | ||
1821 | EXIT: | |
1822 | FunctionOut(); | |
1823 | ||
1824 | return ret; | |
1825 | } | |
1826 | ||
1827 | OMX_ERRORTYPE Exynos_WmvDec_DstOut(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
1828 | { | |
1829 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1830 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1831 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
1832 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1833 | void *hMFCHandle = pWmvDec->hMFCWmvHandle.hMFCHandle; | |
1834 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1835 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
1836 | ExynosVideoDecOps *pDecOps = pWmvDec->hMFCWmvHandle.pDecOps; | |
1837 | ExynosVideoDecBufferOps *pOutbufOps = pWmvDec->hMFCWmvHandle.pOutbufOps; | |
1838 | ExynosVideoBuffer *pVideoBuffer = NULL; | |
1839 | ExynosVideoFrameStatusType displayStatus = VIDEO_FRAME_STATUS_UNKNOWN; | |
1840 | ExynosVideoGeometry *bufferGeometry; | |
1841 | DECODE_CODEC_EXTRA_BUFFERINFO *pBufferInfo = NULL; | |
1842 | OMX_S32 indexTimestamp = 0; | |
1843 | int plane; | |
1844 | ||
1845 | FunctionIn(); | |
1846 | ||
1847 | if (pWmvDec->bDestinationStart == OMX_FALSE) { | |
1848 | ret = OMX_ErrorNone; | |
1849 | goto EXIT; | |
1850 | } | |
1851 | ||
1852 | while (1) { | |
1853 | if ((pVideoBuffer = pOutbufOps->Dequeue(hMFCHandle)) == NULL) { | |
1854 | ret = OMX_ErrorNone; | |
1855 | goto EXIT; | |
1856 | } | |
1857 | displayStatus = pVideoBuffer->displayStatus; | |
1858 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus: 0x%x", displayStatus); | |
1859 | ||
1860 | if ((displayStatus == VIDEO_FRAME_STATUS_DISPLAY_DECODING) || | |
1861 | (displayStatus == VIDEO_FRAME_STATUS_DISPLAY_ONLY) || | |
1862 | (displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
405399e5 | 1863 | (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) || |
9c5c94d6 SKR |
1864 | (CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { |
1865 | ret = OMX_ErrorNone; | |
1866 | break; | |
1867 | } | |
1868 | } | |
1869 | ||
1870 | pWmvDec->hMFCWmvHandle.outputIndexTimestamp++; | |
1871 | pWmvDec->hMFCWmvHandle.outputIndexTimestamp %= MAX_TIMESTAMP; | |
1872 | ||
1873 | pDstOutputData->allocSize = pDstOutputData->dataLen = 0; | |
1874 | for (plane = 0; plane < MFC_OUTPUT_BUFFER_PLANE; plane++) { | |
1875 | pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[plane] = pVideoBuffer->planes[plane].addr; | |
1876 | pDstOutputData->buffer.multiPlaneBuffer.fd[plane] = pVideoBuffer->planes[plane].fd; | |
1877 | pDstOutputData->allocSize += pVideoBuffer->planes[plane].allocSize; | |
1878 | pDstOutputData->dataLen += pVideoBuffer->planes[plane].dataSize; | |
1879 | } | |
1880 | pDstOutputData->usedDataLen = 0; | |
1881 | pDstOutputData->pPrivate = pVideoBuffer; | |
e90eb9e8 TK |
1882 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { |
1883 | int i = 0; | |
1884 | pDstOutputData->pPrivate = NULL; | |
1885 | for (i = 0; i < MFC_OUTPUT_BUFFER_NUM_MAX; i++) { | |
1886 | if (pDstOutputData->buffer.multiPlaneBuffer.dataBuffer[0] == | |
1887 | pVideoDec->pMFCDecOutputBuffer[i]->pVirAddr[0]) { | |
1888 | pDstOutputData->pPrivate = pVideoDec->pMFCDecOutputBuffer[i]; | |
1889 | break; | |
1890 | } | |
1891 | } | |
1892 | ||
1893 | if (pDstOutputData->pPrivate == NULL) { | |
1894 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "Can not find buffer"); | |
1895 | ret = (OMX_ERRORTYPE)OMX_ErrorCodecDecode; | |
1896 | goto EXIT; | |
1897 | } | |
1898 | } | |
1899 | ||
9c5c94d6 SKR |
1900 | /* For Share Buffer */ |
1901 | pDstOutputData->bufferHeader = (OMX_BUFFERHEADERTYPE *)pVideoBuffer->pPrivate; | |
1902 | ||
1903 | pBufferInfo = (DECODE_CODEC_EXTRA_BUFFERINFO *)pDstOutputData->extInfo; | |
1904 | bufferGeometry = &pWmvDec->hMFCWmvHandle.codecOutbufConf; | |
1905 | pBufferInfo->imageWidth = bufferGeometry->nFrameWidth; | |
1906 | pBufferInfo->imageHeight = bufferGeometry->nFrameHeight; | |
1907 | switch (bufferGeometry->eColorFormat) { | |
1908 | case VIDEO_COLORFORMAT_NV12: | |
1909 | pBufferInfo->ColorFormat = OMX_COLOR_FormatYUV420SemiPlanar; | |
1910 | break; | |
1911 | case VIDEO_COLORFORMAT_NV12_TILED: | |
1912 | default: | |
1913 | pBufferInfo->ColorFormat = OMX_SEC_COLOR_FormatNV12Tiled; | |
1914 | break; | |
1915 | } | |
1916 | ||
1917 | indexTimestamp = pDecOps->Get_FrameTag(hMFCHandle); | |
1918 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "out indexTimestamp: %d", indexTimestamp); | |
1919 | if ((indexTimestamp < 0) || (indexTimestamp >= MAX_TIMESTAMP)) { | |
1920 | if ((pExynosComponent->checkTimeStamp.needSetStartTimeStamp != OMX_TRUE) && | |
1921 | (pExynosComponent->checkTimeStamp.needCheckStartTimeStamp != OMX_TRUE)) { | |
f53da333 SK |
1922 | if (indexTimestamp == INDEX_AFTER_EOS) { |
1923 | pDstOutputData->timeStamp = 0x00; | |
1924 | pDstOutputData->nFlags = 0x00; | |
1925 | } else { | |
1926 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[pWmvDec->hMFCWmvHandle.outputIndexTimestamp]; | |
1927 | pDstOutputData->nFlags = pExynosComponent->nFlags[pWmvDec->hMFCWmvHandle.outputIndexTimestamp]; | |
1928 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "missing out indexTimestamp: %d", indexTimestamp); | |
1929 | } | |
9c5c94d6 SKR |
1930 | } else { |
1931 | pDstOutputData->timeStamp = 0x00; | |
1932 | pDstOutputData->nFlags = 0x00; | |
1933 | } | |
1934 | } else { | |
1935 | /* For timestamp correction. if mfc support frametype detect */ | |
1936 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "disp_pic_frame_type: %d", pVideoBuffer->frameType); | |
c70316c7 JY |
1937 | |
1938 | /* NEED TIMESTAMP REORDER */ | |
1939 | if (pVideoDec->bDTSMode == OMX_TRUE) { | |
1940 | if ((pVideoBuffer->frameType == VIDEO_FRAME_I) || | |
1941 | ((pVideoBuffer->frameType == VIDEO_FRAME_OTHERS) && | |
1942 | ((pExynosComponent->nFlags[indexTimestamp] & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS))) | |
1943 | pWmvDec->hMFCWmvHandle.outputIndexTimestamp = indexTimestamp; | |
1944 | else | |
1945 | indexTimestamp = pWmvDec->hMFCWmvHandle.outputIndexTimestamp; | |
9c5c94d6 | 1946 | } |
c70316c7 | 1947 | |
9c5c94d6 SKR |
1948 | pDstOutputData->timeStamp = pExynosComponent->timeStamp[indexTimestamp]; |
1949 | pDstOutputData->nFlags = pExynosComponent->nFlags[indexTimestamp]; | |
c70316c7 | 1950 | |
9c5c94d6 SKR |
1951 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "timestamp %lld us (%.2f secs), indexTimestamp: %d, nFlags: 0x%x", pDstOutputData->timeStamp, pDstOutputData->timeStamp / 1E6, indexTimestamp, pDstOutputData->nFlags); |
1952 | } | |
1953 | ||
1954 | if ((displayStatus == VIDEO_FRAME_STATUS_CHANGE_RESOL) || | |
405399e5 | 1955 | (displayStatus == VIDEO_FRAME_STATUS_DECODING_FINISHED) || |
9c5c94d6 SKR |
1956 | ((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS)) { |
1957 | Exynos_OSAL_Log(EXYNOS_LOG_TRACE, "displayStatus:%d, nFlags0x%x", displayStatus, pDstOutputData->nFlags); | |
1958 | pDstOutputData->remainDataLen = 0; | |
e100a12d SK |
1959 | |
1960 | if (((pDstOutputData->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS) && | |
1961 | (pExynosComponent->bBehaviorEOS == OMX_TRUE)) { | |
1962 | pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2; | |
1963 | pExynosComponent->bBehaviorEOS = OMX_FALSE; | |
1964 | } | |
9c5c94d6 SKR |
1965 | } else { |
1966 | pDstOutputData->remainDataLen = bufferGeometry->nFrameWidth * bufferGeometry->nFrameHeight * 3 / 2; | |
1967 | } | |
1968 | ||
1969 | ret = OMX_ErrorNone; | |
1970 | ||
1971 | EXIT: | |
1972 | FunctionOut(); | |
1973 | ||
1974 | return ret; | |
1975 | } | |
1976 | ||
1977 | OMX_ERRORTYPE Exynos_WmvDec_srcInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcInputData) | |
1978 | { | |
1979 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
1980 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
1981 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
1982 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
1983 | ||
1984 | FunctionIn(); | |
1985 | ||
1986 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
1987 | ret = OMX_ErrorNone; | |
1988 | goto EXIT; | |
1989 | } | |
1990 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
1991 | ret = OMX_ErrorNone; | |
1992 | goto EXIT; | |
1993 | } | |
1994 | ||
1995 | ret = Exynos_WmvDec_SrcIn(pOMXComponent, pSrcInputData); | |
1996 | if ((ret != OMX_ErrorNone) && (ret != OMX_ErrorInputDataDecodeYet)) { | |
1997 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
1998 | pExynosComponent->callbackData, | |
1999 | OMX_EventError, ret, 0, NULL); | |
2000 | } | |
2001 | ||
2002 | EXIT: | |
2003 | FunctionOut(); | |
2004 | ||
2005 | return ret; | |
2006 | } | |
2007 | ||
2008 | OMX_ERRORTYPE Exynos_WmvDec_srcOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pSrcOutputData) | |
2009 | { | |
2010 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2011 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2012 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2013 | EXYNOS_OMX_BASEPORT *pExynosInputPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2014 | ||
2015 | FunctionIn(); | |
2016 | ||
2017 | if ((!CHECK_PORT_ENABLED(pExynosInputPort)) || (!CHECK_PORT_POPULATED(pExynosInputPort))) { | |
2018 | ret = OMX_ErrorNone; | |
2019 | goto EXIT; | |
2020 | } | |
2021 | ||
2022 | if (pExynosInputPort->bufferProcessType & BUFFER_COPY) { | |
2023 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, INPUT_PORT_INDEX)) { | |
2024 | ret = OMX_ErrorNone; | |
2025 | goto EXIT; | |
2026 | } | |
2027 | } | |
2028 | if ((pWmvDec->bSourceStart == OMX_FALSE) && | |
2029 | (!CHECK_PORT_BEING_FLUSHED(pExynosInputPort))) { | |
2030 | Exynos_OSAL_SignalWait(pWmvDec->hSourceStartEvent, DEF_MAX_WAIT_TIME); | |
2031 | Exynos_OSAL_SignalReset(pWmvDec->hSourceStartEvent); | |
2032 | } | |
2033 | ||
2034 | ret = Exynos_WmvDec_SrcOut(pOMXComponent, pSrcOutputData); | |
2035 | if ((ret != OMX_ErrorNone) && | |
2036 | (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2037 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2038 | pExynosComponent->callbackData, | |
2039 | OMX_EventError, ret, 0, NULL); | |
2040 | } | |
2041 | ||
2042 | EXIT: | |
2043 | FunctionOut(); | |
2044 | ||
2045 | return ret; | |
2046 | } | |
2047 | ||
2048 | OMX_ERRORTYPE Exynos_WmvDec_dstInputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstInputData) | |
2049 | { | |
2050 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2051 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2052 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2053 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2054 | ||
2055 | FunctionIn(); | |
2056 | ||
2057 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2058 | ret = OMX_ErrorNone; | |
2059 | goto EXIT; | |
2060 | } | |
2061 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2062 | ret = OMX_ErrorNone; | |
2063 | goto EXIT; | |
2064 | } | |
2065 | if (pExynosOutputPort->bufferProcessType & BUFFER_SHARE) { | |
2066 | if ((pWmvDec->bDestinationStart == OMX_FALSE) && | |
2067 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2068 | Exynos_OSAL_SignalWait(pWmvDec->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2069 | Exynos_OSAL_SignalReset(pWmvDec->hDestinationStartEvent); | |
2070 | } | |
2071 | } | |
2072 | if (pWmvDec->hMFCWmvHandle.bConfiguredMFCDst == OMX_TRUE) { | |
2073 | ret = Exynos_WmvDec_DstIn(pOMXComponent, pDstInputData); | |
2074 | if (ret != OMX_ErrorNone) { | |
2075 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2076 | pExynosComponent->callbackData, | |
2077 | OMX_EventError, ret, 0, NULL); | |
2078 | } | |
2079 | } | |
2080 | ||
2081 | EXIT: | |
2082 | FunctionOut(); | |
2083 | ||
2084 | return ret; | |
2085 | } | |
2086 | ||
2087 | OMX_ERRORTYPE Exynos_WmvDec_dstOutputBufferProcess(OMX_COMPONENTTYPE *pOMXComponent, EXYNOS_OMX_DATA *pDstOutputData) | |
2088 | { | |
2089 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2090 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2091 | EXYNOS_WMVDEC_HANDLE *pWmvDec = (EXYNOS_WMVDEC_HANDLE *)((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle; | |
2092 | EXYNOS_OMX_BASEPORT *pExynosOutputPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2093 | ||
2094 | FunctionIn(); | |
2095 | ||
2096 | if ((!CHECK_PORT_ENABLED(pExynosOutputPort)) || (!CHECK_PORT_POPULATED(pExynosOutputPort))) { | |
2097 | ret = OMX_ErrorNone; | |
2098 | goto EXIT; | |
2099 | } | |
2100 | if (OMX_FALSE == Exynos_Check_BufferProcess_State(pExynosComponent, OUTPUT_PORT_INDEX)) { | |
2101 | ret = OMX_ErrorNone; | |
2102 | goto EXIT; | |
2103 | } | |
2104 | ||
2105 | if (pExynosOutputPort->bufferProcessType & BUFFER_COPY) { | |
2106 | if ((pWmvDec->bDestinationStart == OMX_FALSE) && | |
2107 | (!CHECK_PORT_BEING_FLUSHED(pExynosOutputPort))) { | |
2108 | Exynos_OSAL_SignalWait(pWmvDec->hDestinationStartEvent, DEF_MAX_WAIT_TIME); | |
2109 | Exynos_OSAL_SignalReset(pWmvDec->hDestinationStartEvent); | |
2110 | } | |
2111 | } | |
2112 | ret = Exynos_WmvDec_DstOut(pOMXComponent, pDstOutputData); | |
2113 | if ((ret != OMX_ErrorNone) && | |
2114 | (pExynosComponent->currentState == OMX_StateExecuting)) { | |
2115 | pExynosComponent->pCallbacks->EventHandler((OMX_HANDLETYPE)pOMXComponent, | |
2116 | pExynosComponent->callbackData, | |
2117 | OMX_EventError, ret, 0, NULL); | |
2118 | } | |
2119 | ||
2120 | EXIT: | |
2121 | FunctionOut(); | |
2122 | ||
2123 | return ret; | |
2124 | } | |
2125 | ||
2126 | OSCL_EXPORT_REF OMX_ERRORTYPE Exynos_OMX_ComponentInit( | |
2127 | OMX_HANDLETYPE hComponent, | |
2128 | OMX_STRING componentName) | |
2129 | { | |
2130 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2131 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2132 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2133 | EXYNOS_OMX_BASEPORT *pExynosPort = NULL; | |
2134 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
2135 | EXYNOS_WMVDEC_HANDLE *pWmvDec = NULL; | |
2136 | OMX_S32 wmvFormat = WMV_FORMAT_UNKNOWN; | |
2137 | int i = 0; | |
2138 | ||
2139 | FunctionIn(); | |
2140 | ||
2141 | if ((hComponent == NULL) || (componentName == NULL)) { | |
2142 | ret = OMX_ErrorBadParameter; | |
2143 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, Line:%d", __LINE__); | |
2144 | goto EXIT; | |
2145 | } | |
2146 | if (Exynos_OSAL_Strcmp(EXYNOS_OMX_COMPONENT_WMV_DEC, componentName) != 0) { | |
2147 | ret = OMX_ErrorBadParameter; | |
2148 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorBadParameter, componentName:%s, Line:%d", componentName, __LINE__); | |
2149 | goto EXIT; | |
2150 | } | |
2151 | ||
2152 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2153 | ret = Exynos_OMX_VideoDecodeComponentInit(pOMXComponent); | |
2154 | if (ret != OMX_ErrorNone) { | |
2155 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_Error, Line:%d", __LINE__); | |
2156 | goto EXIT; | |
2157 | } | |
2158 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2159 | pExynosComponent->codecType = HW_VIDEO_DEC_CODEC; | |
2160 | ||
2161 | pExynosComponent->componentName = (OMX_STRING)Exynos_OSAL_Malloc(MAX_OMX_COMPONENT_NAME_SIZE); | |
2162 | if (pExynosComponent->componentName == NULL) { | |
2163 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2164 | ret = OMX_ErrorInsufficientResources; | |
2165 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2166 | goto EXIT; | |
2167 | } | |
2168 | Exynos_OSAL_Memset(pExynosComponent->componentName, 0, MAX_OMX_COMPONENT_NAME_SIZE); | |
2169 | ||
2170 | pWmvDec = Exynos_OSAL_Malloc(sizeof(EXYNOS_WMVDEC_HANDLE)); | |
2171 | if (pWmvDec == NULL) { | |
2172 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2173 | ret = OMX_ErrorInsufficientResources; | |
2174 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2175 | goto EXIT; | |
2176 | } | |
2177 | Exynos_OSAL_Memset(pWmvDec, 0, sizeof(EXYNOS_WMVDEC_HANDLE)); | |
2178 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2179 | pVideoDec->hCodecHandle = (OMX_HANDLETYPE)pWmvDec; | |
2180 | pWmvDec->hMFCWmvHandle.wmvFormat = wmvFormat; | |
2181 | ||
2182 | Exynos_OSAL_Strcpy(pExynosComponent->componentName, EXYNOS_OMX_COMPONENT_WMV_DEC); | |
2183 | ||
2184 | /* Set componentVersion */ | |
2185 | pExynosComponent->componentVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2186 | pExynosComponent->componentVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2187 | pExynosComponent->componentVersion.s.nRevision = REVISION_NUMBER; | |
2188 | pExynosComponent->componentVersion.s.nStep = STEP_NUMBER; | |
2189 | /* Set specVersion */ | |
2190 | pExynosComponent->specVersion.s.nVersionMajor = VERSIONMAJOR_NUMBER; | |
2191 | pExynosComponent->specVersion.s.nVersionMinor = VERSIONMINOR_NUMBER; | |
2192 | pExynosComponent->specVersion.s.nRevision = REVISION_NUMBER; | |
2193 | pExynosComponent->specVersion.s.nStep = STEP_NUMBER; | |
2194 | ||
2195 | /* Input port */ | |
2196 | pExynosPort = &pExynosComponent->pExynosPort[INPUT_PORT_INDEX]; | |
2197 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2198 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2199 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2200 | pExynosPort->portDefinition.format.video.nSliceHeight = 0; | |
2201 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_INPUT_BUFFER_SIZE; | |
2202 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingWMV; | |
2203 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2204 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "video/wmv"); | |
2205 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2206 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2207 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatUnused; | |
2208 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2209 | //pExynosPort->bufferProcessType = BUFFER_SHARE; | |
2210 | pExynosPort->bufferProcessType = BUFFER_COPY; | |
2211 | pExynosPort->portWayType = WAY2_PORT; | |
2212 | ||
2213 | /* Output port */ | |
2214 | pExynosPort = &pExynosComponent->pExynosPort[OUTPUT_PORT_INDEX]; | |
2215 | pExynosPort->portDefinition.format.video.nFrameWidth = DEFAULT_FRAME_WIDTH; | |
2216 | pExynosPort->portDefinition.format.video.nFrameHeight= DEFAULT_FRAME_HEIGHT; | |
2217 | pExynosPort->portDefinition.format.video.nStride = 0; /*DEFAULT_FRAME_WIDTH;*/ | |
2218 | pExynosPort->portDefinition.format.video.nSliceHeight = 0; | |
2219 | pExynosPort->portDefinition.nBufferSize = DEFAULT_VIDEO_OUTPUT_BUFFER_SIZE; | |
2220 | pExynosPort->portDefinition.format.video.eCompressionFormat = OMX_VIDEO_CodingUnused; | |
2221 | Exynos_OSAL_Memset(pExynosPort->portDefinition.format.video.cMIMEType, 0, MAX_OMX_MIMETYPE_SIZE); | |
2222 | Exynos_OSAL_Strcpy(pExynosPort->portDefinition.format.video.cMIMEType, "raw/video"); | |
2223 | pExynosPort->portDefinition.format.video.pNativeRender = 0; | |
2224 | pExynosPort->portDefinition.format.video.bFlagErrorConcealment = OMX_FALSE; | |
2225 | pExynosPort->portDefinition.format.video.eColorFormat = OMX_COLOR_FormatYUV420Planar; | |
2226 | pExynosPort->portDefinition.bEnabled = OMX_TRUE; | |
2227 | pExynosPort->bufferProcessType = BUFFER_COPY | BUFFER_ANBSHARE; | |
2228 | pExynosPort->portWayType = WAY2_PORT; | |
2229 | ||
2230 | for(i = 0; i < ALL_PORT_NUM; i++) { | |
2231 | INIT_SET_SIZE_VERSION(&pWmvDec->WmvComponent[i], OMX_VIDEO_PARAM_WMVTYPE); | |
2232 | pWmvDec->WmvComponent[i].nPortIndex = i; | |
2233 | pWmvDec->WmvComponent[i].eFormat = OMX_VIDEO_WMVFormat9; | |
2234 | } | |
2235 | ||
2236 | pOMXComponent->GetParameter = &Exynos_WmvDec_GetParameter; | |
2237 | pOMXComponent->SetParameter = &Exynos_WmvDec_SetParameter; | |
2238 | pOMXComponent->GetConfig = &Exynos_WmvDec_GetConfig; | |
2239 | pOMXComponent->SetConfig = &Exynos_WmvDec_SetConfig; | |
2240 | pOMXComponent->GetExtensionIndex = &Exynos_WmvDec_GetExtensionIndex; | |
2241 | pOMXComponent->ComponentRoleEnum = &Exynos_WmvDec_ComponentRoleEnum; | |
2242 | pOMXComponent->ComponentDeInit = &Exynos_OMX_ComponentDeinit; | |
2243 | ||
2244 | pExynosComponent->exynos_codec_componentInit = &Exynos_WmvDec_Init; | |
2245 | pExynosComponent->exynos_codec_componentTerminate = &Exynos_WmvDec_Terminate; | |
2246 | ||
2247 | pVideoDec->exynos_codec_srcInputProcess = &Exynos_WmvDec_srcInputBufferProcess; | |
2248 | pVideoDec->exynos_codec_srcOutputProcess = &Exynos_WmvDec_srcOutputBufferProcess; | |
2249 | pVideoDec->exynos_codec_dstInputProcess = &Exynos_WmvDec_dstInputBufferProcess; | |
2250 | pVideoDec->exynos_codec_dstOutputProcess = &Exynos_WmvDec_dstOutputBufferProcess; | |
2251 | ||
2252 | pVideoDec->exynos_codec_start = &WmvCodecStart; | |
2253 | pVideoDec->exynos_codec_stop = &WmvCodecStop; | |
2254 | pVideoDec->exynos_codec_bufferProcessRun = &WmvCodecOutputBufferProcessRun; | |
2255 | pVideoDec->exynos_codec_enqueueAllBuffer = &WmvCodecEnQueueAllBuffer; | |
2256 | ||
2257 | pVideoDec->exynos_checkInputFrame = &Check_Wmv_Frame; | |
2258 | pVideoDec->exynos_codec_getCodecInputPrivateData = &GetCodecInputPrivateData; | |
2259 | pVideoDec->exynos_codec_getCodecOutputPrivateData = &GetCodecOutputPrivateData; | |
2260 | ||
2261 | pVideoDec->hSharedMemory = Exynos_OSAL_SharedMemory_Open(); | |
2262 | if (pVideoDec->hSharedMemory == NULL) { | |
2263 | Exynos_OSAL_Log(EXYNOS_LOG_ERROR, "OMX_ErrorInsufficientResources, Line:%d", __LINE__); | |
2264 | Exynos_OSAL_Free(pWmvDec); | |
2265 | pWmvDec = ((EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle)->hCodecHandle = NULL; | |
2266 | Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2267 | ret = OMX_ErrorInsufficientResources; | |
2268 | goto EXIT; | |
2269 | } | |
2270 | ||
2271 | pExynosComponent->currentState = OMX_StateLoaded; | |
2272 | ||
2273 | ret = OMX_ErrorNone; | |
2274 | ||
2275 | EXIT: | |
2276 | FunctionOut(); | |
2277 | ||
2278 | return ret; | |
2279 | } | |
2280 | ||
2281 | OMX_ERRORTYPE Exynos_OMX_ComponentDeinit( | |
2282 | OMX_HANDLETYPE hComponent) | |
2283 | { | |
2284 | OMX_ERRORTYPE ret = OMX_ErrorNone; | |
2285 | OMX_COMPONENTTYPE *pOMXComponent = NULL; | |
2286 | EXYNOS_OMX_BASECOMPONENT *pExynosComponent = NULL; | |
2287 | EXYNOS_OMX_VIDEODEC_COMPONENT *pVideoDec = NULL; | |
2288 | EXYNOS_WMVDEC_HANDLE *pWmvDec = NULL; | |
2289 | ||
2290 | FunctionIn(); | |
2291 | ||
2292 | if (hComponent == NULL) { | |
2293 | ret = OMX_ErrorBadParameter; | |
2294 | goto EXIT; | |
2295 | } | |
2296 | pOMXComponent = (OMX_COMPONENTTYPE *)hComponent; | |
2297 | pExynosComponent = (EXYNOS_OMX_BASECOMPONENT *)pOMXComponent->pComponentPrivate; | |
2298 | pVideoDec = (EXYNOS_OMX_VIDEODEC_COMPONENT *)pExynosComponent->hComponentHandle; | |
2299 | ||
2300 | Exynos_OSAL_SharedMemory_Close(pVideoDec->hSharedMemory); | |
2301 | ||
2302 | Exynos_OSAL_Free(pExynosComponent->componentName); | |
2303 | pExynosComponent->componentName = NULL; | |
2304 | ||
2305 | pWmvDec = (EXYNOS_WMVDEC_HANDLE *)pVideoDec->hCodecHandle; | |
2306 | if (pWmvDec != NULL) { | |
2307 | Exynos_OSAL_Free(pWmvDec); | |
2308 | pWmvDec = pVideoDec->hCodecHandle = NULL; | |
2309 | } | |
2310 | ||
2311 | ret = Exynos_OMX_VideoDecodeComponentDeinit(pOMXComponent); | |
2312 | if (ret != OMX_ErrorNone) { | |
2313 | goto EXIT; | |
2314 | } | |
2315 | ||
2316 | ret = OMX_ErrorNone; | |
2317 | ||
2318 | EXIT: | |
2319 | FunctionOut(); | |
2320 | ||
2321 | return ret; | |
2322 | } |