Merge pull request #275 from mozilla/idct-selector
Make IDCT method customizable
This commit is contained in:
14
jddctmgr.c
14
jddctmgr.c
@@ -27,6 +27,7 @@
|
|||||||
#include "jdct.h" /* Private declarations for DCT subsystem */
|
#include "jdct.h" /* Private declarations for DCT subsystem */
|
||||||
#include "jsimddct.h"
|
#include "jsimddct.h"
|
||||||
#include "jpegcomp.h"
|
#include "jpegcomp.h"
|
||||||
|
#include "jdmaster.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -86,6 +87,11 @@ typedef union {
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
EXTERN(void) jpeg_set_idct_method_selector (j_decompress_ptr cinfo, jpeg_idct_method_selector selector){
|
||||||
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
master->custom_idct_selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prepare for an output pass.
|
* Prepare for an output pass.
|
||||||
@@ -225,6 +231,14 @@ start_pass(j_decompress_ptr cinfo)
|
|||||||
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
|
ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Allow custom idct function to be set dynamically
|
||||||
|
my_master_ptr master = (my_master_ptr) cinfo->master;
|
||||||
|
|
||||||
|
if (master->custom_idct_selector != NULL) {
|
||||||
|
master->custom_idct_selector(cinfo, compptr, &method_ptr, &method);
|
||||||
|
}
|
||||||
|
|
||||||
idct->pub.inverse_DCT[ci] = method_ptr;
|
idct->pub.inverse_DCT[ci] = method_ptr;
|
||||||
/* Create multiplier table from quant table.
|
/* Create multiplier table from quant table.
|
||||||
* However, we can skip this if the component is uninteresting
|
* However, we can skip this if the component is uninteresting
|
||||||
|
|||||||
@@ -23,6 +23,11 @@ typedef struct {
|
|||||||
*/
|
*/
|
||||||
struct jpeg_color_quantizer *quantizer_1pass;
|
struct jpeg_color_quantizer *quantizer_1pass;
|
||||||
struct jpeg_color_quantizer *quantizer_2pass;
|
struct jpeg_color_quantizer *quantizer_2pass;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Permit users to replace the IDCT method
|
||||||
|
*/
|
||||||
|
jpeg_idct_method_selector custom_idct_selector;
|
||||||
} my_decomp_master;
|
} my_decomp_master;
|
||||||
|
|
||||||
typedef my_decomp_master *my_master_ptr;
|
typedef my_decomp_master *my_master_ptr;
|
||||||
|
|||||||
@@ -514,6 +514,8 @@ struct jpeg_compress_struct {
|
|||||||
int script_space_size;
|
int script_space_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*jpeg_idct_method) (j_decompress_ptr cinfo, jpeg_component_info *compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col);
|
||||||
|
typedef void (*jpeg_idct_method_selector) (j_decompress_ptr cinfo, jpeg_component_info *compptr, jpeg_idct_method * set_idct_method, int * set_idct_category);
|
||||||
|
|
||||||
/* Master record for a decompression instance */
|
/* Master record for a decompression instance */
|
||||||
|
|
||||||
@@ -1137,6 +1139,12 @@ EXTERN(boolean) jpeg_read_icc_profile(j_decompress_ptr cinfo,
|
|||||||
JOCTET **icc_data_ptr,
|
JOCTET **icc_data_ptr,
|
||||||
unsigned int *icc_data_len);
|
unsigned int *icc_data_len);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Permit users to replace the IDCT method dynamically.
|
||||||
|
* The selector callback is called after the default idct implementation was choosen,
|
||||||
|
* and is able to override it.
|
||||||
|
*/
|
||||||
|
EXTERN(void) jpeg_set_idct_method_selector (j_decompress_ptr cinfo, jpeg_idct_method_selector selector);
|
||||||
|
|
||||||
/* These marker codes are exported since applications and data source modules
|
/* These marker codes are exported since applications and data source modules
|
||||||
* are likely to want to use them.
|
* are likely to want to use them.
|
||||||
|
|||||||
Reference in New Issue
Block a user