Skip to content

Commit

Permalink
Remove some unused arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
aaaaaa123456789 committed Jan 14, 2022
1 parent 056abb9 commit f309a18
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/jpegarithmetic.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ void decompress_JPEG_arithmetic_scan (struct context * context, struct JPEG_deco
}
}

void decompress_JPEG_arithmetic_bit_scan (struct context * context, struct JPEG_decompressor_state * restrict state, const struct JPEG_decoder_tables * tables,
size_t rowunits, const struct JPEG_component_info * components, const size_t * offsets, unsigned shift,
unsigned char first, unsigned char last) {
void decompress_JPEG_arithmetic_bit_scan (struct context * context, struct JPEG_decompressor_state * restrict state, size_t rowunits,
const struct JPEG_component_info * components, const size_t * offsets, unsigned shift, unsigned char first,
unsigned char last) {
// this function is very similar to decompress_JPEG_arithmetic_scan, but it only decodes the next bit for already-initialized data
if (last && !first) throw(context, PLUM_ERR_INVALID_FILE_FORMAT);
size_t restart_interval;
Expand Down
8 changes: 4 additions & 4 deletions src/jpegcompress.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct JPEG_encoded_value * generate_JPEG_luminance_data_stream (struct context
double predicted = 0.0;
for (unit = 0; unit < units; unit ++) {
if ((allocated - *count) < 64) result = ctxrealloc(context, result, sizeof *result * (allocated += 3 * (units - unit) + 64));
predicted = generate_JPEG_data_unit(context, result, count, data[unit], quantization, predicted);
predicted = generate_JPEG_data_unit(result, count, data[unit], quantization, predicted);
}
return ctxrealloc(context, result, sizeof *result * *count);
}
Expand All @@ -21,13 +21,13 @@ struct JPEG_encoded_value * generate_JPEG_chrominance_data_stream (struct contex
double predicted_blue = 0.0, predicted_red = 0.0;
for (unit = 0; unit < units; unit ++) {
if ((allocated - *count) < 128) result = ctxrealloc(context, result, sizeof *result * (allocated += 6 * (units - unit) + 128));
predicted_blue = generate_JPEG_data_unit(context, result, count, blue[unit], quantization, predicted_blue);
predicted_red = generate_JPEG_data_unit(context, result, count, red[unit], quantization, predicted_red);
predicted_blue = generate_JPEG_data_unit(result, count, blue[unit], quantization, predicted_blue);
predicted_red = generate_JPEG_data_unit(result, count, red[unit], quantization, predicted_red);
}
return ctxrealloc(context, result, sizeof *result * *count);
}

double generate_JPEG_data_unit (struct context * context, struct JPEG_encoded_value * data, size_t * restrict count, const double unit[restrict static 64],
double generate_JPEG_data_unit (struct JPEG_encoded_value * data, size_t * restrict count, const double unit[restrict static 64],
const uint8_t quantization[restrict static 64], double predicted) {
int16_t output[64];
predicted = apply_JPEG_DCT(output, unit, quantization, predicted);
Expand Down
24 changes: 16 additions & 8 deletions src/jpegreadframe.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,19 @@ void load_JPEG_DCT_frame (struct context * context, const struct JPEG_marker_lay
size_t scanunitrow = unitrow;
initialize_JPEG_decompressor_state(context, &state, component_info, scancomponents, &scanunitrow, unitcol, width, height, maxH, maxV, tables, *offsets,
component_data);
// call the decompression function -- each pair of functions shares the argument list, so select the function inline and write each argument list only once
// call the decompression function, depending on the frame type (Huffman or arithmetic) and whether it is progressive or not
if (bitstart == 0xff)
((layout -> frametype[frameindex] & 8) ? decompress_JPEG_arithmetic_scan : decompress_JPEG_Huffman_scan)
(context, &state, tables, scanunitrow, component_info, *offsets, bitend, *progdata, progdata[1], layout -> frametype[frameindex] & 4);
if (layout -> frametype[frameindex] & 8)
decompress_JPEG_arithmetic_scan(context, &state, tables, scanunitrow, component_info, *offsets, bitend, *progdata, progdata[1],
layout -> frametype[frameindex] & 4);
else
decompress_JPEG_Huffman_scan(context, &state, tables, scanunitrow, component_info, *offsets, bitend, *progdata, progdata[1],
layout -> frametype[frameindex] & 4);
else
((layout -> frametype[frameindex] & 8) ? decompress_JPEG_arithmetic_bit_scan : decompress_JPEG_Huffman_bit_scan)
(context, &state, tables, scanunitrow, component_info, *offsets, bitend, *progdata, progdata[1]);
if (layout -> frametype[frameindex] & 8)
decompress_JPEG_arithmetic_bit_scan(context, &state, scanunitrow, component_info, *offsets, bitend, *progdata, progdata[1]);
else
decompress_JPEG_Huffman_bit_scan(context, &state, tables, scanunitrow, component_info, *offsets, bitend, *progdata, progdata[1]);
}
for (p = 0; p < count; p ++) for (coefficient = 0; coefficient < 64; coefficient ++)
if (currentbits[p][coefficient]) throw(context, PLUM_ERR_INVALID_FILE_FORMAT);
Expand Down Expand Up @@ -105,9 +111,11 @@ void load_JPEG_lossless_frame (struct context * context, const struct JPEG_marke
size_t scanunitrow = unitrow;
initialize_JPEG_decompressor_state_lossless(context, &state, component_info, scancomponents, &scanunitrow, unitcol, width, height, maxH, maxV, tables,
*offsets, component_data);
// call the decompression function: same as above, but without needing to account for progressive scans
((layout -> frametype[frameindex] & 8) ? decompress_JPEG_arithmetic_lossless_scan : decompress_JPEG_Huffman_lossless_scan)
(context, &state, tables, scanunitrow, component_info, *offsets, predictor, precision - shift);
// call the decompression function, depending on the frame type (Huffman or arithmetic) - lossless scans cannot be progressive
if (layout -> frametype[frameindex] & 8)
decompress_JPEG_arithmetic_lossless_scan(context, &state, tables, scanunitrow, component_info, *offsets, predictor, precision - shift);
else
decompress_JPEG_Huffman_lossless_scan(context, &state, tables, scanunitrow, component_info, *offsets, predictor, precision - shift);
}
for (p = 0; p < count; p ++) if (component_shift[p] < 0) throw(context, PLUM_ERR_INVALID_FILE_FORMAT);
// same as in the previous function: loop backwards
Expand Down
8 changes: 4 additions & 4 deletions src/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ internal void generate_Huffman_codes(unsigned short * restrict, unsigned, const
// jpegarithmetic.c
internal void decompress_JPEG_arithmetic_scan(struct context *, struct JPEG_decompressor_state * restrict, const struct JPEG_decoder_tables *, size_t,
const struct JPEG_component_info *, const size_t *, unsigned, unsigned char, unsigned char, int);
internal void decompress_JPEG_arithmetic_bit_scan(struct context *, struct JPEG_decompressor_state * restrict, const struct JPEG_decoder_tables *, size_t,
const struct JPEG_component_info *, const size_t *, unsigned, unsigned char, unsigned char);
internal void decompress_JPEG_arithmetic_bit_scan(struct context *, struct JPEG_decompressor_state * restrict, size_t, const struct JPEG_component_info *,
const size_t *, unsigned, unsigned char, unsigned char);
internal void decompress_JPEG_arithmetic_lossless_scan(struct context *, struct JPEG_decompressor_state * restrict, const struct JPEG_decoder_tables *, size_t,
const struct JPEG_component_info *, const size_t *, unsigned char, unsigned);
internal void initialize_JPEG_arithmetic_counters(struct context *, size_t * restrict, size_t * restrict, uint32_t * restrict);
Expand Down Expand Up @@ -147,8 +147,8 @@ internal struct JPEG_encoded_value * generate_JPEG_luminance_data_stream(struct
size_t * restrict);
internal struct JPEG_encoded_value * generate_JPEG_chrominance_data_stream(struct context *, double (* restrict)[64], double (* restrict)[64], size_t,
const uint8_t [restrict static 64], size_t * restrict);
internal double generate_JPEG_data_unit(struct context *, struct JPEG_encoded_value *, size_t * restrict, const double [restrict static 64],
const uint8_t [restrict static 64], double);
internal double generate_JPEG_data_unit(struct JPEG_encoded_value *, size_t * restrict, const double [restrict static 64], const uint8_t [restrict static 64],
double);
internal void encode_JPEG_value(struct JPEG_encoded_value *, int16_t, unsigned, unsigned char);
internal size_t generate_JPEG_Huffman_table(struct context *, const struct JPEG_encoded_value *, size_t, unsigned char * restrict,
unsigned char [restrict static 0x100], unsigned char);
Expand Down

0 comments on commit f309a18

Please sign in to comment.