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