Skip to content

Commit 4c274a8

Browse files
committed
add methods/fields for decoding compression block structures
1 parent 9fc13c7 commit 4c274a8

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

tinyfseq.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
#include <stdint.h>
4343

44-
#define TINYFSEQ_VERSION "2.1.0"
44+
#define TINYFSEQ_VERSION "2.1.1"
4545

4646
enum tf_err_t {
4747
TF_OK = 0,
@@ -51,6 +51,7 @@ enum tf_err_t {
5151
TF_EINVALID_VAR_HEADER_SIZE,
5252
TF_EINVALID_VAR_VALUE_SIZE,
5353
TF_EINVALID_CHANNEL_RANGE_SIZE,
54+
TF_EINVALID_COMPRESSION_BLOCK_SIZE,
5455
};
5556

5657
/**
@@ -77,6 +78,7 @@ struct tf_file_header_t {
7778
uint32_t frameCount;
7879
uint8_t frameStepTimeMillis;
7980
enum tf_ctype_t compressionType;
81+
uint8_t compressionBlockCount;
8082
uint8_t channelRangeCount;
8183
uint64_t sequenceUid;
8284
};
@@ -93,6 +95,13 @@ struct tf_file_header_t {
9395
*/
9496
enum tf_err_t tf_read_file_header(const uint8_t *bd, int bs, struct tf_file_header_t *header, uint8_t **ep);
9597

98+
struct tf_compression_block_t {
99+
uint32_t firstFrameId;
100+
uint32_t size;
101+
};
102+
103+
enum tf_err_t tf_read_compression_block(const uint8_t *bd, int bs, struct tf_compression_block_t *block, uint8_t **ep);
104+
96105
struct tf_var_header_t {
97106
uint16_t size;
98107
uint8_t id[2];
@@ -171,6 +180,8 @@ const char *tf_err_str(enum tf_err_t err) {
171180
return "TF_EINVALID_VAR_VALUE_SIZE (undersized variable value data decoding buffer)";
172181
case TF_EINVALID_CHANNEL_RANGE_SIZE:
173182
return "TF_EINVALID_CHANNEL_RANGE_SIZE (undersized `tf_channel_range_t` data decoding buffer)";
183+
case TF_EINVALID_COMPRESSION_BLOCK_SIZE:
184+
return "TF_EINVALID_COMPRESSION_BLOCK_SIZE (undersized `tf_compression_block_t` data decoding buffer)";
174185
default:
175186
return "unknown `tf_err_t` value";
176187
}
@@ -219,7 +230,8 @@ enum tf_err_t tf_read_file_header(const uint8_t *bd, int bs, struct tf_file_head
219230
return TF_EINVALID_COMPRESSION_TYPE;
220231
}
221232

222-
header->compressionType = (enum tf_ctype_t) compressionType;
233+
header->compressionType = (enum tf_ctype_t) compressionType;
234+
header->compressionBlockCount = bd[21];
223235

224236
header->channelRangeCount = bd[22];
225237
header->sequenceUid = ((uint64_t *) &bd[24])[0];
@@ -231,6 +243,23 @@ enum tf_err_t tf_read_file_header(const uint8_t *bd, int bs, struct tf_file_head
231243
return TF_OK;
232244
}
233245

246+
enum tf_err_t tf_read_compression_block(const uint8_t *bd, int bs, struct tf_compression_block_t *block, uint8_t **ep) {
247+
const int COMPRESSION_BLOCK_SIZE = 8;
248+
249+
if (bs < COMPRESSION_BLOCK_SIZE) {
250+
return TF_EINVALID_COMPRESSION_BLOCK_SIZE;
251+
}
252+
253+
block->firstFrameId = ((uint32_t *) &bd[0])[0];
254+
block->size = ((uint32_t *) &bd[4])[0];
255+
256+
if (ep) {
257+
*ep = ((uint8_t *) bd) + COMPRESSION_BLOCK_SIZE;
258+
}
259+
260+
return TF_OK;
261+
}
262+
234263
enum tf_err_t tf_read_var_header(const uint8_t *bd, int bs, struct tf_var_header_t *varHeader, uint8_t *vd, int vs, uint8_t **ep) {
235264
const int VAR_HEADER_SIZE = 4;
236265

0 commit comments

Comments
 (0)