Path: blob/master/3rdparty/libjpeg-turbo/src/jcdctmgr.c
16337 views
/*1* jcdctmgr.c2*3* This file was part of the Independent JPEG Group's software:4* Copyright (C) 1994-1996, Thomas G. Lane.5* libjpeg-turbo Modifications:6* Copyright (C) 1999-2006, MIYASAKA Masaru.7* Copyright 2009 Pierre Ossman <[email protected]> for Cendio AB8* Copyright (C) 2011, 2014-2015, D. R. Commander.9* For conditions of distribution and use, see the accompanying README.ijg10* file.11*12* This file contains the forward-DCT management logic.13* This code selects a particular DCT implementation to be used,14* and it performs related housekeeping chores including coefficient15* quantization.16*/1718#define JPEG_INTERNALS19#include "jinclude.h"20#include "jpeglib.h"21#include "jdct.h" /* Private declarations for DCT subsystem */22#include "jsimddct.h"232425/* Private subobject for this module */2627typedef void (*forward_DCT_method_ptr) (DCTELEM *data);28typedef void (*float_DCT_method_ptr) (FAST_FLOAT *data);2930typedef void (*convsamp_method_ptr) (JSAMPARRAY sample_data,31JDIMENSION start_col,32DCTELEM *workspace);33typedef void (*float_convsamp_method_ptr) (JSAMPARRAY sample_data,34JDIMENSION start_col,35FAST_FLOAT *workspace);3637typedef void (*quantize_method_ptr) (JCOEFPTR coef_block, DCTELEM *divisors,38DCTELEM *workspace);39typedef void (*float_quantize_method_ptr) (JCOEFPTR coef_block,40FAST_FLOAT *divisors,41FAST_FLOAT *workspace);4243METHODDEF(void) quantize (JCOEFPTR, DCTELEM *, DCTELEM *);4445typedef struct {46struct jpeg_forward_dct pub; /* public fields */4748/* Pointer to the DCT routine actually in use */49forward_DCT_method_ptr dct;50convsamp_method_ptr convsamp;51quantize_method_ptr quantize;5253/* The actual post-DCT divisors --- not identical to the quant table54* entries, because of scaling (especially for an unnormalized DCT).55* Each table is given in normal array order.56*/57DCTELEM *divisors[NUM_QUANT_TBLS];5859/* work area for FDCT subroutine */60DCTELEM *workspace;6162#ifdef DCT_FLOAT_SUPPORTED63/* Same as above for the floating-point case. */64float_DCT_method_ptr float_dct;65float_convsamp_method_ptr float_convsamp;66float_quantize_method_ptr float_quantize;67FAST_FLOAT *float_divisors[NUM_QUANT_TBLS];68FAST_FLOAT *float_workspace;69#endif70} my_fdct_controller;7172typedef my_fdct_controller *my_fdct_ptr;737475#if BITS_IN_JSAMPLE == 87677/*78* Find the highest bit in an integer through binary search.79*/8081LOCAL(int)82flss (UINT16 val)83{84int bit;8586bit = 16;8788if (!val)89return 0;9091if (!(val & 0xff00)) {92bit -= 8;93val <<= 8;94}95if (!(val & 0xf000)) {96bit -= 4;97val <<= 4;98}99if (!(val & 0xc000)) {100bit -= 2;101val <<= 2;102}103if (!(val & 0x8000)) {104bit -= 1;105val <<= 1;106}107108return bit;109}110111112/*113* Compute values to do a division using reciprocal.114*115* This implementation is based on an algorithm described in116* "How to optimize for the Pentium family of microprocessors"117* (http://www.agner.org/assem/).118* More information about the basic algorithm can be found in119* the paper "Integer Division Using Reciprocals" by Robert Alverson.120*121* The basic idea is to replace x/d by x * d^-1. In order to store122* d^-1 with enough precision we shift it left a few places. It turns123* out that this algoright gives just enough precision, and also fits124* into DCTELEM:125*126* b = (the number of significant bits in divisor) - 1127* r = (word size) + b128* f = 2^r / divisor129*130* f will not be an integer for most cases, so we need to compensate131* for the rounding error introduced:132*133* no fractional part:134*135* result = input >> r136*137* fractional part of f < 0.5:138*139* round f down to nearest integer140* result = ((input + 1) * f) >> r141*142* fractional part of f > 0.5:143*144* round f up to nearest integer145* result = (input * f) >> r146*147* This is the original algorithm that gives truncated results. But we148* want properly rounded results, so we replace "input" with149* "input + divisor/2".150*151* In order to allow SIMD implementations we also tweak the values to152* allow the same calculation to be made at all times:153*154* dctbl[0] = f rounded to nearest integer155* dctbl[1] = divisor / 2 (+ 1 if fractional part of f < 0.5)156* dctbl[2] = 1 << ((word size) * 2 - r)157* dctbl[3] = r - (word size)158*159* dctbl[2] is for stupid instruction sets where the shift operation160* isn't member wise (e.g. MMX).161*162* The reason dctbl[2] and dctbl[3] reduce the shift with (word size)163* is that most SIMD implementations have a "multiply and store top164* half" operation.165*166* Lastly, we store each of the values in their own table instead167* of in a consecutive manner, yet again in order to allow SIMD168* routines.169*/170171LOCAL(int)172compute_reciprocal (UINT16 divisor, DCTELEM *dtbl)173{174UDCTELEM2 fq, fr;175UDCTELEM c;176int b, r;177178if (divisor == 1) {179/* divisor == 1 means unquantized, so these reciprocal/correction/shift180* values will cause the C quantization algorithm to act like the181* identity function. Since only the C quantization algorithm is used in182* these cases, the scale value is irrelevant.183*/184dtbl[DCTSIZE2 * 0] = (DCTELEM) 1; /* reciprocal */185dtbl[DCTSIZE2 * 1] = (DCTELEM) 0; /* correction */186dtbl[DCTSIZE2 * 2] = (DCTELEM) 1; /* scale */187dtbl[DCTSIZE2 * 3] = -(DCTELEM) (sizeof(DCTELEM) * 8); /* shift */188return 0;189}190191b = flss(divisor) - 1;192r = sizeof(DCTELEM) * 8 + b;193194fq = ((UDCTELEM2)1 << r) / divisor;195fr = ((UDCTELEM2)1 << r) % divisor;196197c = divisor / 2; /* for rounding */198199if (fr == 0) { /* divisor is power of two */200/* fq will be one bit too large to fit in DCTELEM, so adjust */201fq >>= 1;202r--;203} else if (fr <= (divisor / 2U)) { /* fractional part is < 0.5 */204c++;205} else { /* fractional part is > 0.5 */206fq++;207}208209dtbl[DCTSIZE2 * 0] = (DCTELEM) fq; /* reciprocal */210dtbl[DCTSIZE2 * 1] = (DCTELEM) c; /* correction + roundfactor */211#ifdef WITH_SIMD212dtbl[DCTSIZE2 * 2] = (DCTELEM) (1 << (sizeof(DCTELEM)*8*2 - r)); /* scale */213#else214dtbl[DCTSIZE2 * 2] = 1;215#endif216dtbl[DCTSIZE2 * 3] = (DCTELEM) r - sizeof(DCTELEM)*8; /* shift */217218if (r <= 16) return 0;219else return 1;220}221222#endif223224225/*226* Initialize for a processing pass.227* Verify that all referenced Q-tables are present, and set up228* the divisor table for each one.229* In the current implementation, DCT of all components is done during230* the first pass, even if only some components will be output in the231* first scan. Hence all components should be examined here.232*/233234METHODDEF(void)235start_pass_fdctmgr (j_compress_ptr cinfo)236{237my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;238int ci, qtblno, i;239jpeg_component_info *compptr;240JQUANT_TBL *qtbl;241DCTELEM *dtbl;242243for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components;244ci++, compptr++) {245qtblno = compptr->quant_tbl_no;246/* Make sure specified quantization table is present */247if (qtblno < 0 || qtblno >= NUM_QUANT_TBLS ||248cinfo->quant_tbl_ptrs[qtblno] == NULL)249ERREXIT1(cinfo, JERR_NO_QUANT_TABLE, qtblno);250qtbl = cinfo->quant_tbl_ptrs[qtblno];251/* Compute divisors for this quant table */252/* We may do this more than once for same table, but it's not a big deal */253switch (cinfo->dct_method) {254#ifdef DCT_ISLOW_SUPPORTED255case JDCT_ISLOW:256/* For LL&M IDCT method, divisors are equal to raw quantization257* coefficients multiplied by 8 (to counteract scaling).258*/259if (fdct->divisors[qtblno] == NULL) {260fdct->divisors[qtblno] = (DCTELEM *)261(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,262(DCTSIZE2 * 4) * sizeof(DCTELEM));263}264dtbl = fdct->divisors[qtblno];265for (i = 0; i < DCTSIZE2; i++) {266#if BITS_IN_JSAMPLE == 8267if (!compute_reciprocal(qtbl->quantval[i] << 3, &dtbl[i]) &&268fdct->quantize == jsimd_quantize)269fdct->quantize = quantize;270#else271dtbl[i] = ((DCTELEM) qtbl->quantval[i]) << 3;272#endif273}274break;275#endif276#ifdef DCT_IFAST_SUPPORTED277case JDCT_IFAST:278{279/* For AA&N IDCT method, divisors are equal to quantization280* coefficients scaled by scalefactor[row]*scalefactor[col], where281* scalefactor[0] = 1282* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7283* We apply a further scale factor of 8.284*/285#define CONST_BITS 14286static const INT16 aanscales[DCTSIZE2] = {287/* precomputed values scaled up by 14 bits */28816384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,28922725, 31521, 29692, 26722, 22725, 17855, 12299, 6270,29021407, 29692, 27969, 25172, 21407, 16819, 11585, 5906,29119266, 26722, 25172, 22654, 19266, 15137, 10426, 5315,29216384, 22725, 21407, 19266, 16384, 12873, 8867, 4520,29312873, 17855, 16819, 15137, 12873, 10114, 6967, 3552,2948867, 12299, 11585, 10426, 8867, 6967, 4799, 2446,2954520, 6270, 5906, 5315, 4520, 3552, 2446, 1247296};297SHIFT_TEMPS298299if (fdct->divisors[qtblno] == NULL) {300fdct->divisors[qtblno] = (DCTELEM *)301(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,302(DCTSIZE2 * 4) * sizeof(DCTELEM));303}304dtbl = fdct->divisors[qtblno];305for (i = 0; i < DCTSIZE2; i++) {306#if BITS_IN_JSAMPLE == 8307if (!compute_reciprocal(308DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],309(JLONG) aanscales[i]),310CONST_BITS-3), &dtbl[i]) &&311fdct->quantize == jsimd_quantize)312fdct->quantize = quantize;313#else314dtbl[i] = (DCTELEM)315DESCALE(MULTIPLY16V16((JLONG) qtbl->quantval[i],316(JLONG) aanscales[i]),317CONST_BITS-3);318#endif319}320}321break;322#endif323#ifdef DCT_FLOAT_SUPPORTED324case JDCT_FLOAT:325{326/* For float AA&N IDCT method, divisors are equal to quantization327* coefficients scaled by scalefactor[row]*scalefactor[col], where328* scalefactor[0] = 1329* scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7330* We apply a further scale factor of 8.331* What's actually stored is 1/divisor so that the inner loop can332* use a multiplication rather than a division.333*/334FAST_FLOAT *fdtbl;335int row, col;336static const double aanscalefactor[DCTSIZE] = {3371.0, 1.387039845, 1.306562965, 1.175875602,3381.0, 0.785694958, 0.541196100, 0.275899379339};340341if (fdct->float_divisors[qtblno] == NULL) {342fdct->float_divisors[qtblno] = (FAST_FLOAT *)343(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,344DCTSIZE2 * sizeof(FAST_FLOAT));345}346fdtbl = fdct->float_divisors[qtblno];347i = 0;348for (row = 0; row < DCTSIZE; row++) {349for (col = 0; col < DCTSIZE; col++) {350fdtbl[i] = (FAST_FLOAT)351(1.0 / (((double) qtbl->quantval[i] *352aanscalefactor[row] * aanscalefactor[col] * 8.0)));353i++;354}355}356}357break;358#endif359default:360ERREXIT(cinfo, JERR_NOT_COMPILED);361break;362}363}364}365366367/*368* Load data into workspace, applying unsigned->signed conversion.369*/370371METHODDEF(void)372convsamp (JSAMPARRAY sample_data, JDIMENSION start_col, DCTELEM *workspace)373{374register DCTELEM *workspaceptr;375register JSAMPROW elemptr;376register int elemr;377378workspaceptr = workspace;379for (elemr = 0; elemr < DCTSIZE; elemr++) {380elemptr = sample_data[elemr] + start_col;381382#if DCTSIZE == 8 /* unroll the inner loop */383*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;384*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;385*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;386*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;387*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;388*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;389*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;390*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;391#else392{393register int elemc;394for (elemc = DCTSIZE; elemc > 0; elemc--)395*workspaceptr++ = GETJSAMPLE(*elemptr++) - CENTERJSAMPLE;396}397#endif398}399}400401402/*403* Quantize/descale the coefficients, and store into coef_blocks[].404*/405406METHODDEF(void)407quantize (JCOEFPTR coef_block, DCTELEM *divisors, DCTELEM *workspace)408{409int i;410DCTELEM temp;411JCOEFPTR output_ptr = coef_block;412413#if BITS_IN_JSAMPLE == 8414415UDCTELEM recip, corr;416int shift;417UDCTELEM2 product;418419for (i = 0; i < DCTSIZE2; i++) {420temp = workspace[i];421recip = divisors[i + DCTSIZE2 * 0];422corr = divisors[i + DCTSIZE2 * 1];423shift = divisors[i + DCTSIZE2 * 3];424425if (temp < 0) {426temp = -temp;427product = (UDCTELEM2)(temp + corr) * recip;428product >>= shift + sizeof(DCTELEM)*8;429temp = (DCTELEM)product;430temp = -temp;431} else {432product = (UDCTELEM2)(temp + corr) * recip;433product >>= shift + sizeof(DCTELEM)*8;434temp = (DCTELEM)product;435}436output_ptr[i] = (JCOEF) temp;437}438439#else440441register DCTELEM qval;442443for (i = 0; i < DCTSIZE2; i++) {444qval = divisors[i];445temp = workspace[i];446/* Divide the coefficient value by qval, ensuring proper rounding.447* Since C does not specify the direction of rounding for negative448* quotients, we have to force the dividend positive for portability.449*450* In most files, at least half of the output values will be zero451* (at default quantization settings, more like three-quarters...)452* so we should ensure that this case is fast. On many machines,453* a comparison is enough cheaper than a divide to make a special test454* a win. Since both inputs will be nonnegative, we need only test455* for a < b to discover whether a/b is 0.456* If your machine's division is fast enough, define FAST_DIVIDE.457*/458#ifdef FAST_DIVIDE459#define DIVIDE_BY(a,b) a /= b460#else461#define DIVIDE_BY(a,b) if (a >= b) a /= b; else a = 0462#endif463if (temp < 0) {464temp = -temp;465temp += qval>>1; /* for rounding */466DIVIDE_BY(temp, qval);467temp = -temp;468} else {469temp += qval>>1; /* for rounding */470DIVIDE_BY(temp, qval);471}472output_ptr[i] = (JCOEF) temp;473}474475#endif476477}478479480/*481* Perform forward DCT on one or more blocks of a component.482*483* The input samples are taken from the sample_data[] array starting at484* position start_row/start_col, and moving to the right for any additional485* blocks. The quantized coefficients are returned in coef_blocks[].486*/487488METHODDEF(void)489forward_DCT (j_compress_ptr cinfo, jpeg_component_info *compptr,490JSAMPARRAY sample_data, JBLOCKROW coef_blocks,491JDIMENSION start_row, JDIMENSION start_col,492JDIMENSION num_blocks)493/* This version is used for integer DCT implementations. */494{495/* This routine is heavily used, so it's worth coding it tightly. */496my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;497DCTELEM *divisors = fdct->divisors[compptr->quant_tbl_no];498DCTELEM *workspace;499JDIMENSION bi;500501/* Make sure the compiler doesn't look up these every pass */502forward_DCT_method_ptr do_dct = fdct->dct;503convsamp_method_ptr do_convsamp = fdct->convsamp;504quantize_method_ptr do_quantize = fdct->quantize;505workspace = fdct->workspace;506507sample_data += start_row; /* fold in the vertical offset once */508509for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {510/* Load data into workspace, applying unsigned->signed conversion */511(*do_convsamp) (sample_data, start_col, workspace);512513/* Perform the DCT */514(*do_dct) (workspace);515516/* Quantize/descale the coefficients, and store into coef_blocks[] */517(*do_quantize) (coef_blocks[bi], divisors, workspace);518}519}520521522#ifdef DCT_FLOAT_SUPPORTED523524525METHODDEF(void)526convsamp_float (JSAMPARRAY sample_data, JDIMENSION start_col, FAST_FLOAT *workspace)527{528register FAST_FLOAT *workspaceptr;529register JSAMPROW elemptr;530register int elemr;531532workspaceptr = workspace;533for (elemr = 0; elemr < DCTSIZE; elemr++) {534elemptr = sample_data[elemr] + start_col;535#if DCTSIZE == 8 /* unroll the inner loop */536*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);537*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);538*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);539*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);540*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);541*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);542*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);543*workspaceptr++ = (FAST_FLOAT)(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);544#else545{546register int elemc;547for (elemc = DCTSIZE; elemc > 0; elemc--)548*workspaceptr++ = (FAST_FLOAT)549(GETJSAMPLE(*elemptr++) - CENTERJSAMPLE);550}551#endif552}553}554555556METHODDEF(void)557quantize_float (JCOEFPTR coef_block, FAST_FLOAT *divisors, FAST_FLOAT *workspace)558{559register FAST_FLOAT temp;560register int i;561register JCOEFPTR output_ptr = coef_block;562563for (i = 0; i < DCTSIZE2; i++) {564/* Apply the quantization and scaling factor */565temp = workspace[i] * divisors[i];566567/* Round to nearest integer.568* Since C does not specify the direction of rounding for negative569* quotients, we have to force the dividend positive for portability.570* The maximum coefficient size is +-16K (for 12-bit data), so this571* code should work for either 16-bit or 32-bit ints.572*/573output_ptr[i] = (JCOEF) ((int) (temp + (FAST_FLOAT) 16384.5) - 16384);574}575}576577578METHODDEF(void)579forward_DCT_float (j_compress_ptr cinfo, jpeg_component_info *compptr,580JSAMPARRAY sample_data, JBLOCKROW coef_blocks,581JDIMENSION start_row, JDIMENSION start_col,582JDIMENSION num_blocks)583/* This version is used for floating-point DCT implementations. */584{585/* This routine is heavily used, so it's worth coding it tightly. */586my_fdct_ptr fdct = (my_fdct_ptr) cinfo->fdct;587FAST_FLOAT *divisors = fdct->float_divisors[compptr->quant_tbl_no];588FAST_FLOAT *workspace;589JDIMENSION bi;590591592/* Make sure the compiler doesn't look up these every pass */593float_DCT_method_ptr do_dct = fdct->float_dct;594float_convsamp_method_ptr do_convsamp = fdct->float_convsamp;595float_quantize_method_ptr do_quantize = fdct->float_quantize;596workspace = fdct->float_workspace;597598sample_data += start_row; /* fold in the vertical offset once */599600for (bi = 0; bi < num_blocks; bi++, start_col += DCTSIZE) {601/* Load data into workspace, applying unsigned->signed conversion */602(*do_convsamp) (sample_data, start_col, workspace);603604/* Perform the DCT */605(*do_dct) (workspace);606607/* Quantize/descale the coefficients, and store into coef_blocks[] */608(*do_quantize) (coef_blocks[bi], divisors, workspace);609}610}611612#endif /* DCT_FLOAT_SUPPORTED */613614615/*616* Initialize FDCT manager.617*/618619GLOBAL(void)620jinit_forward_dct (j_compress_ptr cinfo)621{622my_fdct_ptr fdct;623int i;624625fdct = (my_fdct_ptr)626(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,627sizeof(my_fdct_controller));628cinfo->fdct = (struct jpeg_forward_dct *) fdct;629fdct->pub.start_pass = start_pass_fdctmgr;630631/* First determine the DCT... */632switch (cinfo->dct_method) {633#ifdef DCT_ISLOW_SUPPORTED634case JDCT_ISLOW:635fdct->pub.forward_DCT = forward_DCT;636if (jsimd_can_fdct_islow())637fdct->dct = jsimd_fdct_islow;638else639fdct->dct = jpeg_fdct_islow;640break;641#endif642#ifdef DCT_IFAST_SUPPORTED643case JDCT_IFAST:644fdct->pub.forward_DCT = forward_DCT;645if (jsimd_can_fdct_ifast())646fdct->dct = jsimd_fdct_ifast;647else648fdct->dct = jpeg_fdct_ifast;649break;650#endif651#ifdef DCT_FLOAT_SUPPORTED652case JDCT_FLOAT:653fdct->pub.forward_DCT = forward_DCT_float;654if (jsimd_can_fdct_float())655fdct->float_dct = jsimd_fdct_float;656else657fdct->float_dct = jpeg_fdct_float;658break;659#endif660default:661ERREXIT(cinfo, JERR_NOT_COMPILED);662break;663}664665/* ...then the supporting stages. */666switch (cinfo->dct_method) {667#ifdef DCT_ISLOW_SUPPORTED668case JDCT_ISLOW:669#endif670#ifdef DCT_IFAST_SUPPORTED671case JDCT_IFAST:672#endif673#if defined(DCT_ISLOW_SUPPORTED) || defined(DCT_IFAST_SUPPORTED)674if (jsimd_can_convsamp())675fdct->convsamp = jsimd_convsamp;676else677fdct->convsamp = convsamp;678if (jsimd_can_quantize())679fdct->quantize = jsimd_quantize;680else681fdct->quantize = quantize;682break;683#endif684#ifdef DCT_FLOAT_SUPPORTED685case JDCT_FLOAT:686if (jsimd_can_convsamp_float())687fdct->float_convsamp = jsimd_convsamp_float;688else689fdct->float_convsamp = convsamp_float;690if (jsimd_can_quantize_float())691fdct->float_quantize = jsimd_quantize_float;692else693fdct->float_quantize = quantize_float;694break;695#endif696default:697ERREXIT(cinfo, JERR_NOT_COMPILED);698break;699}700701/* Allocate workspace memory */702#ifdef DCT_FLOAT_SUPPORTED703if (cinfo->dct_method == JDCT_FLOAT)704fdct->float_workspace = (FAST_FLOAT *)705(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,706sizeof(FAST_FLOAT) * DCTSIZE2);707else708#endif709fdct->workspace = (DCTELEM *)710(*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE,711sizeof(DCTELEM) * DCTSIZE2);712713/* Mark divisor tables unallocated */714for (i = 0; i < NUM_QUANT_TBLS; i++) {715fdct->divisors[i] = NULL;716#ifdef DCT_FLOAT_SUPPORTED717fdct->float_divisors[i] = NULL;718#endif719}720}721722723