123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- #ifndef METHODS_BAG_C
- #define METHODS_BAG_C
- #include "MethodsBag.h"
- #include "ErrorCodes.h"
- static const uint16_t smallLengths[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4,
- 4, 4, 4 };
- int exiGetCodingLength(size_t characteristics, size_t* codingLength) {
-
-
- int errn = 0;
- if (characteristics < 17) {
- *codingLength = smallLengths[characteristics];
- } else if (characteristics < 33) {
-
- *codingLength = 5;
- } else if (characteristics < 65) {
-
- *codingLength = 6;
- } else if (characteristics < 129) {
-
- *codingLength = 7;
- } else if (characteristics < 257) {
-
- *codingLength = 8;
- } else if (characteristics < 513) {
-
- *codingLength = 9;
- } else if (characteristics < 1025) {
-
- *codingLength = 10;
- } else if (characteristics < 2049) {
-
- *codingLength = 11;
- } else if (characteristics < 4097) {
-
- *codingLength = 12;
- } else if (characteristics < 8193) {
-
- *codingLength = 13;
- } else if (characteristics < 16385) {
-
- *codingLength = 14;
- } else if (characteristics < 32769) {
-
- *codingLength = 15;
- } else {
-
- *codingLength = 16;
- }
- return errn;
- }
- uint8_t numberOf7BitBlocksToRepresent(uint32_t n) {
-
-
- if (n < 128) {
- return 1;
- }
-
- else if (n < 16384) {
- return 2;
- }
-
- else if (n < 2097152) {
- return 3;
- }
-
- else if (n < 268435456) {
- return 4;
- }
-
- else {
-
- return 5;
- }
- }
- #endif
|