Hi,
my name is Andrew. I believe this will be my first post on daniweb so please bear with me.
I'm working on a compression algorithm (miniSEED steim 2 compression if anyone is interested, its for seismic lossless compression) in C so I do a lot of bit manipulation of the data. I need to save the data in a record that has 64 64-byte frames. The first frame is header information. The second frame is where all the real data begins to be stored. Each frame contains 16 32-bit words (or subframes).
So I've created a Record structure that contains a header struct and a new data type of 64 bytes. My issue arises when i do my compression algorithm and I'm trying to transfer the 64 bytes from my temporary frame storage to the corresponding frame in the record structure.
Here's the code to help clarify what I'm talking about.
//Here's the excerpt from my miniSEED.h
#define MAXSEEDFRAMES 7 //7 for 512, 63 for 4096
#define MAXWORDSPERFRAME 16
typedef int compressed_frame[MAXWORDSPERFRAME];
typedef struct {
mSEED_header head;
compressed_frame frames[MAXSEEDFRAMES];
} mSEED_record;
typedef struct mSEED_secBuf {
mSEED_record *rec_ptr; //some pointer to the seed data frame
int subframe[MAXWORDSPERFRAME]; // temp array to hold frame data
int channel; // Determines which channel's frame
int ori_dnib; // Subframe formatting
int new_dnib;
int data_buffer[7]; // Compressed data pre-storage
int buff_count; // The current buffer position
int sub_count; // The current subframe being written to
int frame_count; // The current frame # being written to
int fwd_int_const; // Forward Integration Constant
int rev_int_const; // Reverse Integration Constant
} mSEED_data, *pmSEED_data;
//heres the excerpt where i copy the data over
// store the dnib code, if buffer has enough data, fill the subframe
if(steim_concat(p_msDAT)) {
fill_subframe(p_msDAT);
memcpy(p_msDAT->subframe, p_msDAT->rec_ptr->frames[p_msDAT->frame_count],
(sizeof(int)*MAXWORDSPERFRAME));
}
Right now I'm using typedef and to copy over the mSEED_data.subframe
to the mSEED_record.frames[x]
. I use memcpy. Would a multidimensional array better serve my purposes or is it simply a matter of style?
Thanks in advance,
Andrew