| 1 | /********** |
| 2 | This library is free software; you can redistribute it and/or modify it under |
| 3 | the terms of the GNU Lesser General Public License as published by the |
| 4 | Free Software Foundation; either version 3 of the License, or (at your |
| 5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
| 6 | |
| 7 | This library is distributed in the hope that it will be useful, but WITHOUT |
| 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 10 | more details. |
| 11 | |
| 12 | You should have received a copy of the GNU Lesser General Public License |
| 13 | along with this library; if not, write to the Free Software Foundation, Inc., |
| 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | **********/ |
| 16 | // "liveMedia" |
| 17 | // Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved. |
| 18 | // MP3 internal implementation details (Huffman encoding) |
| 19 | // C++ header |
| 20 | |
| 21 | #ifndef _MP3_INTERNALS_HUFFMAN_HH |
| 22 | #define _MP3_INTERNALS_HUFFMAN_HH |
| 23 | |
| 24 | #ifndef _MP3_INTERNALS_HH |
| 25 | #include "MP3Internals.hh" |
| 26 | #endif |
| 27 | |
| 28 | void updateSideInfoForHuffman(MP3SideInfo& sideInfo, Boolean isMPEG2, |
| 29 | unsigned char const* mainDataPtr, |
| 30 | unsigned p23L0, unsigned p23L1, |
| 31 | unsigned& part23Length0a, |
| 32 | unsigned& part23Length0aTruncation, |
| 33 | unsigned& part23Length0b, |
| 34 | unsigned& part23Length0bTruncation, |
| 35 | unsigned& part23Length1a, |
| 36 | unsigned& part23Length1aTruncation, |
| 37 | unsigned& part23Length1b, |
| 38 | unsigned& part23Length1bTruncation); |
| 39 | |
| 40 | #define SSLIMIT 18 |
| 41 | |
| 42 | class MP3HuffmanEncodingInfo { |
| 43 | public: |
| 44 | MP3HuffmanEncodingInfo(Boolean includeDecodedValues = False); |
| 45 | ~MP3HuffmanEncodingInfo(); |
| 46 | |
| 47 | public: |
| 48 | unsigned numSamples; |
| 49 | unsigned allBitOffsets[SBLIMIT*SSLIMIT + 1]; |
| 50 | unsigned reg1Start, reg2Start, bigvalStart; /* special bit offsets */ |
| 51 | unsigned* decodedValues; |
| 52 | }; |
| 53 | |
| 54 | /* forward */ |
| 55 | void MP3HuffmanDecode(MP3SideInfo::gr_info_s_t* gr, Boolean isMPEG2, |
| 56 | unsigned char const* fromBasePtr, |
| 57 | unsigned fromBitOffset, unsigned fromLength, |
| 58 | unsigned& scaleFactorsLength, |
| 59 | MP3HuffmanEncodingInfo& hei); |
| 60 | |
| 61 | extern unsigned char huffdec[]; // huffman table data |
| 62 | |
| 63 | // The following are used if we process Huffman-decoded values |
| 64 | #ifdef FOUR_BYTE_SAMPLES |
| 65 | #define BYTES_PER_SAMPLE_VALUE 4 |
| 66 | #else |
| 67 | #ifdef TWO_BYTE_SAMPLES |
| 68 | #define BYTES_PER_SAMPLE_VALUE 2 |
| 69 | #else |
| 70 | // ONE_BYTE_SAMPLES |
| 71 | #define BYTES_PER_SAMPLE_VALUE 1 |
| 72 | #endif |
| 73 | #endif |
| 74 | |
| 75 | #ifdef DO_HUFFMAN_ENCODING |
| 76 | unsigned MP3HuffmanEncode(MP3SideInfo::gr_info_s_t const* gr, |
| 77 | unsigned char const* fromPtr, |
| 78 | unsigned char* toPtr, unsigned toBitOffset, |
| 79 | unsigned numHuffBits); |
| 80 | #endif |
| 81 | |
| 82 | #endif |
| 83 | |