1/*
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
17/**
18 ******************************************************************************
19 * @file    M4MP4W_Utils.h
20 * @brief   Utilities and private functions declaration for the MP4 writer
21 ******************************************************************************
22 */
23
24#ifndef M4MP4W_UTILS_H
25#define M4MP4W_UTILS_H
26
27#ifdef __cplusplus
28extern "C" {
29#endif /* __cplusplus */
30
31#include "NXPSW_CompilerSwitches.h"
32
33#ifndef _M4MP4W_USE_CST_MEMORY_WRITER
34
35/* includes */
36#include "M4OSA_Types.h"
37#include "M4OSA_FileWriter.h"
38
39
40/**
41 ******************************************************************************
42 * Utility functions to write data in big endian
43 ******************************************************************************
44 */
45M4OSA_ERR M4MP4W_putByte(M4OSA_UChar c,    M4OSA_FileWriterPointer* fileFunction,
46                         M4OSA_Context context);
47M4OSA_ERR M4MP4W_putBE16(M4OSA_UInt32 val, M4OSA_FileWriterPointer* fileFunction,
48                         M4OSA_Context context);
49M4OSA_ERR M4MP4W_putBE24(M4OSA_UInt32 val, M4OSA_FileWriterPointer* fileFunction,
50                         M4OSA_Context context);
51M4OSA_ERR M4MP4W_putBE32(M4OSA_UInt32 val, M4OSA_FileWriterPointer* fileFunction,
52                         M4OSA_Context context);
53
54/**
55 ******************************************************************************
56 * Write a bulk of data into the specified file, size is given in bytes
57 ******************************************************************************
58 */
59M4OSA_ERR M4MP4W_putBlock(const M4OSA_UChar* Block, M4OSA_UInt32 size,
60                          M4OSA_FileWriterPointer* fileFunction, M4OSA_Context context);
61
62/**
63 ******************************************************************************
64 * Convert the 'nb' unsigned integers in 'tab' table from LE into BE
65 ******************************************************************************
66 */
67void M4MP4W_table32ToBE(M4OSA_UInt32* tab, M4OSA_UInt32 nb);
68
69/**
70 ******************************************************************************
71 * Convert an unsigned 32 bits integer from LE into BE
72 ******************************************************************************
73 */
74void M4MP4W_convertInt32BE(M4OSA_UInt32* valPtr);
75
76/**
77 ******************************************************************************
78 * Re-allocation function
79 ******************************************************************************
80 */
81void* M4MP4W_realloc(M4OSA_MemAddr32 ptr, M4OSA_UInt32 oldSize, M4OSA_UInt32 newSize);
82
83/**
84 ******************************************************************************
85 * De-allocate the context
86 * This method is no longer in the writer external interface, but is called from
87 * the function M4MP4W_closeWrite
88 ******************************************************************************
89 */
90M4OSA_ERR M4MP4W_freeContext(M4OSA_Context context);
91
92
93#ifdef _M4MP4W_OPTIMIZE_FOR_PHONE
94/**
95 ******************************************************************************
96 * Put Hi and Lo u16 part in a u32 variable
97 ******************************************************************************
98 */
99M4OSA_Void M4MP4W_put32_Hi(M4OSA_UInt32* tab, M4OSA_UInt16 Hi);
100M4OSA_Void M4MP4W_put32_Lo(M4OSA_UInt32* tab, M4OSA_UInt16 Lo);
101M4OSA_UInt16 M4MP4W_get32_Hi(M4OSA_UInt32* tab);
102M4OSA_UInt16 M4MP4W_get32_Lo(M4OSA_UInt32* tab);
103#endif
104
105#endif /* _M4MP4W_USE_CST_MEMORY_WRITER */
106
107#ifdef __cplusplus
108}
109#endif /* __cplusplus */
110
111#endif /*M4MP4W_UTILS_H*/
112
113