Home | History | Annotate | Download | only in src
      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 Portions of this file are derived from the following 3GPP standard:
     20 
     21     3GPP TS 26.073
     22     ANSI-C code for the Adaptive Multi-Rate (AMR) speech codec
     23     Available from http://www.3gpp.org
     24 
     25 (C) 2004, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC)
     26 Permission to distribute, modify and use this file under the standard license
     27 terms listed above has been obtained from the copyright holder.
     28 ****************************************************************************************/
     29 /*
     30 
     31 
     32 
     33 
     34  Filename: /audio/gsm_amr/c/src/l_extract.c
     35 
     36      Date: 09/07/2000
     37 
     38 ------------------------------------------------------------------------------
     39  REVISION HISTORY
     40 
     41  Description: Updated template. Changed function interface to pass in a
     42               pointer to overflow flag into the function instead of using a
     43               global flag. Changed names of function parameters for clarity.
     44               Removed inclusion of unwanted header files.
     45 
     46  Description:
     47 
     48 ------------------------------------------------------------------------------
     49 */
     50 
     51 /*----------------------------------------------------------------------------
     52 ; INCLUDES
     53 ----------------------------------------------------------------------------*/
     54 #include    "basic_op.h"
     55 
     56 /*----------------------------------------------------------------------------
     57 ; MACROS
     58 ; [Define module specific macros here]
     59 ----------------------------------------------------------------------------*/
     60 
     61 /*----------------------------------------------------------------------------
     62 ; DEFINES
     63 ; [Include all pre-processor statements here. Include conditional
     64 ; compile variables also.]
     65 ----------------------------------------------------------------------------*/
     66 
     67 /*----------------------------------------------------------------------------
     68 ; LOCAL FUNCTION DEFINITIONS
     69 ; [List function prototypes here]
     70 ----------------------------------------------------------------------------*/
     71 
     72 /*----------------------------------------------------------------------------
     73 ; LOCAL VARIABLE DEFINITIONS
     74 ; [Variable declaration - defined here and used outside this module]
     75 ----------------------------------------------------------------------------*/
     76 
     77 
     78 /*
     79 ------------------------------------------------------------------------------
     80  FUNCTION NAME: L_extract
     81 ------------------------------------------------------------------------------
     82  INPUT AND OUTPUT DEFINITIONS
     83 
     84  Inputs:
     85     L_var = 32 bit signed integer (Word32) whose value falls
     86            in the range : 0x8000 0000 <= L_32 <= 0x7fff ffff.
     87 
     88     pL_var_hi =  pointer to the most significant word of L_var (Word16).
     89 
     90     pL_var_lo =  pointer to the least significant word of L_var shifted
     91               to the left by 1 (Word16).
     92 
     93     pOverflow = pointer to overflow (Flag)
     94 
     95  Outputs:
     96     pOverflow -> 1 if the 32 bit add operation resulted in overflow
     97     pL_var_hi -> MS word of L_32.
     98     pL_var_lo -> LS word of L_32 shifted left by 1.
     99 
    100  Returns:
    101     None
    102 
    103  Global Variables Used:
    104     None
    105 
    106  Local Variables Needed:
    107     None
    108 
    109 ------------------------------------------------------------------------------
    110  FUNCTION DESCRIPTION
    111 
    112  This function extracts two 16-bit double precision format (DPF) numbers
    113  from a 32-bit integer. The MS word of L_var will be stored in the location
    114  pointed to by pL_var_hi and the shifted LS word of L_var will be stored in
    115  the location pointed to by pL_var_lo.
    116 
    117 ------------------------------------------------------------------------------
    118  REQUIREMENTS
    119 
    120  None
    121 
    122 ------------------------------------------------------------------------------
    123  REFERENCES
    124 
    125  [1] L_extract() function in oper_32b.c,  UMTS GSM AMR speech codec, R99 -
    126  Version 3.2.0, March 2, 2001
    127 
    128 ------------------------------------------------------------------------------
    129  PSEUDO-CODE
    130 
    131 
    132 ------------------------------------------------------------------------------
    133  RESOURCES USED [optional]
    134 
    135  When the code is written for a specific target processor the
    136  the resources used should be documented below.
    137 
    138  HEAP MEMORY USED: x bytes
    139 
    140  STACK MEMORY USED: x bytes
    141 
    142  CLOCK CYCLES: (cycle count equation for this function) + (variable
    143                 used to represent cycle count for each subroutine
    144                 called)
    145      where: (cycle count variable) = cycle count for [subroutine
    146                                      name]
    147 
    148 ------------------------------------------------------------------------------
    149  CAUTION [optional]
    150  [State any special notes, constraints or cautions for users of this function]
    151 
    152 ------------------------------------------------------------------------------
    153 */
    154 
    155 /*----------------------------------------------------------------------------
    156 ; FUNCTION CODE
    157 ----------------------------------------------------------------------------*/
    158 void L_Extract(Word32 L_var,
    159                Word16 *pL_var_hi,
    160                Word16 *pL_var_lo,
    161                Flag   *pOverflow)
    162 {
    163 
    164     Word32  temp;
    165 
    166     OSCL_UNUSED_ARG(pOverflow);
    167 
    168     temp = (L_var >> 16);
    169 
    170     *(pL_var_hi) = (Word16) temp;
    171     *(pL_var_lo) = (Word16)((L_var >> 1) - (temp << 15));
    172 
    173     return;
    174 }
    175