|
1 /* |
|
2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "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 * |
|
14 * Description: Common AMR codec data utilities |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef AMRCOMMONUTIL_H |
|
22 #define AMRCOMMONUTIL_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include "AmrFrameInfo.h" |
|
27 |
|
28 // CLASS DECLARATION |
|
29 |
|
30 #ifdef _DEBUG |
|
31 #include <e32svr.h> |
|
32 #define _DEBUG_AMR_CHECK_ELEMENT_RANGE |
|
33 #endif |
|
34 |
|
35 #ifdef _DEBUG_AMR_CHECK_ELEMENT_RANGE |
|
36 #define _DEBUG_AMR_ELEMENT_RANGE_ERROR (a, b) \ |
|
37 { _LIT( KName, a); RDebug::Print(KName, b); } |
|
38 #else |
|
39 #define _DEBUG_AMR_ELEMENT_RANGE_ERROR(a, b) |
|
40 #endif |
|
41 |
|
42 const TUint KNumValue0 = 0; |
|
43 const TUint KNumValue1 = 1; |
|
44 const TUint KNumValue2 = 2; |
|
45 const TUint KNumValue3 = 3; |
|
46 const TUint KNumValue4 = 4; |
|
47 const TUint KNumValue5 = 5; |
|
48 const TUint KNumValue8 = 8; |
|
49 const TUint KNumValue9 = 9; |
|
50 const TUint KNumValue10 = 10; |
|
51 const TUint KNumValue11 = 11; |
|
52 const TUint KNumValue100 = 100; |
|
53 const TUint KNumValue400 = 400; |
|
54 |
|
55 const TInt KBitIndex7 = 7; |
|
56 |
|
57 |
|
58 /** |
|
59 * Common utility functions for AMR encoded data |
|
60 * |
|
61 * @lib Mccamrplformat.lib |
|
62 * @since Series 60 3.0 |
|
63 */ |
|
64 class CAmrCommonUtility : public CBase |
|
65 { |
|
66 public: |
|
67 /** |
|
68 * Calculates frame size and returns information about the frame. |
|
69 * @since Series 60 3.0 |
|
70 * @param aBuf Contains frame to be examined at the beginning of the |
|
71 * buffer |
|
72 * @param aBufLen Length of the buffer |
|
73 * @param aInfo - [output] Frame info |
|
74 * @param aIsNb Is AMR narrow band? |
|
75 * @return TInt - 0 if frame bit syntax is incorrect |
|
76 */ |
|
77 static TInt FrameInfo( const TUint8* aBuf, TInt aBufLen, |
|
78 TAmrFrameInfo& aInfo, TBool aIsNb ); |
|
79 |
|
80 /** |
|
81 * Seeks the start position of the next frame and returns the byte |
|
82 * position of frames header. |
|
83 * @since Series 60 3.0 |
|
84 * @param aBuf Buffer which contains frames |
|
85 * @param aBufLen Length of the buffer |
|
86 * @param aIsNb Is AMR narrow band? |
|
87 * @return TInt - Byte position of the frames header or aBufLen, if no |
|
88 * valid frame can not be found. |
|
89 */ |
|
90 static TInt SeekSync( const TUint8* aBuf, TInt aBufLen, TBool aIsNb ); |
|
91 |
|
92 /** |
|
93 * Returns the size of frame described by given coding parameters. |
|
94 * @since Series 60 3.0 |
|
95 * @param aInfo Frame info containing coding parameters |
|
96 * @param aIsNb Is AMR narrow band? |
|
97 * @return TInt - Size of the frame |
|
98 */ |
|
99 static TInt FrameSize( const TAmrFrameInfo& aInfo, TBool aIsNb ); |
|
100 |
|
101 /** |
|
102 * Returns the size of one AMR frame header. |
|
103 * @since Series 60 3.0 |
|
104 * @return TInt - Size of one AMR frame header in bytes |
|
105 */ |
|
106 static TInt FrameHeaderSize( ); |
|
107 }; |
|
108 |
|
109 #endif // MCCAMRCOMMONUTIL_H |
|
110 |