fplayer
C99 Falcon Sequence (fseq) file player for Light-O-Rama hardware (like xLights)
Loading...
Searching...
No Matches
writer.c File Reference

FSEQ sequence file encoding function implementations. More...

#include "writer.h"
#include <assert.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "tinyfseq.h"
#include "fseq/enc.h"
#include "std2/errcode.h"
#include "std2/fc.h"
Include dependency graph for writer.c:

Macros

#define HEADER_SIZE   32
 Size of the FSEQ file format header in bytes.
 
#define VAR_HEADER_SIZE   4
 Size of a FSEQ file format variable header in bytes.
 

Functions

int fseqWriteHeader (struct FC *fc, const struct tf_header_t *header)
 Encodes the given header and writes it at the beginning of the file.
 
int fseqWriteCompressionBlocks (struct FC *fc, const struct tf_header_t *header, const struct tf_compression_block_t *blocks)
 Encodes the given compression blocks writes them to the file at the at the end of the format header.
 
static int fseqGetVarSectionSize (const struct fseq_var_s *vars, const int count, const bool align, uint16_t *size)
 Calculates the size in bytes of the variable section according to the given variables. The size is stored in the given pointer.
 
int fseqWriteVars (struct FC *fc, const struct tf_header_t *header, const struct fseq_var_s *vars, const int count)
 Encodes the given variables and writes them to the file after the compression block and channel range tables.
 
int fseqRealignHeaderOffsets (struct tf_header_t *header, const struct fseq_var_s *vars, const int count)
 Re-aligns the offsets in the given header to account for the length of the variable data that will be written to the file.
 

Detailed Description

FSEQ sequence file encoding function implementations.

Macro Definition Documentation

◆ HEADER_SIZE

#define HEADER_SIZE   32

Size of the FSEQ file format header in bytes.

◆ VAR_HEADER_SIZE

#define VAR_HEADER_SIZE   4

Size of a FSEQ file format variable header in bytes.

Function Documentation

◆ fseqGetVarSectionSize()

static int fseqGetVarSectionSize ( const struct fseq_var_s * vars,
const int count,
const bool align,
uint16_t * size )
static

Calculates the size in bytes of the variable section according to the given variables. The size is stored in the given pointer.

Parameters
varsvariables to calculate the size of
countnumber of variables in the array
alignwhether to align the size to the nearest multiple of 4
sizepointer to store the calculated size
Returns
0 on success, a negative error code on failure
Here is the caller graph for this function:

◆ fseqRealignHeaderOffsets()

int fseqRealignHeaderOffsets ( struct tf_header_t * header,
const struct fseq_var_s * vars,
int count )

Re-aligns the offsets in the given header to account for the length of the variable data that will be written to the file.

Parameters
headerheader to update
varsvariables to account for
countnumber of variables in the array
Returns
0 on success, a negative error code on failure
Here is the call graph for this function:

◆ fseqWriteCompressionBlocks()

int fseqWriteCompressionBlocks ( struct FC * fc,
const struct tf_header_t * header,
const struct tf_compression_block_t * blocks )

Encodes the given compression blocks writes them to the file at the at the end of the format header.

Parameters
fctarget file controller
headerheader to account for
blockscompression blocks to encode and write
Returns
0 on success, a negative error code on failure
Here is the call graph for this function:

◆ fseqWriteHeader()

int fseqWriteHeader ( struct FC * fc,
const struct tf_header_t * header )

Encodes the given header and writes it at the beginning of the file.

Parameters
fctarget file controller
headerheader to encode and write
Returns
0 on success, a negative error code on failure
Here is the call graph for this function:

◆ fseqWriteVars()

int fseqWriteVars ( struct FC * fc,
const struct tf_header_t * header,
const struct fseq_var_s * vars,
int count )

Encodes the given variables and writes them to the file after the compression block and channel range tables.

Parameters
fctarget file controller
headerheader to account for
varsvariables to encode and write
countnumber of variables in the array
Returns
0 on success, a negative error code on failure
Here is the call graph for this function: