/*==================================================================================== EVS Codec 3GPP TS26.443 Jun 30, 2015. Version CR 26.443-0006 ====================================================================================*/ #include "options.h" #include "cnst.h" #include "prot.h" #include "rom_com.h" #include "rom_dec.h" /*--------------------------------------------------------------------------*/ /* Function decode_huff_context */ /* ~~~~~~~~~~~~~~~~~ */ /* */ /* Context based Huffman decoding for indices of quantized norms */ /*--------------------------------------------------------------------------*/ /* const short *hufftab, (i) Huffman table */ /* short *rbits (i/o) the number of read bits */ /*--------------------------------------------------------------------------*/ static short decode_huff_context( Decoder_State *st, /* i/o: decoder state structure */ const short *hufftab, short *rbits ) { while( *hufftab > 0) { *rbits+=(*hufftab & 0xf); hufftab += (*hufftab >> 4) + get_next_indice( st, *hufftab & 0xf ); } return (-*hufftab); } /*--------------------------------------------------------------------------*/ /* Function hdecnrm */ /* ~~~~~~~~~~~~~~~~~ */ /* */ /* Huffman decoding for indices of quantized norms */ /*--------------------------------------------------------------------------*/ /* short N (i) number of norms */ /* short *index (o) indices of quantized norms */ /*--------------------------------------------------------------------------*/ void hdecnrm( Decoder_State *st, /* i/o: decoder state structure */ const short N, short *index ) { short i, j, k, n, m; short temp; short *pidx; pidx = index; m = N - 1; for (i=0; i> j; *index++ = huff_tab[offset[j] + k]; } /* Put back unused bits */ st->next_bit_pos -= j; return; } /*-------------------------------------------------------------------------- * hdecnrm_context() * * Huffman decoding for indices of quantized norms *--------------------------------------------------------------------------*/ void hdecnrm_context( Decoder_State *st, /* i/o: decoder state structure */ const short N, /* i : number of norms */ short *index, /* o : indices of quantized norms */ short *n_length /* o : decoded stream length */ ) { short i, prevj; prevj = index[0] + OFFSET_NORM; for( i=1; i < N; i++) { if( prevj > HTH_NORM ) { /* above */ index[i] = decode_huff_context( st, hntable, n_length); index[i] = 31 - index[i]; } else { if( prevj < LTH_NORM ) { /* less */ index[i] = decode_huff_context( st, hntable, n_length ); } else { /* equal */ index[i] = decode_huff_context( st, hetable, n_length ); } } prevj = index[i]; } return; } void hdecnrm_resize( Decoder_State *st, /* i/o: decoder state structure */ const short N, short *index ) { short i, j, k, m; short temp; short *pidx; pidx = index; m = N - 1; for (i=0; i