rename tANS_X_st_X to tANS_X
authorGeoffrey Allott <geoffrey@allott.email>
Tue, 2 Aug 2022 07:57:35 +0000 (08:57 +0100)
committerGeoffrey Allott <geoffrey@allott.email>
Tue, 2 Aug 2022 07:57:35 +0000 (08:57 +0100)
src/tANS_constants.h
src/tANS_decode_st.c
src/tANS_decode_st.h
src/tANS_encode_st.c
src/tANS_encode_st.h
test/test_tANS.c

index 16a816f432f5284499aaaedbac4ac158cd509283..4a69e3441a638aa1d36155969f457c79e2f13f9d 100644 (file)
@@ -1,11 +1,5 @@
 #pragma once
 
-/*
-#define TANS_LOG2_MAX_TBLSZ        10
-#define TANS_MAX_TBLSZ        (1 << TANS_LOG2_MAX_TBLSZ)
-#define TANS_MAX_SYMBOLS  256
-*/
-
 #define TANS_LOG2_MAX_TBLSZ   12
 #define TANS_MAX_TBLSZ        (1 << TANS_LOG2_MAX_TBLSZ)
 #define TANS_MAX_SYMBOLS      256
index 2a51c0f480ddc09c4552b8f481a71f154c17e57b..6f3c4b2ff952c0525dc742313d9417a56b417487 100644 (file)
@@ -11,7 +11,7 @@ static inline uint32_t get_uint32(uint8_t buf[const static 4])
     return (uint32_t) buf[0] | (uint32_t) buf[1] << 8 | (uint32_t) buf[2] << 16 | (uint32_t) buf[3] << 24;
 }
 
-uint32_t tANS_decode_st_decode(struct tANS_decode_st *self, uint8_t *data, uint32_t len, uint8_t *buf, uint32_t bits)
+uint32_t tANS_decode(struct tANS_decode_st *self, uint8_t *data, uint32_t len, uint8_t *buf, uint32_t bits)
 {
     uint32_t i;
     struct tANS_decode_tbl_entry t;
index c576f4f5800cfa690ff5884958a481d8aaff0524..67cd065409219d4effda1b7e1cf9392bda591277 100644 (file)
@@ -8,4 +8,4 @@ struct tANS_decode_st {
 };
 
 void tANS_decode_st_init(struct tANS_decode_st *self, struct tANS_symbol_tbl *symbol_tbl);
-uint32_t tANS_decode_st_decode(struct tANS_decode_st *self, uint8_t *data, uint32_t len, uint8_t *buf, uint32_t bits);
+uint32_t tANS_decode(struct tANS_decode_st *self, uint8_t *data, uint32_t len, uint8_t *buf, uint32_t bits);
index 7fab5088a55795d42be5774435be325b9d671e94..8eb9d017451d84f50455454567988319029d7136 100644 (file)
@@ -20,7 +20,7 @@ static inline void set_uint32(uint8_t buf[static 4], uint32_t value)
     buf[3] = (uint8_t) (value >> 24);
 }
 
-uint32_t tANS_encode_st_encode(struct tANS_encode_st *self, uint8_t *data, uint32_t len, uint8_t *buf)
+uint32_t tANS_encode(struct tANS_encode_st *self, uint8_t *data, uint32_t len, uint8_t *buf)
 {
     uint8_t nb_bits;
     uint32_t i, written = 0;
index e0078c6f752f7024818fe2ed8f2885505cb7beab..8e3eed9e2f85db7e59acdb0e42635418dd82c173 100644 (file)
@@ -9,4 +9,4 @@ struct tANS_encode_st {
 };
 
 void tANS_encode_st_init(struct tANS_encode_st *self, const struct tANS_symbol_tbl *symbol_tbl);
-uint32_t tANS_encode_st_encode(struct tANS_encode_st *self, uint8_t *data, uint32_t len, uint8_t *buf);
+uint32_t tANS_encode(struct tANS_encode_st *self, uint8_t *data, uint32_t len, uint8_t *buf);
index f8e98652fba7fef6f078593cfd4d4e1786f64911..6e1d919491c654c2290b63402002e790c034a74a 100644 (file)
@@ -21,7 +21,7 @@ enum test_result test_tANS_encode_equal_freq(void)
     ASSERT_EQ(tANS_symbol_tbl_init(&symbol_tbl, &freq_tbl), 0);
     tANS_encode_st_init(&encode_st, &symbol_tbl);
 
-    ASSERT_EQ(tANS_encode_st_encode(&encode_st, data, sizeof data, buf + 4), sizeof data * 8);
+    ASSERT_EQ(tANS_encode(&encode_st, data, sizeof data, buf + 4), sizeof data * 8);
 
 
     return TEST_SUCCESS;
@@ -45,7 +45,7 @@ enum test_result test_tANS_encode_high_zero_probability(void)
     ASSERT_EQ(tANS_symbol_tbl_init(&symbol_tbl, &freq_tbl), 0);
     tANS_encode_st_init(&encode_st, &symbol_tbl);
 
-    ASSERT_LT(tANS_encode_st_encode(&encode_st, data, sizeof data, buf + 4), 24);
+    ASSERT_LT(tANS_encode(&encode_st, data, sizeof data, buf + 4), 24);
 
     return TEST_SUCCESS;
 }
@@ -68,12 +68,12 @@ enum test_result test_tANS_encode_decode_equal_freq(void)
     ASSERT_NE(tANS_freq_tbl_init(&freq_tbl, n_symbols, p, log2_tblsz), -1);
     ASSERT_EQ(tANS_symbol_tbl_init(&symbol_tbl, &freq_tbl), 0);
     tANS_encode_st_init(&encode_st, &symbol_tbl);
-    tANS_decode_st_init(&decode_st, &symbol_tbl);
 
-    ASSERT_EQ(tANS_encode_st_encode(&encode_st, data, sizeof data, buf + 4), 64);
+    ASSERT_EQ(tANS_encode(&encode_st, data, sizeof data, buf + 4), 64);
+    tANS_decode_st_init(&decode_st, &symbol_tbl);
     decode_st.x = (uint16_t) (encode_st.x - (1 << log2_tblsz));
 
-    ASSERT_EQ(tANS_decode_st_decode(&decode_st, rec, sizeof rec, buf + 4, 64), 0);
+    ASSERT_EQ(tANS_decode(&decode_st, rec, sizeof rec, buf + 4, 64), 0);
 
     for (i = 0; i < sizeof rec; ++i) {
         ASSERT_EQ(data[i], rec[i]);
@@ -104,11 +104,11 @@ enum test_result test_tANS_encode_decode_high_zero_probability(void)
     tANS_encode_st_init(&encode_st, &symbol_tbl);
     tANS_decode_st_init(&decode_st, &symbol_tbl);
 
-    bits = tANS_encode_st_encode(&encode_st, data, sizeof data, buf + 4);
+    bits = tANS_encode(&encode_st, data, sizeof data, buf + 4);
 
     decode_st.x = (uint16_t) (encode_st.x - (1 << log2_tblsz));
 
-    ASSERT_EQ(tANS_decode_st_decode(&decode_st, rec, sizeof rec, buf + 4, bits), 0);
+    ASSERT_EQ(tANS_decode(&decode_st, rec, sizeof rec, buf + 4, bits), 0);
 
     for (i = 0; i < sizeof rec; ++i) {
         ASSERT_EQ(data[i], rec[i]);
@@ -143,10 +143,10 @@ enum test_result test_tANS_encode_decode_long_stream(void)
         data[i] = (uint8_t) (i % 4 == 3 ? i / 4 : 0);
     }
 
-    bits = (uint32_t) tANS_encode_st_encode(&encode_st, data, sizeof data, buf + 4);
+    bits = (uint32_t) tANS_encode(&encode_st, data, sizeof data, buf + 4);
     decode_st.x = (uint16_t) (encode_st.x - (1 << log2_tblsz));
 
-    ASSERT_EQ(tANS_decode_st_decode(&decode_st, rec, sizeof rec, buf + 4, bits), 0);
+    ASSERT_EQ(tANS_decode(&decode_st, rec, sizeof rec, buf + 4, bits), 0);
 
     for (i = 0; i < sizeof rec; ++i) {
         ASSERT_EQ(data[i], rec[i]);