1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // Include Files |
|
21 #include <mp4lib.h> |
|
22 #include "ctrtranscoder.h" |
|
23 #include "ctrtranscoderobserver.h" |
|
24 #include "VedVideoClip.h" |
|
25 #include "vedvideosettings.h" |
|
26 #include "vedvolreader.h" |
|
27 #include "vedcodecchecker.h" |
|
28 #include "vedavcedit.h" |
|
29 |
|
30 // Constants |
|
31 const TUint KVOLHeaderBufferSize = 256; |
|
32 const TUint KAVCDCRBufferSize = 16384; |
|
33 const TUint KSubQCIFWidth = 128; |
|
34 const TUint KQCIFWidth = 176; |
|
35 const TUint KCIFWidth = 352; |
|
36 const TUint KQVGAWidth = 320; |
|
37 const TUint KVGAWidth = 640; |
|
38 //WVGA task |
|
39 const TUint KWVGAWidth = 864; |
|
40 |
|
41 // An assertion macro wrapper to clean up the code a bit |
|
42 #define CCASSERT(x) __ASSERT_DEBUG(x, User::Panic(_L("CVedCodecChecker"), -5000)) |
|
43 |
|
44 // Print macro |
|
45 #ifdef _DEBUG |
|
46 #include <e32svr.h> |
|
47 #define PRINT(x) RDebug::Print x |
|
48 #else |
|
49 #define PRINT(x) |
|
50 #endif |
|
51 |
|
52 // Near-dummy observer class for temporary transcoder instance. In practice is only used to provide input framerate |
|
53 // to the transcoder |
|
54 class CTrObs : public CBase, public MTRTranscoderObserver |
|
55 { |
|
56 public: |
|
57 /* Constructor & destructor */ |
|
58 |
|
59 inline CTrObs(TReal aFrameRate) : iInputFrameRate(aFrameRate) |
|
60 { |
|
61 }; |
|
62 inline ~CTrObs() |
|
63 { |
|
64 }; |
|
65 |
|
66 // Dummy methods from MTRTranscoderObserver, just used to complete the observer class |
|
67 inline void MtroInitializeComplete(TInt /*aError*/) |
|
68 { |
|
69 }; |
|
70 inline void MtroFatalError(TInt /*aError*/) |
|
71 { |
|
72 }; |
|
73 inline void MtroReturnCodedBuffer(CCMRMediaBuffer* /*aBuffer*/) |
|
74 { |
|
75 }; |
|
76 // method to provide clip input framerate to transcoder |
|
77 inline void MtroSetInputFrameRate(TReal& aRate) |
|
78 { |
|
79 aRate = iInputFrameRate; |
|
80 }; |
|
81 inline void MtroAsyncStopComplete() |
|
82 { |
|
83 }; |
|
84 |
|
85 inline void MtroSuspend() |
|
86 { |
|
87 }; |
|
88 |
|
89 inline void MtroResume() |
|
90 { |
|
91 }; |
|
92 |
|
93 private:// data |
|
94 |
|
95 // clip input framerate (fps) |
|
96 TReal iInputFrameRate; |
|
97 |
|
98 }; |
|
99 |
|
100 |
|
101 // ================= MEMBER FUNCTIONS ======================= |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CVedCodecChecker::NewL |
|
105 // Two-phased constructor. |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 CVedCodecChecker* CVedCodecChecker::NewL() |
|
109 { |
|
110 PRINT(_L("CVedCodecChecker::NewL in")); |
|
111 |
|
112 CVedCodecChecker* self = NewLC(); |
|
113 CleanupStack::Pop(self); |
|
114 |
|
115 PRINT(_L("CVedCodecChecker::NewL out")); |
|
116 return self; |
|
117 } |
|
118 |
|
119 CVedCodecChecker* CVedCodecChecker::NewLC() |
|
120 { |
|
121 PRINT(_L("CVedCodecChecker::NewLC in")); |
|
122 |
|
123 CVedCodecChecker* self = new (ELeave) CVedCodecChecker(); |
|
124 CleanupStack::PushL(self); |
|
125 self->ConstructL(); |
|
126 |
|
127 PRINT(_L("CVedCodecChecker::NewLC out")); |
|
128 return self; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CVedCodecChecker::CVedCodecChecker |
|
133 // C++ default constructor can NOT contain any code, that |
|
134 // might leave. |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 CVedCodecChecker::CVedCodecChecker() : iOutputFormatsChecked(EFalse) |
|
138 { |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CSizeEstimate::~CSizeEstimate |
|
143 // Destructor. |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 CVedCodecChecker::~CVedCodecChecker() |
|
147 { |
|
148 |
|
149 // free all memory |
|
150 for (TInt i = 0; i < KNumCodecs; i++) |
|
151 { |
|
152 if (iInputCodecsAndResolutions[i] != 0) |
|
153 delete [] iInputCodecsAndResolutions[i]; |
|
154 |
|
155 iInputCodecsAndResolutions[i] = 0; |
|
156 |
|
157 if (iOutputCodecsAndResolutions[i] != 0) |
|
158 delete [] iOutputCodecsAndResolutions[i]; |
|
159 |
|
160 iOutputCodecsAndResolutions[i] = 0; |
|
161 } |
|
162 |
|
163 |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CSizeEstimate::ConstructL |
|
168 // Symbian 2nd phase constructor can leave. |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CVedCodecChecker::ConstructL() |
|
172 { |
|
173 |
|
174 PRINT(_L("CVedCodecChecker::ConstructL in")); |
|
175 |
|
176 TInt i; |
|
177 |
|
178 // reset pointer tables |
|
179 for (i = 0; i < KNumCodecs; i++) |
|
180 { |
|
181 iInputCodecsAndResolutions[i] = 0; |
|
182 iOutputCodecsAndResolutions[i] = 0; |
|
183 } |
|
184 |
|
185 // allocate resolution tables |
|
186 for (i = 0; i < KNumCodecs; i++) |
|
187 { |
|
188 TBool* temp = new ( ELeave ) TBool[KNumResolutions]; |
|
189 for (TInt j = 0; j < KNumResolutions; j++) |
|
190 temp[j] = 0; |
|
191 |
|
192 iInputCodecsAndResolutions[i] = temp; |
|
193 |
|
194 temp = new ( ELeave ) TBool[KNumResolutions]; |
|
195 for (TInt j = 0; j < KNumResolutions; j++) |
|
196 temp[j] = 0; |
|
197 |
|
198 iOutputCodecsAndResolutions[i] = temp; |
|
199 } |
|
200 |
|
201 // check supported input codecs / resolutions |
|
202 GetSupportedInputFormatsL(); |
|
203 |
|
204 PRINT(_L("CVedCodecChecker::ConstructL out")); |
|
205 |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CVedCodecChecker::GetSupportedInputFormatsL |
|
210 // (other items were commented in a header). |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CVedCodecChecker::GetSupportedInputFormatsL() |
|
214 { |
|
215 |
|
216 PRINT(_L("CVedCodecChecker::GetSupportedInputFormatsL in")); |
|
217 |
|
218 const TSize KResolutions[KNumResolutions] = { KVedResolutionSubQCIF, |
|
219 KVedResolutionQCIF, |
|
220 KVedResolutionCIF, |
|
221 KVedResolutionQVGA, |
|
222 KVedResolutionVGA16By9, |
|
223 KVedResolutionVGA, |
|
224 //WVGA task |
|
225 KVedResolutionWVGA }; |
|
226 |
|
227 const TPtrC8 KCodecs[KNumCodecs] = { _L8("video/H263-2000; profile=0; level=10"), |
|
228 _L8("video/H263-2000; profile=0; level=45"), |
|
229 _L8("video/mp4v-es; profile-level-id=8"), |
|
230 _L8("video/mp4v-es; profile-level-id=9"), |
|
231 _L8("video/mp4v-es; profile-level-id=1"), |
|
232 _L8("video/mp4v-es; profile-level-id=2"), |
|
233 _L8("video/mp4v-es; profile-level-id=3"), |
|
234 _L8("video/mp4v-es; profile-level-id=4"), |
|
235 _L8("video/H264; profile-level-id=42800A"), |
|
236 _L8("video/H264; profile-level-id=42900B"), |
|
237 _L8("video/H264; profile-level-id=42800B"), |
|
238 _L8("video/H264; profile-level-id=42800C"), |
|
239 _L8("video/H264; profile-level-id=42800D"), |
|
240 _L8("video/H264; profile-level-id=428014"), |
|
241 //WVGA task |
|
242 _L8("video/H264; profile-level-id=428015"), |
|
243 _L8("video/H264; profile-level-id=428016"), |
|
244 _L8("video/H264; profile-level-id=42801E"), |
|
245 _L8("video/H264; profile-level-id=42801F") }; |
|
246 |
|
247 TTRVideoFormat inputFormat; |
|
248 TTRVideoFormat outputFormat; |
|
249 |
|
250 inputFormat.iDataType = CTRTranscoder::ETRDuCodedPicture; |
|
251 outputFormat.iDataType = CTRTranscoder::ETRYuvRawData420; |
|
252 |
|
253 for (TInt i = 0; i < KNumCodecs; i++) |
|
254 { |
|
255 |
|
256 PRINT((_L("GetSupportedInputFormatsL - testing codec %d"), i)); |
|
257 |
|
258 // create temporary transcoder observer object, with input framerate as parameter, since it is asked by the transcoder |
|
259 CTrObs* tmpObs = new (ELeave) CTrObs(15.0); |
|
260 CleanupStack::PushL(tmpObs); |
|
261 |
|
262 // create temporary transcoder instance |
|
263 CTRTranscoder* tmpTranscoder = CTRTranscoder::NewL(*tmpObs); |
|
264 CleanupStack::PushL(tmpTranscoder); |
|
265 |
|
266 // check if codec supported at all |
|
267 if ( tmpTranscoder->SupportsInputVideoFormat(KCodecs[i]) ) |
|
268 { |
|
269 TInt error = KErrNone; |
|
270 // check all resolutions |
|
271 for (TInt j = 0; j < KNumResolutions; j++) |
|
272 { |
|
273 |
|
274 if ( (i < ECodecMPEG4VSPLevel0) && (j > EResolutionQCIF) ) |
|
275 { |
|
276 // Do not allow larger resolutions than QCIF for H.263 |
|
277 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
278 CleanupStack::PopAndDestroy(tmpObs); |
|
279 PRINT((_L("GetSupportedInputFormatsL - break"))); |
|
280 break; |
|
281 } |
|
282 |
|
283 PRINT((_L("GetSupportedInputFormatsL - testing (%d, %d)"), i, j)); |
|
284 |
|
285 inputFormat.iSize = outputFormat.iSize = KResolutions[j]; |
|
286 |
|
287 TRAP( error, tmpTranscoder->OpenL(reinterpret_cast<MCMRMediaSink*>(1),//the sink will not be used, hence this is acceptable |
|
288 CTRTranscoder::EDecoding, |
|
289 KCodecs[i], |
|
290 KNullDesC8, |
|
291 inputFormat, |
|
292 outputFormat, |
|
293 EFalse ) ); |
|
294 |
|
295 if (error == KErrNone) |
|
296 { |
|
297 PRINT((_L("GetSupportedInputFormatsL - (%d, %d) supported"), i, j)); |
|
298 iInputCodecsAndResolutions[i][j] = ETrue; |
|
299 } |
|
300 else if (error == KErrNotSupported) |
|
301 { |
|
302 PRINT((_L("GetSupportedInputFormatsL - (%d, %d) not supported"), i, j)); |
|
303 iInputCodecsAndResolutions[i][j] = EFalse; |
|
304 } |
|
305 else |
|
306 User::Leave(error); |
|
307 |
|
308 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
309 CleanupStack::PopAndDestroy(tmpObs); |
|
310 |
|
311 if ( j < (KNumResolutions - 1) ) |
|
312 { |
|
313 tmpObs = new (ELeave) CTrObs(15.0); |
|
314 CleanupStack::PushL(tmpObs); |
|
315 |
|
316 // create temporary transcoder instance |
|
317 tmpTranscoder = CTRTranscoder::NewL(*tmpObs); |
|
318 CleanupStack::PushL(tmpTranscoder); |
|
319 } |
|
320 } |
|
321 } |
|
322 else |
|
323 { |
|
324 // all resolutions unsupported |
|
325 for (TInt j=0; j < KNumResolutions; j++) |
|
326 { |
|
327 iInputCodecsAndResolutions[i][j] = EFalse; |
|
328 } |
|
329 |
|
330 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
331 CleanupStack::PopAndDestroy(tmpObs); |
|
332 |
|
333 } |
|
334 } |
|
335 |
|
336 PRINT(_L("CVedCodecChecker::GetSupportedInputFormatsL out")); |
|
337 |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CVedCodecChecker::GetSupportedOutputFormatsL |
|
342 // (other items were commented in a header). |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 void CVedCodecChecker::GetSupportedOutputFormatsL() |
|
346 { |
|
347 |
|
348 PRINT(_L("CVedCodecChecker::GetSupportedOutputFormatsL in")); |
|
349 |
|
350 const TSize KResolutions[KNumResolutions] = { KVedResolutionSubQCIF, |
|
351 KVedResolutionQCIF, |
|
352 KVedResolutionCIF, |
|
353 KVedResolutionQVGA, |
|
354 KVedResolutionVGA16By9, |
|
355 KVedResolutionVGA }; |
|
356 |
|
357 const TPtrC8 KCodecs[KNumCodecs] = { _L8("video/H263-2000; profile=0; level=10"), |
|
358 _L8("video/H263-2000; profile=0; level=45"), |
|
359 _L8("video/mp4v-es; profile-level-id=8"), |
|
360 _L8("video/mp4v-es; profile-level-id=9"), |
|
361 _L8("video/mp4v-es; profile-level-id=1"), |
|
362 _L8("video/mp4v-es; profile-level-id=2"), |
|
363 _L8("video/mp4v-es; profile-level-id=3"), |
|
364 _L8("video/mp4v-es; profile-level-id=4"), |
|
365 _L8("video/H264; profile-level-id=42800A"), |
|
366 _L8("video/H264; profile-level-id=42900B"), |
|
367 _L8("video/H264; profile-level-id=42800B"), |
|
368 _L8("video/H264; profile-level-id=42800C"), |
|
369 |
|
370 //WVGA task |
|
371 //(TPtrC8&)KNullDesC8, // level 1.3 not supported in output |
|
372 //(TPtrC8&)KNullDesC8, // level 2 not supported in output |
|
373 _L8("video/H264; profile-level-id=42800D"), |
|
374 _L8("video/H264; profile-level-id=428014"), |
|
375 _L8("video/H264; profile-level-id=428015"), |
|
376 _L8("video/H264; profile-level-id=428016"), |
|
377 _L8("video/H264; profile-level-id=42801E"), |
|
378 _L8("video/H264; profile-level-id=42801F") |
|
379 }; |
|
380 |
|
381 |
|
382 |
|
383 TTRVideoFormat inputFormat; |
|
384 TTRVideoFormat outputFormat; |
|
385 |
|
386 inputFormat.iDataType = CTRTranscoder::ETRYuvRawData420; |
|
387 outputFormat.iDataType = CTRTranscoder::ETRDuCodedPicture; |
|
388 |
|
389 for (TInt i = 0; i < KNumCodecs; i++) |
|
390 { |
|
391 PRINT((_L("GetSupportedOutputFormatsL - testing codec %d"), i)); |
|
392 |
|
393 // create temporary transcoder observer object, with input framerate as parameter, since it is asked by the transcoder |
|
394 CTrObs* tmpObs = new (ELeave) CTrObs(15.0); |
|
395 CleanupStack::PushL(tmpObs); |
|
396 |
|
397 // create temporary transcoder instance |
|
398 CTRTranscoder* tmpTranscoder = CTRTranscoder::NewL(*tmpObs); |
|
399 CleanupStack::PushL(tmpTranscoder); |
|
400 |
|
401 //WVGA task |
|
402 // AVC levels 3.1 and higher are not supported in output |
|
403 if (i >= ECodecAVCBPLevel3_1) |
|
404 { |
|
405 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
406 CleanupStack::PopAndDestroy(tmpObs); |
|
407 PRINT((_L("GetSupportedOutputFormatsL - break AVC check"))); |
|
408 break; |
|
409 } |
|
410 |
|
411 |
|
412 // check if codec supported at all |
|
413 if ( tmpTranscoder->SupportsOutputVideoFormat(KCodecs[i]) ) |
|
414 { |
|
415 TInt error = KErrNone; |
|
416 // check all resolutions |
|
417 for (TInt j = 0; j < KNumResolutions; j++) |
|
418 { |
|
419 |
|
420 if ( (i < ECodecMPEG4VSPLevel0) && (j > EResolutionQCIF) ) |
|
421 { |
|
422 // Do not allow larger resolutions than QCIF for H.263 |
|
423 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
424 CleanupStack::PopAndDestroy(tmpObs); |
|
425 PRINT((_L("GetSupportedOutputFormatsL - break"))); |
|
426 break; |
|
427 } |
|
428 |
|
429 PRINT((_L("GetSupportedOutputFormatsL - testing (%d, %d)"), i, j)); |
|
430 |
|
431 inputFormat.iSize = outputFormat.iSize = KResolutions[j]; |
|
432 |
|
433 TRAP( error, tmpTranscoder->OpenL(reinterpret_cast<MCMRMediaSink*>(1),//the sink will not be used, hence this is acceptable |
|
434 CTRTranscoder::EEncoding, |
|
435 KNullDesC8, |
|
436 KCodecs[i], |
|
437 inputFormat, |
|
438 outputFormat, |
|
439 EFalse ) ); |
|
440 |
|
441 if (error == KErrNone) |
|
442 { |
|
443 PRINT((_L("GetSupportedOutputFormatsL - (%d, %d) supported"), i, j)); |
|
444 iOutputCodecsAndResolutions[i][j] = ETrue; |
|
445 } |
|
446 else if (error == KErrNotSupported) |
|
447 { |
|
448 PRINT((_L("GetSupportedOutputFormatsL - (%d, %d) not supported"), i, j)); |
|
449 iOutputCodecsAndResolutions[i][j] = EFalse; |
|
450 } |
|
451 else |
|
452 User::Leave(error); |
|
453 |
|
454 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
455 CleanupStack::PopAndDestroy(tmpObs); |
|
456 |
|
457 if ( j < (KNumResolutions - 1) ) |
|
458 { |
|
459 tmpObs = new (ELeave) CTrObs(15.0); |
|
460 CleanupStack::PushL(tmpObs); |
|
461 |
|
462 // create temporary transcoder instance |
|
463 tmpTranscoder = CTRTranscoder::NewL(*tmpObs); |
|
464 CleanupStack::PushL(tmpTranscoder); |
|
465 } |
|
466 } |
|
467 } |
|
468 else |
|
469 { |
|
470 // all resolutions unsupported |
|
471 for (TInt j=0; j < KNumResolutions; j++) |
|
472 { |
|
473 iOutputCodecsAndResolutions[i][j] = EFalse; |
|
474 } |
|
475 |
|
476 CleanupStack::PopAndDestroy(tmpTranscoder); |
|
477 CleanupStack::PopAndDestroy(tmpObs); |
|
478 |
|
479 } |
|
480 } |
|
481 |
|
482 PRINT(_L("CVedCodecChecker::GetSupportedOutputFormatsL out")); |
|
483 |
|
484 } |
|
485 |
|
486 |
|
487 // ----------------------------------------------------------------------------- |
|
488 // CVedCodecChecker::IsSupportedInputClip |
|
489 // (other items were commented in a header). |
|
490 // ----------------------------------------------------------------------------- |
|
491 // |
|
492 TBool CVedCodecChecker::IsSupportedInputClipL(CVedVideoClip* aClip) |
|
493 { |
|
494 |
|
495 PRINT(_L("CVedCodecChecker::IsSupportedInputClipL in")); |
|
496 |
|
497 if ( (aClip->Info()->VideoType() != EVedVideoTypeH263Profile0Level10) && |
|
498 (aClip->Info()->VideoType() != EVedVideoTypeH263Profile0Level45) && |
|
499 (aClip->Info()->VideoType() != EVedVideoTypeMPEG4SimpleProfile) && |
|
500 (aClip->Info()->VideoType() != EVedVideoTypeAVCBaselineProfile) |
|
501 ) |
|
502 { |
|
503 return KErrNotSupported; |
|
504 } |
|
505 |
|
506 TResolution resolution = MapResolution( aClip->Info()->Resolution() ); |
|
507 |
|
508 if ( resolution == EResolutionUnsupported ) |
|
509 return EFalse; |
|
510 |
|
511 if ( aClip->Info()->VideoType() == EVedVideoTypeH263Profile0Level10 ) |
|
512 { |
|
513 return iInputCodecsAndResolutions[ECodecH263BPLevel10][resolution]; |
|
514 } |
|
515 |
|
516 if ( aClip->Info()->VideoType() == EVedVideoTypeH263Profile0Level45 ) |
|
517 { |
|
518 return iInputCodecsAndResolutions[ECodecH263BPLevel45][resolution]; |
|
519 } |
|
520 |
|
521 #ifndef VIDEOEDITORENGINE_AVC_EDITING |
|
522 if ( aClip->Info()->VideoType() == EVedVideoTypeAVCBaselineProfile ) |
|
523 { |
|
524 return EFalse; |
|
525 } |
|
526 #endif |
|
527 |
|
528 // clip is MPEG-4 or AVC |
|
529 |
|
530 // create parser to fetch codec specific info |
|
531 MP4Handle mp4Handle = 0; |
|
532 MP4Err mp4Error; |
|
533 if (!aClip->Info()->FileHandle()) |
|
534 { |
|
535 TBuf<258> tempFileName(aClip->Info()->FileName()); |
|
536 tempFileName.ZeroTerminate(); |
|
537 |
|
538 MP4FileName name = reinterpret_cast<MP4FileName>( const_cast<TUint16*>(tempFileName.Ptr()) ); |
|
539 mp4Error = MP4ParseOpen(&mp4Handle, name); |
|
540 } |
|
541 else |
|
542 { |
|
543 mp4Error = MP4ParseOpenFileHandle(&mp4Handle, aClip->Info()->FileHandle()); |
|
544 } |
|
545 |
|
546 if (mp4Error != MP4_OK) |
|
547 { |
|
548 if (mp4Handle) |
|
549 MP4ParseClose(mp4Handle); |
|
550 mp4Handle = 0; |
|
551 |
|
552 if (mp4Error == MP4_OUT_OF_MEMORY) |
|
553 User::Leave(KErrNoMemory); |
|
554 else |
|
555 User::Leave(KErrGeneral); |
|
556 } |
|
557 |
|
558 TInt bufSize = 0; |
|
559 |
|
560 if (aClip->Info()->VideoType() == EVedVideoTypeMPEG4SimpleProfile) |
|
561 bufSize = KVOLHeaderBufferSize; |
|
562 else |
|
563 bufSize = KAVCDCRBufferSize; |
|
564 |
|
565 HBufC8* tmpBuffer = (HBufC8*) HBufC8::NewLC(bufSize); |
|
566 |
|
567 TPtr8 tmpPtr = tmpBuffer->Des(); |
|
568 mp4_u32 infoSize = 0; |
|
569 |
|
570 // get info |
|
571 mp4Error = MP4ParseReadVideoDecoderSpecificInfo( mp4Handle, |
|
572 (mp4_u8*)(tmpPtr.Ptr()), |
|
573 bufSize, |
|
574 &infoSize ); |
|
575 |
|
576 MP4ParseClose(mp4Handle); |
|
577 |
|
578 if ( mp4Error != MP4_OK ) |
|
579 { |
|
580 User::Leave(KErrGeneral); |
|
581 } |
|
582 |
|
583 tmpPtr.SetLength(infoSize); |
|
584 |
|
585 TCodec codec = ECodecUnsupported; |
|
586 |
|
587 if (aClip->Info()->VideoType() == EVedVideoTypeMPEG4SimpleProfile) |
|
588 { |
|
589 // Parse profile-level-id |
|
590 CVedVolReader* tmpVolReader = CVedVolReader::NewL(); |
|
591 CleanupStack::PushL(tmpVolReader); |
|
592 |
|
593 tmpVolReader->ParseVolHeaderL(tmpPtr); |
|
594 |
|
595 TInt profileLevelId = tmpVolReader->ProfileLevelId(); |
|
596 |
|
597 codec = MapProfileLevelId(profileLevelId); |
|
598 } |
|
599 |
|
600 #ifdef VIDEOEDITORENGINE_AVC_EDITING |
|
601 else |
|
602 { |
|
603 CVedAVCEdit* tmpAvcEdit = CVedAVCEdit::NewL(); |
|
604 CleanupStack::PushL(tmpAvcEdit); |
|
605 |
|
606 // this leaves with KErrNotSupported if clip is not supported |
|
607 tmpAvcEdit->SaveAVCDecoderConfigurationRecordL(tmpPtr, EFalse); |
|
608 |
|
609 // Parse level |
|
610 TInt level = 0; |
|
611 User::LeaveIfError( tmpAvcEdit->GetLevel(tmpPtr, level) ); |
|
612 |
|
613 codec = MapAVCLevel(level); |
|
614 } |
|
615 #endif |
|
616 |
|
617 CleanupStack::PopAndDestroy(2); |
|
618 |
|
619 if (codec == ECodecUnsupported) |
|
620 return EFalse; |
|
621 |
|
622 PRINT(_L("CVedCodecChecker::IsSupportedInputClipL out")); |
|
623 |
|
624 return iInputCodecsAndResolutions[codec][resolution]; |
|
625 |
|
626 } |
|
627 |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CVedCodecChecker::IsSupportedOutputFormatL |
|
631 // (other items were commented in a header). |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 TBool CVedCodecChecker::IsSupportedOutputFormatL(const TPtrC8& aMimeType, TSize aResolution) |
|
635 { |
|
636 |
|
637 PRINT(_L("CVedCodecChecker::IsSupportedOutputFormatL in")); |
|
638 |
|
639 if (aMimeType == KNullDesC8) |
|
640 { |
|
641 User::Leave(KErrArgument); |
|
642 } |
|
643 |
|
644 if ( !iOutputFormatsChecked ) |
|
645 { |
|
646 // check supported output formats |
|
647 GetSupportedOutputFormatsL(); |
|
648 iOutputFormatsChecked = ETrue; |
|
649 } |
|
650 |
|
651 TResolution resolution = MapResolution(aResolution); |
|
652 |
|
653 if (resolution == EResolutionUnsupported) |
|
654 return EFalse; |
|
655 |
|
656 TCodec codec = ParseMimeType(aMimeType, aResolution); |
|
657 |
|
658 if (codec == ECodecUnsupported) |
|
659 return EFalse; |
|
660 |
|
661 PRINT(_L("CVedCodecChecker::IsSupportedOutputFormatL out")); |
|
662 |
|
663 return iOutputCodecsAndResolutions[codec][resolution]; |
|
664 |
|
665 } |
|
666 |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CVedCodecChecker::MapResolution |
|
670 // (other items were commented in a header). |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 TResolution CVedCodecChecker::MapResolution(TSize aResolution) |
|
674 { |
|
675 |
|
676 if ( aResolution == KVedResolutionSubQCIF ) |
|
677 return EResolutionSubQCIF; |
|
678 |
|
679 else if ( aResolution == KVedResolutionQCIF ) |
|
680 return EResolutionQCIF; |
|
681 |
|
682 else if ( aResolution == KVedResolutionCIF ) |
|
683 return EResolutionCIF; |
|
684 |
|
685 else if ( aResolution == KVedResolutionQVGA ) |
|
686 return EResolutionQVGA; |
|
687 |
|
688 else if ( aResolution == KVedResolutionVGA16By9 ) |
|
689 return EResolutionVGA16By9; |
|
690 |
|
691 else if ( aResolution == KVedResolutionVGA ) |
|
692 return EResolutionVGA; |
|
693 //WVGA task |
|
694 else if ( aResolution == KVedResolutionWVGA ) |
|
695 return EResolutionWVGA; |
|
696 |
|
697 return EResolutionUnsupported; |
|
698 } |
|
699 |
|
700 // ----------------------------------------------------------------------------- |
|
701 // CVedCodecChecker::MapProfileLevelId |
|
702 // (other items were commented in a header). |
|
703 // ----------------------------------------------------------------------------- |
|
704 // |
|
705 TCodec CVedCodecChecker::MapProfileLevelId(TInt aProfileLevelId) |
|
706 { |
|
707 |
|
708 if ( aProfileLevelId == 8 ) |
|
709 return ECodecMPEG4VSPLevel0; |
|
710 |
|
711 if ( aProfileLevelId == 9 ) |
|
712 return ECodecMPEG4VSPLevel0B; |
|
713 |
|
714 if ( aProfileLevelId == 1 ) |
|
715 return ECodecMPEG4VSPLevel1; |
|
716 |
|
717 if ( aProfileLevelId == 2 ) |
|
718 return ECodecMPEG4VSPLevel3; |
|
719 |
|
720 if ( aProfileLevelId == 3 ) |
|
721 return ECodecMPEG4VSPLevel3; |
|
722 |
|
723 if ( aProfileLevelId == 4 ) |
|
724 return ECodecMPEG4VSPLevel4; |
|
725 |
|
726 return ECodecUnsupported; |
|
727 |
|
728 } |
|
729 |
|
730 // ----------------------------------------------------------------------------- |
|
731 // CVedCodecChecker::MapAVCLevel |
|
732 // (other items were commented in a header). |
|
733 // ----------------------------------------------------------------------------- |
|
734 // |
|
735 TCodec CVedCodecChecker::MapAVCLevel(TInt aLevel) |
|
736 { |
|
737 |
|
738 if ( aLevel == 10 ) |
|
739 return ECodecAVCBPLevel1; |
|
740 |
|
741 if ( aLevel == 101 ) |
|
742 return ECodecAVCBPLevel1B; |
|
743 |
|
744 if ( aLevel == 11 ) |
|
745 return ECodecAVCBPLevel1_1; |
|
746 |
|
747 if ( aLevel == 12 ) |
|
748 return ECodecAVCBPLevel1_2; |
|
749 |
|
750 if ( aLevel == 13 ) |
|
751 return ECodecAVCBPLevel1_3; |
|
752 |
|
753 if ( aLevel == 20 ) |
|
754 return ECodecAVCBPLevel2; |
|
755 //WVGA task |
|
756 if ( aLevel == 21 ) |
|
757 return ECodecAVCBPLevel2_1; |
|
758 |
|
759 if ( aLevel == 22 ) |
|
760 return ECodecAVCBPLevel2_2; |
|
761 |
|
762 if ( aLevel == 30 ) |
|
763 return ECodecAVCBPLevel3; |
|
764 |
|
765 if ( aLevel == 31 ) |
|
766 return ECodecAVCBPLevel3_1; |
|
767 |
|
768 return ECodecUnsupported; |
|
769 |
|
770 } |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CVedCodecChecker::ParseMimeType |
|
774 // (other items were commented in a header). |
|
775 // ----------------------------------------------------------------------------- |
|
776 // |
|
777 TCodec CVedCodecChecker::ParseMimeType(const TPtrC8& aMimeType, TSize aResolution) |
|
778 { |
|
779 |
|
780 // figure out codec |
|
781 TCodec codec; |
|
782 |
|
783 if ( aMimeType.MatchF( _L8("*video/H263-2000*") ) != KErrNotFound ) |
|
784 { |
|
785 codec = ECodecH263BPLevel10; |
|
786 |
|
787 if ( aMimeType.MatchF( _L8("*profile*") ) != KErrNotFound ) |
|
788 { |
|
789 // Profile info is given, check it |
|
790 if ( aMimeType.MatchF( _L8("*profile=0*") ) == KErrNotFound ) |
|
791 { |
|
792 return ECodecUnsupported; |
|
793 } |
|
794 } |
|
795 else |
|
796 { |
|
797 // no profile given |
|
798 } |
|
799 |
|
800 if ( aMimeType.MatchF( _L8("*level=10*") ) != KErrNotFound ) |
|
801 { |
|
802 codec = ECodecH263BPLevel10; |
|
803 } |
|
804 |
|
805 else if ( aMimeType.MatchF( _L8("*level=45*") ) != KErrNotFound ) |
|
806 { |
|
807 codec = ECodecH263BPLevel45; |
|
808 } |
|
809 |
|
810 else if ( aMimeType.MatchF( _L8("*level*") ) != KErrNotFound ) |
|
811 { |
|
812 // no other levels supported |
|
813 return ECodecUnsupported; |
|
814 } |
|
815 else |
|
816 { |
|
817 // if no level is given assume 10 |
|
818 } |
|
819 } |
|
820 else if ( (aMimeType.MatchF( _L8("*video/mp4v-es*") ) != KErrNotFound) || |
|
821 (aMimeType.MatchF( _L8("*video/MP4V-ES*") ) != KErrNotFound) ) |
|
822 { |
|
823 |
|
824 codec = ECodecMPEG4VSPLevel0; |
|
825 |
|
826 // Check profile-level |
|
827 if ( aMimeType.MatchF( _L8("*profile-level-id=*") ) != KErrNotFound ) |
|
828 { |
|
829 if ( aMimeType.MatchF( _L8("*profile-level-id=8*") ) != KErrNotFound ) |
|
830 { |
|
831 codec = ECodecMPEG4VSPLevel0; |
|
832 } |
|
833 else if( aMimeType.MatchF( _L8("*profile-level-id=1*") ) != KErrNotFound ) |
|
834 { |
|
835 codec = ECodecMPEG4VSPLevel1; |
|
836 } |
|
837 else if ( aMimeType.MatchF( _L8("*profile-level-id=2*") ) != KErrNotFound ) |
|
838 { |
|
839 codec = ECodecMPEG4VSPLevel2; |
|
840 } |
|
841 else if ( aMimeType.MatchF( _L8("*profile-level-id=3*") ) != KErrNotFound ) |
|
842 { |
|
843 codec = ECodecMPEG4VSPLevel3; |
|
844 } |
|
845 else if ( aMimeType.MatchF( _L8("*profile-level-id=9*") ) != KErrNotFound ) |
|
846 { |
|
847 codec = ECodecMPEG4VSPLevel0B; |
|
848 } |
|
849 else if ( aMimeType.MatchF( _L8("*profile-level-id=4*") ) != KErrNotFound ) |
|
850 { |
|
851 codec = ECodecMPEG4VSPLevel4; |
|
852 } |
|
853 else |
|
854 { |
|
855 return ECodecUnsupported; |
|
856 } |
|
857 |
|
858 } |
|
859 else |
|
860 { // no profile-level id |
|
861 switch( aResolution.iWidth ) |
|
862 { |
|
863 case KSubQCIFWidth: |
|
864 case KQCIFWidth: |
|
865 { |
|
866 // Set profile-level-id=0 |
|
867 codec = ECodecMPEG4VSPLevel0; |
|
868 break; |
|
869 } |
|
870 |
|
871 case KCIFWidth: |
|
872 case KQVGAWidth: |
|
873 { |
|
874 // Set profile-level-id=2 |
|
875 codec = ECodecMPEG4VSPLevel2; |
|
876 break; |
|
877 } |
|
878 |
|
879 case KVGAWidth: |
|
880 { |
|
881 // Set profile-level-id=4 (4a) |
|
882 codec = ECodecMPEG4VSPLevel4; |
|
883 break; |
|
884 } |
|
885 |
|
886 default: |
|
887 { |
|
888 // Set profile-level-id=0 |
|
889 codec = ECodecMPEG4VSPLevel0; |
|
890 } |
|
891 } |
|
892 |
|
893 } |
|
894 } |
|
895 |
|
896 #ifdef VIDEOEDITORENGINE_AVC_EDITING |
|
897 else if ( (aMimeType.MatchF( _L8("*video/h264*") ) != KErrNotFound) || |
|
898 (aMimeType.MatchF( _L8("*video/H264*") ) != KErrNotFound) ) |
|
899 |
|
900 { |
|
901 codec = ECodecAVCBPLevel1; |
|
902 |
|
903 if ( aMimeType.MatchF( _L8("*profile-level-id=42800A*") ) != KErrNotFound ) |
|
904 { |
|
905 codec = ECodecAVCBPLevel1; |
|
906 } |
|
907 else if( aMimeType.MatchF( _L8("*profile-level-id=42900B*") ) != KErrNotFound ) |
|
908 { |
|
909 codec = ECodecAVCBPLevel1B; |
|
910 } |
|
911 else if ( aMimeType.MatchF( _L8("*profile-level-id=42800B*") ) != KErrNotFound ) |
|
912 { |
|
913 codec = ECodecAVCBPLevel1_1; |
|
914 } |
|
915 else if ( aMimeType.MatchF( _L8("*profile-level-id=42800C*") ) != KErrNotFound ) |
|
916 { |
|
917 codec = ECodecAVCBPLevel1_2; |
|
918 } |
|
919 //WVGA task |
|
920 else if ( aMimeType.MatchF( _L8("*profile-level-id=42800D*") ) != KErrNotFound ) |
|
921 { |
|
922 codec = ECodecAVCBPLevel1_3; |
|
923 } |
|
924 else if ( aMimeType.MatchF( _L8("*profile-level-id=428014*") ) != KErrNotFound ) |
|
925 { |
|
926 codec = ECodecAVCBPLevel2; |
|
927 } |
|
928 else if ( aMimeType.MatchF( _L8("*profile-level-id=428015*") ) != KErrNotFound ) |
|
929 { |
|
930 codec = ECodecAVCBPLevel2_1; |
|
931 } |
|
932 else if ( aMimeType.MatchF( _L8("*profile-level-id=428016*") ) != KErrNotFound ) |
|
933 { |
|
934 codec = ECodecAVCBPLevel2_2; |
|
935 } |
|
936 else if ( aMimeType.MatchF( _L8("*profile-level-id=42801E*") ) != KErrNotFound ) |
|
937 { |
|
938 codec = ECodecAVCBPLevel3; |
|
939 } |
|
940 else if ( aMimeType.MatchF( _L8("*profile-level-id=42801F*") ) != KErrNotFound ) |
|
941 { |
|
942 codec = ECodecAVCBPLevel3_1; |
|
943 } |
|
944 else |
|
945 { |
|
946 return ECodecUnsupported; |
|
947 } |
|
948 } |
|
949 #endif |
|
950 |
|
951 else |
|
952 { |
|
953 return ECodecUnsupported; |
|
954 } |
|
955 |
|
956 return codec; |
|
957 |
|
958 } |
|
959 |
|
960 |
|
961 // End of file |
|
962 |
|