#if DCTSIZE != 8
Sorry, this code only copes with 8x8 DCTs. /* deliberate syntax err */ #endif
/* Scaling decisions are generally the same as in the LL&M algorithm; *seejidctint.cformoredetails.However,wechoosetodescale *(rightshift)multiplicationproductsassoonastheyareformed, *ratherthancarryingadditionalfractionalbitsintosubsequentadditions. *Thiscompromisesaccuracyslightly,butitletsussaveafewshifts. *Moreimportantly,16-bitarithmeticisthenadequate(for8-bitsamples) *everywhereexceptinthemultiplicationsproper;thissavesagooddeal *ofworkon16-bit-intmachines. * *ThedequantizedcoefficientsarenotintegersbecausetheAA&Nscaling *factorshavebeenincorporated.WerepresentthemscaledupbyPASS1_BITS, *sothatthefirstandsecondIDCTroundshavethesameinputscaling. *For8-bitJSAMPLEs,wechooseIFAST_SCALE_BITS=PASS1_BITSsoasto *avoidadescalingshift;thiscompromisesaccuracyratherdrastically *forsmallquantizationtableentries,butitsavesalotofshifts. *For12-bitJSAMPLEs,there'snohopeofusing16x16multipliesanyway, *soweuseamuchlargerscalingfactortopreserveaccuracy. * *Afinalcompromiseistorepresentthemultiplicativeconstantstoonly *8fractionalbits,ratherthan13.Thissavessomeshiftingworkonsome *machines,andmayalsoreducethecostofmultiplication(sincethere *arefewerone-bitsintheconstants).
*/
#if BITS_IN_JSAMPLE == 8 #define CONST_BITS 8 #define PASS1_BITS 2 #else #define CONST_BITS 8 #define PASS1_BITS 1/* lose a little precision to avoid overflow */ #endif
/* Some C compilers fail to reduce "FIX(constant)" at compile time, thus *causingalotofuselessfloating-pointoperationsatruntime. *Togetaroundthisweusethefollowingpre-calculatedconstants. *IfyouchangeCONST_BITSyoumaywanttoaddappropriatevalues. *(WithareasonableCcompiler,youcanjustrelyontheFIX()macro...)
*/
/* We can gain a little more speed, with a further compromise in accuracy, *byomittingtheadditioninadescalingshift.Thisyieldsanincorrectly *roundedresulthalfthetime...
*/
/* Dequantize a coefficient by multiplying it by the multiplier-table *entry;produceaDCTELEMresult.For8-bitdataa16x16->16 *multiplicationwilldo.For12-bitdata,themultipliertableis *declaredINT32,soa32-bitmultiplywillbeused.
*/
GLOBAL(void)
jpeg_idct_ifast (j_decompress_ptr cinfo, jpeg_component_info * compptr,
JCOEFPTR coef_block,
JSAMPARRAY output_buf, JDIMENSION output_col)
{
DCTELEM tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
DCTELEM tmp10, tmp11, tmp12, tmp13;
DCTELEM z5, z10, z11, z12, z13;
JCOEFPTR inptr;
IFAST_MULT_TYPE * quantptr; int * wsptr;
JSAMPROW outptr;
JSAMPLE *range_limit = IDCT_range_limit(cinfo); int ctr; int workspace[DCTSIZE2]; /* buffers data between passes */
SHIFT_TEMPS /* for DESCALE */
ISHIFT_TEMPS /* for IDESCALE */
/* Pass 1: process columns from input, store into work array. */
inptr = coef_block;
quantptr = (IFAST_MULT_TYPE *) compptr->dct_table;
wsptr = workspace; for (ctr = DCTSIZE; ctr > 0; ctr--) { /* Due to quantization, we will usually find that many of the input *coefficientsarezero,especiallytheACterms.Wecanexploitthis *byshort-circuitingtheIDCTcalculationforanycolumninwhichall *theACtermsarezero.Inthatcaseeachoutputisequaltothe *DCcoefficient(withscalefactorasneeded). *Withtypicalimagesandquantizationtables,halformoreofthe *columnDCTcalculationscanbesimplifiedthisway.
*/
if (inptr[DCTSIZE*1] == 0 && inptr[DCTSIZE*2] == 0 &&
inptr[DCTSIZE*3] == 0 && inptr[DCTSIZE*4] == 0 &&
inptr[DCTSIZE*5] == 0 && inptr[DCTSIZE*6] == 0 &&
inptr[DCTSIZE*7] == 0) { /* AC terms all zero */ int dcval = (int) DEQUANTIZE(inptr[DCTSIZE*0], quantptr[DCTSIZE*0]);
inptr++; /* advance pointers to next column */
quantptr++;
wsptr++;
}
/* Pass 2: process rows from work array, store into output array. */ /* Note that we must descale the results by a factor of 8 == 2**3, */ /* and also undo the PASS1_BITS scaling. */
wsptr = workspace; for (ctr = 0; ctr < DCTSIZE; ctr++) {
outptr = output_buf[ctr] + output_col; /* Rows of zeroes can be exploited in the same way as we did with columns. *However,thecolumncalculationhascreatedmanynonzeroACterms,so *thesimplificationapplieslessoften(typically5%to10%ofthetime). *Onmachineswithveryfastmultiplication,it'spossiblethatthe *testtakesmoretimethanit'sworth.Inthatcasethissection *maybecommentedout.
*/
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.