1cb93a386Sopenharmony_ci/* 2cb93a386Sopenharmony_ci * jddctmgr.c 3cb93a386Sopenharmony_ci * 4cb93a386Sopenharmony_ci * This file was part of the Independent JPEG Group's software: 5cb93a386Sopenharmony_ci * Copyright (C) 1994-1996, Thomas G. Lane. 6cb93a386Sopenharmony_ci * Modified 2002-2010 by Guido Vollbeding. 7cb93a386Sopenharmony_ci * libjpeg-turbo Modifications: 8cb93a386Sopenharmony_ci * Copyright 2009 Pierre Ossman <ossman@cendio.se> for Cendio AB 9cb93a386Sopenharmony_ci * Copyright (C) 2010, 2015, D. R. Commander. 10cb93a386Sopenharmony_ci * Copyright (C) 2013, MIPS Technologies, Inc., California. 11cb93a386Sopenharmony_ci * For conditions of distribution and use, see the accompanying README.ijg 12cb93a386Sopenharmony_ci * file. 13cb93a386Sopenharmony_ci * 14cb93a386Sopenharmony_ci * This file contains the inverse-DCT management logic. 15cb93a386Sopenharmony_ci * This code selects a particular IDCT implementation to be used, 16cb93a386Sopenharmony_ci * and it performs related housekeeping chores. No code in this file 17cb93a386Sopenharmony_ci * is executed per IDCT step, only during output pass setup. 18cb93a386Sopenharmony_ci * 19cb93a386Sopenharmony_ci * Note that the IDCT routines are responsible for performing coefficient 20cb93a386Sopenharmony_ci * dequantization as well as the IDCT proper. This module sets up the 21cb93a386Sopenharmony_ci * dequantization multiplier table needed by the IDCT routine. 22cb93a386Sopenharmony_ci */ 23cb93a386Sopenharmony_ci 24cb93a386Sopenharmony_ci#define JPEG_INTERNALS 25cb93a386Sopenharmony_ci#include "jinclude.h" 26cb93a386Sopenharmony_ci#include "jpeglib.h" 27cb93a386Sopenharmony_ci#include "jdct.h" /* Private declarations for DCT subsystem */ 28cb93a386Sopenharmony_ci#include "jsimddct.h" 29cb93a386Sopenharmony_ci#include "jpegcomp.h" 30cb93a386Sopenharmony_ci 31cb93a386Sopenharmony_ci 32cb93a386Sopenharmony_ci/* 33cb93a386Sopenharmony_ci * The decompressor input side (jdinput.c) saves away the appropriate 34cb93a386Sopenharmony_ci * quantization table for each component at the start of the first scan 35cb93a386Sopenharmony_ci * involving that component. (This is necessary in order to correctly 36cb93a386Sopenharmony_ci * decode files that reuse Q-table slots.) 37cb93a386Sopenharmony_ci * When we are ready to make an output pass, the saved Q-table is converted 38cb93a386Sopenharmony_ci * to a multiplier table that will actually be used by the IDCT routine. 39cb93a386Sopenharmony_ci * The multiplier table contents are IDCT-method-dependent. To support 40cb93a386Sopenharmony_ci * application changes in IDCT method between scans, we can remake the 41cb93a386Sopenharmony_ci * multiplier tables if necessary. 42cb93a386Sopenharmony_ci * In buffered-image mode, the first output pass may occur before any data 43cb93a386Sopenharmony_ci * has been seen for some components, and thus before their Q-tables have 44cb93a386Sopenharmony_ci * been saved away. To handle this case, multiplier tables are preset 45cb93a386Sopenharmony_ci * to zeroes; the result of the IDCT will be a neutral gray level. 46cb93a386Sopenharmony_ci */ 47cb93a386Sopenharmony_ci 48cb93a386Sopenharmony_ci 49cb93a386Sopenharmony_ci/* Private subobject for this module */ 50cb93a386Sopenharmony_ci 51cb93a386Sopenharmony_citypedef struct { 52cb93a386Sopenharmony_ci struct jpeg_inverse_dct pub; /* public fields */ 53cb93a386Sopenharmony_ci 54cb93a386Sopenharmony_ci /* This array contains the IDCT method code that each multiplier table 55cb93a386Sopenharmony_ci * is currently set up for, or -1 if it's not yet set up. 56cb93a386Sopenharmony_ci * The actual multiplier tables are pointed to by dct_table in the 57cb93a386Sopenharmony_ci * per-component comp_info structures. 58cb93a386Sopenharmony_ci */ 59cb93a386Sopenharmony_ci int cur_method[MAX_COMPONENTS]; 60cb93a386Sopenharmony_ci} my_idct_controller; 61cb93a386Sopenharmony_ci 62cb93a386Sopenharmony_citypedef my_idct_controller *my_idct_ptr; 63cb93a386Sopenharmony_ci 64cb93a386Sopenharmony_ci 65cb93a386Sopenharmony_ci/* Allocated multiplier tables: big enough for any supported variant */ 66cb93a386Sopenharmony_ci 67cb93a386Sopenharmony_citypedef union { 68cb93a386Sopenharmony_ci ISLOW_MULT_TYPE islow_array[DCTSIZE2]; 69cb93a386Sopenharmony_ci#ifdef DCT_IFAST_SUPPORTED 70cb93a386Sopenharmony_ci IFAST_MULT_TYPE ifast_array[DCTSIZE2]; 71cb93a386Sopenharmony_ci#endif 72cb93a386Sopenharmony_ci#ifdef DCT_FLOAT_SUPPORTED 73cb93a386Sopenharmony_ci FLOAT_MULT_TYPE float_array[DCTSIZE2]; 74cb93a386Sopenharmony_ci#endif 75cb93a386Sopenharmony_ci} multiplier_table; 76cb93a386Sopenharmony_ci 77cb93a386Sopenharmony_ci 78cb93a386Sopenharmony_ci/* The current scaled-IDCT routines require ISLOW-style multiplier tables, 79cb93a386Sopenharmony_ci * so be sure to compile that code if either ISLOW or SCALING is requested. 80cb93a386Sopenharmony_ci */ 81cb93a386Sopenharmony_ci#ifdef DCT_ISLOW_SUPPORTED 82cb93a386Sopenharmony_ci#define PROVIDE_ISLOW_TABLES 83cb93a386Sopenharmony_ci#else 84cb93a386Sopenharmony_ci#ifdef IDCT_SCALING_SUPPORTED 85cb93a386Sopenharmony_ci#define PROVIDE_ISLOW_TABLES 86cb93a386Sopenharmony_ci#endif 87cb93a386Sopenharmony_ci#endif 88cb93a386Sopenharmony_ci 89cb93a386Sopenharmony_ci 90cb93a386Sopenharmony_ci/* 91cb93a386Sopenharmony_ci * Prepare for an output pass. 92cb93a386Sopenharmony_ci * Here we select the proper IDCT routine for each component and build 93cb93a386Sopenharmony_ci * a matching multiplier table. 94cb93a386Sopenharmony_ci */ 95cb93a386Sopenharmony_ci 96cb93a386Sopenharmony_ciMETHODDEF(void) 97cb93a386Sopenharmony_cistart_pass(j_decompress_ptr cinfo) 98cb93a386Sopenharmony_ci{ 99cb93a386Sopenharmony_ci my_idct_ptr idct = (my_idct_ptr)cinfo->idct; 100cb93a386Sopenharmony_ci int ci, i; 101cb93a386Sopenharmony_ci jpeg_component_info *compptr; 102cb93a386Sopenharmony_ci int method = 0; 103cb93a386Sopenharmony_ci inverse_DCT_method_ptr method_ptr = NULL; 104cb93a386Sopenharmony_ci JQUANT_TBL *qtbl; 105cb93a386Sopenharmony_ci 106cb93a386Sopenharmony_ci for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 107cb93a386Sopenharmony_ci ci++, compptr++) { 108cb93a386Sopenharmony_ci /* Select the proper IDCT routine for this component's scaling */ 109cb93a386Sopenharmony_ci switch (compptr->_DCT_scaled_size) { 110cb93a386Sopenharmony_ci#ifdef IDCT_SCALING_SUPPORTED 111cb93a386Sopenharmony_ci case 1: 112cb93a386Sopenharmony_ci method_ptr = jpeg_idct_1x1; 113cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctred uses islow-style table */ 114cb93a386Sopenharmony_ci break; 115cb93a386Sopenharmony_ci case 2: 116cb93a386Sopenharmony_ci if (jsimd_can_idct_2x2()) 117cb93a386Sopenharmony_ci method_ptr = jsimd_idct_2x2; 118cb93a386Sopenharmony_ci else 119cb93a386Sopenharmony_ci method_ptr = jpeg_idct_2x2; 120cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctred uses islow-style table */ 121cb93a386Sopenharmony_ci break; 122cb93a386Sopenharmony_ci case 3: 123cb93a386Sopenharmony_ci method_ptr = jpeg_idct_3x3; 124cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 125cb93a386Sopenharmony_ci break; 126cb93a386Sopenharmony_ci case 4: 127cb93a386Sopenharmony_ci if (jsimd_can_idct_4x4()) 128cb93a386Sopenharmony_ci method_ptr = jsimd_idct_4x4; 129cb93a386Sopenharmony_ci else 130cb93a386Sopenharmony_ci method_ptr = jpeg_idct_4x4; 131cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctred uses islow-style table */ 132cb93a386Sopenharmony_ci break; 133cb93a386Sopenharmony_ci case 5: 134cb93a386Sopenharmony_ci method_ptr = jpeg_idct_5x5; 135cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 136cb93a386Sopenharmony_ci break; 137cb93a386Sopenharmony_ci case 6: 138cb93a386Sopenharmony_ci#if defined(__mips__) 139cb93a386Sopenharmony_ci if (jsimd_can_idct_6x6()) 140cb93a386Sopenharmony_ci method_ptr = jsimd_idct_6x6; 141cb93a386Sopenharmony_ci else 142cb93a386Sopenharmony_ci#endif 143cb93a386Sopenharmony_ci method_ptr = jpeg_idct_6x6; 144cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 145cb93a386Sopenharmony_ci break; 146cb93a386Sopenharmony_ci case 7: 147cb93a386Sopenharmony_ci method_ptr = jpeg_idct_7x7; 148cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 149cb93a386Sopenharmony_ci break; 150cb93a386Sopenharmony_ci#endif 151cb93a386Sopenharmony_ci case DCTSIZE: 152cb93a386Sopenharmony_ci switch (cinfo->dct_method) { 153cb93a386Sopenharmony_ci#ifdef DCT_ISLOW_SUPPORTED 154cb93a386Sopenharmony_ci case JDCT_ISLOW: 155cb93a386Sopenharmony_ci if (jsimd_can_idct_islow()) 156cb93a386Sopenharmony_ci method_ptr = jsimd_idct_islow; 157cb93a386Sopenharmony_ci else 158cb93a386Sopenharmony_ci method_ptr = jpeg_idct_islow; 159cb93a386Sopenharmony_ci method = JDCT_ISLOW; 160cb93a386Sopenharmony_ci break; 161cb93a386Sopenharmony_ci#endif 162cb93a386Sopenharmony_ci#ifdef DCT_IFAST_SUPPORTED 163cb93a386Sopenharmony_ci case JDCT_IFAST: 164cb93a386Sopenharmony_ci if (jsimd_can_idct_ifast()) 165cb93a386Sopenharmony_ci method_ptr = jsimd_idct_ifast; 166cb93a386Sopenharmony_ci else 167cb93a386Sopenharmony_ci method_ptr = jpeg_idct_ifast; 168cb93a386Sopenharmony_ci method = JDCT_IFAST; 169cb93a386Sopenharmony_ci break; 170cb93a386Sopenharmony_ci#endif 171cb93a386Sopenharmony_ci#ifdef DCT_FLOAT_SUPPORTED 172cb93a386Sopenharmony_ci case JDCT_FLOAT: 173cb93a386Sopenharmony_ci if (jsimd_can_idct_float()) 174cb93a386Sopenharmony_ci method_ptr = jsimd_idct_float; 175cb93a386Sopenharmony_ci else 176cb93a386Sopenharmony_ci method_ptr = jpeg_idct_float; 177cb93a386Sopenharmony_ci method = JDCT_FLOAT; 178cb93a386Sopenharmony_ci break; 179cb93a386Sopenharmony_ci#endif 180cb93a386Sopenharmony_ci default: 181cb93a386Sopenharmony_ci ERREXIT(cinfo, JERR_NOT_COMPILED); 182cb93a386Sopenharmony_ci break; 183cb93a386Sopenharmony_ci } 184cb93a386Sopenharmony_ci break; 185cb93a386Sopenharmony_ci#ifdef IDCT_SCALING_SUPPORTED 186cb93a386Sopenharmony_ci case 9: 187cb93a386Sopenharmony_ci method_ptr = jpeg_idct_9x9; 188cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 189cb93a386Sopenharmony_ci break; 190cb93a386Sopenharmony_ci case 10: 191cb93a386Sopenharmony_ci method_ptr = jpeg_idct_10x10; 192cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 193cb93a386Sopenharmony_ci break; 194cb93a386Sopenharmony_ci case 11: 195cb93a386Sopenharmony_ci method_ptr = jpeg_idct_11x11; 196cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 197cb93a386Sopenharmony_ci break; 198cb93a386Sopenharmony_ci case 12: 199cb93a386Sopenharmony_ci#if defined(__mips__) 200cb93a386Sopenharmony_ci if (jsimd_can_idct_12x12()) 201cb93a386Sopenharmony_ci method_ptr = jsimd_idct_12x12; 202cb93a386Sopenharmony_ci else 203cb93a386Sopenharmony_ci#endif 204cb93a386Sopenharmony_ci method_ptr = jpeg_idct_12x12; 205cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 206cb93a386Sopenharmony_ci break; 207cb93a386Sopenharmony_ci case 13: 208cb93a386Sopenharmony_ci method_ptr = jpeg_idct_13x13; 209cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 210cb93a386Sopenharmony_ci break; 211cb93a386Sopenharmony_ci case 14: 212cb93a386Sopenharmony_ci method_ptr = jpeg_idct_14x14; 213cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 214cb93a386Sopenharmony_ci break; 215cb93a386Sopenharmony_ci case 15: 216cb93a386Sopenharmony_ci method_ptr = jpeg_idct_15x15; 217cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 218cb93a386Sopenharmony_ci break; 219cb93a386Sopenharmony_ci case 16: 220cb93a386Sopenharmony_ci method_ptr = jpeg_idct_16x16; 221cb93a386Sopenharmony_ci method = JDCT_ISLOW; /* jidctint uses islow-style table */ 222cb93a386Sopenharmony_ci break; 223cb93a386Sopenharmony_ci#endif 224cb93a386Sopenharmony_ci default: 225cb93a386Sopenharmony_ci ERREXIT1(cinfo, JERR_BAD_DCTSIZE, compptr->_DCT_scaled_size); 226cb93a386Sopenharmony_ci break; 227cb93a386Sopenharmony_ci } 228cb93a386Sopenharmony_ci idct->pub.inverse_DCT[ci] = method_ptr; 229cb93a386Sopenharmony_ci /* Create multiplier table from quant table. 230cb93a386Sopenharmony_ci * However, we can skip this if the component is uninteresting 231cb93a386Sopenharmony_ci * or if we already built the table. Also, if no quant table 232cb93a386Sopenharmony_ci * has yet been saved for the component, we leave the 233cb93a386Sopenharmony_ci * multiplier table all-zero; we'll be reading zeroes from the 234cb93a386Sopenharmony_ci * coefficient controller's buffer anyway. 235cb93a386Sopenharmony_ci */ 236cb93a386Sopenharmony_ci if (!compptr->component_needed || idct->cur_method[ci] == method) 237cb93a386Sopenharmony_ci continue; 238cb93a386Sopenharmony_ci qtbl = compptr->quant_table; 239cb93a386Sopenharmony_ci if (qtbl == NULL) /* happens if no data yet for component */ 240cb93a386Sopenharmony_ci continue; 241cb93a386Sopenharmony_ci idct->cur_method[ci] = method; 242cb93a386Sopenharmony_ci switch (method) { 243cb93a386Sopenharmony_ci#ifdef PROVIDE_ISLOW_TABLES 244cb93a386Sopenharmony_ci case JDCT_ISLOW: 245cb93a386Sopenharmony_ci { 246cb93a386Sopenharmony_ci /* For LL&M IDCT method, multipliers are equal to raw quantization 247cb93a386Sopenharmony_ci * coefficients, but are stored as ints to ensure access efficiency. 248cb93a386Sopenharmony_ci */ 249cb93a386Sopenharmony_ci ISLOW_MULT_TYPE *ismtbl = (ISLOW_MULT_TYPE *)compptr->dct_table; 250cb93a386Sopenharmony_ci for (i = 0; i < DCTSIZE2; i++) { 251cb93a386Sopenharmony_ci ismtbl[i] = (ISLOW_MULT_TYPE)qtbl->quantval[i]; 252cb93a386Sopenharmony_ci } 253cb93a386Sopenharmony_ci } 254cb93a386Sopenharmony_ci break; 255cb93a386Sopenharmony_ci#endif 256cb93a386Sopenharmony_ci#ifdef DCT_IFAST_SUPPORTED 257cb93a386Sopenharmony_ci case JDCT_IFAST: 258cb93a386Sopenharmony_ci { 259cb93a386Sopenharmony_ci /* For AA&N IDCT method, multipliers are equal to quantization 260cb93a386Sopenharmony_ci * coefficients scaled by scalefactor[row]*scalefactor[col], where 261cb93a386Sopenharmony_ci * scalefactor[0] = 1 262cb93a386Sopenharmony_ci * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 263cb93a386Sopenharmony_ci * For integer operation, the multiplier table is to be scaled by 264cb93a386Sopenharmony_ci * IFAST_SCALE_BITS. 265cb93a386Sopenharmony_ci */ 266cb93a386Sopenharmony_ci IFAST_MULT_TYPE *ifmtbl = (IFAST_MULT_TYPE *)compptr->dct_table; 267cb93a386Sopenharmony_ci#define CONST_BITS 14 268cb93a386Sopenharmony_ci static const INT16 aanscales[DCTSIZE2] = { 269cb93a386Sopenharmony_ci /* precomputed values scaled up by 14 bits */ 270cb93a386Sopenharmony_ci 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, 271cb93a386Sopenharmony_ci 22725, 31521, 29692, 26722, 22725, 17855, 12299, 6270, 272cb93a386Sopenharmony_ci 21407, 29692, 27969, 25172, 21407, 16819, 11585, 5906, 273cb93a386Sopenharmony_ci 19266, 26722, 25172, 22654, 19266, 15137, 10426, 5315, 274cb93a386Sopenharmony_ci 16384, 22725, 21407, 19266, 16384, 12873, 8867, 4520, 275cb93a386Sopenharmony_ci 12873, 17855, 16819, 15137, 12873, 10114, 6967, 3552, 276cb93a386Sopenharmony_ci 8867, 12299, 11585, 10426, 8867, 6967, 4799, 2446, 277cb93a386Sopenharmony_ci 4520, 6270, 5906, 5315, 4520, 3552, 2446, 1247 278cb93a386Sopenharmony_ci }; 279cb93a386Sopenharmony_ci SHIFT_TEMPS 280cb93a386Sopenharmony_ci 281cb93a386Sopenharmony_ci for (i = 0; i < DCTSIZE2; i++) { 282cb93a386Sopenharmony_ci ifmtbl[i] = (IFAST_MULT_TYPE) 283cb93a386Sopenharmony_ci DESCALE(MULTIPLY16V16((JLONG)qtbl->quantval[i], 284cb93a386Sopenharmony_ci (JLONG)aanscales[i]), 285cb93a386Sopenharmony_ci CONST_BITS - IFAST_SCALE_BITS); 286cb93a386Sopenharmony_ci } 287cb93a386Sopenharmony_ci } 288cb93a386Sopenharmony_ci break; 289cb93a386Sopenharmony_ci#endif 290cb93a386Sopenharmony_ci#ifdef DCT_FLOAT_SUPPORTED 291cb93a386Sopenharmony_ci case JDCT_FLOAT: 292cb93a386Sopenharmony_ci { 293cb93a386Sopenharmony_ci /* For float AA&N IDCT method, multipliers are equal to quantization 294cb93a386Sopenharmony_ci * coefficients scaled by scalefactor[row]*scalefactor[col], where 295cb93a386Sopenharmony_ci * scalefactor[0] = 1 296cb93a386Sopenharmony_ci * scalefactor[k] = cos(k*PI/16) * sqrt(2) for k=1..7 297cb93a386Sopenharmony_ci */ 298cb93a386Sopenharmony_ci FLOAT_MULT_TYPE *fmtbl = (FLOAT_MULT_TYPE *)compptr->dct_table; 299cb93a386Sopenharmony_ci int row, col; 300cb93a386Sopenharmony_ci static const double aanscalefactor[DCTSIZE] = { 301cb93a386Sopenharmony_ci 1.0, 1.387039845, 1.306562965, 1.175875602, 302cb93a386Sopenharmony_ci 1.0, 0.785694958, 0.541196100, 0.275899379 303cb93a386Sopenharmony_ci }; 304cb93a386Sopenharmony_ci 305cb93a386Sopenharmony_ci i = 0; 306cb93a386Sopenharmony_ci for (row = 0; row < DCTSIZE; row++) { 307cb93a386Sopenharmony_ci for (col = 0; col < DCTSIZE; col++) { 308cb93a386Sopenharmony_ci fmtbl[i] = (FLOAT_MULT_TYPE) 309cb93a386Sopenharmony_ci ((double)qtbl->quantval[i] * 310cb93a386Sopenharmony_ci aanscalefactor[row] * aanscalefactor[col]); 311cb93a386Sopenharmony_ci i++; 312cb93a386Sopenharmony_ci } 313cb93a386Sopenharmony_ci } 314cb93a386Sopenharmony_ci } 315cb93a386Sopenharmony_ci break; 316cb93a386Sopenharmony_ci#endif 317cb93a386Sopenharmony_ci default: 318cb93a386Sopenharmony_ci ERREXIT(cinfo, JERR_NOT_COMPILED); 319cb93a386Sopenharmony_ci break; 320cb93a386Sopenharmony_ci } 321cb93a386Sopenharmony_ci } 322cb93a386Sopenharmony_ci} 323cb93a386Sopenharmony_ci 324cb93a386Sopenharmony_ci 325cb93a386Sopenharmony_ci/* 326cb93a386Sopenharmony_ci * Initialize IDCT manager. 327cb93a386Sopenharmony_ci */ 328cb93a386Sopenharmony_ci 329cb93a386Sopenharmony_ciGLOBAL(void) 330cb93a386Sopenharmony_cijinit_inverse_dct(j_decompress_ptr cinfo) 331cb93a386Sopenharmony_ci{ 332cb93a386Sopenharmony_ci my_idct_ptr idct; 333cb93a386Sopenharmony_ci int ci; 334cb93a386Sopenharmony_ci jpeg_component_info *compptr; 335cb93a386Sopenharmony_ci 336cb93a386Sopenharmony_ci idct = (my_idct_ptr) 337cb93a386Sopenharmony_ci (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, 338cb93a386Sopenharmony_ci sizeof(my_idct_controller)); 339cb93a386Sopenharmony_ci cinfo->idct = (struct jpeg_inverse_dct *)idct; 340cb93a386Sopenharmony_ci idct->pub.start_pass = start_pass; 341cb93a386Sopenharmony_ci 342cb93a386Sopenharmony_ci for (ci = 0, compptr = cinfo->comp_info; ci < cinfo->num_components; 343cb93a386Sopenharmony_ci ci++, compptr++) { 344cb93a386Sopenharmony_ci /* Allocate and pre-zero a multiplier table for each component */ 345cb93a386Sopenharmony_ci compptr->dct_table = 346cb93a386Sopenharmony_ci (*cinfo->mem->alloc_small) ((j_common_ptr)cinfo, JPOOL_IMAGE, 347cb93a386Sopenharmony_ci sizeof(multiplier_table)); 348cb93a386Sopenharmony_ci MEMZERO(compptr->dct_table, sizeof(multiplier_table)); 349cb93a386Sopenharmony_ci /* Mark multiplier table not yet set up for any method */ 350cb93a386Sopenharmony_ci idct->cur_method[ci] = -1; 351cb93a386Sopenharmony_ci } 352cb93a386Sopenharmony_ci} 353