In the raw2dng file, rather than fseek'ing a fixed distance from the end of the file, I would recommend starting at the end of the file and gradually working back until the magic char ("RAWM") is in the "magic" element of the struct. Something like this:
off_t offset = 4;
fseek(fi, -offset, SEEK_END);
int r = fread(&lv_rec_footer, 1, sizeof(lv_rec_file_footer_t), fi);
while (strncmp((char *)fileFooter.magic, "RAWM", 4)) {
offset++;
fseek(fi, -offset, SEEK_END);
r = fread(&lv_rec_footer, 1, sizeof(lv_rec_file_footer_t), fi);
}
That will make it more flexible in case something goes wrong. You'll only need the very beginning of the footer to read the uncompressed data anyway.