Added support for compressed fuji bayer files

This commit is contained in:
heckflosse
2017-02-12 21:27:11 +01:00
parent 307d5b3a2f
commit 3329899b37
4 changed files with 307 additions and 84 deletions

View File

@@ -90,7 +90,7 @@ protected:
unsigned zero_after_ff, is_raw, dng_version, is_foveon, data_error;
unsigned tile_width, tile_length, gpsdata[32], load_flags;
bool xtransCompressed = false;
struct xtrans_params
struct fuji_compressed_params
{
char *q_table; /* quantization table */
int q_point[5]; /* quantization points */
@@ -115,13 +115,14 @@ protected:
_ltotal
};
struct xtrans_block {
struct fuji_compressed_block {
int cur_bit; // current bit being read (from left to right)
int cur_pos; // current position in a buffer
INT64 cur_buf_offset; // offset of this buffer in a file
unsigned max_read_size; // Amount of data to be read
int cur_buf_size; // buffer size
uchar *cur_buf; // currently read block
int fillbytes; // Counter to add extra byte for block size N*16
IMFILE *input;
struct int_pair grad_even[3][41]; // tables of gradients
struct int_pair grad_odd[3][41];
@@ -129,7 +130,7 @@ protected:
ushort *linebuf[_ltotal];
};
int fuji_total_lines, fuji_total_blocks, fuji_block_width, fuji_bits;
int fuji_total_lines, fuji_total_blocks, fuji_block_width, fuji_bits, fuji_raw_type;
ushort raw_height, raw_width, height, width, top_margin, left_margin;
ushort shrink, iheight, iwidth, fuji_width, thumb_width, thumb_height;
@@ -269,25 +270,27 @@ void adobe_copy_pixel (unsigned row, unsigned col, ushort **rp);
void lossless_dng_load_raw();
void packed_dng_load_raw();
void deflate_dng_load_raw();
void init_xtrans(struct xtrans_params* info);
void fuji_fill_buffer(struct xtrans_block *info);
void init_xtrans_block(struct xtrans_block* info, const struct xtrans_params *params, INT64 raw_offset, unsigned dsize);
void copy_line_to_xtrans(struct xtrans_block* info, int cur_line, int cur_block, int cur_block_width);
void fuji_zerobits(struct xtrans_block* info, int *count);
void fuji_read_code(struct xtrans_block* info, int *data, int bits_to_read);
void init_fuji_compr(struct fuji_compressed_params* info);
void fuji_fill_buffer(struct fuji_compressed_block *info);
void init_fuji_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, INT64 raw_offset, unsigned dsize);
void copy_line_to_xtrans(struct fuji_compressed_block* info, int cur_line, int cur_block, int cur_block_width);
void copy_line_to_bayer(struct fuji_compressed_block* info, int cur_line, int cur_block, int cur_block_width);
void fuji_zerobits(struct fuji_compressed_block* info, int *count);
void fuji_read_code(struct fuji_compressed_block* info, int *data, int bits_to_read);
int bitDiff(int value1, int value2);
int fuji_decode_sample_even(struct xtrans_block* info, const struct xtrans_params * params, ushort* line_buf, int pos, struct int_pair* grads);
int fuji_decode_sample_odd(struct xtrans_block* info, const struct xtrans_params * params, ushort* line_buf, int pos, struct int_pair* grads);
int fuji_decode_sample_even(struct fuji_compressed_block* info, const struct fuji_compressed_params * params, ushort* line_buf, int pos, struct int_pair* grads);
int fuji_decode_sample_odd(struct fuji_compressed_block* info, const struct fuji_compressed_params * params, ushort* line_buf, int pos, struct int_pair* grads);
void fuji_decode_interpolation_even(int line_width, ushort* line_buf, int pos);
void xtrans_extend_generic(ushort *linebuf[_ltotal], int line_width, int start, int end);
void xtrans_extend_red(ushort *linebuf[_ltotal], int line_width);
void xtrans_extend_green(ushort *linebuf[_ltotal], int line_width);
void xtrans_extend_blue(ushort *linebuf[_ltotal], int line_width);
void xtrans_decode_block(struct xtrans_block* info, const struct xtrans_params *params, int cur_line);
void xtrans_decode_strip(const struct xtrans_params* info_common, int cur_block, INT64 raw_offset, unsigned dsize);
void xtrans_compressed_load_raw();
void xtrans_decode_loop(const struct xtrans_params* common_info, int count, INT64* raw_block_offsets, unsigned *block_sizes);
void parse_xtrans_header();
void fuji_extend_generic(ushort *linebuf[_ltotal], int line_width, int start, int end);
void fuji_extend_red(ushort *linebuf[_ltotal], int line_width);
void fuji_extend_green(ushort *linebuf[_ltotal], int line_width);
void fuji_extend_blue(ushort *linebuf[_ltotal], int line_width);
void xtrans_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line);
void fuji_bayer_decode_block(struct fuji_compressed_block* info, const struct fuji_compressed_params *params, int cur_line);
void fuji_decode_strip(const struct fuji_compressed_params* info_common, int cur_block, INT64 raw_offset, unsigned dsize);
void fuji_compressed_load_raw();
void fuji_decode_loop(const struct fuji_compressed_params* common_info, int count, INT64* raw_block_offsets, unsigned *block_sizes);
void parse_fuji_compressed_header();
void pentax_load_raw();
void nikon_load_raw();
int nikon_is_compressed();