blob: caf44975d54ebe1ff2ad5b40cd4367e5bf92f633 [file] [log] [blame]
Dharmaray Kundargicd196d32011-01-16 15:47:16 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#include "VideoEditorVideoDecoder.h"
17#include "VideoEditor3gpReader.h"
18
19#include <utils/Log.h>
20#include "VideoBrowserInternal.h"
21#include "LVOSA_FileReader_optim.h"
22
23//#define M4OSA_TRACE_LEVEL 1
24#if (M4OSA_TRACE_LEVEL >= 1)
25#undef M4OSA_TRACE1_0
26#undef M4OSA_TRACE1_1
27#undef M4OSA_TRACE1_2
28#undef M4OSA_TRACE1_3
29
30#define M4OSA_TRACE1_0(a) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a);
31#define M4OSA_TRACE1_1(a,b) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b);
32#define M4OSA_TRACE1_2(a,b,c) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b,c);
33#define M4OSA_TRACE1_3(a,b,c,d) __android_log_print(ANDROID_LOG_INFO, "Thumbnail", a,b,c,d);
34#endif
35
36/******************************************************************************
37 * M4OSA_ERR videoBrowserSetWindow(
38 * M4OSA_Context pContext, M4OSA_UInt32 x,
39 * M4OSA_UInt32 y, M4OSA_UInt32 dx, M4OSA_UInt32 dy);
40 * @brief This function sets the size and the position of the display.
41 * @param pContext (IN) : Video Browser context
42 * @param pPixelArray (IN) : Array to hold the video frame.
43 * @param x (IN) : Horizontal position of the top left
44 * corner
45 * @param y (IN) : Vertical position of the top left corner
46 * @param dx (IN) : Width of the display window
47 * @param dy (IN) : Height of the video window
48 * @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
49 ******************************************************************************/
50M4OSA_ERR videoBrowserSetWindow(
51 M4OSA_Context pContext,
52 M4OSA_Int32 *pPixelArray,
53 M4OSA_UInt32 x, M4OSA_UInt32 y,
54 M4OSA_UInt32 dx, M4OSA_UInt32 dy)
55{
56 VideoBrowserContext* pC = (VideoBrowserContext*)pContext;
57 M4OSA_ERR err = M4NO_ERROR;
58
59 M4OSA_TRACE2_5("videoBrowserSetWindow: entering with 0x%x %d %d %d %d ",
60 pContext, x, y, dx, dy);
61
62 /*--- Sanity checks ---*/
63 CHECK_PTR(videoBrowserSetWindow, pContext, err, M4ERR_PARAMETER);
64 CHECK_PTR(videoBrowserSetWindow, pPixelArray, err, M4ERR_PARAMETER);
65 CHECK_STATE(videoBrowserSetWindow, VideoBrowser_kVBOpened, pC);
66
67 pC->m_outputPlane[0].u_topleft = 0;
68
69 pC->m_outputPlane[0].u_height = dy;
70 pC->m_outputPlane[0].u_width = dx;
71 pC->m_x = x;
72 pC->m_y = y;
73
74 if (pC->m_frameColorType == VideoBrowser_kGB565) {
75 pC->m_outputPlane[0].u_stride = pC->m_outputPlane[0].u_width << 1;
76 pC->m_outputPlane[0].pac_data = (M4OSA_UInt8*)M4OSA_malloc(
77 pC->m_outputPlane[0].u_stride * pC->m_outputPlane[0].u_height,
78 VIDEOBROWSER, (M4OSA_Char *)"output plane");
79
80 CHECK_PTR(videoBrowserSetWindow,
81 pC->m_outputPlane[0].pac_data, err, M4ERR_ALLOC);
82 }
83 else if (pC->m_frameColorType == VideoBrowser_kYUV420) {
84 pC->m_outputPlane[0].u_stride = pC->m_outputPlane[0].u_width;
85 pC->m_outputPlane[1].u_height = pC->m_outputPlane[0].u_height >> 1;
86 pC->m_outputPlane[1].u_width = pC->m_outputPlane[0].u_width >> 1;
87 pC->m_outputPlane[1].u_topleft = 0;
88 pC->m_outputPlane[1].u_stride = pC->m_outputPlane[1].u_width;
89
90 pC->m_outputPlane[2].u_height = pC->m_outputPlane[0].u_height >> 1;
91 pC->m_outputPlane[2].u_width = pC->m_outputPlane[0].u_width >> 1;
92 pC->m_outputPlane[2].u_topleft = 0;
93 pC->m_outputPlane[2].u_stride = pC->m_outputPlane[2].u_width;
94
95 pC->m_outputPlane[0].pac_data = (M4OSA_UInt8*)pPixelArray;
96
97 CHECK_PTR(videoBrowserSetWindow,
98 pC->m_outputPlane[0].pac_data, err, M4ERR_ALLOC);
99
100 pC->m_outputPlane[1].pac_data =
101 pC->m_outputPlane[0].pac_data +
102 (pC->m_outputPlane[0].u_stride * pC->m_outputPlane[0].u_height);
103
104 pC->m_outputPlane[2].pac_data =
105 pC->m_outputPlane[1].pac_data +
106 (pC->m_outputPlane[1].u_stride * pC->m_outputPlane[1].u_height);
107 }
108
109
110 M4OSA_TRACE2_0("videoBrowserSetWindow returned NO ERROR");
111 return M4NO_ERROR;
112
113videoBrowserSetWindow_cleanUp:
114
115 M4OSA_TRACE2_1("videoBrowserSetWindow returned 0x%x", err);
116 return err;
117}
118
119/******************************************************************************
120* @brief This function allocates the resources needed for browsing a video file
121* @param ppContext (OUT): Pointer on a context filled by this function.
122* @param pURL (IN) : Path of File to browse
123* @param DrawMode (IN) : Indicate which method is used to draw (Direct draw etc...)
124* @param pfCallback (IN) : Callback function to be called when a frame must be displayed
125* @param pCallbackData (IN) : User defined data that will be passed as parameter of the callback
126* @param clrType (IN) : Required color type.
127* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
128******************************************************************************/
129M4OSA_ERR videoBrowserCreate(
130 M4OSA_Context* ppContext,
131 M4OSA_Char* pURL,
132 M4OSA_UInt32 DrawMode,
133 M4OSA_FileReadPointer* ptrF,
134 videoBrowser_Callback pfCallback,
135 M4OSA_Void* pCallbackData,
136 VideoBrowser_VideoColorType clrType)
137{
138 VideoBrowserContext* pContext = M4OSA_NULL;
139 M4READER_MediaFamily mediaFamily = M4READER_kMediaFamilyUnknown;
140 M4_StreamHandler* pStreamHandler = M4OSA_NULL;
141 M4_VideoStreamHandler* pVideoStreamHandler = M4OSA_NULL;
142 M4DECODER_VideoType decoderType;
143 M4DECODER_OutputFilter FilterOption;
144
145 M4OSA_Bool deb = M4OSA_TRUE;
146 M4OSA_ERR err = M4NO_ERROR;
147
148 M4OSA_TRACE1_2(
149 "videoBrowserCreate: entering with 0x%x 0x%x", ppContext, pURL);
150
151 /*--- Sanity checks ---*/
152 CHECK_PTR(videoBrowserCreate, ppContext, err, M4ERR_PARAMETER);
153 *ppContext = M4OSA_NULL ;
154 CHECK_PTR(videoBrowserCreate, pURL, err, M4ERR_PARAMETER);
155
156 /*--- Create context ---*/
157 pContext = (VideoBrowserContext*)M4OSA_malloc(
158 sizeof(VideoBrowserContext),
159 VIDEOBROWSER, (M4OSA_Char*)"Video browser context");
160
161 CHECK_PTR(videoBrowserCreate, pContext,err, M4ERR_ALLOC);
162 M4OSA_memset((M4OSA_MemAddr8)pContext, sizeof(VideoBrowserContext), 0);
163
164 /*--- Initialize the context parameters ---*/
165 pContext->m_state = VideoBrowser_kVBCreating ;
166 pContext->m_frameColorType = clrType;
167
168 /*--- Copy the file reader functions ---*/
169 M4OSA_memcpy((M4OSA_MemAddr8)&pContext->m_fileReadPtr,
170 (M4OSA_MemAddr8)ptrF,
171 sizeof(M4OSA_FileReadPointer)) ;
172
173 /* PR#SP00013 DGR bug 13 : first frame is not visible */
174 pContext->m_drawmode = DrawMode;
175
176
177 /* Retrieve the 3gp reader interface */
178 VideoEditor3gpReader_getInterface(&pContext->m_mediaType,
179 &pContext->m_3gpReader, &pContext->m_3gpData);
180
181 CHECK_PTR(videoBrowserCreate, pContext->m_3gpReader, err, M4ERR_ALLOC);
182 CHECK_PTR(videoBrowserCreate, pContext->m_3gpData, err, M4ERR_ALLOC);
183
184 /*--- Create the file reader ---*/
185 err = pContext->m_3gpReader->m_pFctCreate(&pContext->m_pReaderCtx);
186 CHECK_ERR(videoBrowserCreate, err);
187 CHECK_PTR(videoBrowserCreate, pContext->m_pReaderCtx, err, M4ERR_ALLOC);
188 pContext->m_3gpData->m_readerContext = pContext->m_pReaderCtx;
189
190 /*--- Set the OSAL file reader functions ---*/
191 err = pContext->m_3gpReader->m_pFctSetOption(
192 pContext->m_pReaderCtx,
193 M4READER_kOptionID_SetOsaFileReaderFctsPtr,
194 (M4OSA_DataOption)(&pContext->m_fileReadPtr));
195
196 CHECK_ERR(videoBrowserCreate, err) ;
197
198 /*--- Open the file ---*/
199 err = pContext->m_3gpReader->m_pFctOpen(pContext->m_pReaderCtx, pURL);
200 CHECK_ERR(videoBrowserCreate, err) ;
201
202 /*--- Try to find a video stream ---*/
203 while (err == M4NO_ERROR)
204 {
205 err = pContext->m_3gpReader->m_pFctGetNextStream(
206 pContext->m_pReaderCtx, &mediaFamily, &pStreamHandler);
207
208 /*in case we found a bifs stream or something else...*/
Basavapatna Dattaguru4fad6762011-02-27 21:15:18 -0800209 if ((err == (M4OSA_UInt32)M4ERR_READER_UNKNOWN_STREAM_TYPE) ||
210 (err == (M4OSA_UInt32)M4WAR_TOO_MUCH_STREAMS))
Dharmaray Kundargicd196d32011-01-16 15:47:16 -0800211 {
212 err = M4NO_ERROR;
213 continue;
214 }
215
216 if (err != M4WAR_NO_MORE_STREAM)
217 {
218 if (M4READER_kMediaFamilyVideo != mediaFamily)
219 {
220 err = M4NO_ERROR;
221 continue;
222 }
223
224 pContext->m_pStreamHandler = pStreamHandler;
225
226 err = pContext->m_3gpReader->m_pFctReset(
227 pContext->m_pReaderCtx, pContext->m_pStreamHandler);
228
229 CHECK_ERR(videoBrowserCreate, err);
230
231 err = pContext->m_3gpReader->m_pFctFillAuStruct(
232 pContext->m_pReaderCtx,
233 pContext->m_pStreamHandler,
234 &pContext->m_accessUnit);
235
236 CHECK_ERR(videoBrowserCreate, err);
237
238 pVideoStreamHandler =
239 (M4_VideoStreamHandler*)pContext->m_pStreamHandler;
240
241 switch (pContext->m_pStreamHandler->m_streamType)
242 {
243 case M4DA_StreamTypeVideoMpeg4:
244 case M4DA_StreamTypeVideoH263:
245 {
246 pContext->m_pCodecLoaderContext = M4OSA_NULL;
247 decoderType = M4DECODER_kVideoTypeMPEG4;
248
Dheeraj Sharmab62d78b2011-02-03 21:22:13 -0800249#ifdef USE_SOFTWARE_DECODER
250 err = VideoEditorVideoDecoder_getSoftwareInterface_MPEG4(
251 &decoderType, &pContext->m_pDecoder);
252#else
253 err = VideoEditorVideoDecoder_getInterface_MPEG4(
Basavapatna Dattaguru4fad6762011-02-27 21:15:18 -0800254 &decoderType, (void **)&pContext->m_pDecoder);
Dheeraj Sharmab62d78b2011-02-03 21:22:13 -0800255#endif
Dharmaray Kundargicd196d32011-01-16 15:47:16 -0800256 CHECK_ERR(videoBrowserCreate, err) ;
257
258 err = pContext->m_pDecoder->m_pFctCreate(
259 &pContext->m_pDecoderCtx,
260 pContext->m_pStreamHandler,
261 pContext->m_3gpData,
262 &pContext->m_accessUnit,
263 pContext->m_pCodecLoaderContext) ;
264
265 CHECK_ERR(videoBrowserCreate, err) ;
266 }
267 break;
268
269 case M4DA_StreamTypeVideoMpeg4Avc:
270 {
271 pContext->m_pCodecLoaderContext = M4OSA_NULL;
272
273 decoderType = M4DECODER_kVideoTypeAVC;
Dheeraj Sharmab62d78b2011-02-03 21:22:13 -0800274
275#ifdef USE_SOFTWARE_DECODER
276 err = VideoEditorVideoDecoder_getSoftwareInterface_H264(
277 &decoderType, &pContext->m_pDecoder);
278#else
279 err = VideoEditorVideoDecoder_getInterface_H264(
Basavapatna Dattaguru4fad6762011-02-27 21:15:18 -0800280 &decoderType, (void **)&pContext->m_pDecoder);
Dheeraj Sharmab62d78b2011-02-03 21:22:13 -0800281#endif
Dharmaray Kundargicd196d32011-01-16 15:47:16 -0800282 CHECK_ERR(videoBrowserCreate, err) ;
283
284 err = pContext->m_pDecoder->m_pFctCreate(
285 &pContext->m_pDecoderCtx,
286 pContext->m_pStreamHandler,
287 pContext->m_3gpData,
288 &pContext->m_accessUnit,
289 pContext->m_pCodecLoaderContext) ;
290
291 CHECK_ERR(videoBrowserCreate, err) ;
292 }
293 break;
294
295 default:
296 err = M4ERR_VB_MEDIATYPE_NOT_SUPPORTED;
297 goto videoBrowserCreate_cleanUp;
298 }
299 }
300 }
301
302 if (err == M4WAR_NO_MORE_STREAM)
303 {
304 err = M4NO_ERROR ;
305 }
306
307 if (M4OSA_NULL == pContext->m_pStreamHandler)
308 {
309 err = M4ERR_VB_NO_VIDEO ;
310 goto videoBrowserCreate_cleanUp ;
311 }
312
313 err = pContext->m_pDecoder->m_pFctSetOption(
314 pContext->m_pDecoderCtx,
315 M4DECODER_kOptionID_DeblockingFilter,
316 (M4OSA_DataOption)&deb);
317
318 if (err == M4WAR_DEBLOCKING_FILTER_NOT_IMPLEMENTED)
319 {
320 err = M4NO_ERROR;
321 }
322 CHECK_ERR(videoBrowserCreate, err);
323
324 FilterOption.m_pFilterUserData = M4OSA_NULL;
325
326
327 if (pContext->m_frameColorType == VideoBrowser_kGB565) {
328 FilterOption.m_pFilterFunction =
329 (M4OSA_Void*)M4VIFI_ResizeBilinearYUV420toBGR565;
330 }
331 else if (pContext->m_frameColorType == VideoBrowser_kYUV420) {
332 FilterOption.m_pFilterFunction =
333 (M4OSA_Void*)M4VIFI_ResizeBilinearYUV420toYUV420;
334 }
335 else {
336 err = M4ERR_PARAMETER;
337 goto videoBrowserCreate_cleanUp;
338 }
339
340 err = pContext->m_pDecoder->m_pFctSetOption(
341 pContext->m_pDecoderCtx,
342 M4DECODER_kOptionID_OutputFilter,
343 (M4OSA_DataOption)&FilterOption);
344
345 CHECK_ERR(videoBrowserCreate, err);
346
347 /* store the callback details */
348 pContext->m_pfCallback = pfCallback;
349 pContext->m_pCallbackUserData = pCallbackData;
350 /* store the callback details */
351
352 pContext->m_state = VideoBrowser_kVBOpened;
353 *ppContext = pContext;
354
355 M4OSA_TRACE1_0("videoBrowserCreate returned NO ERROR");
356 return M4NO_ERROR;
357
358videoBrowserCreate_cleanUp:
359
360 if (M4OSA_NULL != pContext)
361 {
362 if (M4OSA_NULL != pContext->m_pDecoderCtx)
363 {
364 pContext->m_pDecoder->m_pFctDestroy(pContext->m_pDecoderCtx);
365 pContext->m_pDecoderCtx = M4OSA_NULL;
366 }
367
368 if (M4OSA_NULL != pContext->m_pReaderCtx)
369 {
370 pContext->m_3gpReader->m_pFctClose(pContext->m_pReaderCtx);
371 pContext->m_3gpReader->m_pFctDestroy(pContext->m_pReaderCtx);
372 pContext->m_pReaderCtx = M4OSA_NULL;
373 }
374 SAFE_FREE(pContext->m_pDecoder);
375 SAFE_FREE(pContext->m_3gpReader);
376 SAFE_FREE(pContext->m_3gpData);
377 SAFE_FREE(pContext);
378 }
379
380 M4OSA_TRACE2_1("videoBrowserCreate returned 0x%x", err);
381 return err;
382}
383
384/******************************************************************************
385* M4OSA_ERR videoBrowserCleanUp(M4OSA_Context pContext);
386* @brief This function frees the resources needed for browsing a
387* video file.
388* @param pContext (IN) : Video browser context
389* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE
390******************************************************************************/
391M4OSA_ERR videoBrowserCleanUp(M4OSA_Context pContext)
392{
393 VideoBrowserContext* pC = (VideoBrowserContext*)pContext;
394 M4OSA_ERR err = M4NO_ERROR;
395
396 M4OSA_TRACE2_1("videoBrowserCleanUp: entering with 0x%x", pContext);
397
398 /*--- Sanity checks ---*/
399 CHECK_PTR(videoBrowserCleanUp, pContext, err, M4ERR_PARAMETER);
400
401 if (M4OSA_NULL != pC->m_pDecoderCtx)
402 {
403 pC->m_pDecoder->m_pFctDestroy(pC->m_pDecoderCtx);
404 pC->m_pDecoderCtx = M4OSA_NULL ;
405 }
406
407 if (M4OSA_NULL != pC->m_pReaderCtx)
408 {
409 pC->m_3gpReader->m_pFctClose(pC->m_pReaderCtx) ;
410 pC->m_3gpReader->m_pFctDestroy(pC->m_pReaderCtx);
411 pC->m_pReaderCtx = M4OSA_NULL;
412 }
413
414 SAFE_FREE(pC->m_pDecoder);
415 SAFE_FREE(pC->m_3gpReader);
416 SAFE_FREE(pC->m_3gpData);
417
418 if (pC->m_frameColorType != VideoBrowser_kYUV420) {
419 SAFE_FREE(pC->m_outputPlane[0].pac_data);
420 }
421 SAFE_FREE(pC);
422
423 M4OSA_TRACE2_0("videoBrowserCleanUp returned NO ERROR");
424 return M4NO_ERROR;
425
426videoBrowserCleanUp_cleanUp:
427
428 M4OSA_TRACE2_1("videoBrowserCleanUp returned 0x%x", err);
429 return err;
430}
431/******************************************************************************
432* M4OSA_ERR videoBrowserPrepareFrame(
433* M4OSA_Context pContext, M4OSA_UInt32* pTime);
434* @brief This function prepares the frame.
435* @param pContext (IN) : Video browser context
436* @param pTime (IN/OUT) : Pointer on the time to reach. Updated
437* by this function with the reached time
438* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
439******************************************************************************/
440M4OSA_ERR videoBrowserPrepareFrame(M4OSA_Context pContext, M4OSA_UInt32* pTime)
441{
442 VideoBrowserContext* pC = (VideoBrowserContext*)pContext;
443 M4OSA_ERR err = M4NO_ERROR;
444 M4OSA_UInt32 targetTime = 0;
445 M4OSA_UInt32 jumpTime = 0;
446 M4_MediaTime timeMS = 0;
447 M4OSA_Int32 rapTime = 0;
448 M4OSA_Bool isBackward = M4OSA_FALSE;
449 M4OSA_Bool bJumpNeeded = M4OSA_FALSE;
450
451
452 /*--- Sanity checks ---*/
453 CHECK_PTR(videoBrowserPrepareFrame, pContext, err, M4ERR_PARAMETER);
454 CHECK_PTR(videoBrowserPrepareFrame, pTime, err, M4ERR_PARAMETER);
455
456 targetTime = *pTime ;
457
458 /*--- Check the state, if this is the first call to this function
459 we move to the state "browsing" ---*/
460 if (VideoBrowser_kVBOpened == pC->m_state)
461 {
462 pC->m_state = VideoBrowser_kVBBrowsing;
463 }
464 else if (VideoBrowser_kVBBrowsing != pC->m_state)
465 {
466 err = M4ERR_STATE ;
467 goto videoBrowserPrepareFrame_cleanUp;
468 }
469
470 /*--- Check the duration ---*/
471 /*--- If we jump backward, we need to jump ---*/
472 if (targetTime < pC->m_currentCTS)
473 {
474 isBackward = M4OSA_TRUE;
475 bJumpNeeded = M4OSA_TRUE;
476 }
477 /*--- If we jumpt to a time greater than "currentTime" + "predecodeTime"
478 we need to jump ---*/
479 else if (targetTime > (pC->m_currentCTS + VIDEO_BROWSER_PREDECODE_TIME))
480 {
481 bJumpNeeded = M4OSA_TRUE;
482 }
483
484 if (M4OSA_TRUE == bJumpNeeded)
485 {
486 rapTime = targetTime;
487 /*--- Retrieve the previous RAP time ---*/
488 err = pC->m_3gpReader->m_pFctGetPrevRapTime(
489 pC->m_pReaderCtx, pC->m_pStreamHandler, &rapTime);
490
491 CHECK_ERR(videoBrowserPrepareFrame, err);
492
493 jumpTime = rapTime;
494
495 err = pC->m_3gpReader->m_pFctJump(pC->m_pReaderCtx,
496 pC->m_pStreamHandler,
497 (M4OSA_Int32*)&jumpTime);
498 CHECK_ERR(videoBrowserPrepareFrame, err);
499 }
500
501 timeMS = (M4_MediaTime)targetTime;
502 err = pC->m_pDecoder->m_pFctDecode(
503 pC->m_pDecoderCtx, &timeMS, bJumpNeeded);
504
505 if ((err != M4NO_ERROR) && (err != M4WAR_NO_MORE_AU))
506 {
507 return err;
508 }
509
510 // FIXME:
511 // Not sure that I understand why we need a second jump logic here
512 if ((timeMS >= pC->m_currentCTS) && (M4OSA_TRUE == isBackward))
513 {
514 jumpTime = rapTime;
515 err = pC->m_3gpReader->m_pFctJump(
516 pC->m_pReaderCtx, pC->m_pStreamHandler, (M4OSA_Int32*)&jumpTime);
517
518 CHECK_ERR(videoBrowserPrepareFrame, err);
519
520 timeMS = (M4_MediaTime)rapTime;
521 err = pC->m_pDecoder->m_pFctDecode(
522 pC->m_pDecoderCtx, &timeMS, M4OSA_TRUE);
523
524 if ((err != M4NO_ERROR) && (err != M4WAR_NO_MORE_AU))
525 {
526 return err;
527 }
528 }
529
530 err = pC->m_pDecoder->m_pFctRender(
531 pC->m_pDecoderCtx, &timeMS, pC->m_outputPlane, M4OSA_TRUE);
532
533 if (M4WAR_VIDEORENDERER_NO_NEW_FRAME == err)
534 {
Dheeraj Sharmab21827d2011-01-23 11:55:47 -0800535 return err;
Dharmaray Kundargicd196d32011-01-16 15:47:16 -0800536 }
537 CHECK_ERR(videoBrowserPrepareFrame, err) ;
538
539 pC->m_currentCTS = (M4OSA_UInt32)timeMS;
540
541 *pTime = pC->m_currentCTS;
542
543 return M4NO_ERROR;
544
545videoBrowserPrepareFrame_cleanUp:
546
547 if ((M4WAR_INVALID_TIME == err) || (M4WAR_NO_MORE_AU == err))
548 {
549 err = M4NO_ERROR;
550 }
551 else if (M4OSA_NULL != pC)
552 {
553 pC->m_currentCTS = 0;
554 }
555
556 M4OSA_TRACE2_1("videoBrowserPrepareFrame returned 0x%x", err);
557 return err;
558}
559
560/******************************************************************************
561* M4OSA_ERR videoBrowserDisplayCurrentFrame(M4OSA_Context pContext);
562* @brief This function displays the current frame.
563* @param pContext (IN) : Video browser context
564* @return M4NO_ERROR / M4ERR_PARAMETER / M4ERR_STATE / M4ERR_ALLOC
565******************************************************************************/
566M4OSA_ERR videoBrowserDisplayCurrentFrame(M4OSA_Context pContext)
567{
568 VideoBrowserContext* pC = (VideoBrowserContext*)pContext ;
569 M4OSA_ERR err = M4NO_ERROR ;
570
571 /*--- Sanity checks ---*/
572 CHECK_PTR(videoBrowserDisplayCurrentFrame, pContext, err, M4ERR_PARAMETER);
573
574 // Request display of the frame
575 pC->m_pfCallback((M4OSA_Context) pC, // VB context
576 VIDEOBROWSER_DISPLAY_FRAME, // action requested
577 M4NO_ERROR, // error code
578 (M4OSA_Void*) &(pC->m_outputPlane[0]), // image to be displayed
579 (M4OSA_Void*) pC->m_pCallbackUserData); // user-provided data
580
581#ifdef DUMPTOFILE
582 {
583 M4OSA_Context fileContext;
584 M4OSA_Char* fileName = "/sdcard/textBuffer_RGB565.rgb";
585 M4OSA_fileWriteOpen(&fileContext, (M4OSA_Void*) fileName,
586 M4OSA_kFileWrite | M4OSA_kFileCreate);
587
588 M4OSA_fileWriteData(fileContext,
589 (M4OSA_MemAddr8) pC->m_outputPlane[0].pac_data,
590 pC->m_outputPlane[0].u_height*pC->m_outputPlane[0].u_width*2);
591
592 M4OSA_fileWriteClose(fileContext);
593 }
594#endif
595
596 M4OSA_TRACE2_0("videoBrowserDisplayCurrentFrame returned NO ERROR") ;
597 return M4NO_ERROR;
598
599videoBrowserDisplayCurrentFrame_cleanUp:
600
601 M4OSA_TRACE2_1("videoBrowserDisplayCurrentFrame returned 0x%x", err) ;
602 return err;
603}