| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | // Qt-Security score:critical reason:network-protocol |
| 4 | |
| 5 | #include "bitstreams_p.h" |
| 6 | #include "huffman_p.h" |
| 7 | |
| 8 | #include <QtCore/qbytearray.h> |
| 9 | |
| 10 | #include <algorithm> |
| 11 | #include <limits> |
| 12 | |
| 13 | QT_BEGIN_NAMESPACE |
| 14 | |
| 15 | namespace HPack |
| 16 | { |
| 17 | |
| 18 | /* |
| 19 | The static Huffman code used here was extracted from: |
| 20 | https://http2.github.io/http2-spec/compression.html#huffman.code |
| 21 | |
| 22 | This code was generated from statistics obtained on a large |
| 23 | sample of HTTP headers. It is a canonical Huffman code |
| 24 | with some tweaking to ensure that no symbol has a unique |
| 25 | code length. All codes were left-aligned - for implementation |
| 26 | convenience. |
| 27 | |
| 28 | Using binary trees to implement decoding would be prohibitively |
| 29 | expensive (both memory and time-wise). Instead we use a table-based |
| 30 | approach and any given code itself works as an index into such table(s). |
| 31 | We have 256 possible byte values and code lengths in |
| 32 | a range [5, 26]. This would require a huge table (and most of entries |
| 33 | would be 'wasted', since we only have to encode 256 elements). |
| 34 | Instead we use multi-level tables. The first level table |
| 35 | is using 9-bit length index; some entries in this table are 'terminal', |
| 36 | some reference the next level table(s). |
| 37 | |
| 38 | For example, bytes with values 48 and 49 (ASCII codes for '0' and '1') |
| 39 | both have code length 5, Huffman codes are: 00000 and 00001. They |
| 40 | both are placed in the 'root' table, |
| 41 | the 'root' table has index length == 9: |
| 42 | [00000 | 4 remaining bits] |
| 43 | ... |
| 44 | [00001 | 4 remaining bits] |
| 45 | |
| 46 | All entries with indices between these two will 'point' to value 48 |
| 47 | with bitLength == 5 so that bit stream (for example) 000001010 will be |
| 48 | decoded as: 48 + "put 1010 back into bitstream". |
| 49 | |
| 50 | A good description can be found here: |
| 51 | http://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art007 |
| 52 | or just google "Efficient Huffman Decoding". |
| 53 | Also see comments below about 'filling holes'. |
| 54 | */ |
| 55 | |
| 56 | namespace |
| 57 | { |
| 58 | |
| 59 | const CodeEntry staticHuffmanCodeTable[] |
| 60 | { |
| 61 | { .byteValue: 0, .huffmanCode: 0xffc00000ul, .bitLength: 13}, // 11111111|11000 |
| 62 | { .byteValue: 1, .huffmanCode: 0xffffb000ul, .bitLength: 23}, // 11111111|11111111|1011000 |
| 63 | { .byteValue: 2, .huffmanCode: 0xfffffe20ul, .bitLength: 28}, // 11111111|11111111|11111110|0010 |
| 64 | { .byteValue: 3, .huffmanCode: 0xfffffe30ul, .bitLength: 28}, // 11111111|11111111|11111110|0011 |
| 65 | { .byteValue: 4, .huffmanCode: 0xfffffe40ul, .bitLength: 28}, // 11111111|11111111|11111110|0100 |
| 66 | { .byteValue: 5, .huffmanCode: 0xfffffe50ul, .bitLength: 28}, // 11111111|11111111|11111110|0101 |
| 67 | { .byteValue: 6, .huffmanCode: 0xfffffe60ul, .bitLength: 28}, // 11111111|11111111|11111110|0110 |
| 68 | { .byteValue: 7, .huffmanCode: 0xfffffe70ul, .bitLength: 28}, // 11111111|11111111|11111110|0111 |
| 69 | { .byteValue: 8, .huffmanCode: 0xfffffe80ul, .bitLength: 28}, // 11111111|11111111|11111110|1000 |
| 70 | { .byteValue: 9, .huffmanCode: 0xffffea00ul, .bitLength: 24}, // 11111111|11111111|11101010 |
| 71 | { .byteValue: 10, .huffmanCode: 0xfffffff0ul, .bitLength: 30}, // 11111111|11111111|11111111|111100 |
| 72 | { .byteValue: 11, .huffmanCode: 0xfffffe90ul, .bitLength: 28}, // 11111111|11111111|11111110|1001 |
| 73 | { .byteValue: 12, .huffmanCode: 0xfffffea0ul, .bitLength: 28}, // 11111111|11111111|11111110|1010 |
| 74 | { .byteValue: 13, .huffmanCode: 0xfffffff4ul, .bitLength: 30}, // 11111111|11111111|11111111|111101 |
| 75 | { .byteValue: 14, .huffmanCode: 0xfffffeb0ul, .bitLength: 28}, // 11111111|11111111|11111110|1011 |
| 76 | { .byteValue: 15, .huffmanCode: 0xfffffec0ul, .bitLength: 28}, // 11111111|11111111|11111110|1100 |
| 77 | { .byteValue: 16, .huffmanCode: 0xfffffed0ul, .bitLength: 28}, // 11111111|11111111|11111110|1101 |
| 78 | { .byteValue: 17, .huffmanCode: 0xfffffee0ul, .bitLength: 28}, // 11111111|11111111|11111110|1110 |
| 79 | { .byteValue: 18, .huffmanCode: 0xfffffef0ul, .bitLength: 28}, // 11111111|11111111|11111110|1111 |
| 80 | { .byteValue: 19, .huffmanCode: 0xffffff00ul, .bitLength: 28}, // 11111111|11111111|11111111|0000 |
| 81 | { .byteValue: 20, .huffmanCode: 0xffffff10ul, .bitLength: 28}, // 11111111|11111111|11111111|0001 |
| 82 | { .byteValue: 21, .huffmanCode: 0xffffff20ul, .bitLength: 28}, // 11111111|11111111|11111111|0010 |
| 83 | { .byteValue: 22, .huffmanCode: 0xfffffff8ul, .bitLength: 30}, // 11111111|11111111|11111111|111110 |
| 84 | { .byteValue: 23, .huffmanCode: 0xffffff30ul, .bitLength: 28}, // 11111111|11111111|11111111|0011 |
| 85 | { .byteValue: 24, .huffmanCode: 0xffffff40ul, .bitLength: 28}, // 11111111|11111111|11111111|0100 |
| 86 | { .byteValue: 25, .huffmanCode: 0xffffff50ul, .bitLength: 28}, // 11111111|11111111|11111111|0101 |
| 87 | { .byteValue: 26, .huffmanCode: 0xffffff60ul, .bitLength: 28}, // 11111111|11111111|11111111|0110 |
| 88 | { .byteValue: 27, .huffmanCode: 0xffffff70ul, .bitLength: 28}, // 11111111|11111111|11111111|0111 |
| 89 | { .byteValue: 28, .huffmanCode: 0xffffff80ul, .bitLength: 28}, // 11111111|11111111|11111111|1000 |
| 90 | { .byteValue: 29, .huffmanCode: 0xffffff90ul, .bitLength: 28}, // 11111111|11111111|11111111|1001 |
| 91 | { .byteValue: 30, .huffmanCode: 0xffffffa0ul, .bitLength: 28}, // 11111111|11111111|11111111|1010 |
| 92 | { .byteValue: 31, .huffmanCode: 0xffffffb0ul, .bitLength: 28}, // 11111111|11111111|11111111|1011 |
| 93 | { .byteValue: 32, .huffmanCode: 0x50000000ul, .bitLength: 6}, // ' ' 010100 |
| 94 | { .byteValue: 33, .huffmanCode: 0xfe000000ul, .bitLength: 10}, // '!' 11111110|00 |
| 95 | { .byteValue: 34, .huffmanCode: 0xfe400000ul, .bitLength: 10}, // '"' 11111110|01 |
| 96 | { .byteValue: 35, .huffmanCode: 0xffa00000ul, .bitLength: 12}, // '#' 11111111|1010 |
| 97 | { .byteValue: 36, .huffmanCode: 0xffc80000ul, .bitLength: 13}, // '$' 11111111|11001 |
| 98 | { .byteValue: 37, .huffmanCode: 0x54000000ul, .bitLength: 6}, // '%' 010101 |
| 99 | { .byteValue: 38, .huffmanCode: 0xf8000000ul, .bitLength: 8}, // '&' 11111000 |
| 100 | { .byteValue: 39, .huffmanCode: 0xff400000ul, .bitLength: 11}, // ''' 11111111|010 |
| 101 | { .byteValue: 40, .huffmanCode: 0xfe800000ul, .bitLength: 10}, // '(' 11111110|10 |
| 102 | { .byteValue: 41, .huffmanCode: 0xfec00000ul, .bitLength: 10}, // ')' 11111110|11 |
| 103 | { .byteValue: 42, .huffmanCode: 0xf9000000ul, .bitLength: 8}, // '*' 11111001 |
| 104 | { .byteValue: 43, .huffmanCode: 0xff600000ul, .bitLength: 11}, // '+' 11111111|011 |
| 105 | { .byteValue: 44, .huffmanCode: 0xfa000000ul, .bitLength: 8}, // ',' 11111010 |
| 106 | { .byteValue: 45, .huffmanCode: 0x58000000ul, .bitLength: 6}, // '-' 010110 |
| 107 | { .byteValue: 46, .huffmanCode: 0x5c000000ul, .bitLength: 6}, // '.' 010111 |
| 108 | { .byteValue: 47, .huffmanCode: 0x60000000ul, .bitLength: 6}, // '/' 011000 |
| 109 | { .byteValue: 48, .huffmanCode: 0x00000000ul, .bitLength: 5}, // '0' 00000 |
| 110 | { .byteValue: 49, .huffmanCode: 0x08000000ul, .bitLength: 5}, // '1' 00001 |
| 111 | { .byteValue: 50, .huffmanCode: 0x10000000ul, .bitLength: 5}, // '2' 00010 |
| 112 | { .byteValue: 51, .huffmanCode: 0x64000000ul, .bitLength: 6}, // '3' 011001 |
| 113 | { .byteValue: 52, .huffmanCode: 0x68000000ul, .bitLength: 6}, // '4' 011010 |
| 114 | { .byteValue: 53, .huffmanCode: 0x6c000000ul, .bitLength: 6}, // '5' 011011 |
| 115 | { .byteValue: 54, .huffmanCode: 0x70000000ul, .bitLength: 6}, // '6' 011100 |
| 116 | { .byteValue: 55, .huffmanCode: 0x74000000ul, .bitLength: 6}, // '7' 011101 |
| 117 | { .byteValue: 56, .huffmanCode: 0x78000000ul, .bitLength: 6}, // '8' 011110 |
| 118 | { .byteValue: 57, .huffmanCode: 0x7c000000ul, .bitLength: 6}, // '9' 011111 |
| 119 | { .byteValue: 58, .huffmanCode: 0xb8000000ul, .bitLength: 7}, // ':' 1011100 |
| 120 | { .byteValue: 59, .huffmanCode: 0xfb000000ul, .bitLength: 8}, // ';' 11111011 |
| 121 | { .byteValue: 60, .huffmanCode: 0xfff80000ul, .bitLength: 15}, // '<' 11111111|1111100 |
| 122 | { .byteValue: 61, .huffmanCode: 0x80000000ul, .bitLength: 6}, // '=' 100000 |
| 123 | { .byteValue: 62, .huffmanCode: 0xffb00000ul, .bitLength: 12}, // '>' 11111111|1011 |
| 124 | { .byteValue: 63, .huffmanCode: 0xff000000ul, .bitLength: 10}, // '?' 11111111|00 |
| 125 | { .byteValue: 64, .huffmanCode: 0xffd00000ul, .bitLength: 13}, // '@' 11111111|11010 |
| 126 | { .byteValue: 65, .huffmanCode: 0x84000000ul, .bitLength: 6}, // 'A' 100001 |
| 127 | { .byteValue: 66, .huffmanCode: 0xba000000ul, .bitLength: 7}, // 'B' 1011101 |
| 128 | { .byteValue: 67, .huffmanCode: 0xbc000000ul, .bitLength: 7}, // 'C' 1011110 |
| 129 | { .byteValue: 68, .huffmanCode: 0xbe000000ul, .bitLength: 7}, // 'D' 1011111 |
| 130 | { .byteValue: 69, .huffmanCode: 0xc0000000ul, .bitLength: 7}, // 'E' 1100000 |
| 131 | { .byteValue: 70, .huffmanCode: 0xc2000000ul, .bitLength: 7}, // 'F' 1100001 |
| 132 | { .byteValue: 71, .huffmanCode: 0xc4000000ul, .bitLength: 7}, // 'G' 1100010 |
| 133 | { .byteValue: 72, .huffmanCode: 0xc6000000ul, .bitLength: 7}, // 'H' 1100011 |
| 134 | { .byteValue: 73, .huffmanCode: 0xc8000000ul, .bitLength: 7}, // 'I' 1100100 |
| 135 | { .byteValue: 74, .huffmanCode: 0xca000000ul, .bitLength: 7}, // 'J' 1100101 |
| 136 | { .byteValue: 75, .huffmanCode: 0xcc000000ul, .bitLength: 7}, // 'K' 1100110 |
| 137 | { .byteValue: 76, .huffmanCode: 0xce000000ul, .bitLength: 7}, // 'L' 1100111 |
| 138 | { .byteValue: 77, .huffmanCode: 0xd0000000ul, .bitLength: 7}, // 'M' 1101000 |
| 139 | { .byteValue: 78, .huffmanCode: 0xd2000000ul, .bitLength: 7}, // 'N' 1101001 |
| 140 | { .byteValue: 79, .huffmanCode: 0xd4000000ul, .bitLength: 7}, // 'O' 1101010 |
| 141 | { .byteValue: 80, .huffmanCode: 0xd6000000ul, .bitLength: 7}, // 'P' 1101011 |
| 142 | { .byteValue: 81, .huffmanCode: 0xd8000000ul, .bitLength: 7}, // 'Q' 1101100 |
| 143 | { .byteValue: 82, .huffmanCode: 0xda000000ul, .bitLength: 7}, // 'R' 1101101 |
| 144 | { .byteValue: 83, .huffmanCode: 0xdc000000ul, .bitLength: 7}, // 'S' 1101110 |
| 145 | { .byteValue: 84, .huffmanCode: 0xde000000ul, .bitLength: 7}, // 'T' 1101111 |
| 146 | { .byteValue: 85, .huffmanCode: 0xe0000000ul, .bitLength: 7}, // 'U' 1110000 |
| 147 | { .byteValue: 86, .huffmanCode: 0xe2000000ul, .bitLength: 7}, // 'V' 1110001 |
| 148 | { .byteValue: 87, .huffmanCode: 0xe4000000ul, .bitLength: 7}, // 'W' 1110010 |
| 149 | { .byteValue: 88, .huffmanCode: 0xfc000000ul, .bitLength: 8}, // 'X' 11111100 |
| 150 | { .byteValue: 89, .huffmanCode: 0xe6000000ul, .bitLength: 7}, // 'Y' 1110011 |
| 151 | { .byteValue: 90, .huffmanCode: 0xfd000000ul, .bitLength: 8}, // 'Z' 11111101 |
| 152 | { .byteValue: 91, .huffmanCode: 0xffd80000ul, .bitLength: 13}, // '[' 11111111|11011 |
| 153 | { .byteValue: 92, .huffmanCode: 0xfffe0000ul, .bitLength: 19}, // '\' 11111111|11111110|000 |
| 154 | { .byteValue: 93, .huffmanCode: 0xffe00000ul, .bitLength: 13}, // ']' 11111111|11100 |
| 155 | { .byteValue: 94, .huffmanCode: 0xfff00000ul, .bitLength: 14}, // '^' 11111111|111100 |
| 156 | { .byteValue: 95, .huffmanCode: 0x88000000ul, .bitLength: 6}, // '_' 100010 |
| 157 | { .byteValue: 96, .huffmanCode: 0xfffa0000ul, .bitLength: 15}, // '`' 11111111|1111101 |
| 158 | { .byteValue: 97, .huffmanCode: 0x18000000ul, .bitLength: 5}, // 'a' 00011 |
| 159 | { .byteValue: 98, .huffmanCode: 0x8c000000ul, .bitLength: 6}, // 'b' 100011 |
| 160 | { .byteValue: 99, .huffmanCode: 0x20000000ul, .bitLength: 5}, // 'c' 00100 |
| 161 | {.byteValue: 100, .huffmanCode: 0x90000000ul, .bitLength: 6}, // 'd' 100100 |
| 162 | {.byteValue: 101, .huffmanCode: 0x28000000ul, .bitLength: 5}, // 'e' 00101 |
| 163 | {.byteValue: 102, .huffmanCode: 0x94000000ul, .bitLength: 6}, // 'f' 100101 |
| 164 | {.byteValue: 103, .huffmanCode: 0x98000000ul, .bitLength: 6}, // 'g' 100110 |
| 165 | {.byteValue: 104, .huffmanCode: 0x9c000000ul, .bitLength: 6}, // 'h' 100111 |
| 166 | {.byteValue: 105, .huffmanCode: 0x30000000ul, .bitLength: 5}, // 'i' 00110 |
| 167 | {.byteValue: 106, .huffmanCode: 0xe8000000ul, .bitLength: 7}, // 'j' 1110100 |
| 168 | {.byteValue: 107, .huffmanCode: 0xea000000ul, .bitLength: 7}, // 'k' 1110101 |
| 169 | {.byteValue: 108, .huffmanCode: 0xa0000000ul, .bitLength: 6}, // 'l' 101000 |
| 170 | {.byteValue: 109, .huffmanCode: 0xa4000000ul, .bitLength: 6}, // 'm' 101001 |
| 171 | {.byteValue: 110, .huffmanCode: 0xa8000000ul, .bitLength: 6}, // 'n' 101010 |
| 172 | {.byteValue: 111, .huffmanCode: 0x38000000ul, .bitLength: 5}, // 'o' 00111 |
| 173 | {.byteValue: 112, .huffmanCode: 0xac000000ul, .bitLength: 6}, // 'p' 101011 |
| 174 | {.byteValue: 113, .huffmanCode: 0xec000000ul, .bitLength: 7}, // 'q' 1110110 |
| 175 | {.byteValue: 114, .huffmanCode: 0xb0000000ul, .bitLength: 6}, // 'r' 101100 |
| 176 | {.byteValue: 115, .huffmanCode: 0x40000000ul, .bitLength: 5}, // 's' 01000 |
| 177 | {.byteValue: 116, .huffmanCode: 0x48000000ul, .bitLength: 5}, // 't' 01001 |
| 178 | {.byteValue: 117, .huffmanCode: 0xb4000000ul, .bitLength: 6}, // 'u' 101101 |
| 179 | {.byteValue: 118, .huffmanCode: 0xee000000ul, .bitLength: 7}, // 'v' 1110111 |
| 180 | {.byteValue: 119, .huffmanCode: 0xf0000000ul, .bitLength: 7}, // 'w' 1111000 |
| 181 | {.byteValue: 120, .huffmanCode: 0xf2000000ul, .bitLength: 7}, // 'x' 1111001 |
| 182 | {.byteValue: 121, .huffmanCode: 0xf4000000ul, .bitLength: 7}, // 'y' 1111010 |
| 183 | {.byteValue: 122, .huffmanCode: 0xf6000000ul, .bitLength: 7}, // 'z' 1111011 |
| 184 | {.byteValue: 123, .huffmanCode: 0xfffc0000ul, .bitLength: 15}, // '{' 11111111|1111110 |
| 185 | {.byteValue: 124, .huffmanCode: 0xff800000ul, .bitLength: 11}, // '|' 11111111|100 |
| 186 | {.byteValue: 125, .huffmanCode: 0xfff40000ul, .bitLength: 14}, // '}' 11111111|111101 |
| 187 | {.byteValue: 126, .huffmanCode: 0xffe80000ul, .bitLength: 13}, // '~' 11111111|11101 |
| 188 | {.byteValue: 127, .huffmanCode: 0xffffffc0ul, .bitLength: 28}, // 11111111|11111111|11111111|1100 |
| 189 | {.byteValue: 128, .huffmanCode: 0xfffe6000ul, .bitLength: 20}, // 11111111|11111110|0110 |
| 190 | {.byteValue: 129, .huffmanCode: 0xffff4800ul, .bitLength: 22}, // 11111111|11111111|010010 |
| 191 | {.byteValue: 130, .huffmanCode: 0xfffe7000ul, .bitLength: 20}, // 11111111|11111110|0111 |
| 192 | {.byteValue: 131, .huffmanCode: 0xfffe8000ul, .bitLength: 20}, // 11111111|11111110|1000 |
| 193 | {.byteValue: 132, .huffmanCode: 0xffff4c00ul, .bitLength: 22}, // 11111111|11111111|010011 |
| 194 | {.byteValue: 133, .huffmanCode: 0xffff5000ul, .bitLength: 22}, // 11111111|11111111|010100 |
| 195 | {.byteValue: 134, .huffmanCode: 0xffff5400ul, .bitLength: 22}, // 11111111|11111111|010101 |
| 196 | {.byteValue: 135, .huffmanCode: 0xffffb200ul, .bitLength: 23}, // 11111111|11111111|1011001 |
| 197 | {.byteValue: 136, .huffmanCode: 0xffff5800ul, .bitLength: 22}, // 11111111|11111111|010110 |
| 198 | {.byteValue: 137, .huffmanCode: 0xffffb400ul, .bitLength: 23}, // 11111111|11111111|1011010 |
| 199 | {.byteValue: 138, .huffmanCode: 0xffffb600ul, .bitLength: 23}, // 11111111|11111111|1011011 |
| 200 | {.byteValue: 139, .huffmanCode: 0xffffb800ul, .bitLength: 23}, // 11111111|11111111|1011100 |
| 201 | {.byteValue: 140, .huffmanCode: 0xffffba00ul, .bitLength: 23}, // 11111111|11111111|1011101 |
| 202 | {.byteValue: 141, .huffmanCode: 0xffffbc00ul, .bitLength: 23}, // 11111111|11111111|1011110 |
| 203 | {.byteValue: 142, .huffmanCode: 0xffffeb00ul, .bitLength: 24}, // 11111111|11111111|11101011 |
| 204 | {.byteValue: 143, .huffmanCode: 0xffffbe00ul, .bitLength: 23}, // 11111111|11111111|1011111 |
| 205 | {.byteValue: 144, .huffmanCode: 0xffffec00ul, .bitLength: 24}, // 11111111|11111111|11101100 |
| 206 | {.byteValue: 145, .huffmanCode: 0xffffed00ul, .bitLength: 24}, // 11111111|11111111|11101101 |
| 207 | {.byteValue: 146, .huffmanCode: 0xffff5c00ul, .bitLength: 22}, // 11111111|11111111|010111 |
| 208 | {.byteValue: 147, .huffmanCode: 0xffffc000ul, .bitLength: 23}, // 11111111|11111111|1100000 |
| 209 | {.byteValue: 148, .huffmanCode: 0xffffee00ul, .bitLength: 24}, // 11111111|11111111|11101110 |
| 210 | {.byteValue: 149, .huffmanCode: 0xffffc200ul, .bitLength: 23}, // 11111111|11111111|1100001 |
| 211 | {.byteValue: 150, .huffmanCode: 0xffffc400ul, .bitLength: 23}, // 11111111|11111111|1100010 |
| 212 | {.byteValue: 151, .huffmanCode: 0xffffc600ul, .bitLength: 23}, // 11111111|11111111|1100011 |
| 213 | {.byteValue: 152, .huffmanCode: 0xffffc800ul, .bitLength: 23}, // 11111111|11111111|1100100 |
| 214 | {.byteValue: 153, .huffmanCode: 0xfffee000ul, .bitLength: 21}, // 11111111|11111110|11100 |
| 215 | {.byteValue: 154, .huffmanCode: 0xffff6000ul, .bitLength: 22}, // 11111111|11111111|011000 |
| 216 | {.byteValue: 155, .huffmanCode: 0xffffca00ul, .bitLength: 23}, // 11111111|11111111|1100101 |
| 217 | {.byteValue: 156, .huffmanCode: 0xffff6400ul, .bitLength: 22}, // 11111111|11111111|011001 |
| 218 | {.byteValue: 157, .huffmanCode: 0xffffcc00ul, .bitLength: 23}, // 11111111|11111111|1100110 |
| 219 | {.byteValue: 158, .huffmanCode: 0xffffce00ul, .bitLength: 23}, // 11111111|11111111|1100111 |
| 220 | {.byteValue: 159, .huffmanCode: 0xffffef00ul, .bitLength: 24}, // 11111111|11111111|11101111 |
| 221 | {.byteValue: 160, .huffmanCode: 0xffff6800ul, .bitLength: 22}, // 11111111|11111111|011010 |
| 222 | {.byteValue: 161, .huffmanCode: 0xfffee800ul, .bitLength: 21}, // 11111111|11111110|11101 |
| 223 | {.byteValue: 162, .huffmanCode: 0xfffe9000ul, .bitLength: 20}, // 11111111|11111110|1001 |
| 224 | {.byteValue: 163, .huffmanCode: 0xffff6c00ul, .bitLength: 22}, // 11111111|11111111|011011 |
| 225 | {.byteValue: 164, .huffmanCode: 0xffff7000ul, .bitLength: 22}, // 11111111|11111111|011100 |
| 226 | {.byteValue: 165, .huffmanCode: 0xffffd000ul, .bitLength: 23}, // 11111111|11111111|1101000 |
| 227 | {.byteValue: 166, .huffmanCode: 0xffffd200ul, .bitLength: 23}, // 11111111|11111111|1101001 |
| 228 | {.byteValue: 167, .huffmanCode: 0xfffef000ul, .bitLength: 21}, // 11111111|11111110|11110 |
| 229 | {.byteValue: 168, .huffmanCode: 0xffffd400ul, .bitLength: 23}, // 11111111|11111111|1101010 |
| 230 | {.byteValue: 169, .huffmanCode: 0xffff7400ul, .bitLength: 22}, // 11111111|11111111|011101 |
| 231 | {.byteValue: 170, .huffmanCode: 0xffff7800ul, .bitLength: 22}, // 11111111|11111111|011110 |
| 232 | {.byteValue: 171, .huffmanCode: 0xfffff000ul, .bitLength: 24}, // 11111111|11111111|11110000 |
| 233 | {.byteValue: 172, .huffmanCode: 0xfffef800ul, .bitLength: 21}, // 11111111|11111110|11111 |
| 234 | {.byteValue: 173, .huffmanCode: 0xffff7c00ul, .bitLength: 22}, // 11111111|11111111|011111 |
| 235 | {.byteValue: 174, .huffmanCode: 0xffffd600ul, .bitLength: 23}, // 11111111|11111111|1101011 |
| 236 | {.byteValue: 175, .huffmanCode: 0xffffd800ul, .bitLength: 23}, // 11111111|11111111|1101100 |
| 237 | {.byteValue: 176, .huffmanCode: 0xffff0000ul, .bitLength: 21}, // 11111111|11111111|00000 |
| 238 | {.byteValue: 177, .huffmanCode: 0xffff0800ul, .bitLength: 21}, // 11111111|11111111|00001 |
| 239 | {.byteValue: 178, .huffmanCode: 0xffff8000ul, .bitLength: 22}, // 11111111|11111111|100000 |
| 240 | {.byteValue: 179, .huffmanCode: 0xffff1000ul, .bitLength: 21}, // 11111111|11111111|00010 |
| 241 | {.byteValue: 180, .huffmanCode: 0xffffda00ul, .bitLength: 23}, // 11111111|11111111|1101101 |
| 242 | {.byteValue: 181, .huffmanCode: 0xffff8400ul, .bitLength: 22}, // 11111111|11111111|100001 |
| 243 | {.byteValue: 182, .huffmanCode: 0xffffdc00ul, .bitLength: 23}, // 11111111|11111111|1101110 |
| 244 | {.byteValue: 183, .huffmanCode: 0xffffde00ul, .bitLength: 23}, // 11111111|11111111|1101111 |
| 245 | {.byteValue: 184, .huffmanCode: 0xfffea000ul, .bitLength: 20}, // 11111111|11111110|1010 |
| 246 | {.byteValue: 185, .huffmanCode: 0xffff8800ul, .bitLength: 22}, // 11111111|11111111|100010 |
| 247 | {.byteValue: 186, .huffmanCode: 0xffff8c00ul, .bitLength: 22}, // 11111111|11111111|100011 |
| 248 | {.byteValue: 187, .huffmanCode: 0xffff9000ul, .bitLength: 22}, // 11111111|11111111|100100 |
| 249 | {.byteValue: 188, .huffmanCode: 0xffffe000ul, .bitLength: 23}, // 11111111|11111111|1110000 |
| 250 | {.byteValue: 189, .huffmanCode: 0xffff9400ul, .bitLength: 22}, // 11111111|11111111|100101 |
| 251 | {.byteValue: 190, .huffmanCode: 0xffff9800ul, .bitLength: 22}, // 11111111|11111111|100110 |
| 252 | {.byteValue: 191, .huffmanCode: 0xffffe200ul, .bitLength: 23}, // 11111111|11111111|1110001 |
| 253 | {.byteValue: 192, .huffmanCode: 0xfffff800ul, .bitLength: 26}, // 11111111|11111111|11111000|00 |
| 254 | {.byteValue: 193, .huffmanCode: 0xfffff840ul, .bitLength: 26}, // 11111111|11111111|11111000|01 |
| 255 | {.byteValue: 194, .huffmanCode: 0xfffeb000ul, .bitLength: 20}, // 11111111|11111110|1011 |
| 256 | {.byteValue: 195, .huffmanCode: 0xfffe2000ul, .bitLength: 19}, // 11111111|11111110|001 |
| 257 | {.byteValue: 196, .huffmanCode: 0xffff9c00ul, .bitLength: 22}, // 11111111|11111111|100111 |
| 258 | {.byteValue: 197, .huffmanCode: 0xffffe400ul, .bitLength: 23}, // 11111111|11111111|1110010 |
| 259 | {.byteValue: 198, .huffmanCode: 0xffffa000ul, .bitLength: 22}, // 11111111|11111111|101000 |
| 260 | {.byteValue: 199, .huffmanCode: 0xfffff600ul, .bitLength: 25}, // 11111111|11111111|11110110|0 |
| 261 | {.byteValue: 200, .huffmanCode: 0xfffff880ul, .bitLength: 26}, // 11111111|11111111|11111000|10 |
| 262 | {.byteValue: 201, .huffmanCode: 0xfffff8c0ul, .bitLength: 26}, // 11111111|11111111|11111000|11 |
| 263 | {.byteValue: 202, .huffmanCode: 0xfffff900ul, .bitLength: 26}, // 11111111|11111111|11111001|00 |
| 264 | {.byteValue: 203, .huffmanCode: 0xfffffbc0ul, .bitLength: 27}, // 11111111|11111111|11111011|110 |
| 265 | {.byteValue: 204, .huffmanCode: 0xfffffbe0ul, .bitLength: 27}, // 11111111|11111111|11111011|111 |
| 266 | {.byteValue: 205, .huffmanCode: 0xfffff940ul, .bitLength: 26}, // 11111111|11111111|11111001|01 |
| 267 | {.byteValue: 206, .huffmanCode: 0xfffff100ul, .bitLength: 24}, // 11111111|11111111|11110001 |
| 268 | {.byteValue: 207, .huffmanCode: 0xfffff680ul, .bitLength: 25}, // 11111111|11111111|11110110|1 |
| 269 | {.byteValue: 208, .huffmanCode: 0xfffe4000ul, .bitLength: 19}, // 11111111|11111110|010 |
| 270 | {.byteValue: 209, .huffmanCode: 0xffff1800ul, .bitLength: 21}, // 11111111|11111111|00011 |
| 271 | {.byteValue: 210, .huffmanCode: 0xfffff980ul, .bitLength: 26}, // 11111111|11111111|11111001|10 |
| 272 | {.byteValue: 211, .huffmanCode: 0xfffffc00ul, .bitLength: 27}, // 11111111|11111111|11111100|000 |
| 273 | {.byteValue: 212, .huffmanCode: 0xfffffc20ul, .bitLength: 27}, // 11111111|11111111|11111100|001 |
| 274 | {.byteValue: 213, .huffmanCode: 0xfffff9c0ul, .bitLength: 26}, // 11111111|11111111|11111001|11 |
| 275 | {.byteValue: 214, .huffmanCode: 0xfffffc40ul, .bitLength: 27}, // 11111111|11111111|11111100|010 |
| 276 | {.byteValue: 215, .huffmanCode: 0xfffff200ul, .bitLength: 24}, // 11111111|11111111|11110010 |
| 277 | {.byteValue: 216, .huffmanCode: 0xffff2000ul, .bitLength: 21}, // 11111111|11111111|00100 |
| 278 | {.byteValue: 217, .huffmanCode: 0xffff2800ul, .bitLength: 21}, // 11111111|11111111|00101 |
| 279 | {.byteValue: 218, .huffmanCode: 0xfffffa00ul, .bitLength: 26}, // 11111111|11111111|11111010|00 |
| 280 | {.byteValue: 219, .huffmanCode: 0xfffffa40ul, .bitLength: 26}, // 11111111|11111111|11111010|01 |
| 281 | {.byteValue: 220, .huffmanCode: 0xffffffd0ul, .bitLength: 28}, // 11111111|11111111|11111111|1101 |
| 282 | {.byteValue: 221, .huffmanCode: 0xfffffc60ul, .bitLength: 27}, // 11111111|11111111|11111100|011 |
| 283 | {.byteValue: 222, .huffmanCode: 0xfffffc80ul, .bitLength: 27}, // 11111111|11111111|11111100|100 |
| 284 | {.byteValue: 223, .huffmanCode: 0xfffffca0ul, .bitLength: 27}, // 11111111|11111111|11111100|101 |
| 285 | {.byteValue: 224, .huffmanCode: 0xfffec000ul, .bitLength: 20}, // 11111111|11111110|1100 |
| 286 | {.byteValue: 225, .huffmanCode: 0xfffff300ul, .bitLength: 24}, // 11111111|11111111|11110011 |
| 287 | {.byteValue: 226, .huffmanCode: 0xfffed000ul, .bitLength: 20}, // 11111111|11111110|1101 |
| 288 | {.byteValue: 227, .huffmanCode: 0xffff3000ul, .bitLength: 21}, // 11111111|11111111|00110 |
| 289 | {.byteValue: 228, .huffmanCode: 0xffffa400ul, .bitLength: 22}, // 11111111|11111111|101001 |
| 290 | {.byteValue: 229, .huffmanCode: 0xffff3800ul, .bitLength: 21}, // 11111111|11111111|00111 |
| 291 | {.byteValue: 230, .huffmanCode: 0xffff4000ul, .bitLength: 21}, // 11111111|11111111|01000 |
| 292 | {.byteValue: 231, .huffmanCode: 0xffffe600ul, .bitLength: 23}, // 11111111|11111111|1110011 |
| 293 | {.byteValue: 232, .huffmanCode: 0xffffa800ul, .bitLength: 22}, // 11111111|11111111|101010 |
| 294 | {.byteValue: 233, .huffmanCode: 0xffffac00ul, .bitLength: 22}, // 11111111|11111111|101011 |
| 295 | {.byteValue: 234, .huffmanCode: 0xfffff700ul, .bitLength: 25}, // 11111111|11111111|11110111|0 |
| 296 | {.byteValue: 235, .huffmanCode: 0xfffff780ul, .bitLength: 25}, // 11111111|11111111|11110111|1 |
| 297 | {.byteValue: 236, .huffmanCode: 0xfffff400ul, .bitLength: 24}, // 11111111|11111111|11110100 |
| 298 | {.byteValue: 237, .huffmanCode: 0xfffff500ul, .bitLength: 24}, // 11111111|11111111|11110101 |
| 299 | {.byteValue: 238, .huffmanCode: 0xfffffa80ul, .bitLength: 26}, // 11111111|11111111|11111010|10 |
| 300 | {.byteValue: 239, .huffmanCode: 0xffffe800ul, .bitLength: 23}, // 11111111|11111111|1110100 |
| 301 | {.byteValue: 240, .huffmanCode: 0xfffffac0ul, .bitLength: 26}, // 11111111|11111111|11111010|11 |
| 302 | {.byteValue: 241, .huffmanCode: 0xfffffcc0ul, .bitLength: 27}, // 11111111|11111111|11111100|110 |
| 303 | {.byteValue: 242, .huffmanCode: 0xfffffb00ul, .bitLength: 26}, // 11111111|11111111|11111011|00 |
| 304 | {.byteValue: 243, .huffmanCode: 0xfffffb40ul, .bitLength: 26}, // 11111111|11111111|11111011|01 |
| 305 | {.byteValue: 244, .huffmanCode: 0xfffffce0ul, .bitLength: 27}, // 11111111|11111111|11111100|111 |
| 306 | {.byteValue: 245, .huffmanCode: 0xfffffd00ul, .bitLength: 27}, // 11111111|11111111|11111101|000 |
| 307 | {.byteValue: 246, .huffmanCode: 0xfffffd20ul, .bitLength: 27}, // 11111111|11111111|11111101|001 |
| 308 | {.byteValue: 247, .huffmanCode: 0xfffffd40ul, .bitLength: 27}, // 11111111|11111111|11111101|010 |
| 309 | {.byteValue: 248, .huffmanCode: 0xfffffd60ul, .bitLength: 27}, // 11111111|11111111|11111101|011 |
| 310 | {.byteValue: 249, .huffmanCode: 0xffffffe0ul, .bitLength: 28}, // 11111111|11111111|11111111|1110 |
| 311 | {.byteValue: 250, .huffmanCode: 0xfffffd80ul, .bitLength: 27}, // 11111111|11111111|11111101|100 |
| 312 | {.byteValue: 251, .huffmanCode: 0xfffffda0ul, .bitLength: 27}, // 11111111|11111111|11111101|101 |
| 313 | {.byteValue: 252, .huffmanCode: 0xfffffdc0ul, .bitLength: 27}, // 11111111|11111111|11111101|110 |
| 314 | {.byteValue: 253, .huffmanCode: 0xfffffde0ul, .bitLength: 27}, // 11111111|11111111|11111101|111 |
| 315 | {.byteValue: 254, .huffmanCode: 0xfffffe00ul, .bitLength: 27}, // 11111111|11111111|11111110|000 |
| 316 | {.byteValue: 255, .huffmanCode: 0xfffffb80ul, .bitLength: 26}, // 11111111|11111111|11111011|10 |
| 317 | {.byteValue: 256, .huffmanCode: 0xfffffffcul, .bitLength: 30} // EOS 11111111|11111111|11111111|111111 |
| 318 | }; |
| 319 | |
| 320 | void write_huffman_code(BitOStream &outputStream, CodeEntry code) |
| 321 | { |
| 322 | // Append octet by octet. |
| 323 | auto bitLength = code.bitLength; |
| 324 | const auto hc = code.huffmanCode >> (32 - bitLength); |
| 325 | |
| 326 | if (bitLength > 24) { |
| 327 | outputStream.writeBits(bits: uchar(hc >> 24), bitLength: bitLength - 24); |
| 328 | bitLength = 24; |
| 329 | } |
| 330 | |
| 331 | if (bitLength > 16) { |
| 332 | outputStream.writeBits(bits: uchar(hc >> 16), bitLength: bitLength - 16); |
| 333 | bitLength = 16; |
| 334 | } |
| 335 | |
| 336 | if (bitLength > 8) { |
| 337 | outputStream.writeBits(bits: uchar(hc >> 8), bitLength: bitLength - 8); |
| 338 | bitLength = 8; |
| 339 | } |
| 340 | |
| 341 | outputStream.writeBits(bits: uchar(hc), bitLength); |
| 342 | } |
| 343 | |
| 344 | } |
| 345 | |
| 346 | // That's from HPACK's specs - we deal with octets. |
| 347 | static_assert(std::numeric_limits<uchar>::digits == 8, "octets expected" ); |
| 348 | |
| 349 | quint64 huffman_encoded_bit_length(QByteArrayView inputData) |
| 350 | { |
| 351 | quint64 bitLength = 0; |
| 352 | for (int i = 0, e = inputData.size(); i < e; ++i) |
| 353 | bitLength += staticHuffmanCodeTable[int(inputData[i])].bitLength; |
| 354 | |
| 355 | return bitLength; |
| 356 | } |
| 357 | |
| 358 | void huffman_encode_string(QByteArrayView inputData, BitOStream &outputStream) |
| 359 | { |
| 360 | for (int i = 0, e = inputData.size(); i < e; ++i) { |
| 361 | const auto value = uchar(inputData[i]); |
| 362 | write_huffman_code(outputStream, code: staticHuffmanCodeTable[value]); |
| 363 | } |
| 364 | |
| 365 | // Pad bits ... |
| 366 | if (outputStream.bitLength() % 8) |
| 367 | outputStream.writeBits(bits: 0xff, bitLength: 8 - outputStream.bitLength() % 8); |
| 368 | } |
| 369 | |
| 370 | static constexpr |
| 371 | bool padding_is_valid(quint32 chunk, quint32 nBits) |
| 372 | { |
| 373 | Q_ASSERT(nBits); |
| 374 | |
| 375 | // HPACK, 5.2: "A padding strictly longer than 7 bits MUST be |
| 376 | // treated as a decoding error." |
| 377 | if (nBits > 7) |
| 378 | return false; |
| 379 | // HPACK, 5.2: |
| 380 | // "A padding not corresponding to the most significant bits |
| 381 | // of the code for the EOS symbol MUST be treated as a decoding error." |
| 382 | return (chunk >> (32 - nBits)) == quint32((1 << nBits) - 1); |
| 383 | } |
| 384 | |
| 385 | HuffmanDecoder::HuffmanDecoder() |
| 386 | : minCodeLength() |
| 387 | { |
| 388 | const auto nCodes = sizeof staticHuffmanCodeTable / sizeof staticHuffmanCodeTable[0]; |
| 389 | |
| 390 | std::vector<CodeEntry> symbols(staticHuffmanCodeTable, staticHuffmanCodeTable + nCodes); |
| 391 | // Now we sort: by bit length first (in the descending order) and by the symbol |
| 392 | // value (descending). Descending order: to make sure we do not create prefix tables with |
| 393 | // short 'indexLength' first and having longer codes that do not fit into such tables later. |
| 394 | std::sort(first: symbols.begin(), last: symbols.end(), comp: [](CodeEntry code1, CodeEntry code2) { |
| 395 | if (code1.bitLength == code2.bitLength) |
| 396 | return code1.byteValue > code2.byteValue; |
| 397 | return code1.bitLength > code2.bitLength; |
| 398 | }); |
| 399 | |
| 400 | minCodeLength = symbols.back().bitLength; // The shortest one, currently it's 5. |
| 401 | |
| 402 | // TODO: add a verification - Huffman codes |
| 403 | // within a given bit length range also |
| 404 | // should be in descending order. |
| 405 | |
| 406 | // Initialize 'prefixTables' and 'tableData'. |
| 407 | addTable(prefixLength: 0, indexLength: quint32(BitConstants::rootPrefix)); // 'root' table. |
| 408 | |
| 409 | for (const auto &s : symbols) { |
| 410 | quint32 tableIndex = 0; |
| 411 | while (true) { |
| 412 | Q_ASSERT(tableIndex < prefixTables.size()); |
| 413 | // Note, by value - since prefixTables will be updated in between. |
| 414 | const auto table = prefixTables[tableIndex]; |
| 415 | // We skip prefixed bits (if any) and use indexed bits only: |
| 416 | const auto entryIndex = s.huffmanCode << table.prefixLength >> (32 - table.indexLength); |
| 417 | // Again, by value. |
| 418 | PrefixTableEntry entry = tableEntry(table, index: entryIndex); |
| 419 | // How many bits were coded by previous tables and this table: |
| 420 | const auto codedLength = table.prefixLength + table.indexLength; |
| 421 | if (codedLength < s.bitLength) { |
| 422 | // We have to add a new prefix table ... (if it's not done yet). |
| 423 | if (!entry.bitLength) { |
| 424 | entry.nextTable = addTable(prefixLength: codedLength, indexLength: std::min<quint32>(a: quint32(BitConstants::childPrefix), |
| 425 | b: s.bitLength - codedLength)); |
| 426 | entry.bitLength = s.bitLength; |
| 427 | entry.byteValue = s.byteValue; |
| 428 | setTableEntry(table, index: entryIndex, entry); |
| 429 | } |
| 430 | tableIndex = entry.nextTable; |
| 431 | } else { |
| 432 | // We found the slot for our code (terminal entry): |
| 433 | entry.byteValue = s.byteValue; |
| 434 | entry.bitLength = s.bitLength; |
| 435 | // Refer to our own table as 'nextTable': |
| 436 | entry.nextTable = tableIndex; |
| 437 | setTableEntry(table, index: entryIndex, entry); |
| 438 | break; |
| 439 | } |
| 440 | } |
| 441 | } |
| 442 | |
| 443 | // Now, we have a table(s) and have to fill 'holes' to |
| 444 | // 'fix' terminal entries. |
| 445 | for (const auto &table : prefixTables) { |
| 446 | const quint32 codedLength = table.prefixLength + table.indexLength; |
| 447 | for (quint32 j = 0; j < table.size();) { |
| 448 | const PrefixTableEntry &entry = tableEntry(table, index: j); |
| 449 | if (entry.bitLength && entry.bitLength < codedLength) { |
| 450 | const quint32 range = 1 << (codedLength - entry.bitLength); |
| 451 | for (quint32 k = 1; k < range; ++k) |
| 452 | setTableEntry(table, index: j + k, entry); |
| 453 | j += range; |
| 454 | } else { |
| 455 | ++j; |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | |
| 461 | bool HuffmanDecoder::decodeStream(BitIStream &inputStream, QByteArray &outputBuffer) |
| 462 | { |
| 463 | while (true) { |
| 464 | quint32 chunk = 0; |
| 465 | const quint32 readBits = inputStream.peekBits(from: inputStream.streamOffset(), length: 32, dstPtr: &chunk); |
| 466 | if (!readBits) |
| 467 | return !inputStream.hasMoreBits(); |
| 468 | |
| 469 | if (readBits < minCodeLength) { |
| 470 | inputStream.skipBits(nBits: readBits); |
| 471 | return padding_is_valid(chunk, nBits: readBits); |
| 472 | } |
| 473 | |
| 474 | quint32 tableIndex = 0; |
| 475 | const PrefixTable *table = &prefixTables[tableIndex]; |
| 476 | quint32 entryIndex = chunk >> (32 - table->indexLength); |
| 477 | PrefixTableEntry entry = tableEntry(table: *table, index: entryIndex); |
| 478 | |
| 479 | while (true) { |
| 480 | if (entry.nextTable == tableIndex) |
| 481 | break; |
| 482 | |
| 483 | tableIndex = entry.nextTable; |
| 484 | table = &prefixTables[tableIndex]; |
| 485 | entryIndex = chunk << table->prefixLength >> (32 - table->indexLength); |
| 486 | entry = tableEntry(table: *table, index: entryIndex); |
| 487 | } |
| 488 | |
| 489 | if (entry.bitLength > readBits) { |
| 490 | inputStream.skipBits(nBits: readBits); |
| 491 | return padding_is_valid(chunk, nBits: readBits); |
| 492 | } |
| 493 | |
| 494 | if (!entry.bitLength || entry.byteValue == 256) { |
| 495 | //EOS (256) == compression error (HPACK). |
| 496 | inputStream.skipBits(nBits: readBits); |
| 497 | return false; |
| 498 | } |
| 499 | |
| 500 | outputBuffer.append(c: entry.byteValue); |
| 501 | inputStream.skipBits(nBits: entry.bitLength); |
| 502 | } |
| 503 | |
| 504 | return false; |
| 505 | } |
| 506 | |
| 507 | quint32 HuffmanDecoder::addTable(quint32 prefix, quint32 index) |
| 508 | { |
| 509 | PrefixTable newTable{prefix, index}; |
| 510 | newTable.offset = quint32(tableData.size()); |
| 511 | prefixTables.push_back(x: newTable); |
| 512 | // Add entries for this table: |
| 513 | tableData.resize(new_size: tableData.size() + newTable.size()); |
| 514 | |
| 515 | return quint32(prefixTables.size() - 1); |
| 516 | } |
| 517 | |
| 518 | PrefixTableEntry HuffmanDecoder::tableEntry(PrefixTable table, quint32 index) |
| 519 | { |
| 520 | Q_ASSERT(index < table.size()); |
| 521 | return tableData[table.offset + index]; |
| 522 | } |
| 523 | |
| 524 | void HuffmanDecoder::setTableEntry(PrefixTable table, quint32 index, |
| 525 | PrefixTableEntry entry) |
| 526 | { |
| 527 | Q_ASSERT(index < table.size()); |
| 528 | tableData[table.offset + index] = entry; |
| 529 | } |
| 530 | |
| 531 | bool huffman_decode_string(BitIStream &inputStream, QByteArray *outputBuffer) |
| 532 | { |
| 533 | Q_ASSERT(outputBuffer); |
| 534 | |
| 535 | static HuffmanDecoder decoder; |
| 536 | return decoder.decodeStream(inputStream, outputBuffer&: *outputBuffer); |
| 537 | } |
| 538 | |
| 539 | } |
| 540 | |
| 541 | QT_END_NAMESPACE |
| 542 | |