Home | History | Annotate | Download | only in common
      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 //  File: pvgsmamrdecoderinterface.h                                            //
     21 //                                                                              //
     22 //////////////////////////////////////////////////////////////////////////////////
     23 
     24 #ifndef _PVGSMAMR_DECODER_INTERFACE_H
     25 #define _PVGSMAMR_DECODER_INTERFACE_H
     26 
     27 /*----------------------------------------------------------------------------
     28 ; ENUMERATED TYPEDEF'S
     29 ----------------------------------------------------------------------------*/
     30 
     31 typedef enum
     32 {
     33     /*
     34      *    One word (2-byte) to indicate type of frame type.
     35      *    One word (2-byte) to indicate frame type.
     36      *    One word (2-byte) to indicate mode.
     37      *    N words (2-byte) containing N bits (bit 0 = 0xff81, bit 1 = 0x007f).
     38      */
     39     ETS = 0, /* Both AMR-Narrowband and AMR-Wideband */
     40 
     41     /*
     42      *    One word (2-byte) for sync word (good frames: 0x6b21, bad frames: 0x6b20)
     43      *    One word (2-byte) for frame length N.
     44      *    N words (2-byte) containing N bits (bit 0 = 0x007f, bit 1 = 0x0081).
     45      */
     46     ITU, /* AMR-Wideband */
     47 
     48     /*
     49      *   AMR-WB MIME/storage format, see RFC 3267 (sections 5.1 and 5.3) for details
     50      */
     51     MIME_IETF,
     52 
     53     WMF, /* AMR-Narrowband */
     54 
     55     IF2  /* AMR-Narrowband */
     56 
     57 } bitstream_format;
     58 
     59 
     60 
     61 /*----------------------------------------------------------------------------
     62 ; STRUCTURES TYPEDEF'S
     63 ----------------------------------------------------------------------------*/
     64 typedef struct
     65 {
     66     int16_t prev_ft;
     67     int16_t prev_mode;
     68 } RX_State;
     69 
     70 
     71 typedef struct tPVAmrDecoderExternal
     72 {
     73     /*
     74      * INPUT:
     75      * Pointer to the input buffer that contains the encoded bistream data.
     76      * The data is filled in such that the first bit transmitted is
     77      * the most-significant bit (MSB) of the first array element.
     78      * The buffer is accessed in a linear fashion for speed, and the number of
     79      * bytes consumed varies frame to frame. This is use for mime/ietf data
     80      */
     81     uint8_t  *pInputBuffer;
     82 
     83     /*
     84      * INPUT:
     85      * Pointer to the input buffer that contains the encoded stream data.
     86      * The data is filled such that the first bit transmitted is
     87      * in the  first int16_t element.
     88      * The buffer is accessed in a linear fashion for speed, and the number of
     89      * bytes consumed varies frame to frame.
     90      */
     91     int16_t  *pInputSampleBuffer;
     92 
     93     /*
     94      * INPUT: (but what is pointed to is an output)
     95      * Pointer to the output buffer to hold the 16-bit PCM audio samples.
     96      */
     97     int16_t  *pOutputBuffer;
     98 
     99     /*
    100      * INPUT:
    101      * Number of requested output audio channels. This relieves the calling
    102      * environment from having to perform stereo-to-mono or mono-to-stereo
    103      * conversions.
    104      */
    105     int32_t     desiredChannels;
    106 
    107     /*
    108          * INPUT:
    109          * Format type of the encoded bitstream.
    110          */
    111     bitstream_format     input_format;
    112 
    113     /*
    114      * OUTPUT:
    115      * The sampling rate decoded from the bitstream, in units of
    116      * samples/second. For this release of the library this value does
    117      * not change from frame to frame, but future versions will.
    118      */
    119     int32_t   samplingRate;
    120 
    121     /*
    122      * OUTPUT:
    123      * This value is the bitrate in units of bits/second. IT
    124      * is calculated using the number of bits consumed for the current frame,
    125      * and then multiplying by the sampling_rate, divided by points in a frame.
    126      * This value can changes frame to frame.
    127      */
    128     int32_t   bitRate;
    129 
    130     /*
    131      * OUTPUT:
    132      * The number of channels decoded from the bitstream. The output data
    133      * will have be the amount specified in the variable desiredChannels,
    134      * this output is informative only, and can be ignored.
    135      */
    136     int32_t     encodedChannels;
    137 
    138     /*
    139      * OUTPUT:
    140      * This value is the number of output PCM samples per channel.
    141      * It is  320.
    142      */
    143     int16_t     frameLength;
    144 
    145     /*
    146      * OUTPUT:
    147      * This value is the quality indicator. 1 (good)  0 (bad)
    148     */
    149     uint8_t     quality;
    150 
    151 
    152     /*
    153      * OUTPUT:
    154      *  GSM AMR NB and WB mode (i.e. bit-rate )
    155      */
    156     int16_t     mode;
    157     int16_t     mode_old;
    158 
    159     /*
    160      * OUTPUT:
    161      *  GSM AMR NB and WB frame type ( speech_good, speech_bad, sid, etc.)
    162      */
    163     int16_t     frame_type;
    164 
    165     int16_t reset_flag;
    166     int16_t reset_flag_old;
    167 
    168     /*
    169      * OUTPUT:
    170      *  Decoder  status
    171      */
    172     int32_t     status;
    173 
    174     /*
    175      * OUTPUT:
    176      *  Rx status state
    177      */
    178     RX_State  rx_state;
    179 
    180 } tPVAmrDecoderExternal;
    181 
    182 #endif
    183 
    184