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 Filename: sbr_decode_huff_cw.c
21
22------------------------------------------------------------------------------
23 REVISION HISTORY
24
25
26 Who:                                   Date: MM/DD/YYYY
27 Description:
28
29------------------------------------------------------------------------------
30 INPUT AND OUTPUT DEFINITIONS
31
32        SbrHuffman          h,     pointer to huffman codebook table
33        BIT_BUFFER    * hBitBuf    pointer  to Bitbuffer
34
35    return    decoded value
36------------------------------------------------------------------------------
37 FUNCTION DESCRIPTION
38
39  Decodes one huffman code word
40
41  Reads bits from the bitstream until a valid codeword is found.
42  The table entries are interpreted either as index to the next entry
43  or - if negative - as the codeword.
44
45------------------------------------------------------------------------------
46 REQUIREMENTS
47
48
49------------------------------------------------------------------------------
50 REFERENCES
51
52SC 29 Software Copyright Licencing Disclaimer:
53
54This software module was originally developed by
55  Coding Technologies
56
57and edited by
58  -
59
60in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
61standards for reference purposes and its performance may not have been
62optimized. This software module is an implementation of one or more tools as
63specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
64ISO/IEC gives users free license to this software module or modifications
65thereof for use in products claiming conformance to audiovisual and
66image-coding related ITU Recommendations and/or ISO/IEC International
67Standards. ISO/IEC gives users the same free license to this software module or
68modifications thereof for research purposes and further ISO/IEC standardisation.
69Those intending to use this software module in products are advised that its
70use may infringe existing patents. ISO/IEC have no liability for use of this
71software module or modifications thereof. Copyright is not released for
72products that do not conform to audiovisual and image-coding related ITU
73Recommendations and/or ISO/IEC International Standards.
74The original developer retains full right to modify and use the code for its
75own purpose, assign or donate the code to a third party and to inhibit third
76parties from using the code for products that do not conform to audiovisual and
77image-coding related ITU Recommendations and/or ISO/IEC International Standards.
78This copyright notice must be included in all copies or derivative works.
79Copyright (c) ISO/IEC 2002.
80
81------------------------------------------------------------------------------
82 PSEUDO-CODE
83
84------------------------------------------------------------------------------
85*/
86
87
88/*----------------------------------------------------------------------------
89; INCLUDES
90----------------------------------------------------------------------------*/
91
92#ifdef AAC_PLUS
93
94
95#include    "sbr_decode_huff_cw.h"
96#include    "buf_getbits.h"
97
98/*----------------------------------------------------------------------------
99; MACROS
100; Define module specific macros here
101----------------------------------------------------------------------------*/
102
103
104/*----------------------------------------------------------------------------
105; DEFINES
106; Include all pre-processor statements here. Include conditional
107; compile variables also.
108----------------------------------------------------------------------------*/
109
110/*----------------------------------------------------------------------------
111; LOCAL FUNCTION DEFINITIONS
112; Function Prototype declaration
113----------------------------------------------------------------------------*/
114
115/*----------------------------------------------------------------------------
116; LOCAL STORE/BUFFER/POINTER DEFINITIONS
117; Variable declaration - defined here and used outside this module
118----------------------------------------------------------------------------*/
119
120/*----------------------------------------------------------------------------
121; EXTERNAL FUNCTION REFERENCES
122; Declare functions defined elsewhere and referenced in this module
123----------------------------------------------------------------------------*/
124
125/*----------------------------------------------------------------------------
126; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
127; Declare variables used in this module but defined elsewhere
128----------------------------------------------------------------------------*/
129
130/*----------------------------------------------------------------------------
131; FUNCTION CODE
132----------------------------------------------------------------------------*/
133
134Int32 sbr_decode_huff_cw(SbrHuffman h,
135                         BIT_BUFFER * hBitBuf)
136{
137    Int32 bits;
138    Char index = 0;
139
140    while (index >= 0)
141    {
142        bits = buf_get_1bit(hBitBuf);
143        index = h[index][bits];
144    }
145
146    return((Int32)index + 64); /* Add offset */
147}
148
149#endif
150