Home | History | Annotate | Download | only in include
      1 /* ------------------------------------------------------------------
      2  * Copyright (C) 1998-2009 PacketVideo
      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
     13  * express or implied.
     14  * See the License for the specific language governing permissions
     15  * and limitations under the License.
     16  * -------------------------------------------------------------------
     17  */
     18 /*
     19 ------------------------------------------------------------------------------
     20    PacketVideo Corp.
     21    MP3 Decoder Library
     22 
     23    Filename: pvmp3decoder_api.h
     24 
     25    Date: 09/21/2007
     26 
     27 ------------------------------------------------------------------------------
     28  REVISION HISTORY
     29 
     30  Description:
     31 
     32 ------------------------------------------------------------------------------
     33  INCLUDE DESCRIPTION
     34 
     35  This include file defines the structure tPVMP3DecoderExternal
     36 
     37 ------------------------------------------------------------------------------
     38 */
     39 
     40 /*----------------------------------------------------------------------------
     41 ; CONTINUE ONLY IF NOT ALREADY DEFINED
     42 ----------------------------------------------------------------------------*/
     43 #ifndef PVMP3DECODER_API_H
     44 #define PVMP3DECODER_API_H
     45 
     46 /*----------------------------------------------------------------------------
     47 ; INCLUDES
     48 ----------------------------------------------------------------------------*/
     49 
     50 #include "pvmp3_audio_type_defs.h"
     51 #include "pvmp3_dec_defs.h"
     52 
     53 /*----------------------------------------------------------------------------
     54 ; MACROS
     55 ; Define module specific macros here
     56 ----------------------------------------------------------------------------*/
     57 #ifdef __cplusplus
     58 extern "C"
     59 {
     60 #endif
     61 
     62     /*----------------------------------------------------------------------------
     63     ; DEFINES
     64     ; Include all pre-processor statements here.
     65     ----------------------------------------------------------------------------*/
     66 
     67     /*----------------------------------------------------------------------------
     68     ; EXTERNAL VARIABLES REFERENCES
     69     ; Declare variables used in this module but defined elsewhere
     70     ----------------------------------------------------------------------------*/
     71 
     72     /*----------------------------------------------------------------------------
     73     ; SIMPLE TYPEDEF'S
     74     ----------------------------------------------------------------------------*/
     75 
     76     /*----------------------------------------------------------------------------
     77     ; ENUMERATED TYPEDEF'S
     78     ----------------------------------------------------------------------------*/
     79     typedef enum
     80     {
     81         flat       = 0,
     82         bass_boost = 1,
     83         rock       = 2,
     84         pop        = 3,
     85         jazz       = 4,
     86         classical  = 5,
     87         talk       = 6,
     88         flat_      = 7
     89 
     90     } e_equalization;
     91 
     92 
     93 
     94     typedef enum ERROR_CODE
     95     {
     96         NO_DECODING_ERROR         = 0,
     97         UNSUPPORTED_LAYER         = 1,
     98         UNSUPPORTED_FREE_BITRATE  = 2,
     99         FILE_OPEN_ERROR           = 3,          /* error opening file */
    100         CHANNEL_CONFIG_ERROR      = 4,     /* error in channel configuration */
    101         SYNTHESIS_WINDOW_ERROR    = 5,   /* error in synthesis window table */
    102         READ_FILE_ERROR           = 6,          /* error reading input file */
    103         SIDE_INFO_ERROR           = 7,          /* error in side info */
    104         HUFFMAN_TABLE_ERROR       = 8,      /* error in Huffman table */
    105         COMMAND_LINE_ERROR        = 9,       /* error in command line */
    106         MEMORY_ALLOCATION_ERROR   = 10,   /* error allocating memory */
    107         NO_ENOUGH_MAIN_DATA_ERROR = 11,
    108         SYNCH_LOST_ERROR          = 12,
    109         OUTPUT_BUFFER_TOO_SMALL   = 13     /* output buffer can't hold output */
    110     } ERROR_CODE;
    111 
    112     /*----------------------------------------------------------------------------
    113     ; STRUCTURES TYPEDEF'S
    114     ----------------------------------------------------------------------------*/
    115 
    116     typedef struct
    117 #ifdef __cplusplus
    118                 tPVMP3DecoderExternal
    119 #endif
    120     {
    121 
    122         /*
    123          * INPUT:
    124          * Pointer to the input buffer that contains the encoded bistream data.
    125          * The data is filled in such that the first bit transmitted is
    126          * the most-significant bit (MSB) of the first array element.
    127          * The buffer is accessed in a linear fashion for speed, and the number of
    128          * bytes consumed varies frame to frame.
    129          * The calling environment can change what is pointed to between calls to
    130          * the decode function, library, as long as the inputBufferCurrentLength,
    131          * and inputBufferUsedLength are updated too. Also, any remaining bits in
    132          * the old buffer must be put at the beginning of the new buffer.
    133          */
    134         uint8      *pInputBuffer;
    135 
    136         /*
    137          * INPUT:
    138          * Number of valid bytes in the input buffer, set by the calling
    139          * function. After decoding the bitstream the library checks to
    140          * see if it when past this value; it would be to prohibitive to
    141          * check after every read operation. This value is not modified by
    142          * the MP3 library.
    143          */
    144         int32     inputBufferCurrentLength;
    145 
    146         /*
    147          * INPUT/OUTPUT:
    148          * Number of elements used by the library, initially set to zero by
    149          * the function pvmp3_resetDecoder(), and modified by each
    150          * call to pvmp3_framedecoder().
    151          */
    152         int32     inputBufferUsedLength;
    153 
    154         /*
    155          * OUTPUT:
    156          * holds the predicted frame size. It used on the test console, for parsing
    157          * purposes.
    158          */
    159         uint32     CurrentFrameLength;
    160 
    161         /*
    162          * INPUT:
    163          * This variable holds the type of equalization used
    164          *
    165          *
    166          */
    167         e_equalization     equalizerType;
    168 
    169 
    170         /*
    171          * INPUT:
    172          * The actual size of the buffer.
    173          * This variable is not used by the library, but is used by the
    174          * console test application. This parameter could be deleted
    175          * if this value was passed into these function.
    176          */
    177         int32     inputBufferMaxLength;
    178 
    179         /*
    180          * OUTPUT:
    181          * The number of channels decoded from the bitstream.
    182          */
    183         int16       num_channels;
    184 
    185         /*
    186          * OUTPUT:
    187          * The number of channels decoded from the bitstream.
    188          */
    189         int16       version;
    190 
    191         /*
    192          * OUTPUT:
    193          * The sampling rate decoded from the bitstream, in units of
    194          * samples/second.
    195          */
    196         int32       samplingRate;
    197 
    198         /*
    199          * OUTPUT:
    200          * This value is the bitrate in units of bits/second. IT
    201          * is calculated using the number of bits consumed for the current frame,
    202          * and then multiplying by the sampling_rate, divided by points in a frame.
    203          * This value can changes frame to frame.
    204          */
    205         int32       bitRate;
    206 
    207         /*
    208          * INPUT/OUTPUT:
    209          * In: Inform decoder how much more room is available in the output buffer in int16 samples
    210          * Out: Size of the output frame in 16-bit words, This value depends on the mp3 version
    211          */
    212         int32     outputFrameSize;
    213 
    214         /*
    215          * INPUT:
    216          * Flag to enable/disable crc error checking
    217          */
    218         int32     crcEnabled;
    219 
    220         /*
    221          * OUTPUT:
    222          * This value is used to accumulate bit processed and compute an estimate of the
    223          * bitrate. For debugging purposes only, as it will overflow for very long clips
    224          */
    225         uint32     totalNumberOfBitsUsed;
    226 
    227 
    228         /*
    229          * INPUT: (but what is pointed to is an output)
    230          * Pointer to the output buffer to hold the 16-bit PCM audio samples.
    231          * If the output is stereo, both left and right channels will be stored
    232          * in this one buffer.
    233          */
    234 
    235         int16       *pOutputBuffer;
    236 
    237     } tPVMP3DecoderExternal;
    238 
    239 uint32 pvmp3_decoderMemRequirements(void);
    240 
    241 void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt,
    242                        void  *pMem);
    243 
    244 void pvmp3_resetDecoder(void  *pMem);
    245 
    246 ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt,
    247                               void              *pMem);
    248 
    249 #ifdef __cplusplus
    250 }
    251 #endif
    252 
    253 /*----------------------------------------------------------------------------
    254 ; END
    255 ----------------------------------------------------------------------------*/
    256 
    257 #endif
    258 
    259 
    260