X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=libcds%2Fsrc%2Fcoders%2Fhuff.h;h=e9909748de92baed67d733025828789f31cf263f;hb=a9846746dc7a55764591fcc273fd48c6049df962;hp=2dc96e276e9fc9c6e7f5574d2937cbb9d41fb979;hpb=efe894650813a19a0e1408eb5807e59f037afc3b;p=SXSI%2FXMLTree.git diff --git a/libcds/src/coders/huff.h b/libcds/src/coders/huff.h index 2dc96e2..e990974 100644 --- a/libcds/src/coders/huff.h +++ b/libcds/src/coders/huff.h @@ -1,5 +1,23 @@ +/* huff.h + Copyright (C) 2008, Gonzalo Navarro, all rights reserved. -// implements canonical Huffman + Canonical Huffman + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ #ifndef HUFFINCLUDED #define HUFFINCLUDED @@ -18,36 +36,51 @@ typedef struct ulong total; // total length to achieve, in bits } THuff; - // Creates Huffman encoder given symbols 0..lim with frequencies - // freq[i], ready for compression +/** Creates Huffman encoder given symbols 0..lim with frequencies + * freq[i], ready for compression + * + * @author Gonzalo Navarro + */ THuff createHuff (uint *freq, uint lim); - // Encodes symb using H, over stream[ptr...lim] (ptr and lim are - // bit positions of stream). Returns the new ptr. - +/** Encodes symb using H, over stream[ptr...lim] (ptr and lim are + * bit positions of stream). Returns the new ptr. + * + * @author Gonzalo Navarro + */ ulong encodeHuff (THuff H, uint symb, uint *stream, ulong ptr); - // Decodes *symb using H, over stream[ptr...lim] (ptr and lim are - // bit positions of stream). Returns the new ptr. - +/** Decodes *symb using H, over stream[ptr...lim] (ptr and lim are + * bit positions of stream). Returns the new ptr. + * + * @author Gonzalo Navarro + */ ulong decodeHuff (THuff H, uint *symb, uint *stream, ulong ptr); - // Writes H in file f - +/** Writes H in file f + * + * @author Gonzalo Navarro + */ void saveHuff (THuff H, FILE *f); - // Size of H written on file - +/** Size of H written on file + * + * @author Gonzalo Navarro + */ uint sizeHuff (THuff H); - // Frees H - +/** Frees H + * + * @author Gonzalo Navarro + */ void freeHuff (THuff H); - // Loads H from file f, prepared for encoding or decoding depending - // on enc - +/** Loads H from file f, prepared for encoding or decoding depending + * on enc + * + * @author Gonzalo Navarro + */ THuff loadHuff (FILE *f, int enc); #endif