Annotation of embedaddon/strongswan/src/libstrongswan/plugins/bliss/bliss_huffman_coder.h, revision 1.1.1.1

1.1       misho       1: /*
                      2:  * Copyright (C) 2014 Andreas Steffen
                      3:  * HSR Hochschule fuer Technik Rapperswil
                      4:  *
                      5:  * This program is free software; you can redistribute it and/or modify it
                      6:  * under the terms of the GNU General Public License as published by the
                      7:  * Free Software Foundation; either version 2 of the License, or (at your
                      8:  * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
                      9:  *
                     10:  * This program is distributed in the hope that it will be useful, but
                     11:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
                     12:  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
                     13:  * for more details.
                     14:  */
                     15: 
                     16: /**
                     17:  * @defgroup bliss_huffman_coder bliss_huffman_coder
                     18:  * @{ @ingroup bliss_p
                     19:  */
                     20: 
                     21: #ifndef BLISS_HUFFMAN_CODER_H_
                     22: #define BLISS_HUFFMAN_CODER_H_
                     23: 
                     24: #include "bliss_huffman_code.h"
                     25: #include "bliss_bitpacker.h"
                     26: 
                     27: #include <library.h>
                     28: 
                     29: typedef struct bliss_huffman_coder_t bliss_huffman_coder_t;
                     30: 
                     31: /**
                     32:  * Encodes and decodes binary Huffman codes
                     33:  */
                     34: struct bliss_huffman_coder_t {
                     35: 
                     36:        /**
                     37:         * Get number of encoded or decoded bits
                     38:         *
                     39:         * @result                      Number of bits
                     40:         */
                     41:        size_t (*get_bits)(bliss_huffman_coder_t *this);
                     42: 
                     43:        /**
                     44:         * Encode a (z1, z2) tuple using a Huffman code
                     45:         *
                     46:         * @param z1            z1 value to be encoded
                     47:         * @param z2            z2 value to be encoded
                     48:         * @result                      TRUE if value could be encoded
                     49:         */
                     50:        bool (*encode)(bliss_huffman_coder_t *this, int32_t z1, int16_t z2);
                     51: 
                     52: 
                     53:        /**
                     54:         * Decode a (z1, z2) tuple using a Huffman code
                     55:         *
                     56:         * @param z1            Decoded z1 value returned
                     57:         * @param z2            Decoded z2 value returned
                     58:         * @result                      TRUE if value could be decoded from bitpacker
                     59:         */
                     60:        bool (*decode)(bliss_huffman_coder_t *this, int32_t *z1, int16_t *z2);
                     61: 
                     62:        /**
                     63:         * Destroy bliss_huffman_coder_t object
                     64:         */
                     65:        void (*destroy)(bliss_huffman_coder_t *this);
                     66: };
                     67: 
                     68: /**
                     69:  * Create a bliss_huffman_coder_t object
                     70:  *
                     71:  * @param code                 Huffman code table
                     72:  * @param packer               Bitpacker to write to or read from
                     73:  */
                     74: bliss_huffman_coder_t* bliss_huffman_coder_create(bliss_huffman_code_t *code,
                     75:                                                                                                  bliss_bitpacker_t *packer);
                     76: 
                     77: #endif /** BLISS_HUFFMAN_CODER_H_ @}*/

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>