get_amr_wb_bits.cpp revision 4f1efc098cb5791c3e9f483f2af84aef70d2d0a0
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/**************************************************************************************** 19Portions of this file are derived from the following 3GPP standard: 20 21 3GPP TS 26.173 22 ANSI-C code for the Adaptive Multi-Rate - Wideband (AMR-WB) speech codec 23 Available from http://www.3gpp.org 24 25(C) 2007, 3GPP Organizational Partners (ARIB, ATIS, CCSA, ETSI, TTA, TTC) 26Permission to distribute, modify and use this file under the standard license 27terms listed above has been obtained from the copyright holder. 28****************************************************************************************/ 29/* 30------------------------------------------------------------------------------ 31 32 33 34 Filename: get_amr_wb_bits.cpp 35 36 Date: 05/08/2007 37 38------------------------------------------------------------------------------ 39 REVISION HISTORY 40 41 42 Description: 43 44------------------------------------------------------------------------------ 45 INPUT AND OUTPUT DEFINITIONS 46 47 int16 no_of_bits, input : number of bits 48 int16 ** prms bitstream pointer 49 50 51------------------------------------------------------------------------------ 52 FUNCTION DESCRIPTION 53 54 Returns no_of_bits from serial bit stream 55 Serial_parm -> convert serial stream to parameters 56 57------------------------------------------------------------------------------ 58 REQUIREMENTS 59 60 61------------------------------------------------------------------------------ 62 REFERENCES 63 64------------------------------------------------------------------------------ 65 PSEUDO-CODE 66 67------------------------------------------------------------------------------ 68*/ 69 70 71/*---------------------------------------------------------------------------- 72; INCLUDES 73----------------------------------------------------------------------------*/ 74 75#include "pv_amr_wb_type_defs.h" 76#include "pvamrwbdecoder_cnst.h" 77#include "get_amr_wb_bits.h" 78 79/*---------------------------------------------------------------------------- 80; MACROS 81; Define module specific macros here 82----------------------------------------------------------------------------*/ 83 84 85/*---------------------------------------------------------------------------- 86; DEFINES 87; Include all pre-processor statements here. Include conditional 88; compile variables also. 89----------------------------------------------------------------------------*/ 90 91/*---------------------------------------------------------------------------- 92; LOCAL FUNCTION DEFINITIONS 93; Function Prototype declaration 94----------------------------------------------------------------------------*/ 95 96/*---------------------------------------------------------------------------- 97; LOCAL STORE/BUFFER/POINTER DEFINITIONS 98; Variable declaration - defined here and used outside this module 99----------------------------------------------------------------------------*/ 100 101/*---------------------------------------------------------------------------- 102; EXTERNAL FUNCTION REFERENCES 103; Declare functions defined elsewhere and referenced in this module 104----------------------------------------------------------------------------*/ 105 106/*---------------------------------------------------------------------------- 107; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES 108; Declare variables used in this module but defined elsewhere 109----------------------------------------------------------------------------*/ 110 111/*---------------------------------------------------------------------------- 112; FUNCTION CODE 113----------------------------------------------------------------------------*/ 114 115 116int16 Serial_parm( /* Return the parameter */ 117 int16 no_of_bits, /* input : number of bits */ 118 int16 ** prms 119) 120{ 121 int16 value = 0; 122 123 for (int16 i = no_of_bits >> 1; i != 0; i--) 124 { 125 value <<= 2; 126 127 if (*((*prms)++) == BIT_1) 128 { 129 value |= 2; 130 } 131 132 if (*((*prms)++) == BIT_1) 133 { 134 value |= 1; 135 } 136 137 } 138 139 if (no_of_bits&1) 140 { 141 value <<= 1; 142 143 if (*((*prms)++) == BIT_1) 144 { 145 value |= 1; 146 } 147 148 } 149 150 return (value); 151} 152 153 154int16 Serial_parm_1bit(int16 ** prms) /* Return the parameter */ 155{ 156 int16 value = 0; 157 158 if (*((*prms)++) == BIT_1) 159 { 160 value = 1; 161 } 162 return (value); 163} 164