typedefstruct { struct jpeg_forward_dct pub; /* public fields */
/* Pointer to the DCT routine actually in use */
forward_DCT_method_ptr do_dct;
/* The actual post-DCT divisors --- not identical to the quant table *entries,becauseofscaling(especiallyforanunnormalizedDCT). *Eachtableisgiveninnormalarrayorder.
*/
DCTELEM * divisors[NUM_QUANT_TBLS];
#ifdef DCT_FLOAT_SUPPORTED /* Same as above for the floating-point case. */
float_DCT_method_ptr do_float_dct;
FAST_FLOAT * float_divisors[NUM_QUANT_TBLS]; #endif
} my_fdct_controller;
/* Quantize/descale the coefficients, and store into coef_blocks[] */
{ register DCTELEM temp, qval; register int i; register JCOEFPTR output_ptr = coef_blocks[bi];
for (i = 0; i < DCTSIZE2; i++) {
qval = divisors[i];
temp = workspace[i]; /* Divide the coefficient value by qval, ensuring proper rounding. *SinceCdoesnotspecifythedirectionofroundingfornegative *quotients,wehavetoforcethedividendpositiveforportability. * *Inmostfiles,atleasthalfoftheoutputvalueswillbezero *(atdefaultquantizationsettings,morelikethree-quarters...) *soweshouldensurethatthiscaseisfast.Onmanymachines, *acomparisonisenoughcheaperthanadividetomakeaspecialtest *awin.Sincebothinputswillbenonnegative,weneedonlytest *fora<btodiscoverwhethera/bis0. *Ifyourmachine'sdivisionisfastenough,defineFAST_DIVIDE.
*/ #ifdef FAST_DIVIDE #define DIVIDE_BY(a,b) a /= b #else #define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0 #endif
if (temp < 0) {
temp = -temp;
temp += qval>>1; /* for rounding */
DIVIDE_BY(temp, qval);
temp = -temp;
} else {
temp += qval>>1; /* for rounding */
DIVIDE_BY(temp, qval);
}
output_ptr[i] = (JCOEF) temp;
}
}
}
}
#ifdef DCT_FLOAT_SUPPORTED
METHODDEF(void)
forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info * compptr,
JSAMPARRAY sample_data, JBLOCKROW coef_blocks,
JDIMENSION start_row, JDIMENSION start_col,
JDIMENSION num_blocks) /* This version is used for floating-point DCT implementations. */
{ /* This routine is heavily used, so it's worth coding it tightly. */
my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;
float_DCT_method_ptr do_dct = fdct->do_float_dct;
FAST_FLOAT * divisors = fdct->float_divisors[compptr->quant_tbl_no];
FAST_FLOAT workspace[DCTSIZE2]; /* work area for FDCT subroutine */
JDIMENSION bi;
sample_data += start_row; /* fold in the vertical offset once */
for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) { /* Load data into workspace, applying unsigned->signed conversion */
{ register FAST_FLOAT *workspaceptr; register JSAMPROW elemptr; register int elemr;
/* Quantize/descale the coefficients, and store into coef_blocks[] */
{ register FAST_FLOAT temp; register int i; register JCOEFPTR output_ptr = coef_blocks[bi];
for (i = 0; i < DCTSIZE2; i++) { /* Apply the quantization and scaling factor */
temp = workspace[i] * divisors[i]; /* Round to nearest integer. *SinceCdoesnotspecifythedirectionofroundingfornegative *quotients,wehavetoforcethedividendpositiveforportability. *Themaximumcoefficientsizeis+-16K(for12-bitdata),sothis *codeshouldworkforeither16-bitor32-bitints.
*/
output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);
}
}
}
}
#endif/* DCT_FLOAT_SUPPORTED */
/* *InitializeFDCTmanager.
*/
GLOBAL(void)
jinit_forward_dct (j_compress_ptr cinfo)
{
my_fdct_ptr fdct;
int i;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.