| 1219 | } |
| 1220 | |
| 1221 | void sendTree (const ct_data* tree, uint32_t max_code) |
| 1222 | { |
| 1223 | uint32_t prevlen = 0xffffffff; /* last emitted length */ |
| 1224 | uint32_t curlen; /* length of current code */ |
| 1225 | auto nextlen = tree[0].dl.len; /* length of next code */ |
| 1226 | uint32_t count = 0; /* repeat count of the current code */ |
| 1227 | uint32_t max_count = 7; /* max repeat count */ |
| 1228 | uint32_t min_count = 4; /* min repeat count */ |
| 1229 | |
| 1230 | /* tree[max_code+1].dl.len = -1; */ /* guard already set */ |
| 1231 | if (nextlen == 0) |
| 1232 | { |
| 1233 | max_count = 138; |
| 1234 | min_count = 3; |
| 1235 | } |
| 1236 | |
| 1237 | for (uint32_t n = 0; n <= max_code; n++) |
| 1238 | { |
| 1239 | curlen = nextlen; |
| 1240 | nextlen = tree[n + 1].dl.len; |
| 1241 | |
| 1242 | if (++count < max_count && curlen == nextlen) |
| 1243 | continue; |
| 1244 | |
| 1245 | if (count < min_count) |
| 1246 | { |
| 1247 | do { send_code (curlen, bl_tree); } while (--count != 0); |
| 1248 | } |
| 1249 | else if (curlen != 0) |
| 1250 | { |
| 1251 | if (curlen != prevlen) |
| 1252 | { |
| 1253 | send_code (curlen, bl_tree); |
| 1254 | count--; |
| 1255 | } |
| 1256 | |
| 1257 | CHOC_ASSERT(count >= 3 && count <= 6); |
| 1258 | send_code (REP_3_6, bl_tree); send_bits (count - 3, 2); |
| 1259 | } |
| 1260 | else if (count <= 10) |
| 1261 | { |
| 1262 | send_code (REPZ_3_10, bl_tree); send_bits (count - 3, 3); |
| 1263 | } |
| 1264 | else |
| 1265 | { |
| 1266 | send_code (REPZ_11_138, bl_tree); send_bits (count - 11, 7); |
| 1267 | } |
| 1268 | |
| 1269 | count = 0; |
| 1270 | prevlen = curlen; |
| 1271 | |
| 1272 | if (nextlen == 0) |
| 1273 | max_count = 138, min_count = 3; |
| 1274 | else if (curlen == nextlen) |
| 1275 | max_count = 6, min_count = 3; |
| 1276 | else |
| 1277 | max_count = 7, min_count = 4; |
| 1278 | } |
nothing calls this directly
no outgoing calls
no test coverage detected