| 8669 | } HUF_buildCTable_wksp_tables; |
| 8670 | |
| 8671 | static void HUF_sort(nodeElt* huffNode, const unsigned* count, U32 maxSymbolValue, rankPos* rankPosition) |
| 8672 | { |
| 8673 | U32 n; |
| 8674 | |
| 8675 | memset(rankPosition, 0, sizeof(*rankPosition) * RANK_POSITION_TABLE_SIZE); |
| 8676 | for (n=0; n<=maxSymbolValue; n++) { |
| 8677 | U32 r = BIT_highbit32(count[n] + 1); |
| 8678 | rankPosition[r].base ++; |
| 8679 | } |
| 8680 | for (n=30; n>0; n--) rankPosition[n-1].base += rankPosition[n].base; |
| 8681 | for (n=0; n<32; n++) rankPosition[n].current = rankPosition[n].base; |
| 8682 | for (n=0; n<=maxSymbolValue; n++) { |
| 8683 | U32 const c = count[n]; |
| 8684 | U32 const r = BIT_highbit32(c+1) + 1; |
| 8685 | U32 pos = rankPosition[r].current++; |
| 8686 | while ((pos > rankPosition[r].base) && (c > huffNode[pos-1].count)) { |
| 8687 | huffNode[pos] = huffNode[pos-1]; |
| 8688 | pos--; |
| 8689 | } |
| 8690 | huffNode[pos].count = c; |
| 8691 | huffNode[pos].byte = (BYTE)n; |
| 8692 | } |
| 8693 | } |
| 8694 | |
| 8695 | |
| 8696 | /** HUF_buildCTable_wksp() : |
no test coverage detected