summaryrefslogtreecommitdiffstats
path: root/media/libstagefright/codecs/mp3dec/include/pvmp3decoder_api.h
blob: 1568e7c1ddb4e19efc32708fdf8826e809cac734 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/* ------------------------------------------------------------------
 * Copyright (C) 1998-2009 PacketVideo
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
 * express or implied.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 * -------------------------------------------------------------------
 */
/*
------------------------------------------------------------------------------
   PacketVideo Corp.
   MP3 Decoder Library

   Filename: pvmp3decoder_api.h

   Date: 09/21/2007

------------------------------------------------------------------------------
 REVISION HISTORY

 Description:

------------------------------------------------------------------------------
 INCLUDE DESCRIPTION

 This include file defines the structure tPVMP3DecoderExternal

------------------------------------------------------------------------------
*/

/*----------------------------------------------------------------------------
; CONTINUE ONLY IF NOT ALREADY DEFINED
----------------------------------------------------------------------------*/
#ifndef PVMP3DECODER_API_H
#define PVMP3DECODER_API_H

/*----------------------------------------------------------------------------
; INCLUDES
----------------------------------------------------------------------------*/

#include "pvmp3_audio_type_defs.h"
#include "pvmp3_dec_defs.h"

/*----------------------------------------------------------------------------
; MACROS
; Define module specific macros here
----------------------------------------------------------------------------*/
#ifdef __cplusplus
extern "C"
{
#endif

    /*----------------------------------------------------------------------------
    ; DEFINES
    ; Include all pre-processor statements here.
    ----------------------------------------------------------------------------*/

    /*----------------------------------------------------------------------------
    ; EXTERNAL VARIABLES REFERENCES
    ; Declare variables used in this module but defined elsewhere
    ----------------------------------------------------------------------------*/

    /*----------------------------------------------------------------------------
    ; SIMPLE TYPEDEF'S
    ----------------------------------------------------------------------------*/

    /*----------------------------------------------------------------------------
    ; ENUMERATED TYPEDEF'S
    ----------------------------------------------------------------------------*/
    typedef enum
    {
        flat       = 0,
        bass_boost = 1,
        rock       = 2,
        pop        = 3,
        jazz       = 4,
        classical  = 5,
        talk       = 6,
        flat_      = 7

    } e_equalization;



    typedef enum ERROR_CODE
    {
        NO_DECODING_ERROR         = 0,
        UNSUPPORTED_LAYER         = 1,
        UNSUPPORTED_FREE_BITRATE  = 2,
        FILE_OPEN_ERROR           = 3,          /* error opening file */
        CHANNEL_CONFIG_ERROR      = 4,     /* error in channel configuration */
        SYNTHESIS_WINDOW_ERROR    = 5,   /* error in synthesis window table */
        READ_FILE_ERROR           = 6,          /* error reading input file */
        SIDE_INFO_ERROR           = 7,          /* error in side info */
        HUFFMAN_TABLE_ERROR       = 8,      /* error in Huffman table */
        COMMAND_LINE_ERROR        = 9,       /* error in command line */
        MEMORY_ALLOCATION_ERROR   = 10,   /* error allocating memory */
        NO_ENOUGH_MAIN_DATA_ERROR = 11,
        SYNCH_LOST_ERROR          = 12,
        OUTPUT_BUFFER_TOO_SMALL   = 13     /* output buffer can't hold output */
    } ERROR_CODE;

    /*----------------------------------------------------------------------------
    ; STRUCTURES TYPEDEF'S
    ----------------------------------------------------------------------------*/

    typedef struct
#ifdef __cplusplus
                tPVMP3DecoderExternal
#endif
    {

        /*
         * INPUT:
         * Pointer to the input buffer that contains the encoded bistream data.
         * The data is filled in such that the first bit transmitted is
         * the most-significant bit (MSB) of the first array element.
         * The buffer is accessed in a linear fashion for speed, and the number of
         * bytes consumed varies frame to frame.
         * The calling environment can change what is pointed to between calls to
         * the decode function, library, as long as the inputBufferCurrentLength,
         * and inputBufferUsedLength are updated too. Also, any remaining bits in
         * the old buffer must be put at the beginning of the new buffer.
         */
        uint8      *pInputBuffer;

        /*
         * INPUT:
         * Number of valid bytes in the input buffer, set by the calling
         * function. After decoding the bitstream the library checks to
         * see if it when past this value; it would be to prohibitive to
         * check after every read operation. This value is not modified by
         * the MP3 library.
         */
        int32     inputBufferCurrentLength;

        /*
         * INPUT/OUTPUT:
         * Number of elements used by the library, initially set to zero by
         * the function pvmp3_resetDecoder(), and modified by each
         * call to pvmp3_framedecoder().
         */
        int32     inputBufferUsedLength;

        /*
         * OUTPUT:
         * holds the predicted frame size. It used on the test console, for parsing
         * purposes.
         */
        uint32     CurrentFrameLength;

        /*
         * INPUT:
         * This variable holds the type of equalization used
         *
         *
         */
        e_equalization     equalizerType;


        /*
         * INPUT:
         * The actual size of the buffer.
         * This variable is not used by the library, but is used by the
         * console test application. This parameter could be deleted
         * if this value was passed into these function.
         */
        int32     inputBufferMaxLength;

        /*
         * OUTPUT:
         * The number of channels decoded from the bitstream.
         */
        int16       num_channels;

        /*
         * OUTPUT:
         * The number of channels decoded from the bitstream.
         */
        int16       version;

        /*
         * OUTPUT:
         * The sampling rate decoded from the bitstream, in units of
         * samples/second.
         */
        int32       samplingRate;

        /*
         * OUTPUT:
         * This value is the bitrate in units of bits/second. IT
         * is calculated using the number of bits consumed for the current frame,
         * and then multiplying by the sampling_rate, divided by points in a frame.
         * This value can changes frame to frame.
         */
        int32       bitRate;

        /*
         * INPUT/OUTPUT:
         * In: Inform decoder how much more room is available in the output buffer in int16 samples
         * Out: Size of the output frame in 16-bit words, This value depends on the mp3 version
         */
        int32     outputFrameSize;

        /*
         * INPUT:
         * Flag to enable/disable crc error checking
         */
        int32     crcEnabled;

        /*
         * OUTPUT:
         * This value is used to accumulate bit processed and compute an estimate of the
         * bitrate. For debugging purposes only, as it will overflow for very long clips
         */
        uint32     totalNumberOfBitsUsed;


        /*
         * INPUT: (but what is pointed to is an output)
         * Pointer to the output buffer to hold the 16-bit PCM audio samples.
         * If the output is stereo, both left and right channels will be stored
         * in this one buffer.
         */

        int16       *pOutputBuffer;

    } tPVMP3DecoderExternal;

uint32 pvmp3_decoderMemRequirements(void);

void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt,
                       void  *pMem);

void pvmp3_resetDecoder(void  *pMem);

ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt,
                              void              *pMem);

#ifdef __cplusplus
}
#endif

/*----------------------------------------------------------------------------
; END
----------------------------------------------------------------------------*/

#endif